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
10print "1..", 6 + 8 + 1 + 8 + 4 + 12 + 7 + 1 + 12 + 2, "\n";
11
12my $a = new Set::IntSpan "1-5";
13my $e = new Set::IntSpan;
14my $i = new Set::IntSpan "(-)";
15
16
17# Conversion
18$a or  Not; OK;
19$e and Not; OK;
20$i or  Not; OK;
21
22"$a" eq "1-5" or Not; OK;
23"$e" eq "-"   or Not; OK;
24"$i" eq "(-)" or Not; OK;
25
26# Equality
27$a eq "1-5" or Not; OK;  $a eq "6-9" and Not; OK;
28"1-5" eq $a or Not; OK;  "6-9" eq $a and Not; OK;
29$a ne "6-9" or Not; OK;  $a ne "1-5" and Not; OK;
30"6-9" ne $a or Not; OK;  "1-5" ne $a and Not; OK;
31
32# Unary
33~$a eq "(-0,6-)" or Not; OK;
34
35# Binary
36my $u1 = $a + "3-8";
37my $u2 = "3-8" + $a;
38$u1 eq "1-8" or Not; OK;
39$u2 eq "1-8" or Not; OK;
40
41my $d1 = $a - "3-8";
42my $d2 = "3-8" - $a;
43$d1 eq "1-2" or Not; OK;
44$d2 eq "6-8" or Not; OK;
45
46my $i1 = $a * "3-8";
47my $i2 = "3-8" * $a;
48$i1 eq "3-5" or Not; OK;
49$i2 eq "3-5" or Not; OK;
50
51# Assignment
52my $x1 = $a ^ "3-8";
53my $x2 = "3-8" ^ $a;
54$x1 eq "1-2,6-8" or Not; OK;
55$x2 eq "1-2,6-8" or Not; OK;
56
57$a += "3-8";
58$a eq "1-8" or Not; OK;
59
60$a -= "3-8";
61$a eq "1-2" or Not; OK;
62
63$a *= "3-8";
64$a eq "-"   or Not; OK;
65
66$a ^= "3-8";
67$a eq "3-8" or Not; OK;
68
69# Equivalence
70$a == 6 or Not; OK;	 $a == 7 and Not; OK;
71$a != 7 or Not; OK;	 $a != 6 and Not; OK;
72$a <  7 or Not; OK;	 $a <  6 and Not; OK;
73$a <= 6 or Not; OK;	 $a <= 5 and Not; OK;
74$a >  5 or Not; OK;	 $a >  6 and Not; OK;
75$a >= 6 or Not; OK;	 $a >= 7 and Not; OK;
76
77($a <=>  7) == -1 or Not; OK;
78($a <=>  6) ==  0 or Not; OK;
79($a <=>  5) ==  1 or Not; OK;
80( 5 <=> $a) == -1 or Not; OK;
81( 7 <=> $a) ==  1 or Not; OK;
82($a <=> $i) == -1 or Not; OK;
83($i <=> $a) ==  1 or Not; OK;
84
85my @c = sort($i, $a, $e);
86$c[0] eq $e and $c[1] eq $a and $c[2] eq $i or Not; OK;
87
88$a lt $i or Not; OK;     $i lt $a and Not; OK;
89$a le $i or Not; OK;     $i le $a and Not; OK;
90$i gt $a or Not; OK;     $a gt $i and Not; OK;
91$i ge $a or Not; OK;     $a ge $i and Not; OK;
92$a le $a or Not; OK;     $a lt $a and Not; OK;
93$a ge $a or Not; OK;     $a gt $a and Not; OK;
94
95"3-8" le $a or Not; OK;
96"3-8" ge $a or Not; OK;
97