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;
127 print "not " unless $x == 15241567763770867 && $x > $f;
131 print "not " unless $x == $q && $x > $f;
134 $x = 98765432109 % 12345678901;
135 print "not " unless $x == 901;
138 # The following 12 tests adapted from op/inc.
140 $a = 9223372036854775807;
142 print "not " unless $a == 9223372036854775808;
145 $a = 9223372036854775807;
147 print "not " unless $a == 9223372036854775808 && $c == $a;
150 $a = 9223372036854775807;
152 print "not " unless $a == 9223372036854775807 && $c == 9223372036854775808;
155 $a = -9223372036854775808;
157 print "not " unless $a == -9223372036854775809 && $c == -9223372036854775808;
160 $a = -9223372036854775808;
162 print "not " unless $a == -9223372036854775809 && $c == $a;
165 $a = -9223372036854775808;
167 print "not " unless $a == -9223372036854775808 && $c == -9223372036854775809;
170 $a = 9223372036854775808;
173 print "not " unless $a == -9223372036854775809 && $c == -9223372036854775808;
176 $a = 9223372036854775808;
179 print "not " unless $a == -9223372036854775809 && $c == $a;
182 $a = 9223372036854775808;
185 print "not " unless $a == -9223372036854775808 && $c == -9223372036854775809;
188 $a = 9223372036854775808;
191 print "not " unless $b == -$a-1 && $c == -$a;
194 $a = 9223372036854775808;
197 print "not " unless $b == -$a-1 && $c == $b;
200 $a = 9223372036854775808;
203 print "not " unless $b == -(++$a);
208 print "not " unless (vec($x, 1, 64) = $q) == $q;
211 print "not " unless vec($x, 1, 64) == $q && vec($x, 1, 64) > $f;
214 print "not " unless vec($x, 0, 64) == 0 && vec($x, 2, 64) == 0;
218 print "not " unless ~0 == 0xffffffffffffffff;
221 print "not " unless (0xffffffff<<32) == 0xffffffff00000000;
224 print "not " unless ((0xffffffff)<<32)>>32 == 0xffffffff;
227 print "not " unless 1<<63 == 0x8000000000000000;
230 print "not " unless (sprintf "%#Vx", 1<<63) eq '0x8000000000000000';
233 print "not " unless (0x8000000000000000 | 1) == 0x8000000000000001;
236 print "not " unless (0xf000000000000000 & 0x8000000000000000) == 0x8000000000000000;
239 print "not " unless (0xf000000000000000 ^ 0xfffffffffffffff0) == 0x0ffffffffffffff0;
243 print "not " unless (sprintf "%b", ~0) eq '1111111111111111111111111111111111111111111111111111111111111111';
246 print "not " unless (sprintf "%64b", ~0) eq '1111111111111111111111111111111111111111111111111111111111111111';
249 print "not " unless (sprintf "%d", ~0>>1) eq '9223372036854775807';
252 print "not " unless (sprintf "%u", ~0) eq '18446744073709551615';