Commit | Line | Data |
0f4b6630 |
1 | BEGIN { |
ea2b5ef6 |
2 | eval { my $q = pack "q", 0 }; |
0f4b6630 |
3 | if ($@) { |
4 | print "1..0\n# no 64-bit types\n"; |
5 | exit(0); |
6 | } |
ea2b5ef6 |
7 | chdir 't' if -d 't'; |
8 | unshift @INC, '../lib'; |
0f4b6630 |
9 | } |
10 | |
11 | # This could use a lot of more tests. |
12 | # |
817e2dcb |
13 | # Nota bene: bit operations (&, |, ^, ~, <<, >>, vec) are not 64-bit clean. |
14 | # See the beginning of pp.c and the explanation next to IBW/UBW. |
0f4b6630 |
15 | |
20fe1ea2 |
16 | no warning 'overflow'; # so that using > 0xfffffff constants doesn't whine |
ea2b5ef6 |
17 | |
29fe7a80 |
18 | print "1..30\n"; |
0f4b6630 |
19 | |
20 | my $q = 12345678901; |
21 | my $r = 23456789012; |
20fe1ea2 |
22 | my $f = 0xffffffff; |
0f4b6630 |
23 | my $x; |
24 | |
25 | |
26 | $x = unpack "q", pack "q", $q; |
20fe1ea2 |
27 | print "not " unless $x == $q && $x > $f; |
0f4b6630 |
28 | print "ok 1\n"; |
29 | |
30 | |
31 | $x = sprintf("%d", 12345678901); |
20fe1ea2 |
32 | print "not " unless $x eq $q && $x > $f; |
0f4b6630 |
33 | print "ok 2\n"; |
34 | |
35 | |
36 | $x = sprintf("%d", $q); |
20fe1ea2 |
37 | print "not " unless $x == $q && $x eq $q && $x > $f; |
0f4b6630 |
38 | print "ok 3\n"; |
39 | |
40 | $x = sprintf("%lld", $q); |
20fe1ea2 |
41 | print "not " unless $x == $q && $x eq $q && $x > $f; |
0f4b6630 |
42 | print "ok 4\n"; |
43 | |
44 | $x = sprintf("%Ld", $q); |
20fe1ea2 |
45 | print "not " unless $x == $q && $x eq $q && $x > $f; |
0f4b6630 |
46 | print "ok 5\n"; |
47 | |
48 | $x = sprintf("%qd", $q); |
20fe1ea2 |
49 | print "not " unless $x == $q && $x eq $q && $x > $f; |
0f4b6630 |
50 | print "ok 6\n"; |
51 | |
52 | |
53 | $x = sprintf("%x", $q); |
20fe1ea2 |
54 | print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f; |
0f4b6630 |
55 | print "ok 7\n"; |
56 | |
57 | $x = sprintf("%llx", $q); |
20fe1ea2 |
58 | print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f; |
0f4b6630 |
59 | print "ok 8\n"; |
60 | |
61 | $x = sprintf("%Lx", $q); |
20fe1ea2 |
62 | print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f; |
0f4b6630 |
63 | print "ok 9\n"; |
64 | |
65 | $x = sprintf("%qx", $q); |
20fe1ea2 |
66 | print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f; |
0f4b6630 |
67 | print "ok 10\n"; |
68 | |
69 | |
70 | $x = sprintf("%o", $q); |
20fe1ea2 |
71 | print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f; |
0f4b6630 |
72 | print "ok 11\n"; |
73 | |
74 | $x = sprintf("%llo", $q); |
20fe1ea2 |
75 | print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f; |
0f4b6630 |
76 | print "ok 12\n"; |
77 | |
78 | $x = sprintf("%Lo", $q); |
20fe1ea2 |
79 | print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f; |
0f4b6630 |
80 | print "ok 13\n"; |
81 | |
82 | $x = sprintf("%qo", $q); |
20fe1ea2 |
83 | print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f; |
0f4b6630 |
84 | print "ok 14\n"; |
85 | |
86 | |
87 | $x = sprintf("%b", $q); |
20fe1ea2 |
88 | print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 && |
89 | oct("0b$x") > $f; |
0f4b6630 |
90 | print "ok 15\n"; |
91 | |
92 | $x = sprintf("%llb", $q); |
20fe1ea2 |
93 | print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 && |
94 | oct("0b$x") > $f; |
0f4b6630 |
95 | print "ok 16\n"; |
96 | |
97 | $x = sprintf("%Lb", $q); |
20fe1ea2 |
98 | print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 && |
99 | oct("0b$x") > $f; |
0f4b6630 |
100 | print "ok 17\n"; |
101 | |
102 | $x = sprintf("%qb", $q); |
20fe1ea2 |
103 | print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 && |
104 | oct("0b$x") > $f; |
0f4b6630 |
105 | print "ok 18\n"; |
106 | |
107 | |
108 | $x = sprintf("%u", 12345678901); |
20fe1ea2 |
109 | print "not " unless $x eq $q && $x > $f; |
0f4b6630 |
110 | print "ok 19\n"; |
111 | |
112 | $x = sprintf("%u", $q); |
20fe1ea2 |
113 | print "not " unless $x == $q && $x eq $q && $x > $f; |
0f4b6630 |
114 | print "ok 20\n"; |
115 | |
116 | $x = sprintf("%llu", $q); |
20fe1ea2 |
117 | print "not " unless $x == $q && $x eq $q && $x > $f; |
0f4b6630 |
118 | print "ok 21\n"; |
119 | |
120 | $x = sprintf("%Lu", $q); |
20fe1ea2 |
121 | print "not " unless $x == $q && $x eq $q && $x > $f; |
0f4b6630 |
122 | print "ok 22\n"; |
123 | |
124 | |
29fe7a80 |
125 | $x = sprintf("%D", $q); |
20fe1ea2 |
126 | print "not " unless $x == $q && $x eq $q && $x > $f; |
29fe7a80 |
127 | print "ok 23\n"; |
128 | |
129 | $x = sprintf("%U", $q); |
20fe1ea2 |
130 | print "not " unless $x == $q && $x eq $q && $x > $f; |
29fe7a80 |
131 | print "ok 24\n"; |
132 | |
133 | $x = sprintf("%O", $q); |
20fe1ea2 |
134 | print "not " unless oct($x) == $q && oct($x) > $f; |
29fe7a80 |
135 | print "ok 25\n"; |
136 | |
137 | |
0f4b6630 |
138 | $x = $q + $r; |
20fe1ea2 |
139 | print "not " unless $x == 35802467913 && $x > $f; |
29fe7a80 |
140 | print "ok 26\n"; |
0f4b6630 |
141 | |
142 | $x = $q - $r; |
20fe1ea2 |
143 | print "not " unless $x == -11111110111 && -$x > $f; |
29fe7a80 |
144 | print "ok 27\n"; |
0f4b6630 |
145 | |
146 | $x = $q * $r; |
20fe1ea2 |
147 | print "not " unless $x == 289589985190657035812 && $x > $f; |
29fe7a80 |
148 | print "ok 28\n"; |
0f4b6630 |
149 | |
150 | $x /= $r; |
20fe1ea2 |
151 | print "not " unless $x == $q && $x > $f; |
29fe7a80 |
152 | print "ok 29\n"; |
0f4b6630 |
153 | |
154 | $x = 98765432109 % 12345678901; |
155 | print "not " unless $x == 901; |
29fe7a80 |
156 | print "ok 30\n"; |