2 eval { my $q = pack "q", 0 };
4 print "1..0\n# no 64-bit types\n";
8 unshift @INC, '../lib';
11 # This could use a lot of more tests.
13 # Nota bene: bit operations (&, |, ^, ~, <<, >>) are not 64-bit clean.
14 # See the beginning of pp.c and the explanation next to IBW/UBW.
16 # So that using > 0xfffffff constants and
17 # 32+ bit vector sizes and shift doesn't cause noise.
18 no warnings qw(overflow portable);
30 $x = unpack "q", pack "q", $q;
31 print "not " unless $x == $q && $x > $f;
35 $x = sprintf("%d", 12345678901);
36 print "not " unless $x eq $q && $x > $f;
40 $x = sprintf("%d", $q);
41 print "not " unless $x == $q && $x eq $q && $x > $f;
44 $x = sprintf("%lld", $q);
45 print "not " unless $x == $q && $x eq $q && $x > $f;
48 $x = sprintf("%Ld", $q);
49 print "not " unless $x == $q && $x eq $q && $x > $f;
52 $x = sprintf("%qd", $q);
53 print "not " unless $x == $q && $x eq $q && $x > $f;
57 $x = sprintf("%x", $q);
58 print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
61 $x = sprintf("%llx", $q);
62 print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
65 $x = sprintf("%Lx", $q);
66 print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
69 $x = sprintf("%qx", $q);
70 print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
74 $x = sprintf("%o", $q);
75 print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
78 $x = sprintf("%llo", $q);
79 print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
82 $x = sprintf("%Lo", $q);
83 print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
86 $x = sprintf("%qo", $q);
87 print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
91 $x = sprintf("%b", $q);
92 print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
96 $x = sprintf("%llb", $q);
97 print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
101 $x = sprintf("%Lb", $q);
102 print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
106 $x = sprintf("%qb", $q);
107 print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
112 $x = sprintf("%u", 12345678901);
113 print "not " unless $x eq $q && $x > $f;
116 $x = sprintf("%u", $q);
117 print "not " unless $x == $q && $x eq $q && $x > $f;
120 $x = sprintf("%llu", $q);
121 print "not " unless $x == $q && $x eq $q && $x > $f;
124 $x = sprintf("%Lu", $q);
125 print "not " unless $x == $q && $x eq $q && $x > $f;
129 $x = sprintf("%D", $q);
130 print "not " unless $x == $q && $x eq $q && $x > $f;
133 $x = sprintf("%U", $q);
134 print "not " unless $x == $q && $x eq $q && $x > $f;
137 $x = sprintf("%O", $q);
138 print "not " unless oct($x) == $q && oct($x) > $f;
143 print "not " unless $x == 35802467913 && $x > $f;
147 print "not " unless $x == -11111110111 && -$x > $f;
151 print "not " unless $x == 15241567763770867 && $x > $f;
155 print "not " unless $x == $q && $x > $f;
158 $x = 98765432109 % 12345678901;
159 print "not " unless $x == 901;
162 # The following six adapted from op/inc.
164 $a = 9223372036854775807;
166 print "not " unless $a == 9223372036854775808;
169 $a = 9223372036854775807;
171 print "not " unless $a == 9223372036854775808;
174 $a = 9223372036854775807;
176 print "not " unless $a == 9223372036854775808;
179 $a = -9223372036854775808;
181 print "not " unless $a == -9223372036854775809;
184 $a = -9223372036854775808;
186 print "not " unless $a == -9223372036854775809;
189 $a = -9223372036854775808;
191 print "not " unless $a == -9223372036854775809;
196 print "not " unless (vec($x, 1, 64) = $q) == $q;
199 print "not " unless vec($x, 1, 64) == $q && vec($x, 1, 64) > $f;
202 print "not " unless vec($x, 0, 64) == 0 && vec($x, 2, 64) == 0;
206 print "not " unless ($q & $r) == 1442844692;
209 print "not " unless ($q | $r) == 34359623221;
212 print "not " unless ($q ^ $r) == 32916778529;
215 print "not " unless ~$q == 18446744061363872714;
218 print "not " unless ($q << 1) == 24691357802;
221 print "not " unless (($q << 1) >> 1) == $q;
224 print "not " unless (1 << 32) == 2**32; # Risky because of the **?
227 print "not " unless ((1 << 40) >> 32) == 256;
230 print "not " unless (1 << 63) == ~0 ^ (~0 >> 1);