1# -*- perl -*-
2
3use strict;
4use Set::IntSpan 1.17;
5
6my $N = 1;
7sub Not { print "not " }
8sub OK  { print "ok ", $N++, "\n" }
9
10sub Table { map { [ split(' ', $_) ] } split(/\s*\n\s*/, shift) }
11
12my @Unaries = Table <<TABLE;
13-            (-)
14(-1          2-)
151            (-0,2-)
161-3          (-0,4-)
171-3,5-9,15-) (-0,4,10-14
18TABLE
19
20print "1..", 4 * @Unaries, "\n";
21Complement();
22
23
24sub Complement
25{
26    print "#complement\n";
27
28    for my $t (@Unaries)
29    {
30	Unary("complement", $t->[0], $t->[1]);
31	Unary("complement", $t->[1], $t->[0]);
32	U    ("C"	  , $t->[0], $t->[1]);
33	U    ("C"	  , $t->[1], $t->[0]);
34    }
35}
36
37
38sub Unary
39{
40    my($method, $operand, $expected) = @_;
41    my $set = new Set::IntSpan $operand;
42    my $setE = $set->$method();
43    my $run_list = run_list $setE;
44
45    printf "#%-12s %-10s -> %-10s\n", $method, $operand, $run_list;
46    $run_list eq $expected or Not; OK;
47}
48
49sub U
50{
51    my($method, $operand, $expected) = @_;
52    my $set = new Set::IntSpan $operand;
53    $set->$method();
54    my $run_list = run_list $set;
55
56    printf "#%-12s %-10s -> %-10s\n", $method, $operand, $run_list;
57    $run_list eq $expected or Not; OK;
58}
59
60