Add more known sprintf failures.
[p5sagit/p5-mst-13.2.git] / t / op / cmp.t
CommitLineData
44a8e56a 1#!./perl
2
28e5dec8 3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
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.
10my $uv_max = ~0;
11my $uv_maxm1 = ~0 ^ 1;
12my $uv_big = $uv_max;
13$uv_big = ($uv_big - 20000) | 1;
14my ($iv0, $iv1, $ivm1, $iv_min, $iv_max, $iv_big, $iv_small);
15$iv_max = $uv_max; # Do copy, *then* divide
16$iv_max /= 2;
17$iv_min = $iv_max;
18{
19 use integer;
20 $iv0 = 2 - 2;
21 $iv1 = 3 - 2;
22 $ivm1 = 2 - 3;
23 $iv_max -= 1;
24 $iv_min += 0;
25 $iv_big = $iv_max - 3;
26 $iv_small = $iv_min + 2;
27}
28my $uv_bigi = $iv_big;
29$uv_bigi |= 0x0;
30
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,
35 $iv_small);
44a8e56a 36
28e5dec8 37$expect = 6 * ($#FOO+2) * ($#FOO+1);
44a8e56a 38print "1..$expect\n";
39
40my $ok = 0;
41for my $i (0..$#FOO) {
42 for my $j ($i..$#FOO) {
43 $ok++;
28e5dec8 44 # Comparison routines may convert these internally, which would change
45 # what is used to determine the comparison on later runs. Hence copy
46 my ($i1, $i2, $i3, $i4, $i5, $i6, $i7, $i8, $i9, $i10,
47 $i11, $i12, $i13, $i14, $i15) =
48 ($FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i],
49 $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i],
50 $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i]);
51 my ($j1, $j2, $j3, $j4, $j5, $j6, $j7, $j8, $j9, $j10,
52 $j11, $j12, $j13, $j14, $j15) =
53 ($FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j],
54 $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j],
55 $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j]);
56 my $cmp = $i1 <=> $j1;
57 if (!defined($cmp) ? !($i2 < $j2)
58 : ($cmp == -1 && $i2 < $j2 ||
59 $cmp == 0 && !($i2 < $j2) ||
60 $cmp == 1 && !($i2 < $j2)))
61 {
62 print "ok $ok\n";
63 }
64 else {
65 print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, < disagrees\n";
66 }
67 $ok++;
68 if (!defined($cmp) ? !($i4 == $j4)
69 : ($cmp == -1 && !($i4 == $j4) ||
70 $cmp == 0 && $i4 == $j4 ||
71 $cmp == 1 && !($i4 == $j4)))
72 {
73 print "ok $ok\n";
74 }
75 else {
76 print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, == disagrees\n";
77 }
78 $ok++;
79 if (!defined($cmp) ? !($i5 > $j5)
80 : ($cmp == -1 && !($i5 > $j5) ||
81 $cmp == 0 && !($i5 > $j5) ||
82 $cmp == 1 && ($i5 > $j5)))
83 {
84 print "ok $ok\n";
85 }
86 else {
87 print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, > disagrees\n";
88 }
89 $ok++;
90 if (!defined($cmp) ? !($i6 >= $j6)
91 : ($cmp == -1 && !($i6 >= $j6) ||
92 $cmp == 0 && $i6 >= $j6 ||
93 $cmp == 1 && $i6 >= $j6))
94 {
95 print "ok $ok\n";
96 }
97 else {
98 print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, >= disagrees\n";
99 }
100 $ok++;
101 # OK, so the docs are wrong it seems. NaN != NaN
102 if (!defined($cmp) ? ($i7 != $j7)
103 : ($cmp == -1 && $i7 != $j7 ||
104 $cmp == 0 && !($i7 != $j7) ||
105 $cmp == 1 && $i7 != $j7))
106 {
107 print "ok $ok\n";
108 }
109 else {
110 print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, != disagrees\n";
111 }
112 $ok++;
113 if (!defined($cmp) ? !($i8 <= $j8)
114 : ($cmp == -1 && $i8 <= $j8 ||
115 $cmp == 0 && $i8 <= $j8 ||
116 $cmp == 1 && !($i8 <= $j8)))
117 {
118 print "ok $ok\n";
119 }
120 else {
121 print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, <= disagrees\n";
122 }
123 $ok++;
124 $cmp = $i9 cmp $j9;
125 if ($cmp == -1 && $i10 lt $j10 ||
126 $cmp == 0 && !($i10 lt $j10) ||
127 $cmp == 1 && !($i10 lt $j10))
128 {
129 print "ok $ok\n";
130 }
131 else {
132 print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, lt disagrees\n";
133 }
134 $ok++;
135 if ($cmp == -1 && !($i11 eq $j11) ||
136 $cmp == 0 && ($i11 eq $j11) ||
137 $cmp == 1 && !($i11 eq $j11))
138 {
139 print "ok $ok\n";
140 }
141 else {
142 print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, eq disagrees\n";
143 }
144 $ok++;
145 if ($cmp == -1 && !($i12 gt $j12) ||
146 $cmp == 0 && !($i12 gt $j12) ||
147 $cmp == 1 && ($i12 gt $j12))
148 {
149 print "ok $ok\n";
150 }
151 else {
152 print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, gt disagrees\n";
153 }
154 $ok++;
155 if ($cmp == -1 && $i13 le $j13 ||
156 $cmp == 0 && ($i13 le $j13) ||
157 $cmp == 1 && !($i13 le $j13))
158 {
159 print "ok $ok\n";
160 }
161 else {
162 print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, le disagrees\n";
163 }
164 $ok++;
165 if ($cmp == -1 && ($i14 ne $j14) ||
166 $cmp == 0 && !($i14 ne $j14) ||
167 $cmp == 1 && ($i14 ne $j14))
44a8e56a 168 {
169 print "ok $ok\n";
170 }
171 else {
28e5dec8 172 print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, ne disagrees\n";
44a8e56a 173 }
174 $ok++;
28e5dec8 175 if ($cmp == -1 && !($i15 ge $j15) ||
176 $cmp == 0 && ($i15 ge $j15) ||
177 $cmp == 1 && ($i15 ge $j15))
44a8e56a 178 {
179 print "ok $ok\n";
180 }
181 else {
28e5dec8 182 print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, ge disagrees\n";
44a8e56a 183 }
184 }
185}