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