author | Claus Gittinger <cg@exept.de> |
Fri, 07 Jan 2000 15:38:18 +0100 | |
changeset 54 | 77b06a241d57 |
parent 53 | 94b4cfba8e21 |
child 56 | 77f5ad522f18 |
permissions | -rw-r--r-- |
2 | 1 |
Object subclass:#IntegerTest |
27 | 2 |
instanceVariableNames:'' |
3 |
classVariableNames:'' |
|
4 |
poolDictionaries:'' |
|
5 |
category:'Tests - Numbers' |
|
2 | 6 |
! |
7 |
||
8 |
||
4 | 9 |
!IntegerTest class methodsFor:'misc'! |
10 |
||
31 | 11 |
testMul0_a:arg |
12 |
^ arg * 0 |
|
13 |
||
14 |
" |
|
15 |
(self testMul0_a:0) == 0 |
|
16 |
(self testMul0_a:1) == 0 |
|
17 |
(self testMul0_a:SmallInteger maxVal) == 0 |
|
18 |
(self testMul0_a:SmallInteger minVal) == 0 |
|
19 |
" |
|
20 |
||
21 |
"Created: / 9.6.1999 / 15:50:48 / cg" |
|
22 |
! |
|
23 |
||
24 |
testMul1_a:arg |
|
25 |
^ arg * 1 |
|
26 |
||
27 |
" |
|
28 |
(self testMul1_a:0) == 0 |
|
29 |
(self testMul1_a:1) == 1 |
|
30 |
(self testMul1_a:SmallInteger maxVal) == SmallInteger maxVal |
|
31 |
(self testMul1_a:SmallInteger minVal) == SmallInteger minVal |
|
32 |
" |
|
33 |
||
34 |
"Created: / 9.6.1999 / 15:49:09 / cg" |
|
35 |
! |
|
36 |
||
32 | 37 |
testMul2_a:arg |
38 |
^ arg * 2 |
|
39 |
||
40 |
" |
|
41 |
(self testMul2_a:0) == 0 |
|
42 |
(self testMul2_a:1) == 2 |
|
43 |
(self testMul2_a:SmallInteger maxVal) = (SmallInteger maxVal + SmallInteger maxVal) |
|
44 |
(self testMul2_a:SmallInteger minVal) = (SmallInteger minVal + SmallInteger minVal) |
|
45 |
" |
|
46 |
||
47 |
"Modified: / 9.6.1999 / 16:57:20 / cg" |
|
48 |
! |
|
49 |
||
50 |
testMul3_a:arg |
|
51 |
^ arg * 3 |
|
52 |
||
53 |
" |
|
54 |
(self testMul3_a:0) == 0 |
|
55 |
(self testMul3_a:1) == 3 |
|
56 |
(self testMul3_a:-1) == -3 |
|
57 |
(self testMul3_a:10000) == 30000 |
|
58 |
(self testMul3_a:SmallInteger maxVal) = (SmallInteger maxVal + SmallInteger maxVal + SmallInteger maxVal) |
|
59 |
(self testMul3_a:SmallInteger minVal) = (SmallInteger minVal + SmallInteger minVal + SmallInteger minVal) |
|
60 |
" |
|
61 |
||
62 |
"Created: / 9.6.1999 / 16:57:47 / cg" |
|
63 |
"Modified: / 9.6.1999 / 17:35:34 / cg" |
|
64 |
! |
|
65 |
||
66 |
testMul4_a:arg |
|
67 |
^ arg * 4 |
|
68 |
||
69 |
" |
|
70 |
(self testMul4_a:0) == 0 |
|
71 |
(self testMul4_a:1) == 4 |
|
72 |
(self testMul4_a:-1) == -4 |
|
73 |
(self testMul4_a:10000) == 40000 |
|
74 |
(self testMul4_a:SmallInteger maxVal//4) == 4611686018427387900 |
|
75 |
(self testMul4_a:SmallInteger maxVal//4+1) = 4611686018427387904 |
|
76 |
" |
|
77 |
||
78 |
"Created: / 9.6.1999 / 16:57:47 / cg" |
|
79 |
"Modified: / 9.6.1999 / 17:37:36 / cg" |
|
80 |
! |
|
81 |
||
82 |
testMul5_a:arg |
|
83 |
^ arg * 5 |
|
84 |
||
85 |
" |
|
86 |
(self testMul5_a:0) == 0 |
|
87 |
(self testMul5_a:1) == 5 |
|
88 |
(self testMul5_a:-1) == -5 |
|
89 |
(self testMul5_a:10000) == 50000 |
|
90 |
(self testMul5_a:SmallInteger maxVal//5) == 4611686018427387900 |
|
91 |
(self testMul5_a:SmallInteger maxVal//4+1) = 4611686018427387905 |
|
92 |
" |
|
93 |
||
94 |
"Created: / 9.6.1999 / 17:38:17 / cg" |
|
95 |
! |
|
96 |
||
31 | 97 |
testMulM1_a:arg |
98 |
^ arg * -1 |
|
99 |
||
100 |
" |
|
101 |
(self testMulM1_a:0) == 0 |
|
102 |
(self testMulM1_a:1) == -1 |
|
32 | 103 |
(self testMulM1_a:SmallInteger maxVal) == (SmallInteger minVal + 1) |
104 |
(self testMulM1_a:SmallInteger minVal) = (SmallInteger maxVal + 1) |
|
31 | 105 |
" |
106 |
||
32 | 107 |
"Modified: / 9.6.1999 / 16:54:02 / cg" |
31 | 108 |
! |
109 |
||
4 | 110 |
testPlus1_a:arg |
111 |
^ arg + 1 |
|
112 |
||
113 |
" |
|
114 |
(self testPlus1_a:SmallInteger maxVal) = 1073741824 |
|
115 |
" |
|
116 |
! |
|
117 |
||
118 |
testPlus1_b:arg |
|
119 |
^ arg perform:#+ with:1 |
|
120 |
||
121 |
" |
|
122 |
(self testPlus1_b:SmallInteger maxVal) == 1073741824 |
|
123 |
" |
|
124 |
! ! |
|
125 |
||
3 | 126 |
!IntegerTest class methodsFor:'private'! |
2 | 127 |
|
19 | 128 |
num_00000000000007FFF |
129 |
^ 16r00000000000007FFF |
|
130 |
||
131 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
132 |
"Created: / 4.6.1999 / 15:34:12 / cg" |
|
133 |
! |
|
134 |
||
135 |
num_00000000000008000 |
|
136 |
^ 16r00000000000008000 |
|
137 |
||
138 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
139 |
"Created: / 4.6.1999 / 15:39:32 / cg" |
|
140 |
! |
|
141 |
||
142 |
num_0000000000000FFFF |
|
143 |
^ 16r0000000000000FFFF |
|
144 |
||
145 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
146 |
"Created: / 4.6.1999 / 15:34:26 / cg" |
|
147 |
! |
|
148 |
||
149 |
num_00000000000010000 |
|
150 |
^ 16r00000000000010000 |
|
151 |
||
152 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
153 |
"Created: / 4.6.1999 / 15:34:31 / cg" |
|
154 |
! |
|
155 |
||
156 |
num_00000000000100000 |
|
157 |
^ 16r00000000000100000 |
|
158 |
||
159 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
160 |
"Created: / 4.6.1999 / 15:34:36 / cg" |
|
161 |
! |
|
162 |
||
163 |
num_000000000007FFFFF |
|
164 |
^ 16r000000000007FFFFF |
|
165 |
||
166 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
167 |
"Created: / 4.6.1999 / 15:37:48 / cg" |
|
168 |
! |
|
169 |
||
170 |
num_00000000000800000 |
|
171 |
^ 16r00000000000800000 |
|
172 |
||
173 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
174 |
"Created: / 4.6.1999 / 15:39:43 / cg" |
|
175 |
! |
|
176 |
||
177 |
num_00000000000FFFFFF |
|
178 |
^ 16r00000000000FFFFFF |
|
179 |
||
180 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
181 |
"Created: / 4.6.1999 / 15:37:52 / cg" |
|
182 |
! |
|
183 |
||
184 |
num_00000000001000000 |
|
185 |
^ 16r00000000001000000 |
|
186 |
||
187 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
188 |
"Created: / 4.6.1999 / 15:34:42 / cg" |
|
189 |
! |
|
190 |
||
22 | 191 |
num_0000000000FFF0000 |
192 |
^ 16r0000000000FFF0000 |
|
193 |
||
194 |
"self num_0000000000FFF0000 hexPrintString" |
|
195 |
||
196 |
"Created: / 4.6.1999 / 17:44:26 / cg" |
|
197 |
"Modified: / 4.6.1999 / 18:40:47 / cg" |
|
198 |
! |
|
199 |
||
19 | 200 |
num_00000000010000000 |
201 |
^ 16r00000000010000000 |
|
202 |
||
203 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
204 |
"Created: / 4.6.1999 / 15:34:46 / cg" |
|
205 |
! |
|
206 |
||
207 |
num_0000000007FFFFFFF |
|
208 |
^ 16r0000000007FFFFFFF |
|
209 |
||
210 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
211 |
"Created: / 4.6.1999 / 15:37:31 / cg" |
|
212 |
! |
|
213 |
||
214 |
num_00000000080000000 |
|
215 |
^ 16r00000000080000000 |
|
216 |
||
217 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
218 |
"Created: / 4.6.1999 / 15:39:56 / cg" |
|
219 |
! |
|
220 |
||
221 |
num_000000000FFFFFFFF |
|
222 |
^ 16r000000000FFFFFFFF |
|
223 |
||
224 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
225 |
"Created: / 4.6.1999 / 15:36:16 / cg" |
|
226 |
! |
|
227 |
||
228 |
num_00000000100000000 |
|
229 |
^ 16r00000000100000000 |
|
230 |
||
231 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
232 |
"Created: / 4.6.1999 / 15:34:51 / cg" |
|
233 |
! |
|
234 |
||
235 |
num_00000001000000000 |
|
236 |
^ 16r00000001000000000 |
|
237 |
||
238 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
239 |
"Created: / 4.6.1999 / 15:34:57 / cg" |
|
240 |
! |
|
241 |
||
21 | 242 |
num_0000000FFFFFFFFFF |
243 |
^ 16r0000000FFFFFFFFFF |
|
244 |
||
245 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
246 |
"Created: / 4.6.1999 / 17:41:08 / cg" |
|
247 |
! |
|
248 |
||
19 | 249 |
num_00000010000000000 |
250 |
^ 16r00000010000000000 |
|
251 |
||
252 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
253 |
"Created: / 4.6.1999 / 15:35:03 / cg" |
|
254 |
! |
|
255 |
||
256 |
num_00000100000000000 |
|
257 |
^ 16r00000100000000000 |
|
258 |
||
259 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
260 |
"Created: / 4.6.1999 / 15:35:07 / cg" |
|
261 |
! |
|
262 |
||
21 | 263 |
num_00000FFFFFFFFFF00 |
264 |
^ 16r00000FFFFFFFFFF00 |
|
265 |
||
266 |
"self num_00000FFFFFFFFFF00" |
|
267 |
||
268 |
"Created: / 4.6.1999 / 17:44:26 / cg" |
|
269 |
"Modified: / 4.6.1999 / 17:46:20 / cg" |
|
270 |
! |
|
271 |
||
272 |
num_00000FFFFFFFFFF80 |
|
273 |
^ 16r00000FFFFFFFFFF80 |
|
274 |
||
275 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
276 |
"Created: / 4.6.1999 / 17:44:23 / cg" |
|
277 |
! |
|
278 |
||
279 |
num_00000FFFFFFFFFFC0 |
|
280 |
^ 16r00000FFFFFFFFFFC0 |
|
281 |
||
282 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
283 |
"Created: / 4.6.1999 / 17:44:20 / cg" |
|
284 |
! |
|
285 |
||
286 |
num_00000FFFFFFFFFFE0 |
|
287 |
^ 16r00000FFFFFFFFFFE0 |
|
288 |
||
289 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
290 |
"Created: / 4.6.1999 / 17:44:16 / cg" |
|
291 |
! |
|
292 |
||
293 |
num_00000FFFFFFFFFFF0 |
|
294 |
^ 16r00000FFFFFFFFFFF0 |
|
295 |
||
296 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
297 |
"Created: / 4.6.1999 / 17:44:12 / cg" |
|
298 |
! |
|
299 |
||
300 |
num_00000FFFFFFFFFFF8 |
|
301 |
^ 16r00000FFFFFFFFFFF8 |
|
302 |
||
303 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
304 |
"Created: / 4.6.1999 / 17:44:09 / cg" |
|
305 |
! |
|
306 |
||
307 |
num_00000FFFFFFFFFFFC |
|
308 |
^ 16r00000FFFFFFFFFFFC |
|
309 |
||
310 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
311 |
"Created: / 4.6.1999 / 17:44:05 / cg" |
|
312 |
! |
|
313 |
||
314 |
num_00000FFFFFFFFFFFE |
|
315 |
^ 16r00000FFFFFFFFFFFE |
|
316 |
||
317 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
318 |
"Created: / 4.6.1999 / 17:45:12 / cg" |
|
319 |
! |
|
320 |
||
321 |
num_00000FFFFFFFFFFFF |
|
322 |
^ 16r00000FFFFFFFFFFFF |
|
323 |
||
324 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
325 |
"Created: / 4.6.1999 / 17:41:22 / cg" |
|
326 |
! |
|
327 |
||
19 | 328 |
num_00001000000000000 |
329 |
^ 16r00001000000000000 |
|
330 |
||
331 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
332 |
"Created: / 4.6.1999 / 15:35:13 / cg" |
|
333 |
! |
|
334 |
||
335 |
num_00010000000000000 |
|
336 |
^ 16r00010000000000000 |
|
337 |
||
338 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
339 |
"Created: / 4.6.1999 / 15:35:18 / cg" |
|
340 |
! |
|
341 |
||
21 | 342 |
num_000FFFFFFFFFFFFFF |
343 |
^ 16r000FFFFFFFFFFFFFF |
|
344 |
||
345 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
346 |
"Created: / 4.6.1999 / 17:41:26 / cg" |
|
347 |
! |
|
348 |
||
19 | 349 |
num_00100000000000000 |
350 |
^ 16r00100000000000000 |
|
351 |
||
352 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
353 |
"Created: / 4.6.1999 / 15:35:22 / cg" |
|
354 |
! |
|
355 |
||
356 |
num_01000000000000000 |
|
357 |
^ 16r01000000000000000 |
|
358 |
||
359 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
360 |
"Created: / 4.6.1999 / 15:35:27 / cg" |
|
361 |
! |
|
362 |
||
21 | 363 |
num_0FFFFFFFFFFFFFFFF |
364 |
^ 16r0FFFFFFFFFFFFFFFF |
|
365 |
||
366 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
367 |
"Created: / 4.6.1999 / 17:41:30 / cg" |
|
368 |
! |
|
369 |
||
19 | 370 |
num_10000000000000000 |
371 |
^ 16r10000000000000000 |
|
372 |
||
373 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
374 |
"Created: / 4.6.1999 / 15:35:32 / cg" |
|
375 |
! |
|
376 |
||
21 | 377 |
num_1FFFFFFFFFFFFFFFF |
378 |
^ 16r1FFFFFFFFFFFFFFFF |
|
379 |
||
380 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
381 |
"Created: / 4.6.1999 / 17:41:51 / cg" |
|
382 |
! |
|
383 |
||
384 |
num_20000000000000000 |
|
385 |
^ 16r20000000000000000 |
|
386 |
||
387 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
388 |
"Created: / 4.6.1999 / 17:40:26 / cg" |
|
389 |
! |
|
390 |
||
391 |
num_3FFFFFFFFFFFFFFFF |
|
392 |
^ 16r3FFFFFFFFFFFFFFFF |
|
393 |
||
394 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
395 |
"Created: / 4.6.1999 / 17:42:07 / cg" |
|
396 |
! |
|
397 |
||
398 |
num_40000000000000000 |
|
399 |
^ 16r40000000000000000 |
|
400 |
||
401 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
402 |
"Created: / 4.6.1999 / 17:40:29 / cg" |
|
403 |
! |
|
404 |
||
405 |
num_7FFFFFFFFFFFFFFFF |
|
406 |
^ 16r7FFFFFFFFFFFFFFFF |
|
407 |
||
408 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
409 |
"Created: / 4.6.1999 / 17:42:24 / cg" |
|
410 |
! |
|
411 |
||
412 |
num_80000000000000000 |
|
413 |
^ 16r80000000000000000 |
|
414 |
||
415 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
416 |
"Created: / 4.6.1999 / 17:40:33 / cg" |
|
417 |
! |
|
418 |
||
20 | 419 |
num_smallInt_maxVal |
420 |
^ SmallInteger maxVal |
|
421 |
||
21 | 422 |
"self num_smallInt_maxVal" |
423 |
||
424 |
"Modified: / 4.6.1999 / 17:33:22 / cg" |
|
20 | 425 |
! |
426 |
||
427 |
num_smallInt_minVal |
|
428 |
^ SmallInteger minVal |
|
429 |
||
21 | 430 |
"self num_smallInt_minVal" |
431 |
||
20 | 432 |
"Created: / 4.6.1999 / 16:26:05 / cg" |
21 | 433 |
"Modified: / 4.6.1999 / 17:34:31 / cg" |
20 | 434 |
! |
435 |
||
2 | 436 |
test:aBlock |
3 | 437 |
aBlock value == true ifFalse:[ |
2 | 438 |
self halt:'test failed' |
439 |
] |
|
54 | 440 |
! |
441 |
||
442 |
testIsInteger:arg |
|
443 |
^ arg isInteger |
|
2 | 444 |
! ! |
445 |
||
446 |
!IntegerTest class methodsFor:'tests'! |
|
447 |
||
448 |
test1 |
|
10 | 449 |
"general conversion & arithmetic tests. |
450 |
Notice, the arithmetic tests are both performed via regular sends |
|
451 |
and via constructed performs. The reason is to test both inlined |
|
452 |
JIT-compiler code AND the regular methods code." |
|
2 | 453 |
|
3 | 454 |
|minVal maxVal maxValPlus1 minValMinus1 halfMin halfMax t t1 t2| |
455 |
||
456 |
minVal := SmallInteger perform:('minVal' asSymbol). |
|
457 |
maxVal := SmallInteger perform:('maxVal' asSymbol). |
|
458 |
||
20 | 459 |
self test:[minVal == self num_smallInt_minVal]. |
460 |
self test:[maxVal == self num_smallInt_maxVal]. |
|
461 |
||
3 | 462 |
self test:[minVal == SmallInteger minVal]. |
463 |
self test:[maxVal == SmallInteger maxVal]. |
|
2 | 464 |
|
9 | 465 |
t := SmallInteger perform:('maxBytes' asSymbol). |
466 |
self test:[t == SmallInteger maxBytes]. |
|
467 |
t := SmallInteger perform:('maxBits' asSymbol). |
|
468 |
self test:[t == SmallInteger maxBits]. |
|
469 |
||
7 | 470 |
self testPrinting1. |
2 | 471 |
|
472 |
SmallInteger maxBytes == 4 ifTrue:[ |
|
3 | 473 |
self test:[minVal hexPrintString = '-40000000']. |
474 |
self test:[maxVal hexPrintString = '3FFFFFFF']. |
|
475 |
self test:[minVal == -1073741824]. |
|
476 |
self test:[maxVal == 1073741823]. |
|
2 | 477 |
maxValPlus1 := 1073741824. |
478 |
minValMinus1 := -1073741825. |
|
479 |
self test:[minValMinus1 hexPrintString = '-40000001']. |
|
480 |
self test:[maxValPlus1 hexPrintString = '40000000']. |
|
3 | 481 |
halfMin := -16r20000000. |
482 |
halfMax := 16r20000000. |
|
2 | 483 |
]. |
484 |
SmallInteger maxBytes == 8 ifTrue:[ |
|
3 | 485 |
self test:[minVal hexPrintString = '-4000000000000000']. |
486 |
self test:[maxVal hexPrintString = '3FFFFFFFFFFFFFFF']. |
|
487 |
self test:[minVal == -4611686018427387904]. |
|
488 |
self test:[maxVal == 4611686018427387903]. |
|
2 | 489 |
maxValPlus1 := 4611686018427387904. |
490 |
minValMinus1 := -4611686018427387905. |
|
491 |
self test:[minValMinus1 hexPrintString = '-4000000000000001']. |
|
492 |
self test:[maxValPlus1 hexPrintString = '4000000000000000']. |
|
3 | 493 |
halfMin := -16r2000000000000000. |
494 |
halfMax := 16r2000000000000000. |
|
2 | 495 |
]. |
496 |
||
497 |
"arithmetic overFlow checks" |
|
498 |
||
4 | 499 |
"/ self test:[(maxVal + 1) inspect.maxValPlus1 inspect. true]. |
6 | 500 |
self test:[(maxVal perform:'+' asSymbol with:1) = maxValPlus1]. |
501 |
self test:[(maxVal + 1) = maxValPlus1]. |
|
502 |
self test:[(minVal perform:'-' asSymbol with:1) = minValMinus1]. |
|
503 |
self test:[(minVal - 1) = minValMinus1]. |
|
3 | 504 |
|
6 | 505 |
self test:[(halfMax perform:'+' asSymbol with:halfMax) = maxValPlus1]. |
3 | 506 |
self test:[(halfMax + halfMax) = maxValPlus1]. |
6 | 507 |
self test:[(halfMin perform:'+' asSymbol with:halfMin) == minVal]. |
3 | 508 |
self test:[(halfMin + halfMin) == minVal]. |
6 | 509 |
self test:[(halfMax perform:'*' asSymbol with:2) = maxValPlus1]. |
3 | 510 |
self test:[(halfMax * 2) = maxValPlus1]. |
6 | 511 |
self test:[(halfMin perform:'*' asSymbol with:2) == minVal]. |
3 | 512 |
self test:[(halfMin * 2) == minVal]. |
6 | 513 |
self test:[(maxValPlus1 perform:'//' asSymbol with:2) == halfMax]. |
514 |
self test:[(maxValPlus1 // 2) == halfMax]. |
|
515 |
self test:[(halfMax perform:'bitShift:' asSymbol with:1) = maxValPlus1]. |
|
516 |
self test:[(halfMin perform:'bitShift:' asSymbol with:1) == minVal]. |
|
3 | 517 |
self test:[(halfMax bitShift:1) = maxValPlus1]. |
518 |
self test:[(halfMin bitShift:1) == minVal]. |
|
519 |
||
520 |
"LargeInt op -> SmallInt result" |
|
521 |
t := maxVal + 1. |
|
522 |
self test:[t - 1 == maxVal]. |
|
523 |
t := minVal - 1. |
|
524 |
self test:[t + 1 == minVal]. |
|
525 |
||
54 | 526 |
self testILC. |
27 | 527 |
self testSmallIntegerArithmetic. |
19 | 528 |
self testLiteralNumbers. |
15 | 529 |
self testLargeAddition. |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
530 |
self testLargeMultiplication. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
531 |
self testLargeDivision. |
42 | 532 |
self testIntegerShifts. |
533 |
self testEncodeDecode. |
|
53 | 534 |
self testIntegerMisc. |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
535 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
536 |
" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
537 |
self test1 |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
538 |
" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
539 |
|
27 | 540 |
"Modified: / 6.6.1999 / 14:46:11 / cg" |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
541 |
! |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
542 |
|
42 | 543 |
testEncodeDecode |
544 |
self test:[1 encodeAsBCD hexPrintString = '1']. |
|
545 |
self test:[12 encodeAsBCD hexPrintString = '12']. |
|
546 |
self test:[123 encodeAsBCD hexPrintString = '123']. |
|
547 |
self test:[1234 encodeAsBCD hexPrintString = '1234']. |
|
548 |
self test:[12345 encodeAsBCD hexPrintString = '12345']. |
|
549 |
self test:[123456 encodeAsBCD hexPrintString = '123456']. |
|
550 |
self test:[1234567 encodeAsBCD hexPrintString = '1234567']. |
|
551 |
self test:[12345678 encodeAsBCD hexPrintString = '12345678']. |
|
552 |
self test:[123456789 encodeAsBCD hexPrintString = '123456789']. |
|
553 |
self test:[1234567890 encodeAsBCD hexPrintString = '1234567890']. |
|
554 |
self test:[12345678901 encodeAsBCD hexPrintString = '12345678901']. |
|
555 |
self test:[123456789012 encodeAsBCD hexPrintString = '123456789012']. |
|
556 |
self test:[1234567890123 encodeAsBCD hexPrintString = '1234567890123']. |
|
557 |
self test:[12345678901234 encodeAsBCD hexPrintString = '12345678901234']. |
|
558 |
self test:[123456789012345 encodeAsBCD hexPrintString = '123456789012345']. |
|
559 |
self test:[1234567890123456 encodeAsBCD hexPrintString = '1234567890123456']. |
|
560 |
self test:[12345678901234567 encodeAsBCD hexPrintString = '12345678901234567']. |
|
561 |
self test:[123456789012345678 encodeAsBCD hexPrintString = '123456789012345678']. |
|
562 |
self test:[1234567890123456789 encodeAsBCD hexPrintString = '1234567890123456789']. |
|
563 |
self test:[12345678901234567890 encodeAsBCD hexPrintString = '12345678901234567890']. |
|
564 |
self test:[4611686018427387902 encodeAsBCD hexPrintString = '4611686018427387902']. |
|
565 |
self test:[4611686018427387903 encodeAsBCD hexPrintString = '4611686018427387903']. |
|
566 |
self test:[4611686018427387904 encodeAsBCD hexPrintString = '4611686018427387904']. |
|
567 |
||
568 |
self test:[16r1 decodeFromBCD = 1]. |
|
569 |
self test:[16r12 decodeFromBCD = 12]. |
|
570 |
self test:[16r123 decodeFromBCD = 123]. |
|
571 |
self test:[16r1234 decodeFromBCD = 1234]. |
|
572 |
self test:[16r12345 decodeFromBCD = 12345]. |
|
573 |
self test:[16r123456 decodeFromBCD = 123456]. |
|
574 |
self test:[16r1234567 decodeFromBCD = 1234567]. |
|
575 |
self test:[16r12345678 decodeFromBCD = 12345678]. |
|
576 |
self test:[16r123456789 decodeFromBCD = 123456789]. |
|
577 |
self test:[16r1234567890 decodeFromBCD = 1234567890]. |
|
578 |
self test:[16r12345678901 decodeFromBCD = 12345678901]. |
|
579 |
self test:[16r123456789012 decodeFromBCD = 123456789012]. |
|
580 |
self test:[16r1000000000000 decodeFromBCD = 1000000000000]. |
|
581 |
self test:[16r0000500000000 decodeFromBCD = 500000000]. |
|
582 |
self test:[16r1234500000000 decodeFromBCD = 1234500000000]. |
|
583 |
self test:[16r1234567890000 decodeFromBCD = 1234567890000]. |
|
584 |
||
585 |
self test:[16r1234567890123 decodeFromBCD = 1234567890123]. |
|
586 |
self test:[16r12345678901234 decodeFromBCD = 12345678901234]. |
|
587 |
self test:[16r123456789012345 decodeFromBCD = 123456789012345]. |
|
588 |
self test:[16r1234567890123456 decodeFromBCD = 1234567890123456]. |
|
589 |
self test:[16r12345678901234567 decodeFromBCD = 12345678901234567]. |
|
590 |
self test:[16r123456789012345678 decodeFromBCD = 123456789012345678]. |
|
591 |
self test:[16r1234567890123456789 decodeFromBCD = 1234567890123456789]. |
|
592 |
self test:[16r12345678901234567890 decodeFromBCD = 12345678901234567890]. |
|
593 |
self test:[16r4611686018427387902 decodeFromBCD = 4611686018427387902]. |
|
594 |
self test:[16r4611686018427387903 decodeFromBCD = 4611686018427387903]. |
|
595 |
self test:[16r4611686018427387904 decodeFromBCD = 4611686018427387904]. |
|
596 |
||
597 |
" |
|
598 |
self testEncodeDecode |
|
599 |
" |
|
600 |
||
601 |
"Modified: / 26.10.1999 / 22:01:35 / stefan" |
|
602 |
! |
|
603 |
||
54 | 604 |
testILC |
605 |
"inline-cache" |
|
606 |
||
607 |
self test:[(self testIsInteger:1) == true]. |
|
608 |
self test:[(self testIsInteger:nil) == false]. |
|
609 |
self test:[(self testIsInteger:1) == true]. |
|
610 |
self test:[(self testIsInteger:nil) == false]. |
|
611 |
||
612 |
self test:[(self testIsInteger:0) == true]. |
|
613 |
self test:[(self testIsInteger:nil) == false]. |
|
614 |
self test:[(self testIsInteger:0) == true]. |
|
615 |
self test:[(self testIsInteger:nil) == false]. |
|
616 |
||
617 |
" |
|
618 |
self testILC |
|
619 |
" |
|
620 |
||
621 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
622 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
623 |
! |
|
624 |
||
53 | 625 |
testIntegerMisc |
626 |
"misc tests. |
|
627 |
Notice, the arithmetic tests are both performed via regular sends |
|
628 |
and via constructed performs. The reason is to test both inlined |
|
629 |
JIT-compiler code AND the regular methods code." |
|
630 |
||
631 |
|n1 n2 s| |
|
632 |
||
633 |
n1 := 100000. |
|
634 |
n2 := n1 negated. |
|
635 |
s := 1. |
|
636 |
||
637 |
self test:[n1 printString = '100000']. |
|
638 |
||
639 |
self test:[n1 negated printString = '-100000']. |
|
640 |
self test:[(n1 perform:'negated' asSymbol) printString = '-100000']. |
|
641 |
||
642 |
self test:[n1 negated abs printString = '100000']. |
|
643 |
self test:[(n1 perform:'negated' asSymbol) abs printString = '100000']. |
|
644 |
||
645 |
self test:[n1 abs negated printString = '-100000']. |
|
646 |
self test:[(n1 perform:'abs' asSymbol) negated printString = '-100000']. |
|
647 |
||
648 |
n1 := SmallInteger maxVal. |
|
649 |
self test:[n1 negated class == SmallInteger]. |
|
650 |
self test:[(n1 perform:'negated' asSymbol) class == SmallInteger]. |
|
651 |
||
652 |
n1 := SmallInteger minVal. |
|
653 |
self test:[n1 negated class == LargeInteger]. |
|
654 |
self test:[(n1 perform:'negated' asSymbol) class == LargeInteger]. |
|
655 |
||
656 |
n1 := SmallInteger minVal negated - 1. |
|
657 |
self test:[n1 negated class == SmallInteger]. |
|
658 |
self test:[(n1 perform:'negated' asSymbol) class == SmallInteger]. |
|
659 |
self test:[n1 == SmallInteger maxVal]. |
|
660 |
||
661 |
" |
|
662 |
self testIntegerMisc |
|
663 |
" |
|
664 |
||
665 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
666 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
667 |
! |
|
668 |
||
41 | 669 |
testIntegerShifts |
670 |
"arithmetic tests. |
|
671 |
Notice, the arithmetic tests are both performed via regular sends |
|
672 |
and via constructed performs. The reason is to test both inlined |
|
673 |
JIT-compiler code AND the regular methods code." |
|
674 |
||
45 | 675 |
self testIntegerShifts1. |
676 |
self testIntegerShifts2. |
|
677 |
||
678 |
self test:[ |
|
679 |
(((0 to:64) collect:[:s | 1 bitShift:s]) |
|
680 |
collect:[:n | n highBit]) = (1 to:65) |
|
681 |
]. |
|
682 |
||
683 |
1 to:10000 do:[:s | |
|
684 |
self test:[ (1 bitShift:s) highBit == (s+1) ] |
|
685 |
]. |
|
686 |
1 to:10000 do:[:s | |
|
687 |
self test:[ ((1 bitShift:s) - 1) highBit == s ] |
|
688 |
]. |
|
689 |
||
690 |
" |
|
691 |
self testIntegerShifts |
|
692 |
" |
|
693 |
||
694 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
695 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
696 |
! |
|
697 |
||
698 |
testIntegerShifts1 |
|
699 |
"arithmetic tests. |
|
700 |
Notice, the arithmetic tests are both performed via regular sends |
|
701 |
and via constructed performs. The reason is to test both inlined |
|
702 |
JIT-compiler code AND the regular methods code." |
|
703 |
||
41 | 704 |
|n1 n2 s| |
705 |
||
706 |
n1 := 100000. |
|
707 |
n2 := n1 negated. |
|
708 |
s := 1. |
|
709 |
||
710 |
self test:[n1 printString = '100000']. |
|
711 |
self test:[n2 printString = '-100000']. |
|
712 |
||
713 |
self test:[(n1 bitShift:s) printString = '200000']. |
|
714 |
self test:[(n1 bitShift:1) printString = '200000']. |
|
715 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '200000']. |
|
716 |
self test:[(n1 perform:'bitShift:' asSymbol with:1) printString = '200000']. |
|
717 |
||
718 |
s := s + 1. |
|
719 |
self test:[(n1 bitShift:s) printString = '400000']. |
|
720 |
self test:[(n1 bitShift:2) printString = '400000']. |
|
721 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '400000']. |
|
722 |
self test:[(n1 perform:'bitShift:' asSymbol with:2) printString = '400000']. |
|
723 |
||
724 |
s := s + 1. |
|
725 |
self test:[(n1 bitShift:s) printString = '800000']. |
|
726 |
self test:[(n1 bitShift:3) printString = '800000']. |
|
727 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '800000']. |
|
728 |
self test:[(n1 perform:'bitShift:' asSymbol with:3) printString = '800000']. |
|
729 |
||
730 |
s := s + 1. |
|
731 |
self test:[(n1 bitShift:s) printString = '1600000']. |
|
732 |
self test:[(n1 bitShift:4) printString = '1600000']. |
|
733 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '1600000']. |
|
734 |
self test:[(n1 perform:'bitShift:' asSymbol with:4) printString = '1600000']. |
|
735 |
||
736 |
s := s + 1. |
|
737 |
self test:[(n1 bitShift:s) printString = '3200000']. |
|
738 |
self test:[(n1 bitShift:5) printString = '3200000']. |
|
739 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '3200000']. |
|
740 |
self test:[(n1 perform:'bitShift:' asSymbol with:5) printString = '3200000']. |
|
741 |
||
742 |
s := s + 1. |
|
743 |
self test:[(n1 bitShift:s) printString = '6400000']. |
|
744 |
self test:[(n1 bitShift:6) printString = '6400000']. |
|
745 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '6400000']. |
|
746 |
self test:[(n1 perform:'bitShift:' asSymbol with:6) printString = '6400000']. |
|
747 |
||
748 |
s := s + 1. |
|
749 |
self test:[(n1 bitShift:s) printString = '12800000']. |
|
750 |
self test:[(n1 bitShift:7) printString = '12800000']. |
|
751 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '12800000']. |
|
752 |
self test:[(n1 perform:'bitShift:' asSymbol with:7) printString = '12800000']. |
|
753 |
||
45 | 754 |
" |
755 |
self testIntegerShifts1 |
|
756 |
" |
|
757 |
||
758 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
759 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
760 |
! |
|
761 |
||
762 |
testIntegerShifts2 |
|
763 |
"arithmetic tests. |
|
764 |
Notice, the arithmetic tests are both performed via regular sends |
|
765 |
and via constructed performs. The reason is to test both inlined |
|
766 |
JIT-compiler code AND the regular methods code." |
|
767 |
||
768 |
|n1 s| |
|
769 |
||
41 | 770 |
n1 := 12800000. |
771 |
s := -1. |
|
772 |
self test:[(n1 bitShift:s) printString = '6400000']. |
|
773 |
self test:[(n1 bitShift:-1) printString = '6400000']. |
|
774 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '6400000']. |
|
775 |
self test:[(n1 perform:'bitShift:' asSymbol with:-1) printString = '6400000']. |
|
776 |
||
777 |
s := s - 1. |
|
778 |
self test:[(n1 bitShift:s) printString = '3200000']. |
|
779 |
self test:[(n1 bitShift:-2) printString = '3200000']. |
|
780 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '3200000']. |
|
781 |
self test:[(n1 perform:'bitShift:' asSymbol with:-2) printString = '3200000']. |
|
782 |
||
783 |
s := s - 1. |
|
784 |
self test:[(n1 bitShift:s) printString = '1600000']. |
|
785 |
self test:[(n1 bitShift:-3) printString = '1600000']. |
|
786 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '1600000']. |
|
787 |
self test:[(n1 perform:'bitShift:' asSymbol with:-3) printString = '1600000']. |
|
788 |
||
789 |
s := s - 1. |
|
790 |
self test:[(n1 bitShift:s) printString = '800000']. |
|
791 |
self test:[(n1 bitShift:-4) printString = '800000']. |
|
792 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '800000']. |
|
793 |
self test:[(n1 perform:'bitShift:' asSymbol with:-4) printString = '800000']. |
|
794 |
||
795 |
s := s - 1. |
|
796 |
self test:[(n1 bitShift:s) printString = '400000']. |
|
797 |
self test:[(n1 bitShift:-5) printString = '400000']. |
|
798 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '400000']. |
|
799 |
self test:[(n1 perform:'bitShift:' asSymbol with:-5) printString = '400000']. |
|
800 |
||
801 |
s := s - 1. |
|
802 |
self test:[(n1 bitShift:s) printString = '200000']. |
|
803 |
self test:[(n1 bitShift:-6) printString = '200000']. |
|
804 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '200000']. |
|
805 |
self test:[(n1 perform:'bitShift:' asSymbol with:-6) printString = '200000']. |
|
806 |
||
807 |
s := s - 1. |
|
808 |
self test:[(n1 bitShift:s) printString = '100000']. |
|
809 |
self test:[(n1 bitShift:-7) printString = '100000']. |
|
810 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '100000']. |
|
811 |
self test:[(n1 perform:'bitShift:' asSymbol with:-7) printString = '100000']. |
|
812 |
||
813 |
s := s - 1. |
|
814 |
self test:[(n1 bitShift:s) printString = '50000']. |
|
815 |
self test:[(n1 bitShift:-8) printString = '50000']. |
|
816 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '50000']. |
|
817 |
self test:[(n1 perform:'bitShift:' asSymbol with:-8) printString = '50000']. |
|
818 |
||
819 |
s := s - 1. |
|
820 |
self test:[(n1 bitShift:s) printString = '25000']. |
|
821 |
self test:[(n1 bitShift:-9) printString = '25000']. |
|
822 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '25000']. |
|
823 |
self test:[(n1 perform:'bitShift:' asSymbol with:-9) printString = '25000']. |
|
824 |
||
825 |
s := s - 1. |
|
826 |
self test:[(n1 bitShift:s) printString = '12500']. |
|
827 |
self test:[(n1 bitShift:-10) printString = '12500']. |
|
828 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '12500']. |
|
829 |
self test:[(n1 perform:'bitShift:' asSymbol with:-10) printString = '12500']. |
|
830 |
||
831 |
s := s - 1. |
|
832 |
self test:[(n1 bitShift:s) printString = '6250']. |
|
833 |
self test:[(n1 bitShift:-11) printString = '6250']. |
|
834 |
self test:[(n1 perform:'bitShift:' asSymbol with:s) printString = '6250']. |
|
835 |
self test:[(n1 perform:'bitShift:' asSymbol with:-11) printString = '6250']. |
|
836 |
||
837 |
" |
|
45 | 838 |
self testIntegerShifts2 |
41 | 839 |
" |
840 |
||
841 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
842 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
843 |
! |
|
844 |
||
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
845 |
testLargeAddition |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
846 |
"general conversion & arithmetic tests. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
847 |
Notice, the arithmetic tests are both performed via regular sends |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
848 |
and via constructed performs. The reason is to test both inlined |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
849 |
JIT-compiler code AND the regular methods code." |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
850 |
|
19 | 851 |
|s n1 n2 x| |
13 | 852 |
|
23 | 853 |
"Large + Large addition" |
854 |
self testReading1. |
|
855 |
||
856 |
self test:[(20 factorial + 20 factorial) printString = '4865804016353280000']. |
|
857 |
self test:[(20 factorial + 1) printString = '2432902008176640001']. |
|
858 |
self test:[(20 factorial + 1000) printString = '2432902008176641000']. |
|
859 |
||
29 | 860 |
"Large + Small addition" |
861 |
||
34 | 862 |
self testLargeAddition1. |
863 |
||
864 |
"Large + Large addition" |
|
865 |
||
866 |
self testLargeAddition2. |
|
867 |
||
868 |
"Large - small subtraction" |
|
869 |
||
870 |
self testLargeAddition3. |
|
871 |
||
872 |
" |
|
873 |
self testLargeAddition |
|
874 |
" |
|
875 |
||
876 |
"Modified: / 4.6.1999 / 15:26:55 / cg" |
|
877 |
! |
|
878 |
||
879 |
testLargeAddition1 |
|
880 |
"general conversion & arithmetic tests. |
|
881 |
Notice, the arithmetic tests are both performed via regular sends |
|
882 |
and via constructed performs. The reason is to test both inlined |
|
883 |
JIT-compiler code AND the regular methods code." |
|
884 |
||
885 |
|s n1 n2 x| |
|
886 |
||
887 |
"Large + Small addition" |
|
888 |
||
29 | 889 |
n1 := 16r3FFFFFFF. n2 := 1. |
890 |
self test:[(n1 + n2 ) hexPrintString = '40000000']. |
|
891 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000']. |
|
892 |
n1 := 16r3FFFFFFFF. n2 := 1. |
|
893 |
self test:[(n1 + n2 ) hexPrintString = '400000000']. |
|
894 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000']. |
|
895 |
n1 := 16r3FFFFFFFFF. n2 := 1. |
|
896 |
self test:[(n1 + n2 ) hexPrintString = '4000000000']. |
|
897 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000']. |
|
898 |
n1 := 16r3FFFFFFFFFF. n2 := 1. |
|
899 |
self test:[(n1 + n2 ) hexPrintString = '40000000000']. |
|
900 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000000']. |
|
901 |
n1 := 16r3FFFFFFFFFFF. n2 := 1. |
|
902 |
self test:[(n1 + n2 ) hexPrintString = '400000000000']. |
|
903 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000000']. |
|
904 |
n1 := 16r3FFFFFFFFFFFF. n2 := 1. |
|
905 |
self test:[(n1 + n2 ) hexPrintString = '4000000000000']. |
|
906 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000000']. |
|
907 |
n1 := 16r3FFFFFFFFFFFFF. n2 := 1. |
|
908 |
self test:[(n1 + n2 ) hexPrintString = '40000000000000']. |
|
909 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000000000']. |
|
910 |
n1 := 16r3FFFFFFFFFFFFFF. n2 := 1. |
|
911 |
self test:[(n1 + n2 ) hexPrintString = '400000000000000']. |
|
912 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000000000']. |
|
913 |
n1 := 16r3FFFFFFFFFFFFFFF. n2 := 1. |
|
914 |
self test:[(n1 + n2 ) hexPrintString = '4000000000000000']. |
|
915 |
self test:[(n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000000000']. |
|
916 |
||
34 | 917 |
" |
918 |
self testLargeAddition1 |
|
919 |
" |
|
920 |
||
921 |
"Modified: / 4.6.1999 / 15:26:55 / cg" |
|
922 |
! |
|
923 |
||
924 |
testLargeAddition2 |
|
925 |
"general conversion & arithmetic tests. |
|
926 |
Notice, the arithmetic tests are both performed via regular sends |
|
927 |
and via constructed performs. The reason is to test both inlined |
|
928 |
JIT-compiler code AND the regular methods code." |
|
929 |
||
930 |
|s n1 n2 x| |
|
931 |
||
29 | 932 |
"Large + Large addition" |
23 | 933 |
|
934 |
n1 := 16r100000000. n2 := 16r7FFFFFFF. |
|
935 |
self test:[(n1 - n2 ) hexPrintString = '80000001']. |
|
936 |
self test:[(16r100000000 - n2 ) hexPrintString = '80000001']. |
|
937 |
self test:[(n1 - 16r7FFFFFFF ) hexPrintString = '80000001']. |
|
938 |
self test:[(16r100000000 - 16r7FFFFFFF ) hexPrintString = '80000001']. |
|
939 |
self test:[(n1 perform:'-' asSymbol with:n2 ) hexPrintString = '80000001']. |
|
940 |
self test:[(16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '80000001']. |
|
941 |
self test:[(n1 perform:'-' asSymbol with:16r7FFFFFFF ) hexPrintString = '80000001']. |
|
942 |
self test:[(16r100000000 perform:'-' asSymbol with:16r7FFFFFFF ) hexPrintString = '80000001']. |
|
943 |
||
944 |
n1 := 16r100000000. n2 := 16r80000000. |
|
945 |
self test:[(n1 - n2 ) hexPrintString = '80000000']. |
|
946 |
self test:[(16r100000000 - n2 ) hexPrintString = '80000000']. |
|
947 |
self test:[(n1 - 16r80000000 ) hexPrintString = '80000000']. |
|
948 |
self test:[(16r100000000 - 16r80000000 ) hexPrintString = '80000000']. |
|
949 |
self test:[(n1 perform:'-' asSymbol with:n2 ) hexPrintString = '80000000']. |
|
950 |
self test:[(16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '80000000']. |
|
951 |
self test:[(n1 perform:'-' asSymbol with:16r80000000 ) hexPrintString = '80000000']. |
|
952 |
self test:[(16r100000000 perform:'-' asSymbol with:16r80000000 ) hexPrintString = '80000000']. |
|
17 | 953 |
|
954 |
n1 := 16r100000000. n2 := 16rFFFFFFFF. |
|
23 | 955 |
self test:[(n1 - n2 ) hexPrintString = '1']. |
956 |
self test:[(16r100000000 - n2 ) hexPrintString = '1']. |
|
19 | 957 |
self test:[(x := n1 - 16rFFFFFFFF) == 1]. |
17 | 958 |
|
23 | 959 |
self test:[(n1 - 16rFFFFFFFF ) hexPrintString = '1']. |
960 |
self test:[(16r100000000 - 16rFFFFFFFF ) hexPrintString = '1']. |
|
961 |
self test:[(n1 perform:'-' asSymbol with:n2 ) hexPrintString = '1']. |
|
962 |
self test:[(16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '1']. |
|
963 |
self test:[(n1 perform:'-' asSymbol with:16rFFFFFFFF ) hexPrintString = '1']. |
|
964 |
self test:[(16r100000000 perform:'-' asSymbol with:16rFFFFFFFF ) hexPrintString = '1']. |
|
965 |
||
966 |
n1 := 16r100000000. n2 := 1. |
|
967 |
self test:[(n1 - n2) hexPrintString = 'FFFFFFFF']. |
|
968 |
self test:[(n1 - n2) hexPrintString = 'FFFFFFFF']. |
|
969 |
self test:[(16r100000000 - n2) hexPrintString = 'FFFFFFFF']. |
|
970 |
self test:[(n1 - 1) hexPrintString = 'FFFFFFFF']. |
|
971 |
self test:[(16r100000000 - 1) hexPrintString = 'FFFFFFFF']. |
|
972 |
self test:[(n1 perform:'-' asSymbol with:n2) hexPrintString = 'FFFFFFFF']. |
|
973 |
self test:[(16r100000000 perform:'-' asSymbol with:n2) hexPrintString = 'FFFFFFFF']. |
|
974 |
self test:[(n1 perform:'-' asSymbol with:1) hexPrintString = 'FFFFFFFF']. |
|
975 |
self test:[(16r100000000 perform:'-' asSymbol with:1) hexPrintString = 'FFFFFFFF']. |
|
976 |
||
977 |
n1 := 16r100000000. n2 := 16r10000000. |
|
978 |
self test:[(n1 - n2) hexPrintString = 'F0000000']. |
|
979 |
self test:[(16r100000000 - n2) hexPrintString = 'F0000000']. |
|
980 |
self test:[(n1 - 16r10000000) hexPrintString = 'F0000000']. |
|
981 |
self test:[(16r100000000 - 16r10000000) hexPrintString = 'F0000000']. |
|
982 |
self test:[(n1 perform:'-' asSymbol with:n2) hexPrintString = 'F0000000']. |
|
983 |
self test:[(16r100000000 perform:'-' asSymbol with:n2) hexPrintString = 'F0000000']. |
|
984 |
self test:[(n1 perform:'-' asSymbol with:16r10000000) hexPrintString = 'F0000000']. |
|
985 |
self test:[(16r100000000 perform:'-' asSymbol with:16r10000000) hexPrintString = 'F0000000']. |
|
986 |
||
34 | 987 |
" |
988 |
self testLargeAddition2 |
|
989 |
" |
|
990 |
||
991 |
! |
|
992 |
||
993 |
testLargeAddition3 |
|
994 |
"general conversion & arithmetic tests. |
|
995 |
Notice, the arithmetic tests are both performed via regular sends |
|
996 |
and via constructed performs. The reason is to test both inlined |
|
997 |
JIT-compiler code AND the regular methods code." |
|
998 |
||
999 |
|s n1 n2 x| |
|
1000 |
||
23 | 1001 |
"Large - small subtraction" |
1002 |
self test:[(20 factorial + 20 factorial - 1) printString = '4865804016353279999']. |
|
1003 |
self test:[(20 factorial - 10 factorial + 3628800) printString = '2432902008176640000']. |
|
1004 |
self test:[(20 factorial - 11 factorial + 39916800) printString = '2432902008176640000']. |
|
1005 |
self test:[(20 factorial - 12 factorial + 479001600) printString = '2432902008176640000']. |
|
1006 |
self test:[(20 factorial - 13 factorial + 6227020800) printString = '2432902008176640000']. |
|
1007 |
self test:[(20 factorial - 14 factorial + 87178291200) printString = '2432902008176640000']. |
|
1008 |
self test:[(20 factorial - 15 factorial + 1307674368000) printString = '2432902008176640000']. |
|
1009 |
self test:[(20 factorial - 16 factorial + 20922789888000) printString = '2432902008176640000']. |
|
1010 |
self test:[(20 factorial + 10 factorial - 3628800) printString = '2432902008176640000']. |
|
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1011 |
|
52 | 1012 |
self test:[1000 factorial printString = '402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000']. |
51 | 1013 |
|
1014 |
n1 := n2 := 1. |
|
1015 |
self test:[(1000 factorial + n1 - n2) = 1000 factorial]. |
|
1016 |
n1 := n2 := 1000. |
|
1017 |
self test:[(1000 factorial + n1 - n2) = 1000 factorial]. |
|
1018 |
n1 := n2 := 16rFFFFFFFF. |
|
1019 |
self test:[(1000 factorial + n1 - n2) = 1000 factorial]. |
|
1020 |
n1 := n2 := 16rFFFFFFFFFFFF. |
|
1021 |
self test:[(1000 factorial + n1 - n2) = 1000 factorial]. |
|
1022 |
n1 := n2 := 16rFFFFFFFFFFFFFFFF. |
|
1023 |
self test:[(1000 factorial + n1 - n2) = 1000 factorial]. |
|
1024 |
n1 := n2 := 1000 factorial. |
|
1025 |
self test:[(1000 factorial + n1 - n2) = 1000 factorial]. |
|
1026 |
||
1027 |
||
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1028 |
" |
34 | 1029 |
self testLargeAddition3 |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1030 |
" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1031 |
|
52 | 1032 |
"Modified: / 27.11.1999 / 16:41:54 / cg" |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1033 |
! |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1034 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1035 |
testLargeDivision |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1036 |
|t| |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1037 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1038 |
t := 20 factorial. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1039 |
|
16 | 1040 |
self test:[t printString = '2432902008176640000']. |
1041 |
self test:[t \\ 10 == 0]. |
|
1042 |
t := t // 10. |
|
1043 |
self test:[t printString = '243290200817664000']. |
|
1044 |
self test:[t \\ 10 == 0]. |
|
1045 |
t := t // 10. |
|
1046 |
self test:[t printString = '24329020081766400']. |
|
1047 |
self test:[t \\ 10 == 0]. |
|
1048 |
t := t // 10. |
|
1049 |
self test:[t printString = '2432902008176640']. |
|
1050 |
self test:[t \\ 10 == 0]. |
|
1051 |
t := t // 10. |
|
1052 |
self test:[t printString = '243290200817664']. |
|
1053 |
self test:[t \\ 10 == 4]. |
|
1054 |
t := t // 10. |
|
1055 |
self test:[t printString = '24329020081766']. |
|
1056 |
self test:[t \\ 10 == 6]. |
|
1057 |
t := t // 10. |
|
1058 |
self test:[t printString = '2432902008176']. |
|
1059 |
self test:[t \\ 10 == 6]. |
|
1060 |
t := t // 10. |
|
1061 |
self test:[t printString = '243290200817']. |
|
1062 |
self test:[t \\ 10 == 7]. |
|
1063 |
t := t // 10. |
|
1064 |
self test:[t printString = '24329020081']. |
|
1065 |
self test:[t \\ 10 == 1]. |
|
1066 |
t := t // 10. |
|
1067 |
self test:[t printString = '2432902008']. |
|
1068 |
self test:[t \\ 10 == 8]. |
|
1069 |
t := t // 10. |
|
1070 |
self test:[t printString = '243290200']. |
|
1071 |
self test:[t \\ 10 == 0]. |
|
1072 |
||
1073 |
||
1074 |
t := 20 factorial. |
|
1075 |
||
1076 |
self test:[t printString = '2432902008176640000']. |
|
1077 |
self test:[t \\ 1000 == 0]. |
|
1078 |
t := t // 1000. |
|
1079 |
self test:[t printString = '2432902008176640']. |
|
1080 |
self test:[t \\ 1000 == 640]. |
|
1081 |
t := t // 1000. |
|
1082 |
self test:[t printString = '2432902008176']. |
|
1083 |
self test:[t \\ 1000 == 176]. |
|
1084 |
t := t // 1000. |
|
1085 |
self test:[t printString = '2432902008']. |
|
1086 |
self test:[t \\ 1000 == 8]. |
|
1087 |
t := t // 1000. |
|
1088 |
self test:[t printString = '2432902']. |
|
1089 |
self test:[t \\ 1000 == 902]. |
|
1090 |
t := t // 1000. |
|
1091 |
self test:[t printString = '2432']. |
|
1092 |
self test:[t \\ 1000 == 432]. |
|
1093 |
t := t // 1000. |
|
1094 |
self test:[t == 2]. |
|
1095 |
self test:[t \\ 1000 == 2]. |
|
1096 |
||
1097 |
||
1098 |
t := 20 factorial. |
|
1099 |
||
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1100 |
"Large // SmallInt division" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1101 |
t := t // 20. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1102 |
self test:[t printString = 19 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1103 |
t := t // 19. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1104 |
self test:[t printString = 18 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1105 |
t := t // 18. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1106 |
self test:[t printString = 17 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1107 |
t := t // 17. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1108 |
self test:[t printString = 16 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1109 |
t := t // 16. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1110 |
self test:[t printString = 15 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1111 |
t := t // 15. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1112 |
self test:[t printString = 14 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1113 |
t := t // 14. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1114 |
self test:[t printString = 13 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1115 |
t := t // 13. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1116 |
self test:[t printString = 12 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1117 |
t := t // 12. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1118 |
self test:[t printString = 11 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1119 |
t := t // 11. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1120 |
self test:[t printString = 10 factorial printString]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1121 |
self test:[t == 10 factorial]. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1122 |
|
26 | 1123 |
t := 20 factorial. |
1124 |
t := t + 21 factorial. |
|
1125 |
t absSubtract:21 factorial. |
|
1126 |
self test:[t compressed = 20 factorial]. |
|
1127 |
||
1128 |
self test:[|v| |
|
1129 |
v := 100 factorial copy. |
|
1130 |
v absSubtract:99 factorial. |
|
1131 |
v compressed = (100 factorial - 99 factorial)]. |
|
1132 |
||
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1133 |
"Large // Large division" |
26 | 1134 |
self test:[(20 factorial // 19 factorial) == 20]. |
1135 |
self test:[(20 factorial * 21 // 20 // 21) = (19 factorial)]. |
|
1136 |
self test:[(10000 factorial // 9999 factorial) == 10000]. |
|
1137 |
self test:[(10000 factorial // 9999 factorial) == (10000 factorial / 9999 factorial)]. |
|
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1138 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1139 |
" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1140 |
self testLargeDivision |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1141 |
" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1142 |
|
26 | 1143 |
"Modified: / 4.6.1999 / 23:54:57 / cg" |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1144 |
! |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1145 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1146 |
testLargeMultiplication |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1147 |
|t1| |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1148 |
|
3 | 1149 |
"multiplication" |
1150 |
t1 := 100. |
|
1151 |
self test:[t1 * t1 == 10000]. |
|
10 | 1152 |
self test:[(t1 perform:'*' asSymbol with:t1) == 10000]. |
11 | 1153 |
self test:[(t1 * t1) printString = '10000']. |
1154 |
self test:[(t1 perform:'*' asSymbol with:t1) printString = '10000']. |
|
1155 |
||
3 | 1156 |
t1 := 1000. |
1157 |
self test:[t1 * t1 == 1000000]. |
|
10 | 1158 |
self test:[(t1 perform:'*' asSymbol with:t1) == 1000000]. |
11 | 1159 |
self test:[(t1 * t1) printString = '1000000']. |
1160 |
self test:[(t1 perform:'*' asSymbol with:t1) printString = '1000000']. |
|
1161 |
||
3 | 1162 |
t1 := 10000. |
1163 |
self test:[t1 * t1 == 100000000]. |
|
10 | 1164 |
self test:[(t1 perform:'*' asSymbol with:t1) == 100000000]. |
11 | 1165 |
self test:[(t1 * t1) printString = '100000000']. |
1166 |
self test:[(t1 perform:'*' asSymbol with:t1) printString = '100000000']. |
|
1167 |
||
3 | 1168 |
t1 := 100000. |
1169 |
SmallInteger maxBytes == 4 ifTrue:[ |
|
10 | 1170 |
self test:[t1 * t1 = 10000000000]. |
1171 |
self test:[(t1 perform:'*' asSymbol with:t1) = 10000000000]. |
|
3 | 1172 |
]. |
1173 |
SmallInteger maxBytes == 8 ifTrue:[ |
|
1174 |
self test:[t1 * t1 == 10000000000]. |
|
10 | 1175 |
self test:[(t1 perform:'*' asSymbol with:t1) == 10000000000]. |
3 | 1176 |
]. |
4 | 1177 |
|
11 | 1178 |
self test:[(t1 * t1) printString = '10000000000']. |
4 | 1179 |
self test:[(t1 perform:'*' asSymbol with:t1) printString = '10000000000']. |
11 | 1180 |
|
3 | 1181 |
t1 := 1000000. |
1182 |
self test:[(t1 * t1) printString = '1000000000000']. |
|
11 | 1183 |
self test:[(t1 perform:'*' asSymbol with:t1) printString = '1000000000000']. |
1184 |
||
3 | 1185 |
t1 := 10000000. |
1186 |
self test:[(t1 * t1) printString = '100000000000000']. |
|
11 | 1187 |
self test:[(t1 perform:'*' asSymbol with:t1) printString = '100000000000000']. |
1188 |
||
3 | 1189 |
t1 := 100000000. |
1190 |
self test:[(t1 * t1) printString = '10000000000000000']. |
|
11 | 1191 |
self test:[(t1 perform:'*' asSymbol with:t1) printString = '10000000000000000']. |
1192 |
||
3 | 1193 |
t1 := 1000000000. |
1194 |
self test:[(t1 * t1) printString = '1000000000000000000']. |
|
11 | 1195 |
self test:[(t1 perform:'*' asSymbol with:t1) printString = '1000000000000000000']. |
1196 |
||
2 | 1197 |
|
3 | 1198 |
"Large * SmallInt multiplication" |
1199 |
self test:[10 factorial printString = '3628800']. |
|
1200 |
self test:[20 factorial printString = '2432902008176640000']. |
|
1201 |
self test:[100 factorial printString = '93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000']. |
|
1202 |
self test:[1000 factorial printString = '402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000']. |
|
2 | 1203 |
|
3 | 1204 |
"Large * Large multiplication" |
24 | 1205 |
self test:[(16r3FFF * 16r3FFF) hexPrintString = 'FFF8001']. |
1206 |
self test:[(16r7FFF * 16r7FFF) hexPrintString = '3FFF0001']. |
|
1207 |
self test:[(16rFFFF * 16rFFFF) hexPrintString = 'FFFE0001']. |
|
1208 |
self test:[(16r3FFFFF * 16r3FFFFF) hexPrintString = 'FFFFF800001']. |
|
1209 |
self test:[(16r7FFFFF * 16r7FFFFF) hexPrintString = '3FFFFF000001']. |
|
1210 |
self test:[(16rFFFFFF * 16rFFFFFF) hexPrintString = 'FFFFFE000001']. |
|
1211 |
self test:[(16r3FFFFFFF * 16r3FFFFFFF) hexPrintString = 'FFFFFFF80000001']. |
|
1212 |
self test:[(16r7FFFFFFF * 16r7FFFFFFF) hexPrintString = '3FFFFFFF00000001']. |
|
1213 |
self test:[(16rFFFFFFFF * 16rFFFFFFFF) hexPrintString = 'FFFFFFFE00000001']. |
|
1214 |
self test:[(16r3FFFFFFFFF * 16r3FFFFFFFFF) hexPrintString = 'FFFFFFFFF8000000001']. |
|
1215 |
self test:[(16r7FFFFFFFFF * 16r7FFFFFFFFF) hexPrintString = '3FFFFFFFFF0000000001']. |
|
1216 |
self test:[(16rFFFFFFFFFF * 16rFFFFFFFFFF) hexPrintString = 'FFFFFFFFFE0000000001']. |
|
3 | 1217 |
self test:[(20 factorial * 20 factorial) printString = '5919012181389927685417441689600000000']. |
7 | 1218 |
|
1219 |
" |
|
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1220 |
self testLargeMultiplication |
7 | 1221 |
" |
10 | 1222 |
|
11 | 1223 |
"Modified: / 20.5.1999 / 09:41:19 / cg" |
7 | 1224 |
! |
1225 |
||
19 | 1226 |
testLiteralNumbers |
1227 |
self test:[self num_00000000000010000 hexPrintString = '10000']. |
|
1228 |
self test:[self num_00000000000100000 hexPrintString = '100000']. |
|
1229 |
self test:[self num_00000000001000000 hexPrintString = '1000000']. |
|
1230 |
self test:[self num_00000000010000000 hexPrintString = '10000000']. |
|
1231 |
self test:[self num_00000000100000000 hexPrintString = '100000000']. |
|
1232 |
self test:[self num_00000001000000000 hexPrintString = '1000000000']. |
|
1233 |
self test:[self num_00000010000000000 hexPrintString = '10000000000']. |
|
1234 |
self test:[self num_00000100000000000 hexPrintString = '100000000000']. |
|
1235 |
self test:[self num_00001000000000000 hexPrintString = '1000000000000']. |
|
1236 |
self test:[self num_00010000000000000 hexPrintString = '10000000000000']. |
|
1237 |
self test:[self num_00100000000000000 hexPrintString = '100000000000000']. |
|
1238 |
self test:[self num_01000000000000000 hexPrintString = '1000000000000000']. |
|
1239 |
self test:[self num_10000000000000000 hexPrintString = '10000000000000000']. |
|
1240 |
||
1241 |
self test:[self num_00000000000007FFF hexPrintString = '7FFF']. |
|
1242 |
self test:[self num_00000000000008000 hexPrintString = '8000']. |
|
1243 |
self test:[self num_0000000000000FFFF hexPrintString = 'FFFF']. |
|
1244 |
self test:[self num_000000000007FFFFF hexPrintString = '7FFFFF']. |
|
1245 |
self test:[self num_00000000000800000 hexPrintString = '800000']. |
|
1246 |
self test:[self num_00000000000FFFFFF hexPrintString = 'FFFFFF']. |
|
1247 |
self test:[self num_0000000007FFFFFFF hexPrintString = '7FFFFFFF']. |
|
1248 |
self test:[self num_00000000080000000 hexPrintString = '80000000']. |
|
1249 |
self test:[self num_000000000FFFFFFFF hexPrintString = 'FFFFFFFF']. |
|
21 | 1250 |
self test:[self num_0000000FFFFFFFFFF hexPrintString = 'FFFFFFFFFF']. |
1251 |
self test:[self num_00000FFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFF']. |
|
1252 |
self test:[self num_000FFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFF']. |
|
1253 |
self test:[self num_0FFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFF']. |
|
1254 |
self test:[self num_1FFFFFFFFFFFFFFFF hexPrintString = '1FFFFFFFFFFFFFFFF']. |
|
1255 |
self test:[self num_20000000000000000 hexPrintString = '20000000000000000']. |
|
1256 |
self test:[self num_3FFFFFFFFFFFFFFFF hexPrintString = '3FFFFFFFFFFFFFFFF']. |
|
1257 |
self test:[self num_40000000000000000 hexPrintString = '40000000000000000']. |
|
1258 |
self test:[self num_7FFFFFFFFFFFFFFFF hexPrintString = '7FFFFFFFFFFFFFFFF']. |
|
1259 |
self test:[self num_80000000000000000 hexPrintString = '80000000000000000']. |
|
1260 |
||
1261 |
self test:[self num_00000FFFFFFFFFFFE hexPrintString = 'FFFFFFFFFFFE']. |
|
1262 |
self test:[self num_00000FFFFFFFFFFFC hexPrintString = 'FFFFFFFFFFFC']. |
|
1263 |
self test:[self num_00000FFFFFFFFFFF8 hexPrintString = 'FFFFFFFFFFF8']. |
|
1264 |
self test:[self num_00000FFFFFFFFFFF0 hexPrintString = 'FFFFFFFFFFF0']. |
|
1265 |
self test:[self num_00000FFFFFFFFFFE0 hexPrintString = 'FFFFFFFFFFE0']. |
|
1266 |
self test:[self num_00000FFFFFFFFFFC0 hexPrintString = 'FFFFFFFFFFC0']. |
|
1267 |
self test:[self num_00000FFFFFFFFFF80 hexPrintString = 'FFFFFFFFFF80']. |
|
1268 |
self test:[self num_00000FFFFFFFFFF00 hexPrintString = 'FFFFFFFFFF00']. |
|
19 | 1269 |
|
22 | 1270 |
self test:[self num_0000000000FFF0000 hexPrintString = 'FFF0000']. |
1271 |
||
19 | 1272 |
" |
1273 |
self testLiteralNumbers |
|
1274 |
" |
|
1275 |
||
22 | 1276 |
"Modified: / 4.6.1999 / 18:41:09 / cg" |
19 | 1277 |
! |
1278 |
||
7 | 1279 |
testPrinting1 |
1280 |
self test:[10 printString = '10']. |
|
1281 |
self test:[100 printString = '100']. |
|
1282 |
self test:[1000 printString = '1000']. |
|
1283 |
self test:[10000 printString = '10000']. |
|
1284 |
self test:[100000 printString = '100000']. |
|
1285 |
self test:[1000000 printString = '1000000']. |
|
1286 |
self test:[10000000 printString = '10000000']. |
|
1287 |
self test:[100000000 printString = '100000000']. |
|
1288 |
self test:[1000000000 printString = '1000000000']. |
|
1289 |
self test:[10000000000 printString = '10000000000']. |
|
1290 |
self test:[100000000000 printString = '100000000000']. |
|
1291 |
self test:[1000000000000 printString = '1000000000000']. |
|
1292 |
self test:[10000000000000 printString = '10000000000000']. |
|
1293 |
self test:[100000000000000 printString = '100000000000000']. |
|
1294 |
self test:[1000000000000000 printString = '1000000000000000']. |
|
1295 |
self test:[10000000000000000 printString = '10000000000000000']. |
|
1296 |
self test:[100000000000000000 printString = '100000000000000000']. |
|
1297 |
||
40 | 1298 |
self test:[16rF hexPrintString = 'F']. |
1299 |
self test:[16rFF hexPrintString = 'FF']. |
|
1300 |
self test:[16rFFF hexPrintString = 'FFF']. |
|
1301 |
self test:[16rFFFF hexPrintString = 'FFFF']. |
|
1302 |
self test:[16rFFFFF hexPrintString = 'FFFFF']. |
|
1303 |
self test:[16rFFFFFF hexPrintString = 'FFFFFF']. |
|
1304 |
self test:[16rFFFFFFF hexPrintString = 'FFFFFFF']. |
|
1305 |
self test:[16rFFFFFFFF hexPrintString = 'FFFFFFFF']. |
|
1306 |
self test:[16rFFFFFFFFF hexPrintString = 'FFFFFFFFF']. |
|
1307 |
self test:[16rFFFFFFFFFF hexPrintString = 'FFFFFFFFFF']. |
|
1308 |
self test:[16rFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFF']. |
|
1309 |
self test:[16rFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFF']. |
|
1310 |
self test:[16rFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFF']. |
|
1311 |
self test:[16rFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFF']. |
|
1312 |
self test:[16rFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFF']. |
|
1313 |
self test:[16rFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFF']. |
|
1314 |
self test:[16rFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFF']. |
|
1315 |
self test:[16rFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFF']. |
|
1316 |
self test:[16rFFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFFF']. |
|
1317 |
self test:[16rFFFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFFFF']. |
|
1318 |
||
1319 |
self test:[16r10 hexPrintString = '10']. |
|
1320 |
self test:[16r100 hexPrintString = '100']. |
|
1321 |
self test:[16r1000 hexPrintString = '1000']. |
|
1322 |
self test:[16r10000 hexPrintString = '10000']. |
|
1323 |
self test:[16r100000 hexPrintString = '100000']. |
|
1324 |
self test:[16r1000000 hexPrintString = '1000000']. |
|
1325 |
self test:[16r10000000 hexPrintString = '10000000']. |
|
1326 |
self test:[16r100000000 hexPrintString = '100000000']. |
|
1327 |
self test:[16r1000000000 hexPrintString = '1000000000']. |
|
1328 |
self test:[16r10000000000 hexPrintString = '10000000000']. |
|
1329 |
self test:[16r100000000000 hexPrintString = '100000000000']. |
|
1330 |
self test:[16r1000000000000 hexPrintString = '1000000000000']. |
|
1331 |
self test:[16r10000000000000 hexPrintString = '10000000000000']. |
|
1332 |
self test:[16r100000000000000 hexPrintString = '100000000000000']. |
|
1333 |
self test:[16r1000000000000000 hexPrintString = '1000000000000000']. |
|
1334 |
self test:[16r10000000000000000 hexPrintString = '10000000000000000']. |
|
1335 |
self test:[16r100000000000000000 hexPrintString = '100000000000000000']. |
|
1336 |
||
7 | 1337 |
" |
1338 |
self testPrinting1 |
|
1339 |
" |
|
40 | 1340 |
|
1341 |
"Modified: / 26.10.1999 / 22:01:35 / stefan" |
|
7 | 1342 |
! |
1343 |
||
1344 |
testReading1 |
|
1345 |
|t| |
|
1346 |
||
5 | 1347 |
self test:[(Integer readFrom:'4865804016353280000') printString = '4865804016353280000']. |
1348 |
self test:[(Integer readFrom:'FFFFFFFF' radix:16) hexPrintString = 'FFFFFFFF']. |
|
1349 |
self test:[(Integer readFrom:'FFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFF']. |
|
1350 |
self test:[(Integer readFrom:'FFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFF']. |
|
1351 |
self test:[(Integer readFrom:'FFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFF']. |
|
1352 |
self test:[(Integer readFrom:'FFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFF']. |
|
15 | 1353 |
self test:[(Integer readFrom:'FFFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFFF']. |
1354 |
self test:[(Integer readFrom:'FFFFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFFFF']. |
|
5 | 1355 |
|
1356 |
self test:[(Integer readFrom:'10000000' radix:16) hexPrintString = '10000000']. |
|
1357 |
self test:[(Integer readFrom:'100000000' radix:16) hexPrintString = '100000000']. |
|
1358 |
self test:[(Integer readFrom:'1000000000' radix:16) hexPrintString = '1000000000']. |
|
1359 |
self test:[(Integer readFrom:'10000000000' radix:16) hexPrintString = '10000000000']. |
|
1360 |
self test:[(Integer readFrom:'100000000000' radix:16) hexPrintString = '100000000000']. |
|
15 | 1361 |
self test:[(Integer readFrom:'1000000000000' radix:16) hexPrintString = '1000000000000']. |
1362 |
self test:[(Integer readFrom:'10000000000000' radix:16) hexPrintString = '10000000000000']. |
|
5 | 1363 |
|
1364 |
t := Integer readFrom:'FFFFFFFF' radix:16. |
|
1365 |
self test:[(t + 1) hexPrintString = '100000000']. |
|
1366 |
t := Integer readFrom:'FFFFFFFFF' radix:16. |
|
1367 |
self test:[(t + 1) hexPrintString = '1000000000']. |
|
1368 |
t := Integer readFrom:'FFFFFFFFFF' radix:16. |
|
1369 |
self test:[(t + 1) hexPrintString = '10000000000']. |
|
1370 |
t := Integer readFrom:'FFFFFFFFFFF' radix:16. |
|
1371 |
self test:[(t + 1) hexPrintString = '100000000000']. |
|
1372 |
||
1373 |
t := Integer readFrom:'10000000' radix:16. |
|
1374 |
self test:[(t + 1) hexPrintString = '10000001']. |
|
1375 |
t := Integer readFrom:'100000000' radix:16. |
|
1376 |
self test:[(t + 1) hexPrintString = '100000001']. |
|
1377 |
t := Integer readFrom:'1000000000' radix:16. |
|
1378 |
self test:[(t + 1) hexPrintString = '1000000001']. |
|
1379 |
t := Integer readFrom:'10000000000' radix:16. |
|
1380 |
self test:[(t + 1) hexPrintString = '10000000001']. |
|
1381 |
||
2 | 1382 |
" |
7 | 1383 |
self testReading1 |
2 | 1384 |
" |
27 | 1385 |
! |
1386 |
||
1387 |
testSmallIntegerArithmetic |
|
1388 |
"arithmetic tests. |
|
1389 |
Notice, the arithmetic tests are both performed via regular sends |
|
1390 |
and via constructed performs. The reason is to test both inlined |
|
1391 |
JIT-compiler code AND the regular methods code." |
|
1392 |
||
1393 |
|s n1 n2 t| |
|
1394 |
||
1395 |
"/ test division and modulu ... |
|
1396 |
self test:[1 printString = '1']. |
|
1397 |
self test:[10 printString = '10']. |
|
1398 |
self test:[100 printString = '100']. |
|
1399 |
self test:[1000 printString = '1000']. |
|
1400 |
self test:[10000 printString = '10000']. |
|
1401 |
self test:[100000 printString = '100000']. |
|
1402 |
||
1403 |
"addition with overflow" |
|
1404 |
||
1405 |
SmallInteger maxBytes == 4 ifTrue:[ |
|
1406 |
n1 := 16r3FFFFFFF. |
|
1407 |
n2 := -16r40000000. |
|
1408 |
] ifFalse:[ |
|
1409 |
n1 := 16r3FFFFFFFFFFFFFFF. |
|
1410 |
n2 := -16r4000000000000000. |
|
1411 |
]. |
|
1412 |
self test:[n1 class == SmallInteger]. |
|
1413 |
self test:[n2 class == SmallInteger]. |
|
1414 |
||
1415 |
self test:[(n1 + 1) class == LargeInteger]. |
|
1416 |
t := n1 + 1. |
|
1417 |
self test:[(t - 1) class == SmallInteger]. |
|
1418 |
||
1419 |
self test:[(n2 - 1) class == LargeInteger]. |
|
1420 |
t := n2 - 1. |
|
1421 |
self test:[(t + 1) class == SmallInteger]. |
|
1422 |
||
1423 |
self test:[(n1 negated) class == SmallInteger]. |
|
1424 |
self test:[(n2 negated) class == LargeInteger]. |
|
1425 |
self test:[(n1 perform:'negated' asSymbol) class == SmallInteger]. |
|
1426 |
self test:[(n2 perform:'negated' asSymbol) class == LargeInteger]. |
|
1427 |
||
28 | 1428 |
self test:[(n1 abs == n1)]. |
1429 |
self test:[(n2 abs = n2 negated)]. |
|
1430 |
self test:[(n1 perform:'abs' asSymbol) == n1]. |
|
1431 |
self test:[(n2 perform:'abs' asSymbol) = n2 negated]. |
|
1432 |
||
38 | 1433 |
self testSmallIntegerMultiplication1. |
1434 |
self testSmallIntegerMultiplication1b. |
|
1435 |
self testSmallIntegerMultiplication2. |
|
46 | 1436 |
self testSmallIntegerDivision1. |
38 | 1437 |
|
27 | 1438 |
" |
1439 |
self testSmallIntegerArithmetic |
|
1440 |
" |
|
1441 |
||
1442 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
33 | 1443 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
1444 |
! |
|
1445 |
||
46 | 1446 |
testSmallIntegerDivision1 |
1447 |
"division tests. |
|
1448 |
Notice, the arithmetic tests are both performed via regular sends |
|
1449 |
and via constructed performs. The reason is to test both inlined |
|
1450 |
JIT-compiler code AND the regular methods code." |
|
1451 |
||
1452 |
|s n1 n2 t| |
|
1453 |
||
1454 |
n1 := 1000. |
|
1455 |
||
1456 |
"/ truncation towards... |
|
1457 |
||
1458 |
"/ ... negative infinity |
|
1459 |
n2 := 3. |
|
1460 |
self test:[(n1 // n2) == 333]. |
|
1461 |
self test:[(n1 // n2) printString = '333']. |
|
1462 |
self test:[(n1 perform:'//' asSymbol with:n2) == 333]. |
|
1463 |
||
1464 |
n2 := -3. |
|
1465 |
self test:[(n1 // n2) == -334]. |
|
1466 |
self test:[(n1 // n2) printString = '-334']. |
|
1467 |
self test:[(n1 perform:'//' asSymbol with:n2) == -334]. |
|
1468 |
||
1469 |
n2 := 3600000. |
|
1470 |
self test:[(n1 // n2) == 0]. |
|
1471 |
self test:[(n1 // n2) printString = '0']. |
|
1472 |
self test:[(n1 perform:'//' asSymbol with:n2) == 0]. |
|
1473 |
||
1474 |
n2 := -3600000. |
|
1475 |
self test:[(n1 // n2) == -1]. |
|
1476 |
self test:[(n1 // n2) printString = '-1']. |
|
1477 |
self test:[(n1 perform:'//' asSymbol with:n2) == -1]. |
|
1478 |
||
1479 |
"/ ... zero |
|
1480 |
n2 := 3. |
|
1481 |
self test:[(n1 quo: n2) == 333]. |
|
1482 |
self test:[(n1 quo: n2) printString = '333']. |
|
1483 |
self test:[(n1 perform:'quo:' asSymbol with:n2) == 333]. |
|
1484 |
||
1485 |
n2 := -3. |
|
1486 |
self test:[(n1 quo: n2) == -333]. |
|
1487 |
self test:[(n1 quo: n2) printString = '-333']. |
|
1488 |
self test:[(n1 perform:'quo:' asSymbol with:n2) == -333]. |
|
1489 |
||
1490 |
n2 := 3600000. |
|
1491 |
self test:[(n1 quo: n2) == 0]. |
|
1492 |
self test:[(n1 quo: n2) printString = '0']. |
|
1493 |
self test:[(n1 perform:'quo:' asSymbol with:n2) == 0]. |
|
1494 |
||
1495 |
n2 := -3600000. |
|
1496 |
self test:[(n1 quo: n2) == 0]. |
|
1497 |
self test:[(n1 quo: n2) printString = '0']. |
|
1498 |
self test:[(n1 perform:'quo:' asSymbol with:n2) == 0]. |
|
1499 |
||
1500 |
" |
|
1501 |
self testSmallIntegerDivision1 |
|
1502 |
" |
|
1503 |
||
1504 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
|
1505 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
|
1506 |
! |
|
1507 |
||
33 | 1508 |
testSmallIntegerMultiplication1 |
39 | 1509 |
"multiply tests (var * const). |
33 | 1510 |
Notice, the arithmetic tests are both performed via regular sends |
1511 |
and via constructed performs. The reason is to test both inlined |
|
1512 |
JIT-compiler code AND the regular methods code." |
|
1513 |
||
1514 |
|s n1 n2 t| |
|
1515 |
||
1516 |
n1 := 100000. |
|
1517 |
n2 := n1 negated. |
|
1518 |
||
1519 |
self test:[n1 printString = '100000']. |
|
1520 |
self test:[n2 printString = '-100000']. |
|
1521 |
||
1522 |
self test:[(n1 * 0) printString = '0']. |
|
1523 |
self test:[(n1 perform:'*' asSymbol with:0) printString = '0']. |
|
1524 |
||
1525 |
self test:[(n1 * 1) printString = '100000']. |
|
1526 |
self test:[(n1 perform:'*' asSymbol with:1) printString = '100000']. |
|
1527 |
self test:[(n2 * 1) printString = '-100000']. |
|
1528 |
self test:[(n2 perform:'*' asSymbol with:1) printString = '-100000']. |
|
1529 |
||
1530 |
self test:[(n1 * -1) printString = '-100000']. |
|
1531 |
self test:[(n1 perform:'*' asSymbol with:-1) printString = '-100000']. |
|
1532 |
self test:[(n2 * -1) printString = '100000']. |
|
1533 |
self test:[(n2 perform:'*' asSymbol with:-1) printString = '100000']. |
|
1534 |
||
1535 |
self test:[(n1 * 2) printString = '200000']. |
|
1536 |
self test:[(n1 perform:'*' asSymbol with:2) printString = '200000']. |
|
1537 |
self test:[(n1 * 3) printString = '300000']. |
|
1538 |
self test:[(n1 perform:'*' asSymbol with:3) printString = '300000']. |
|
1539 |
self test:[(n1 * 4) printString = '400000']. |
|
1540 |
self test:[(n1 perform:'*' asSymbol with:4) printString = '400000']. |
|
38 | 1541 |
self test:[(n1 * 5) printString = '500000']. |
33 | 1542 |
self test:[(n1 perform:'*' asSymbol with:5) printString = '500000']. |
38 | 1543 |
self test:[(n1 * 6) printString = '600000']. |
33 | 1544 |
self test:[(n1 perform:'*' asSymbol with:6) printString = '600000']. |
38 | 1545 |
self test:[(n1 * 7) printString = '700000']. |
33 | 1546 |
self test:[(n1 perform:'*' asSymbol with:7) printString = '700000']. |
38 | 1547 |
self test:[(n1 * 8) printString = '800000']. |
37 | 1548 |
self test:[(n1 perform:'*' asSymbol with:8) printString = '800000']. |
38 | 1549 |
self test:[(n1 * 9) printString = '900000']. |
37 | 1550 |
self test:[(n1 perform:'*' asSymbol with:9) printString = '900000']. |
38 | 1551 |
self test:[(n1 * 10) printString = '1000000']. |
37 | 1552 |
self test:[(n1 perform:'*' asSymbol with:10) printString = '1000000']. |
38 | 1553 |
self test:[(n1 * 11) printString = '1100000']. |
37 | 1554 |
self test:[(n1 perform:'*' asSymbol with:11) printString = '1100000']. |
38 | 1555 |
self test:[(n1 * 12) printString = '1200000']. |
37 | 1556 |
self test:[(n1 perform:'*' asSymbol with:12) printString = '1200000']. |
38 | 1557 |
self test:[(n1 * 13) printString = '1300000']. |
37 | 1558 |
self test:[(n1 perform:'*' asSymbol with:13) printString = '1300000']. |
38 | 1559 |
self test:[(n1 * 14) printString = '1400000']. |
37 | 1560 |
self test:[(n1 perform:'*' asSymbol with:14) printString = '1400000']. |
38 | 1561 |
self test:[(n1 * 15) printString = '1500000']. |
37 | 1562 |
self test:[(n1 perform:'*' asSymbol with:15) printString = '1500000']. |
38 | 1563 |
self test:[(n1 * 16) printString = '1600000']. |
37 | 1564 |
self test:[(n1 perform:'*' asSymbol with:16) printString = '1600000']. |
33 | 1565 |
|
41 | 1566 |
n1 := 1. |
1567 |
n2 := 10. |
|
1568 |
self test:[(n1 * n2) printString = '10']. |
|
1569 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10']. |
|
1570 |
n2 := n2 * 10. |
|
1571 |
self test:[(n1 * n2) printString = '100']. |
|
1572 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100']. |
|
1573 |
n2 := n2 * 10. |
|
1574 |
self test:[(n1 * n2) printString = '1000']. |
|
1575 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000']. |
|
1576 |
n2 := n2 * 10. |
|
1577 |
self test:[(n1 * n2) printString = '10000']. |
|
1578 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000']. |
|
1579 |
n2 := n2 * 10. |
|
1580 |
self test:[(n1 * n2) printString = '100000']. |
|
1581 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000']. |
|
1582 |
n2 := n2 * 10. |
|
1583 |
self test:[(n1 * n2) printString = '1000000']. |
|
1584 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000']. |
|
1585 |
n2 := n2 * 10. |
|
1586 |
self test:[(n1 * n2) printString = '10000000']. |
|
1587 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000']. |
|
1588 |
n2 := n2 * 10. |
|
1589 |
self test:[(n1 * n2) printString = '100000000']. |
|
1590 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000000']. |
|
1591 |
n2 := n2 * 10. |
|
1592 |
self test:[(n1 * n2) printString = '1000000000']. |
|
1593 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000000']. |
|
1594 |
n2 := n2 * 10. |
|
1595 |
self test:[(n1 * n2) printString = '10000000000']. |
|
1596 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000000']. |
|
1597 |
n2 := n2 * 10. |
|
1598 |
self test:[(n1 * n2) printString = '100000000000']. |
|
1599 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000000000']. |
|
1600 |
n2 := n2 * 10. |
|
1601 |
self test:[(n1 * n2) printString = '1000000000000']. |
|
1602 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000000000']. |
|
1603 |
n2 := n2 * 10. |
|
1604 |
self test:[(n1 * n2) printString = '10000000000000']. |
|
1605 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000000000']. |
|
1606 |
||
1607 |
n1 := 1. |
|
1608 |
n2 := 10. |
|
1609 |
self test:[(n1 * n2) printString = '10']. |
|
1610 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10']. |
|
1611 |
n1 := n1 * 10. |
|
1612 |
self test:[(n1 * n2) printString = '100']. |
|
1613 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100']. |
|
1614 |
n1 := n1 * 10. |
|
1615 |
self test:[(n1 * n2) printString = '1000']. |
|
1616 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000']. |
|
1617 |
n1 := n1 * 10. |
|
1618 |
self test:[(n1 * n2) printString = '10000']. |
|
1619 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000']. |
|
1620 |
n1 := n1 * 10. |
|
1621 |
self test:[(n1 * n2) printString = '100000']. |
|
1622 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000']. |
|
1623 |
n1 := n1 * 10. |
|
1624 |
self test:[(n1 * n2) printString = '1000000']. |
|
1625 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000']. |
|
1626 |
n1 := n1 * 10. |
|
1627 |
self test:[(n1 * n2) printString = '10000000']. |
|
1628 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000']. |
|
1629 |
n1 := n1 * 10. |
|
1630 |
self test:[(n1 * n2) printString = '100000000']. |
|
1631 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000000']. |
|
1632 |
n1 := n1 * 10. |
|
1633 |
self test:[(n1 * n2) printString = '1000000000']. |
|
1634 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000000']. |
|
1635 |
n1 := n1 * 10. |
|
1636 |
self test:[(n1 * n2) printString = '10000000000']. |
|
1637 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000000']. |
|
1638 |
n1 := n1 * 10. |
|
1639 |
self test:[(n1 * n2) printString = '100000000000']. |
|
1640 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000000000']. |
|
1641 |
n1 := n1 * 10. |
|
1642 |
self test:[(n1 * n2) printString = '1000000000000']. |
|
1643 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000000000']. |
|
1644 |
n1 := n1 * 10. |
|
1645 |
self test:[(n1 * n2) printString = '10000000000000']. |
|
1646 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000000000']. |
|
1647 |
||
1648 |
n1 := 10. |
|
1649 |
n2 := 10. |
|
1650 |
self test:[(n1 * n2) printString = '100']. |
|
1651 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100']. |
|
1652 |
n1 := n1 * 10. |
|
1653 |
n2 := n2 * 10. |
|
1654 |
self test:[(n1 * n2) printString = '10000']. |
|
1655 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000']. |
|
1656 |
n1 := n1 * 10. |
|
1657 |
n2 := n2 * 10. |
|
1658 |
self test:[(n1 * n2) printString = '1000000']. |
|
1659 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000']. |
|
1660 |
n1 := n1 * 10. |
|
1661 |
n2 := n2 * 10. |
|
1662 |
self test:[(n1 * n2) printString = '100000000']. |
|
1663 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000000']. |
|
1664 |
n1 := n1 * 10. |
|
1665 |
n2 := n2 * 10. |
|
1666 |
self test:[(n1 * n2) printString = '10000000000']. |
|
1667 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000000']. |
|
1668 |
n1 := n1 * 10. |
|
1669 |
n2 := n2 * 10. |
|
1670 |
self test:[(n1 * n2) printString = '1000000000000']. |
|
1671 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000000000']. |
|
1672 |
n1 := n1 * 10. |
|
1673 |
n2 := n2 * 10. |
|
1674 |
self test:[(n1 * n2) printString = '100000000000000']. |
|
1675 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000000000000']. |
|
1676 |
n1 := n1 * 10. |
|
1677 |
n2 := n2 * 10. |
|
1678 |
self test:[(n1 * n2) printString = '10000000000000000']. |
|
1679 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000000000000']. |
|
1680 |
n1 := n1 * 10. |
|
1681 |
n2 := n2 * 10. |
|
1682 |
self test:[(n1 * n2) printString = '1000000000000000000']. |
|
1683 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000000000000000']. |
|
1684 |
n1 := n1 * 10. |
|
1685 |
n2 := n2 * 10. |
|
1686 |
self test:[(n1 * n2) printString = '100000000000000000000']. |
|
1687 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000000000000000000']. |
|
1688 |
n1 := n1 * 10. |
|
1689 |
n2 := n2 * 10. |
|
1690 |
self test:[(n1 * n2) printString = '10000000000000000000000']. |
|
1691 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '10000000000000000000000']. |
|
1692 |
n1 := n1 * 10. |
|
1693 |
n2 := n2 * 10. |
|
1694 |
self test:[(n1 * n2) printString = '1000000000000000000000000']. |
|
1695 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '1000000000000000000000000']. |
|
1696 |
n1 := n1 * 10. |
|
1697 |
n2 := n2 * 10. |
|
1698 |
self test:[(n1 * n2) printString = '100000000000000000000000000']. |
|
1699 |
self test:[(n1 perform:'*' asSymbol with:n2) printString = '100000000000000000000000000']. |
|
1700 |
||
33 | 1701 |
" |
1702 |
self testSmallIntegerMultiplication1 |
|
1703 |
" |
|
1704 |
||
32 | 1705 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
33 | 1706 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
34 | 1707 |
! |
1708 |
||
35 | 1709 |
testSmallIntegerMultiplication1b |
39 | 1710 |
"multiply tests (const * var). |
35 | 1711 |
Notice, the arithmetic tests are both performed via regular sends |
1712 |
and via constructed performs. The reason is to test both inlined |
|
1713 |
JIT-compiler code AND the regular methods code." |
|
1714 |
||
1715 |
|s n1 n2 t| |
|
1716 |
||
1717 |
n1 := 100000. |
|
1718 |
n2 := n1 negated. |
|
1719 |
||
38 | 1720 |
self test:[(0 * n1) printString = '0']. |
35 | 1721 |
self test:[(0 perform:'*' asSymbol with:n1) printString = '0']. |
1722 |
||
1723 |
self test:[(1 * n1) printString = '100000']. |
|
36 | 1724 |
self test:[(1 perform:'*' asSymbol with:n1) printString = '100000']. |
35 | 1725 |
self test:[(1 * n2) printString = '-100000']. |
36 | 1726 |
self test:[(1 perform:'*' asSymbol with:n2) printString = '-100000']. |
35 | 1727 |
|
1728 |
self test:[(-1 * n1) printString = '-100000']. |
|
1729 |
self test:[(-1 perform:'*' asSymbol with:n1) printString = '-100000']. |
|
1730 |
self test:[(-1 * n2) printString = '100000']. |
|
1731 |
self test:[(-1 perform:'*' asSymbol with:n2) printString = '100000']. |
|
1732 |
||
1733 |
self test:[(2 * n1) printString = '200000']. |
|
36 | 1734 |
self test:[(2 perform:'*' asSymbol with:n1) printString = '200000']. |
35 | 1735 |
self test:[(3 * n1) printString = '300000']. |
36 | 1736 |
self test:[(3 perform:'*' asSymbol with:n1) printString = '300000']. |
35 | 1737 |
self test:[(4 * n1) printString = '400000']. |
36 | 1738 |
self test:[(4 perform:'*' asSymbol with:n1) printString = '400000']. |
35 | 1739 |
self test:[(5 * n1) printString = '500000']. |
36 | 1740 |
self test:[(5 perform:'*' asSymbol with:n1) printString = '500000']. |
35 | 1741 |
self test:[(6 * n1) printString = '600000']. |
36 | 1742 |
self test:[(6 perform:'*' asSymbol with:n1) printString = '600000']. |
35 | 1743 |
self test:[(7 * n1) printString = '700000']. |
1744 |
self test:[(7 perform:'*' asSymbol with:n1) printString = '700000']. |
|
39 | 1745 |
self test:[(8 * n1) printString = '800000']. |
1746 |
self test:[(8 perform:'*' asSymbol with:n1) printString = '800000']. |
|
1747 |
self test:[(9 * n1) printString = '900000']. |
|
1748 |
self test:[(9 perform:'*' asSymbol with:n1) printString = '900000']. |
|
1749 |
self test:[(10 * n1) printString = '1000000']. |
|
1750 |
self test:[(10 perform:'*' asSymbol with:n1) printString = '1000000']. |
|
1751 |
self test:[(11 * n1) printString = '1100000']. |
|
1752 |
self test:[(11 perform:'*' asSymbol with:n1) printString = '1100000']. |
|
35 | 1753 |
|
1754 |
" |
|
1755 |
self testSmallIntegerMultiplication1b |
|
1756 |
" |
|
1757 |
||
1758 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
|
1759 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
|
1760 |
! |
|
1761 |
||
34 | 1762 |
testSmallIntegerMultiplication2 |
1763 |
"multiply tests. |
|
1764 |
Notice, the arithmetic tests are both performed via regular sends |
|
1765 |
and via constructed performs. The reason is to test both inlined |
|
1766 |
JIT-compiler code AND the regular methods code." |
|
1767 |
||
1768 |
|s n1 n2 t| |
|
1769 |
||
1770 |
n1 := 100000. |
|
1771 |
n2 := n1 negated. |
|
1772 |
||
1773 |
self test:[(n1 * 2) printString = '200000']. |
|
1774 |
self test:[(n1 perform:'*' asSymbol with:2) printString = '200000']. |
|
1775 |
self test:[(n1 * 3) printString = '300000']. |
|
1776 |
self test:[(n1 perform:'*' asSymbol with:3) printString = '300000']. |
|
1777 |
self test:[(n1 * 4) printString = '400000']. |
|
1778 |
self test:[(n1 perform:'*' asSymbol with:4) printString = '400000']. |
|
1779 |
self test:[(n1 * 5) printString = '500000']. |
|
1780 |
self test:[(n1 perform:'*' asSymbol with:5) printString = '500000']. |
|
1781 |
self test:[(n1 * 6) printString = '600000']. |
|
1782 |
self test:[(n1 perform:'*' asSymbol with:6) printString = '600000']. |
|
1783 |
self test:[(n1 * 7) printString = '700000']. |
|
1784 |
self test:[(n1 perform:'*' asSymbol with:7) printString = '700000']. |
|
1785 |
self test:[(n1 * 8) printString = '800000']. |
|
1786 |
self test:[(n1 perform:'*' asSymbol with:8) printString = '800000']. |
|
1787 |
self test:[(n1 * 9) printString = '900000']. |
|
1788 |
self test:[(n1 perform:'*' asSymbol with:9) printString = '900000']. |
|
1789 |
self test:[(n1 * 10) printString = '1000000']. |
|
1790 |
self test:[(n1 perform:'*' asSymbol with:10) printString = '1000000']. |
|
1791 |
self test:[(n1 * 11) printString = '1100000']. |
|
1792 |
self test:[(n1 perform:'*' asSymbol with:11) printString = '1100000']. |
|
1793 |
self test:[(n1 * 12) printString = '1200000']. |
|
1794 |
self test:[(n1 perform:'*' asSymbol with:12) printString = '1200000']. |
|
1795 |
self test:[(n1 * 13) printString = '1300000']. |
|
1796 |
self test:[(n1 perform:'*' asSymbol with:13) printString = '1300000']. |
|
1797 |
self test:[(n1 * 14) printString = '1400000']. |
|
1798 |
self test:[(n1 perform:'*' asSymbol with:14) printString = '1400000']. |
|
1799 |
self test:[(n1 * 15) printString = '1500000']. |
|
1800 |
self test:[(n1 perform:'*' asSymbol with:15) printString = '1500000']. |
|
1801 |
self test:[(n1 * 16) printString = '1600000']. |
|
1802 |
self test:[(n1 perform:'*' asSymbol with:16) printString = '1600000']. |
|
1803 |
self test:[(n1 * 17) printString = '1700000']. |
|
1804 |
self test:[(n1 perform:'*' asSymbol with:17) printString = '1700000']. |
|
1805 |
self test:[(n1 * 18) printString = '1800000']. |
|
1806 |
self test:[(n1 perform:'*' asSymbol with:18) printString = '1800000']. |
|
1807 |
self test:[(n1 * 19) printString = '1900000']. |
|
1808 |
self test:[(n1 perform:'*' asSymbol with:19) printString = '1900000']. |
|
1809 |
||
1810 |
" |
|
1811 |
self testSmallIntegerMultiplication2 |
|
1812 |
" |
|
1813 |
||
1814 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
|
1815 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
|
39 | 1816 |
! |
1817 |
||
1818 |
testSmallIntegerMultiplication3 |
|
1819 |
"multiply tests. |
|
1820 |
Notice, the arithmetic tests are both performed via regular sends |
|
1821 |
and via constructed performs. The reason is to test both inlined |
|
1822 |
JIT-compiler code AND the regular methods code." |
|
1823 |
||
1824 |
|s n1 n2 t| |
|
1825 |
||
1826 |
n1 := 16rFFFF. |
|
1827 |
n2 := n1 negated. |
|
1828 |
||
1829 |
self test:[(n1 * 2) printString = '131070']. |
|
1830 |
self test:[(n1 perform:'*' asSymbol with:2) printString = '131070']. |
|
1831 |
self test:[(n2 * 2) printString = '-131070']. |
|
1832 |
self test:[(n2 perform:'*' asSymbol with:2) printString = '-131070']. |
|
1833 |
||
1834 |
n1 := 16rFFFFFF. |
|
1835 |
n2 := n1 negated. |
|
1836 |
||
1837 |
self test:[(n1 * 2) printString = '33554430']. |
|
1838 |
self test:[(n1 perform:'*' asSymbol with:2) printString = '33554430']. |
|
1839 |
self test:[(n2 * 2) printString = '-33554430']. |
|
1840 |
self test:[(n2 perform:'*' asSymbol with:2) printString = '-33554430']. |
|
1841 |
||
1842 |
n1 := 16r3FFFFFFF. |
|
1843 |
n2 := n1 negated. |
|
1844 |
||
1845 |
self test:[(n1 * 2) printString = '2147483646']. |
|
1846 |
self test:[(n1 perform:'*' asSymbol with:2) printString = '2147483646']. |
|
1847 |
self test:[(n2 * 2) printString = '-2147483646']. |
|
1848 |
self test:[(n2 perform:'*' asSymbol with:2) printString = '-2147483646']. |
|
1849 |
||
1850 |
SmallInteger maxBytes == 4 ifTrue:[ |
|
1851 |
n1 := 16r3FFFFFFF. |
|
1852 |
] ifFalse:[ |
|
1853 |
n1 := 16r3FFFFFFFFFFFFFFF. |
|
1854 |
]. |
|
1855 |
self test:[n1 class == SmallInteger]. |
|
1856 |
self test:[(n1 * 2) class == LargeInteger]. |
|
1857 |
self test:[(n1 perform:'*' asSymbol with:2) class == LargeInteger]. |
|
1858 |
||
1859 |
n1 := SmallInteger maxVal // 11. |
|
1860 |
self test:[(n1 * 11) class == SmallInteger]. |
|
1861 |
||
1862 |
n1 := n1 + 1. |
|
1863 |
self test:[(n1 * 11) class == LargeInteger]. |
|
1864 |
||
1865 |
" |
|
1866 |
self testSmallIntegerMultiplication3 |
|
1867 |
" |
|
1868 |
||
1869 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
|
1870 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
|
2 | 1871 |
! ! |
1872 |
||
1873 |
!IntegerTest class methodsFor:'documentation'! |
|
1874 |
||
1875 |
version |
|
1876 |
^ '$Header$' |
|
1877 |
! ! |