8 # 2s complement assumption. Won't break test, just makes the internals of
9 # the SVs less interesting if were not on 2s complement system.
11 my $uv_maxm1 = ~0 ^ 1;
13 $uv_big = ($uv_big - 20000) | 1;
14 my ($iv0, $iv1, $ivm1, $iv_min, $iv_max, $iv_big, $iv_small);
15 $iv_max = $uv_max; # Do copy, *then* divide
25 $iv_big = $iv_max - 3;
26 $iv_small = $iv_min + 2;
28 my $uv_bigi = $iv_big;
31 # Seems one needs to perform the maths on 'Inf' to get the NV correctly primed.
32 @FOO = ('s', 'N/A', 'a', 'NaN', -1, undef, 0, 1, 3.14, 1e37, 0.632120558, -.5,
33 'Inf'+1, '-Inf'-1, 0x0, 0x1, 0x5, 0xFFFFFFFF, $uv_max, $uv_maxm1,
34 $uv_big, $uv_bigi, $iv0, $iv1, $ivm1, $iv_min, $iv_max, $iv_big,
37 $expect = 6 * ($#FOO+2) * ($#FOO+1);
41 my ($test, $left, $threeway, $right, $result, $i, $j, $boolean) = @_;
42 $result = defined $result ? "'$result'" : 'undef';
43 print "not ok $test # ($left <=> $right) gives: $result \$i=$i \$j=$j, $boolean disagrees\n";
47 for my $i (0..$#FOO) {
48 for my $j ($i..$#FOO) {
50 # Comparison routines may convert these internally, which would change
51 # what is used to determine the comparison on later runs. Hence copy
52 my ($i1, $i2, $i3, $i4, $i5, $i6, $i7, $i8, $i9, $i10,
53 $i11, $i12, $i13, $i14, $i15) =
54 ($FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i],
55 $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i],
56 $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i]);
57 my ($j1, $j2, $j3, $j4, $j5, $j6, $j7, $j8, $j9, $j10,
58 $j11, $j12, $j13, $j14, $j15) =
59 ($FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j],
60 $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j],
61 $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j]);
62 my $cmp = $i1 <=> $j1;
63 if (!defined($cmp) ? !($i2 < $j2)
64 : ($cmp == -1 && $i2 < $j2 ||
65 $cmp == 0 && !($i2 < $j2) ||
66 $cmp == 1 && !($i2 < $j2)))
71 nok ($ok, $i3, '<=>', $j3, $cmp, $i, $j, '<');
74 if (!defined($cmp) ? !($i4 == $j4)
75 : ($cmp == -1 && !($i4 == $j4) ||
76 $cmp == 0 && $i4 == $j4 ||
77 $cmp == 1 && !($i4 == $j4)))
82 nok ($ok, $i3. '<=>', $j3, $cmp, $i, $j, '==');
85 if (!defined($cmp) ? !($i5 > $j5)
86 : ($cmp == -1 && !($i5 > $j5) ||
87 $cmp == 0 && !($i5 > $j5) ||
88 $cmp == 1 && ($i5 > $j5)))
93 nok ($ok, $i3. '<=>', $j3, $cmp, $i, $j, '>');
96 if (!defined($cmp) ? !($i6 >= $j6)
97 : ($cmp == -1 && !($i6 >= $j6) ||
98 $cmp == 0 && $i6 >= $j6 ||
99 $cmp == 1 && $i6 >= $j6))
104 nok ($ok, $i3. '<=>', $j3, $cmp, $i, $j, '>=');
107 # OK, so the docs are wrong it seems. NaN != NaN
108 if (!defined($cmp) ? ($i7 != $j7)
109 : ($cmp == -1 && $i7 != $j7 ||
110 $cmp == 0 && !($i7 != $j7) ||
111 $cmp == 1 && $i7 != $j7))
116 nok ($ok, $i3. '<=>', $j3, $cmp, $i, $j, '!=');
119 if (!defined($cmp) ? !($i8 <= $j8)
120 : ($cmp == -1 && $i8 <= $j8 ||
121 $cmp == 0 && $i8 <= $j8 ||
122 $cmp == 1 && !($i8 <= $j8)))
127 nok ($ok, $i3. '<=>', $j3, $cmp, $i, $j, '<=');
131 if ($cmp == -1 && $i10 lt $j10 ||
132 $cmp == 0 && !($i10 lt $j10) ||
133 $cmp == 1 && !($i10 lt $j10))
138 nok ($ok, $i3, 'cmp', $j3, $cmp, $i, $j, 'lt');
141 if ($cmp == -1 && !($i11 eq $j11) ||
142 $cmp == 0 && ($i11 eq $j11) ||
143 $cmp == 1 && !($i11 eq $j11))
148 nok ($ok, $i3, 'cmp', $j3, $cmp, $i, $j, 'eq');
151 if ($cmp == -1 && !($i12 gt $j12) ||
152 $cmp == 0 && !($i12 gt $j12) ||
153 $cmp == 1 && ($i12 gt $j12))
158 nok ($ok, $i3, 'cmp', $j3, $cmp, $i, $j, 'gt');
161 if ($cmp == -1 && $i13 le $j13 ||
162 $cmp == 0 && ($i13 le $j13) ||
163 $cmp == 1 && !($i13 le $j13))
168 nok ($ok, $i3, 'cmp', $j3, $cmp, $i, $j, 'le');
171 if ($cmp == -1 && ($i14 ne $j14) ||
172 $cmp == 0 && !($i14 ne $j14) ||
173 $cmp == 1 && ($i14 ne $j14))
178 nok ($ok, $i3, 'cmp', $j3, $cmp, $i, $j, 'ne');
181 if ($cmp == -1 && !($i15 ge $j15) ||
182 $cmp == 0 && ($i15 ge $j15) ||
183 $cmp == 1 && ($i15 ge $j15))
188 nok ($ok, $i3, 'cmp', $j3, $cmp, $i, $j, 'ge');