4 eval { my $q = pack "q", 0 };
6 print "1..0\n# Skip: no 64-bit types\n";
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;
132 print "not " unless $x == $q && $x > $f;
135 $x = 98765432109 % 12345678901;
136 print "not " unless $x == 901;
139 # The following 12 tests adapted from op/inc.
141 $a = 9223372036854775807;
143 print "not " unless $a == 9223372036854775808;
146 $a = 9223372036854775807;
149 unless $a == 9223372036854775808 && $c == $a;
152 $a = 9223372036854775807;
155 unless $a == 9223372036854775807 && $c == 9223372036854775808;
158 $a = -9223372036854775808;
161 unless $a == -9223372036854775809 && $c == -9223372036854775808;
164 $a = -9223372036854775808;
167 unless $a == -9223372036854775809 && $c == $a;
170 $a = -9223372036854775808;
173 unless $a == -9223372036854775808 && $c == -9223372036854775809;
176 $a = 9223372036854775808;
180 unless $a == -9223372036854775809 && $c == -9223372036854775808;
183 $a = 9223372036854775808;
187 unless $a == -9223372036854775809 && $c == $a;
190 $a = 9223372036854775808;
194 unless $a == -9223372036854775808 && $c == -9223372036854775809;
197 $a = 9223372036854775808;
201 unless $b == -$a-1 && $c == -$a;
204 $a = 9223372036854775808;
208 unless $b == -$a-1 && $c == $b;
211 $a = 9223372036854775808;
215 unless $b == -(++$a);
219 # Unicos has imprecise doubles (14 decimal digits or so),
220 # especially if operating near the UV/IV limits the low-order bits
221 # become mangled even by simple arithmetic operations.
223 print "ok $_ # skipped: too imprecise numbers\n";
229 print "not " unless (vec($x, 1, 64) = $q) == $q;
232 print "not " unless vec($x, 1, 64) == $q && vec($x, 1, 64) > $f;
235 print "not " unless vec($x, 0, 64) == 0 && vec($x, 2, 64) == 0;
239 print "not " unless ~0 == 0xffffffffffffffff;
242 print "not " unless (0xffffffff<<32) == 0xffffffff00000000;
245 print "not " unless ((0xffffffff)<<32)>>32 == 0xffffffff;
248 print "not " unless 1<<63 == 0x8000000000000000;
251 print "not " unless (sprintf "%#Vx", 1<<63) eq '0x8000000000000000';
254 print "not " unless (0x8000000000000000 | 1) == 0x8000000000000001;
258 unless (0xf000000000000000 & 0x8000000000000000) == 0x8000000000000000;
262 unless (0xf000000000000000 ^ 0xfffffffffffffff0) == 0x0ffffffffffffff0;
267 unless (sprintf "%b", ~0) eq
268 '1111111111111111111111111111111111111111111111111111111111111111';
272 unless (sprintf "%64b", ~0) eq
273 '1111111111111111111111111111111111111111111111111111111111111111';
276 print "not " unless (sprintf "%d", ~0>>1) eq '9223372036854775807';
279 print "not " unless (sprintf "%u", ~0) eq '18446744073709551615';
282 # If the 53..55 fail you have problems in the parser's string->int conversion,
283 # see toke.c:scan_num().
285 $q = -9223372036854775808;
286 print "# $q ne\n# -9223372036854775808\nnot " unless "$q" eq "-9223372036854775808";
289 $q = 9223372036854775807;
290 print "# $q ne\n# 9223372036854775807\nnot " unless "$q" eq "9223372036854775807";
293 $q = 18446744073709551615;
294 print "# $q ne\n# 18446744073709551615\nnot " unless "$q" eq "18446744073709551615";
297 # Test that sv_2nv then sv_2iv is the same as sv_2iv direct
298 # fails if whatever Atol is defined as can't actually cope with >32 bits.
299 my $num = 4294967297;
300 my $string = "4294967297";
306 if ($num eq $string) {
309 print "not ok 56 # \"$num\" ne \"$string\"\n";
312 # Test that sv_2nv then sv_2uv is the same as sv_2uv direct
314 $string = "4294967297";
317 if ($num eq $string) {
320 print "not ok 57 # \"$num\" ne \"$string\"\n";
323 $q = "18446744073709551616e0";
325 print "# \"18446744073709551616e0\" += 0 gives $q\nnot " if "$q" eq "18446744073709551615";