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