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