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