6 print +($_[1] ? "ok" : "not ok"), " $_[0]\n";
12 print "not ok $_[0] # $_[1] != $_[2]\n";
19 tryeq 4, -13 % -4, -1;
23 # Division (and modulo) of floating point numbers
24 # seem to be rather sloppy in Cray.
25 $limit = 1e8 if $^O eq 'unicos';
27 try 5, abs( 13e21 % 4e21 - 1e21) < $limit;
28 try 6, abs(-13e21 % 4e21 - 3e21) < $limit;
29 try 7, abs( 13e21 % -4e21 - -3e21) < $limit;
30 try 8, abs(-13e21 % -4e21 - -1e21) < $limit;
32 # UVs should behave properly
34 tryeq 9, 4063328477 % 65535, 27407;
35 tryeq 10, 4063328477 % 4063328476, 1;
36 tryeq 11, 4063328477 % 2031664238, 1;
37 tryeq 12, 2031664238 % 4063328477, 2031664238;
39 # These should trigger wrapping on 32 bit IVs and UVs
41 tryeq 13, 2147483647 + 0, 2147483647;
43 # IV + IV promote to UV
44 tryeq 14, 2147483647 + 1, 2147483648;
45 tryeq 15, 2147483640 + 10, 2147483650;
46 tryeq 16, 2147483647 + 2147483647, 4294967294;
47 # IV + UV promote to NV
48 tryeq 17, 2147483647 + 2147483649, 4294967296;
49 # UV + IV promote to NV
50 tryeq 18, 4294967294 + 2, 4294967296;
51 # UV + UV promote to NV
52 tryeq 19, 4294967295 + 4294967295, 8589934590;
55 tryeq 20, 2147483648 + -1, 2147483647;
56 tryeq 21, 2147483650 + -10, 2147483640;
58 tryeq 22, -1 + 2147483648, 2147483647;
59 tryeq 23, -10 + 4294967294, 4294967284;
61 tryeq 24, -2147483648 + -2147483648, -4294967296;
62 tryeq 25, -2147483640 + -10, -2147483650;
64 # Hmm. Don't forget the simple stuff
67 tryeq 28, -10 + 100, 90;
68 tryeq 29, -7 + -9, -16;
69 tryeq 30, -63 + +2, -61;
72 tryeq 33, +29 + -29, 0;
74 tryeq 35, +4 + -17, -13;
78 tryeq 37, 3 - 15, -12;
80 tryeq 39, -156 - 5, -161;
81 tryeq 40, -156 - -5, -151;
82 tryeq 41, -5 - -12, 7;
86 tryeq 44, 2147483647 - 0, 2147483647;
87 tryeq 45, 2147483648 - 0, 2147483648;
88 tryeq 46, -2147483648 - 0, -2147483648;
90 tryeq 47, 0 - -2147483647, 2147483647;
91 tryeq 48, -1 - -2147483648, 2147483647;
92 tryeq 49, 2 - -2147483648, 2147483650;
94 tryeq 50, 4294967294 - 3, 4294967291;
95 tryeq 51, -2147483648 - -1, -2147483647;
97 # IV - IV promote to UV
98 tryeq 52, 2147483647 - -1, 2147483648;
99 tryeq 53, 2147483647 - -2147483648, 4294967295;
100 # UV - IV promote to NV
101 tryeq 54, 4294967294 - -3, 4294967297;
102 # IV - IV promote to NV
103 tryeq 55, -2147483648 - +1, -2147483649;
104 # UV - UV promote to IV
105 tryeq 56, 2147483648 - 2147483650, -2;
106 # IV - UV promote to IV
107 tryeq 57, 2000000000 - 4000000000, -2000000000;
109 # No warnings should appear;
118 tryeq 60, $a, 4294967290;
121 tryeq 61, $a, -4294967290;
124 tryeq 62, $a, 4294967297;
127 tryeq 63, $a, -4294967297;
137 tryeq 66, $s, +4294967290;
140 tryeq 67, $s, -4294967290;
143 tryeq 68, $s, -4294967297;
146 tryeq 69, $s, +4294967297;
151 tryeq 71, -2 * 3, -6;
152 tryeq 72, 3 * -3, -9;
153 tryeq 73, -4 * -3, 12;
155 # check with 0xFFFF and 0xFFFF
156 tryeq 74, 65535 * 65535, 4294836225;
157 tryeq 75, 65535 * -65535, -4294836225;
158 tryeq 76, -65535 * 65535, -4294836225;
159 tryeq 77, -65535 * -65535, 4294836225;
161 # check with 0xFFFF and 0x10001
162 tryeq 78, 65535 * 65537, 4294967295;
163 tryeq 79, 65535 * -65537, -4294967295;
164 tryeq 80, -65535 * 65537, -4294967295;
165 tryeq 81, -65535 * -65537, 4294967295;
167 # check with 0x10001 and 0xFFFF
168 tryeq 82, 65537 * 65535, 4294967295;
169 tryeq 83, 65537 * -65535, -4294967295;
170 tryeq 84, -65537 * 65535, -4294967295;
171 tryeq 85, -65537 * -65535, 4294967295;
173 # These should all be dones as NVs
174 tryeq 86, 65537 * 65537, 4295098369;
175 tryeq 87, 65537 * -65537, -4295098369;
176 tryeq 88, -65537 * 65537, -4295098369;
177 tryeq 89, -65537 * -65537, 4295098369;
179 # will overflow an IV (in 32-bit)
180 tryeq 90, 46340 * 46342, 0x80001218;
181 tryeq 91, 46340 * -46342, -0x80001218;
182 tryeq 92, -46340 * 46342, -0x80001218;
183 tryeq 93, -46340 * -46342, 0x80001218;
185 tryeq 94, 46342 * 46340, 0x80001218;
186 tryeq 95, 46342 * -46340, -0x80001218;
187 tryeq 96, -46342 * 46340, -0x80001218;
188 tryeq 97, -46342 * -46340, 0x80001218;
190 # will overflow a positive IV (in 32-bit)
191 tryeq 98, 65536 * 32768, 0x80000000;
192 tryeq 99, 65536 * -32768, -0x80000000;
193 tryeq 100, -65536 * 32768, -0x80000000;
194 tryeq 101, -65536 * -32768, 0x80000000;
196 tryeq 102, 32768 * 65536, 0x80000000;
197 tryeq 103, 32768 * -65536, -0x80000000;
198 tryeq 104, -32768 * 65536, -0x80000000;
199 tryeq 105, -32768 * -65536, 0x80000000;
201 # 2147483647 is prime. bah.
203 tryeq 106, 46339 * 46341, 0x7ffea80f;
204 tryeq 107, 46339 * -46341, -0x7ffea80f;
205 tryeq 108, -46339 * 46341, -0x7ffea80f;
206 tryeq 109, -46339 * -46341, 0x7ffea80f;