4 eval { my $q = pack "q", 0 };
6 print "1..0\n# no 64-bit types\n";
10 unshift @INC, '../lib';
13 # This could use many more tests.
15 # so that using > 0xfffffff constants and
16 # 32+ bit integers don't cause noise
17 no warnings qw(overflow portable);
27 $x = unpack "q", pack "q", $q;
28 print "not " unless $x == $q && $x > $f;
32 $x = sprintf("%lld", 12345678901);
33 print "not " unless $x eq $q && $x > $f;
37 $x = sprintf("%lld", $q);
38 print "not " unless $x == $q && $x eq $q && $x > $f;
41 $x = sprintf("%Ld", $q);
42 print "not " unless $x == $q && $x eq $q && $x > $f;
45 $x = sprintf("%qd", $q);
46 print "not " unless $x == $q && $x eq $q && $x > $f;
50 $x = sprintf("%llx", $q);
51 print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
54 $x = sprintf("%Lx", $q);
55 print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
58 $x = sprintf("%qx", $q);
59 print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
63 $x = sprintf("%llo", $q);
64 print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
67 $x = sprintf("%Lo", $q);
68 print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
71 $x = sprintf("%qo", $q);
72 print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
76 $x = sprintf("%llb", $q);
77 print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
81 $x = sprintf("%Lb", $q);
82 print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
86 $x = sprintf("%qb", $q);
87 print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
92 $x = sprintf("%llu", $q);
93 print "not " unless $x eq $q && $x > $f;
96 $x = sprintf("%Lu", $q);
97 print "not " unless $x == $q && $x eq $q && $x > $f;
100 $x = sprintf("%qu", $q);
101 print "not " unless $x == $q && $x eq $q && $x > $f;
105 $x = sprintf("%D", $q);
106 print "not " unless $x == $q && $x eq $q && $x > $f;
109 $x = sprintf("%U", $q);
110 print "not " unless $x == $q && $x eq $q && $x > $f;
113 $x = sprintf("%O", $q);
114 print "not " unless oct($x) == $q && oct($x) > $f;
119 print "not " unless $x == 35802467913 && $x > $f;
123 print "not " unless $x == -11111110111 && -$x > $f;
126 if ($^O ne 'unicos') {
128 print "not " unless $x == 15241567763770867 && $x > $f;
131 # Unicos has imprecise doubles (14 decimal digits or so),
132 # the multiplication mangles the low-order bits.
134 print "not " unless $x == 15234567763834 && $x > $f;
139 print "not " unless $x == $q && $x > $f;
142 $x = 98765432109 % 12345678901;
143 print "not " unless $x == 901;
146 # The following 12 tests adapted from op/inc.
148 if ($^O ne 'unicos') {
149 $a = 9223372036854775807;
151 print "not " unless $a == 9223372036854775808;
154 $a = 9223372036854775807;
157 unless $a == 9223372036854775808 && $c == $a;
160 $a = 9223372036854775807;
163 unless $a == 9223372036854775807 && $c == 9223372036854775808;
166 $a = -9223372036854775808;
169 unless $a == -9223372036854775809 && $c == -9223372036854775808;
172 $a = -9223372036854775808;
175 unless $a == -9223372036854775809 && $c == $a;
178 $a = -9223372036854775808;
181 unless $a == -9223372036854775808 && $c == -9223372036854775809;
184 $a = 9223372036854775808;
188 unless $a == -9223372036854775809 && $c == -9223372036854775808;
191 $a = 9223372036854775808;
195 unless $a == -9223372036854775809 && $c == $a;
198 $a = 9223372036854775808;
202 unless $a == -9223372036854775808 && $c == -9223372036854775809;
205 $a = 9223372036854775808;
209 unless $b == -$a-1 && $c == -$a;
212 $a = 9223372036854775808;
216 unless $b == -$a-1 && $c == $b;
219 $a = 9223372036854775808;
223 unless $b == -(++$a);
227 # Unicos has imprecise doubles (14 decimal digits or so),
228 # near the UV/IV limites the low-order bits become mangled
229 # even by simple additions and subtractions.
231 print "ok #_ # skipped: too imprecise numbers\n";
237 print "not " unless (vec($x, 1, 64) = $q) == $q;
240 print "not " unless vec($x, 1, 64) == $q && vec($x, 1, 64) > $f;
243 print "not " unless vec($x, 0, 64) == 0 && vec($x, 2, 64) == 0;
247 print "not " unless ~0 == 0xffffffffffffffff;
250 print "not " unless (0xffffffff<<32) == 0xffffffff00000000;
253 print "not " unless ((0xffffffff)<<32)>>32 == 0xffffffff;
256 print "not " unless 1<<63 == 0x8000000000000000;
259 print "not " unless (sprintf "%#Vx", 1<<63) eq '0x8000000000000000';
262 print "not " unless (0x8000000000000000 | 1) == 0x8000000000000001;
266 unless (0xf000000000000000 & 0x8000000000000000) == 0x8000000000000000;
270 unless (0xf000000000000000 ^ 0xfffffffffffffff0) == 0x0ffffffffffffff0;
275 unless (sprintf "%b", ~0) eq
276 '1111111111111111111111111111111111111111111111111111111111111111';
280 unless (sprintf "%64b", ~0) eq
281 '1111111111111111111111111111111111111111111111111111111111111111';
284 print "not " unless (sprintf "%d", ~0>>1) eq '9223372036854775807';
287 print "not " unless (sprintf "%u", ~0) eq '18446744073709551615';