author | Claus Gittinger <cg@exept.de> |
Sat, 21 Jun 2003 14:12:33 +0200 | |
changeset 206 | 5afc9d56ef2c |
parent 172 | 4007fa906cab |
child 238 | 41116eb0ebba |
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:'' |
|
172 | 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 |
||
172 | 562 |
num_16r80000000 |
563 |
^ 16r80000000 |
|
564 |
! |
|
565 |
||
21 | 566 |
num_1FFFFFFFFFFFFFFFF |
567 |
^ 16r1FFFFFFFFFFFFFFFF |
|
568 |
||
569 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
570 |
"Created: / 4.6.1999 / 17:41:51 / cg" |
|
571 |
! |
|
572 |
||
573 |
num_20000000000000000 |
|
574 |
^ 16r20000000000000000 |
|
575 |
||
576 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
577 |
"Created: / 4.6.1999 / 17:40:26 / cg" |
|
578 |
! |
|
579 |
||
580 |
num_3FFFFFFFFFFFFFFFF |
|
581 |
^ 16r3FFFFFFFFFFFFFFFF |
|
582 |
||
583 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
584 |
"Created: / 4.6.1999 / 17:42:07 / cg" |
|
585 |
! |
|
586 |
||
587 |
num_40000000000000000 |
|
588 |
^ 16r40000000000000000 |
|
589 |
||
590 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
591 |
"Created: / 4.6.1999 / 17:40:29 / cg" |
|
592 |
! |
|
593 |
||
594 |
num_7FFFFFFFFFFFFFFFF |
|
595 |
^ 16r7FFFFFFFFFFFFFFFF |
|
596 |
||
597 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
598 |
"Created: / 4.6.1999 / 17:42:24 / cg" |
|
599 |
! |
|
600 |
||
601 |
num_80000000000000000 |
|
602 |
^ 16r80000000000000000 |
|
603 |
||
604 |
"Modified: / 4.6.1999 / 15:29:31 / cg" |
|
605 |
"Created: / 4.6.1999 / 17:40:33 / cg" |
|
606 |
! |
|
607 |
||
20 | 608 |
num_smallInt_maxVal |
609 |
^ SmallInteger maxVal |
|
610 |
||
21 | 611 |
"self num_smallInt_maxVal" |
612 |
||
613 |
"Modified: / 4.6.1999 / 17:33:22 / cg" |
|
20 | 614 |
! |
615 |
||
616 |
num_smallInt_minVal |
|
617 |
^ SmallInteger minVal |
|
618 |
||
21 | 619 |
"self num_smallInt_minVal" |
620 |
||
20 | 621 |
"Created: / 4.6.1999 / 16:26:05 / cg" |
21 | 622 |
"Modified: / 4.6.1999 / 17:34:31 / cg" |
2 | 623 |
! ! |
624 |
||
103 | 625 |
!IntegerTest methodsFor:'tests'! |
2 | 626 |
|
172 | 627 |
doCompare:a againstGreater:b |
628 |
self assert:(a < b). |
|
629 |
self assert:(a <= b). |
|
630 |
self assert:(a = b) not. |
|
631 |
self assert:(a ~= b). |
|
632 |
self assert:(a == b) not. |
|
633 |
self assert:(a ~~ b). |
|
634 |
self assert:(a > b) not. |
|
635 |
self assert:(a >= b) not. |
|
636 |
||
637 |
self assert:(a perform:#< with:b). |
|
638 |
self assert:(a perform:#<= with:b). |
|
639 |
self assert:(a perform:#= with:b) not. |
|
640 |
self assert:(a perform:#~= with:b). |
|
641 |
self assert:(a perform:#== with:b) not. |
|
642 |
self assert:(a perform:#~~ with:b). |
|
643 |
self assert:(a perform:#> with:b) not. |
|
644 |
self assert:(a perform:#>= with:b) not. |
|
645 |
||
646 |
" |
|
647 |
self basicNew doCompare:12 againstGreater:16r80000000 |
|
648 |
" |
|
649 |
! |
|
650 |
||
103 | 651 |
doTestAll |
10 | 652 |
"general conversion & arithmetic tests. |
653 |
Notice, the arithmetic tests are both performed via regular sends |
|
654 |
and via constructed performs. The reason is to test both inlined |
|
655 |
JIT-compiler code AND the regular methods code." |
|
2 | 656 |
|
57 | 657 |
self testInteger1. |
54 | 658 |
self testILC. |
27 | 659 |
self testSmallIntegerArithmetic. |
19 | 660 |
self testLiteralNumbers. |
15 | 661 |
self testLargeAddition. |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
662 |
self testLargeMultiplication. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
663 |
self testLargeDivision. |
42 | 664 |
self testIntegerShifts. |
665 |
self testEncodeDecode. |
|
53 | 666 |
self testIntegerMisc. |
103 | 667 |
self testInline1 |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
668 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
669 |
" |
103 | 670 |
self basicNew doTestAll |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
671 |
" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
672 |
|
91 | 673 |
"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
|
674 |
! |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
675 |
|
172 | 676 |
testComparing |
677 |
|a b| |
|
678 |
||
679 |
a := 12. |
|
680 |
b := 16r80000000. |
|
681 |
self doCompare:a againstGreater:b. |
|
682 |
||
683 |
a := 12. |
|
684 |
b := 16r80000000. |
|
685 |
self doCompare:a againstGreater:16r80000000. |
|
686 |
||
687 |
a := 0. |
|
688 |
self doCompare:a againstGreater:16r80000000. |
|
689 |
||
690 |
a := -1. |
|
691 |
self doCompare:a againstGreater:16r80000000. |
|
692 |
||
693 |
a := 16r-80000000. |
|
694 |
self doCompare:a againstGreater:16r80000000. |
|
695 |
||
696 |
a := 16r-40000000. |
|
697 |
self doCompare:a againstGreater:16r80000000. |
|
698 |
||
699 |
a := 16r-40000000. |
|
700 |
self doCompare:a againstGreater:16r40000000. |
|
701 |
||
702 |
a := 16r-3FFFFFFF. |
|
703 |
self doCompare:a againstGreater:16r3FFFFFFF. |
|
704 |
||
705 |
a := 16r-40000000. |
|
706 |
self doCompare:a againstGreater:16r3FFFFFFF. |
|
707 |
||
708 |
a := 16r-3FFFFFFF. |
|
709 |
self doCompare:a againstGreater:16r40000000. |
|
710 |
||
711 |
" |
|
712 |
self basicNew testComparing |
|
713 |
" |
|
714 |
! |
|
715 |
||
716 |
testConstants |
|
717 |
|t| |
|
718 |
||
719 |
self assert:((t := self num_16r80000000) > 0). |
|
720 |
self assert:((t := self num_16r80000000) = 16r80000000). |
|
721 |
||
722 |
" |
|
723 |
self basicNew testConstants |
|
724 |
" |
|
725 |
! |
|
726 |
||
112 | 727 |
testDivision |
728 |
|a b op rslt| |
|
729 |
||
730 |
op := #//. |
|
731 |
a := -1. |
|
732 |
b := 8. |
|
733 |
self assert:(-1 // 8 == -1). |
|
734 |
self assert:(a // 8 == -1). |
|
735 |
self assert:(-1 // b == -1). |
|
736 |
self assert:(a // b == -1). |
|
737 |
||
738 |
self assert:((rslt := -1 perform:op with: 8) == -1). |
|
739 |
self assert:((rslt := a perform:op with: 8) == -1). |
|
740 |
self assert:((rslt := -1 perform:op with: b) == -1). |
|
741 |
self assert:((rslt := a perform:op with: b) == -1). |
|
742 |
||
743 |
a := 1. |
|
744 |
b := -8. |
|
745 |
self assert:(1 // -8 == -1). |
|
746 |
self assert:(a // -8 == -1). |
|
747 |
self assert:(1 // b == -1). |
|
748 |
self assert:(a // b == -1). |
|
749 |
||
750 |
self assert:((rslt := 1 perform:op with: -8) == -1). |
|
751 |
self assert:((rslt := a perform:op with: -8) == -1). |
|
752 |
self assert:((rslt := 1 perform:op with: b) == -1). |
|
753 |
self assert:((rslt := a perform:op with: b) == -1). |
|
754 |
||
755 |
a := -1. |
|
756 |
b := -8. |
|
757 |
self assert:(-1 // -8 == 0). |
|
758 |
self assert:(a // -8 == 0). |
|
759 |
self assert:(-1 // b == 0). |
|
760 |
self assert:(a // b == 0). |
|
761 |
||
762 |
self assert:((rslt := -1 perform:op with: -8) == 0). |
|
763 |
self assert:((rslt := a perform:op with: -8) == 0). |
|
764 |
self assert:((rslt := -1 perform:op with: b) == 0). |
|
765 |
self assert:((rslt := a perform:op with: b) == 0). |
|
766 |
||
150 | 767 |
a := 1. |
768 |
b := 8. |
|
769 |
self assert:(1 // 8 == 0). |
|
770 |
self assert:(a // 8 == 0). |
|
771 |
self assert:(1 // b == 0). |
|
772 |
self assert:(a // b == 0). |
|
773 |
||
774 |
self assert:((rslt := 1 perform:op with: 8) == 0). |
|
775 |
self assert:((rslt := a perform:op with: 8) == 0). |
|
776 |
self assert:((rslt := 1 perform:op with: b) == 0). |
|
777 |
self assert:((rslt := a perform:op with: b) == 0). |
|
778 |
||
779 |
a := -16. |
|
780 |
b := 8. |
|
781 |
self assert:(-16 // 8 == -2). |
|
782 |
self assert:(a // 8 == -2). |
|
783 |
self assert:(-16 // b == -2). |
|
784 |
self assert:(a // b == -2). |
|
785 |
||
786 |
self assert:((rslt := -16 perform:op with: 8) == -2). |
|
787 |
self assert:((rslt := a perform:op with: 8) == -2). |
|
788 |
self assert:((rslt := -16 perform:op with: b) == -2). |
|
789 |
self assert:((rslt := a perform:op with: b) == -2). |
|
790 |
||
791 |
a := 16. |
|
792 |
b := -8. |
|
793 |
self assert:(16 // -8 == -2). |
|
794 |
self assert:(a // -8 == -2). |
|
795 |
self assert:(16 // b == -2). |
|
796 |
self assert:(a // b == -2). |
|
797 |
||
798 |
self assert:((rslt := 16 perform:op with: -8) == -2). |
|
799 |
self assert:((rslt := a perform:op with: -8) == -2). |
|
800 |
self assert:((rslt := 16 perform:op with: b) == -2). |
|
801 |
self assert:((rslt := a perform:op with: b) == -2). |
|
802 |
||
803 |
a := -16. |
|
804 |
b := -8. |
|
805 |
self assert:(-16 // -8 == 2). |
|
806 |
self assert:(a // -8 == 2). |
|
807 |
self assert:(-16 // b == 2). |
|
808 |
self assert:(a // b == 2). |
|
809 |
||
810 |
self assert:((rslt := -16 perform:op with: -8) == 2). |
|
811 |
self assert:((rslt := a perform:op with: -8) == 2). |
|
812 |
self assert:((rslt := -16 perform:op with: b) == 2). |
|
813 |
self assert:((rslt := a perform:op with: b) == 2). |
|
814 |
||
815 |
a := 16. |
|
816 |
b := 8. |
|
817 |
self assert:(16 // 8 == 2). |
|
818 |
self assert:(a // 8 == 2). |
|
819 |
self assert:(16 // b == 2). |
|
820 |
self assert:(a // b == 2). |
|
821 |
||
822 |
self assert:((rslt := 16 perform:op with: 8) == 2). |
|
823 |
self assert:((rslt := a perform:op with: 8) == 2). |
|
824 |
self assert:((rslt := 16 perform:op with: b) == 2). |
|
825 |
self assert:((rslt := a perform:op with: b) == 2). |
|
826 |
||
112 | 827 |
op := #quo:. |
828 |
a := -1. |
|
829 |
b := 8. |
|
830 |
self assert:((rslt := -1 quo: 8) == 0). |
|
831 |
self assert:((rslt := a quo: 8) == 0). |
|
832 |
self assert:((rslt := -1 quo: b) == 0). |
|
833 |
self assert:((rslt := a quo: b) == 0). |
|
834 |
||
835 |
self assert:((rslt := -1 perform:op with: -8) == 0). |
|
836 |
self assert:((rslt := a perform:op with: -8) == 0). |
|
837 |
self assert:((rslt := -1 perform:op with: b) == 0). |
|
838 |
self assert:((rslt := a perform:op with: b) == 0). |
|
839 |
||
840 |
a := 1. |
|
841 |
b := -8. |
|
842 |
self assert:((rslt := 1 quo: -8) == 0). |
|
843 |
self assert:((rslt := a quo: -8) == 0). |
|
844 |
self assert:((rslt := 1 quo: b) == 0). |
|
845 |
self assert:((rslt := a quo: b) == 0). |
|
846 |
||
847 |
self assert:((rslt := 1 perform:op with: -8) == 0). |
|
848 |
self assert:((rslt := a perform:op with: -8) == 0). |
|
849 |
self assert:((rslt := 1 perform:op with: b) == 0). |
|
850 |
self assert:((rslt := a perform:op with: b) == 0). |
|
851 |
||
852 |
a := -1. |
|
853 |
b := -8. |
|
854 |
self assert:((rslt := -1 quo: -8) == 0). |
|
855 |
self assert:((rslt := a quo: -8) == 0). |
|
856 |
self assert:((rslt := -1 quo: b) == 0). |
|
857 |
self assert:((rslt := a quo: b) == 0). |
|
858 |
||
859 |
self assert:((rslt := -1 perform:op with: -8) == 0). |
|
860 |
self assert:((rslt := a perform:op with: -8) == 0). |
|
861 |
self assert:((rslt := -1 perform:op with: b) == 0). |
|
862 |
self assert:((rslt := a perform:op with: b) == 0). |
|
863 |
||
150 | 864 |
a := 1. |
865 |
b := 8. |
|
866 |
self assert:((rslt := 1 quo: 8) == 0). |
|
867 |
self assert:((rslt := a quo: 8) == 0). |
|
868 |
self assert:((rslt := 1 quo: b) == 0). |
|
869 |
self assert:((rslt := a quo: b) == 0). |
|
870 |
||
871 |
self assert:((rslt := 1 perform:op with: 8) == 0). |
|
872 |
self assert:((rslt := a perform:op with: 8) == 0). |
|
873 |
self assert:((rslt := 1 perform:op with: b) == 0). |
|
874 |
self assert:((rslt := a perform:op with: b) == 0). |
|
875 |
||
876 |
a := -16. |
|
877 |
b := 8. |
|
878 |
self assert:((rslt := -16 quo: 8) == -2). |
|
879 |
self assert:((rslt := a quo: 8) == -2). |
|
880 |
self assert:((rslt := -16 quo: b) == -2). |
|
881 |
self assert:((rslt := a quo: b) == -2). |
|
882 |
||
883 |
self assert:((rslt := -16 perform:op with: 8) == -2). |
|
884 |
self assert:((rslt := a perform:op with: 8) == -2). |
|
885 |
self assert:((rslt := -16 perform:op with: b) == -2). |
|
886 |
self assert:((rslt := a perform:op with: b) == -2). |
|
887 |
||
888 |
a := 16. |
|
889 |
b := -8. |
|
890 |
self assert:((rslt := 16 quo: -8) == -2). |
|
891 |
self assert:((rslt := a quo: -8) == -2). |
|
892 |
self assert:((rslt := 16 quo: b) == -2). |
|
893 |
self assert:((rslt := a quo: b) == -2). |
|
894 |
||
895 |
self assert:((rslt := 16 perform:op with: -8) == -2). |
|
896 |
self assert:((rslt := a perform:op with: -8) == -2). |
|
897 |
self assert:((rslt := 16 perform:op with: b) == -2). |
|
898 |
self assert:((rslt := a perform:op with: b) == -2). |
|
899 |
||
900 |
a := -16. |
|
901 |
b := -8. |
|
902 |
self assert:((rslt := -16 quo: -8) == 2). |
|
903 |
self assert:((rslt := a quo: -8) == 2). |
|
904 |
self assert:((rslt := -16 quo: b) == 2). |
|
905 |
self assert:((rslt := a quo: b) == 2). |
|
906 |
||
907 |
self assert:((rslt := -16 perform:op with: -8) == 2). |
|
908 |
self assert:((rslt := a perform:op with: -8) == 2). |
|
909 |
self assert:((rslt := -16 perform:op with: b) == 2). |
|
910 |
self assert:((rslt := a perform:op with: b) == 2). |
|
911 |
||
912 |
a := 16. |
|
913 |
b := 8. |
|
914 |
self assert:((rslt := 16 quo: 8) == 2). |
|
915 |
self assert:((rslt := a quo: 8) == 2). |
|
916 |
self assert:((rslt := 16 quo: b) == 2). |
|
917 |
self assert:((rslt := a quo: b) == 2). |
|
918 |
||
919 |
self assert:((rslt := 16 perform:op with: 8) == 2). |
|
920 |
self assert:((rslt := a perform:op with: 8) == 2). |
|
921 |
self assert:((rslt := 16 perform:op with: b) == 2). |
|
922 |
self assert:((rslt := a perform:op with: b) == 2). |
|
923 |
||
112 | 924 |
" |
925 |
self basicNew testDivision |
|
926 |
" |
|
927 |
! |
|
928 |
||
42 | 929 |
testEncodeDecode |
103 | 930 |
self assert:(1 encodeAsBCD hexPrintString = '1'). |
931 |
self assert:(12 encodeAsBCD hexPrintString = '12'). |
|
932 |
self assert:(123 encodeAsBCD hexPrintString = '123'). |
|
933 |
self assert:(1234 encodeAsBCD hexPrintString = '1234'). |
|
934 |
self assert:(12345 encodeAsBCD hexPrintString = '12345'). |
|
935 |
self assert:(123456 encodeAsBCD hexPrintString = '123456'). |
|
936 |
self assert:(1234567 encodeAsBCD hexPrintString = '1234567'). |
|
937 |
self assert:(12345678 encodeAsBCD hexPrintString = '12345678'). |
|
938 |
self assert:(123456789 encodeAsBCD hexPrintString = '123456789'). |
|
939 |
self assert:(1234567890 encodeAsBCD hexPrintString = '1234567890'). |
|
940 |
self assert:(12345678901 encodeAsBCD hexPrintString = '12345678901'). |
|
941 |
self assert:(123456789012 encodeAsBCD hexPrintString = '123456789012'). |
|
942 |
self assert:(1234567890123 encodeAsBCD hexPrintString = '1234567890123'). |
|
943 |
self assert:(12345678901234 encodeAsBCD hexPrintString = '12345678901234'). |
|
944 |
self assert:(123456789012345 encodeAsBCD hexPrintString = '123456789012345'). |
|
945 |
self assert:(1234567890123456 encodeAsBCD hexPrintString = '1234567890123456'). |
|
946 |
self assert:(12345678901234567 encodeAsBCD hexPrintString = '12345678901234567'). |
|
947 |
self assert:(123456789012345678 encodeAsBCD hexPrintString = '123456789012345678'). |
|
948 |
self assert:(1234567890123456789 encodeAsBCD hexPrintString = '1234567890123456789'). |
|
949 |
self assert:(12345678901234567890 encodeAsBCD hexPrintString = '12345678901234567890'). |
|
950 |
self assert:(4611686018427387902 encodeAsBCD hexPrintString = '4611686018427387902'). |
|
951 |
self assert:(4611686018427387903 encodeAsBCD hexPrintString = '4611686018427387903'). |
|
952 |
self assert:(4611686018427387904 encodeAsBCD hexPrintString = '4611686018427387904'). |
|
42 | 953 |
|
103 | 954 |
self assert:(16r1 decodeFromBCD = 1). |
955 |
self assert:(16r12 decodeFromBCD = 12). |
|
956 |
self assert:(16r123 decodeFromBCD = 123). |
|
957 |
self assert:(16r1234 decodeFromBCD = 1234). |
|
958 |
self assert:(16r12345 decodeFromBCD = 12345). |
|
959 |
self assert:(16r123456 decodeFromBCD = 123456). |
|
960 |
self assert:(16r1234567 decodeFromBCD = 1234567). |
|
961 |
self assert:(16r12345678 decodeFromBCD = 12345678). |
|
962 |
self assert:(16r123456789 decodeFromBCD = 123456789). |
|
963 |
self assert:(16r1234567890 decodeFromBCD = 1234567890). |
|
964 |
self assert:(16r12345678901 decodeFromBCD = 12345678901). |
|
965 |
self assert:(16r123456789012 decodeFromBCD = 123456789012). |
|
966 |
self assert:(16r1000000000000 decodeFromBCD = 1000000000000). |
|
967 |
self assert:(16r0000500000000 decodeFromBCD = 500000000). |
|
968 |
self assert:(16r1234500000000 decodeFromBCD = 1234500000000). |
|
969 |
self assert:(16r1234567890000 decodeFromBCD = 1234567890000). |
|
42 | 970 |
|
103 | 971 |
self assert:(16r1234567890123 decodeFromBCD = 1234567890123). |
972 |
self assert:(16r12345678901234 decodeFromBCD = 12345678901234). |
|
973 |
self assert:(16r123456789012345 decodeFromBCD = 123456789012345). |
|
974 |
self assert:(16r1234567890123456 decodeFromBCD = 1234567890123456). |
|
975 |
self assert:(16r12345678901234567 decodeFromBCD = 12345678901234567). |
|
976 |
self assert:(16r123456789012345678 decodeFromBCD = 123456789012345678). |
|
977 |
self assert:(16r1234567890123456789 decodeFromBCD = 1234567890123456789). |
|
978 |
self assert:(16r12345678901234567890 decodeFromBCD = 12345678901234567890). |
|
979 |
self assert:(16r4611686018427387902 decodeFromBCD = 4611686018427387902). |
|
980 |
self assert:(16r4611686018427387903 decodeFromBCD = 4611686018427387903). |
|
981 |
self assert:(16r4611686018427387904 decodeFromBCD = 4611686018427387904). |
|
42 | 982 |
|
983 |
" |
|
103 | 984 |
self basicNew testEncodeDecode |
42 | 985 |
" |
986 |
||
987 |
"Modified: / 26.10.1999 / 22:01:35 / stefan" |
|
988 |
! |
|
989 |
||
54 | 990 |
testILC |
991 |
"inline-cache" |
|
992 |
||
103 | 993 |
self assert:((self checkIsInteger:1) == true). |
994 |
self assert:((self checkIsInteger:nil) == false). |
|
995 |
self assert:((self checkIsInteger:1) == true). |
|
996 |
self assert:((self checkIsInteger:nil) == false). |
|
54 | 997 |
|
103 | 998 |
self assert:((self checkIsInteger:0) == true). |
999 |
self assert:((self checkIsInteger:nil) == false). |
|
1000 |
self assert:((self checkIsInteger:0) == true). |
|
1001 |
self assert:((self checkIsInteger:nil) == false). |
|
54 | 1002 |
|
1003 |
" |
|
103 | 1004 |
self basicNew testILC |
54 | 1005 |
" |
1006 |
||
1007 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
1008 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
1009 |
! |
|
1010 |
||
91 | 1011 |
testInline1 |
1012 |
"inlined tests. |
|
1013 |
Notice, the arithmetic tests are both performed via regular sends |
|
1014 |
and via constructed performs. The reason is to test both inlined |
|
1015 |
JIT-compiler code AND the regular methods code." |
|
1016 |
||
103 | 1017 |
self assert:( (self absPlusOneOf:1) = 2 ). |
1018 |
self assert:( (self absPlusOneOf:-1) = 2 ). |
|
1019 |
self assert:( (self absPlusOneOf:1.0) = 2 ). |
|
1020 |
self assert:( (self absPlusOneOf:-1.0) = 2 ). |
|
91 | 1021 |
|
1022 |
" |
|
103 | 1023 |
self basicNew testInline1 |
91 | 1024 |
" |
1025 |
||
1026 |
"Created: / 31.10.2000 / 20:22:48 / cg" |
|
1027 |
"Modified: / 31.10.2000 / 20:23:06 / cg" |
|
1028 |
! |
|
1029 |
||
57 | 1030 |
testInteger1 |
1031 |
"general conversion & arithmetic tests. |
|
1032 |
Notice, the arithmetic tests are both performed via regular sends |
|
1033 |
and via constructed performs. The reason is to test both inlined |
|
1034 |
JIT-compiler code AND the regular methods code." |
|
1035 |
||
1036 |
|minVal maxVal maxValPlus1 minValMinus1 halfMin halfMax t t1 t2| |
|
1037 |
||
1038 |
minVal := SmallInteger perform:('minVal' asSymbol). |
|
1039 |
maxVal := SmallInteger perform:('maxVal' asSymbol). |
|
1040 |
||
103 | 1041 |
self assert:(minVal == self num_smallInt_minVal). |
1042 |
self assert:(maxVal == self num_smallInt_maxVal). |
|
57 | 1043 |
|
103 | 1044 |
self assert:(minVal == SmallInteger minVal). |
1045 |
self assert:(maxVal == SmallInteger maxVal). |
|
57 | 1046 |
|
1047 |
t := SmallInteger perform:('maxBytes' asSymbol). |
|
103 | 1048 |
self assert:(t == SmallInteger maxBytes). |
57 | 1049 |
t := SmallInteger perform:('maxBits' asSymbol). |
103 | 1050 |
self assert:(t == SmallInteger maxBits). |
57 | 1051 |
|
1052 |
self testPrinting1. |
|
1053 |
||
1054 |
SmallInteger maxBytes == 4 ifTrue:[ |
|
103 | 1055 |
self assert:(minVal hexPrintString = '-40000000'). |
1056 |
self assert:(maxVal hexPrintString = '3FFFFFFF'). |
|
1057 |
self assert:(minVal == -1073741824). |
|
1058 |
self assert:(maxVal == 1073741823). |
|
1059 |
maxValPlus1 := 1073741824. |
|
1060 |
minValMinus1 := -1073741825. |
|
1061 |
self assert:(minValMinus1 hexPrintString = '-40000001'). |
|
1062 |
self assert:(maxValPlus1 hexPrintString = '40000000'). |
|
1063 |
halfMin := -16r20000000. |
|
1064 |
halfMax := 16r20000000. |
|
57 | 1065 |
]. |
1066 |
SmallInteger maxBytes == 8 ifTrue:[ |
|
103 | 1067 |
self assert:(minVal hexPrintString = '-4000000000000000'). |
1068 |
self assert:(maxVal hexPrintString = '3FFFFFFFFFFFFFFF'). |
|
1069 |
self assert:(minVal == -4611686018427387904). |
|
1070 |
self assert:(maxVal == 4611686018427387903). |
|
1071 |
maxValPlus1 := 4611686018427387904. |
|
1072 |
minValMinus1 := -4611686018427387905. |
|
1073 |
self assert:(minValMinus1 hexPrintString = '-4000000000000001'). |
|
1074 |
self assert:(maxValPlus1 hexPrintString = '4000000000000000'). |
|
1075 |
halfMin := -16r2000000000000000. |
|
1076 |
halfMax := 16r2000000000000000. |
|
57 | 1077 |
]. |
1078 |
||
1079 |
"arithmetic overFlow checks" |
|
1080 |
||
103 | 1081 |
"/ self assert:((maxVal + 1) inspect.maxValPlus1 inspect. true). |
1082 |
self assert:((maxVal perform:'+' asSymbol with:1) = maxValPlus1). |
|
1083 |
self assert:((maxVal + 1) = maxValPlus1). |
|
1084 |
self assert:((minVal perform:'-' asSymbol with:1) = minValMinus1). |
|
1085 |
self assert:((minVal - 1) = minValMinus1). |
|
57 | 1086 |
|
103 | 1087 |
self assert:((halfMax perform:'+' asSymbol with:halfMax) = maxValPlus1). |
1088 |
self assert:((halfMax + halfMax) = maxValPlus1). |
|
1089 |
self assert:((halfMin perform:'+' asSymbol with:halfMin) == minVal). |
|
1090 |
self assert:((halfMin + halfMin) == minVal). |
|
1091 |
self assert:((halfMax perform:'*' asSymbol with:2) = maxValPlus1). |
|
1092 |
self assert:((halfMax * 2) = maxValPlus1). |
|
1093 |
self assert:((halfMin perform:'*' asSymbol with:2) == minVal). |
|
1094 |
self assert:((halfMin * 2) == minVal). |
|
1095 |
self assert:((maxValPlus1 perform:'//' asSymbol with:2) == halfMax). |
|
1096 |
self assert:((maxValPlus1 // 2) == halfMax). |
|
1097 |
self assert:((halfMax perform:'bitShift:' asSymbol with:1) = maxValPlus1). |
|
1098 |
self assert:((halfMin perform:'bitShift:' asSymbol with:1) == minVal). |
|
1099 |
self assert:((halfMax bitShift:1) = maxValPlus1). |
|
1100 |
self assert:((halfMin bitShift:1) == minVal). |
|
57 | 1101 |
|
1102 |
"LargeInt op -> SmallInt result" |
|
1103 |
t := maxVal + 1. |
|
103 | 1104 |
self assert:(t - 1 == maxVal). |
57 | 1105 |
t := minVal - 1. |
103 | 1106 |
self assert:(t + 1 == minVal). |
57 | 1107 |
|
1108 |
" |
|
103 | 1109 |
self basicNew testInteger1 |
57 | 1110 |
" |
1111 |
||
1112 |
"Modified: / 6.6.1999 / 14:46:11 / cg" |
|
1113 |
! |
|
1114 |
||
53 | 1115 |
testIntegerMisc |
1116 |
"misc tests. |
|
1117 |
Notice, the arithmetic tests are both performed via regular sends |
|
1118 |
and via constructed performs. The reason is to test both inlined |
|
1119 |
JIT-compiler code AND the regular methods code." |
|
1120 |
||
1121 |
|n1 n2 s| |
|
1122 |
||
1123 |
n1 := 100000. |
|
1124 |
n2 := n1 negated. |
|
1125 |
s := 1. |
|
1126 |
||
103 | 1127 |
self assert:(n1 printString = '100000'). |
53 | 1128 |
|
103 | 1129 |
self assert:(n1 negated printString = '-100000'). |
1130 |
self assert:((n1 perform:'negated' asSymbol) printString = '-100000'). |
|
53 | 1131 |
|
103 | 1132 |
self assert:(n1 negated abs printString = '100000'). |
1133 |
self assert:((n1 perform:'negated' asSymbol) abs printString = '100000'). |
|
53 | 1134 |
|
103 | 1135 |
self assert:(n1 abs negated printString = '-100000'). |
1136 |
self assert:((n1 perform:'abs' asSymbol) negated printString = '-100000'). |
|
53 | 1137 |
|
1138 |
n1 := SmallInteger maxVal. |
|
103 | 1139 |
self assert:(n1 negated class == SmallInteger). |
1140 |
self assert:((n1 perform:'negated' asSymbol) class == SmallInteger). |
|
53 | 1141 |
|
1142 |
n1 := SmallInteger minVal. |
|
103 | 1143 |
self assert:(n1 negated class == LargeInteger). |
1144 |
self assert:((n1 perform:'negated' asSymbol) class == LargeInteger). |
|
53 | 1145 |
|
1146 |
n1 := SmallInteger minVal negated - 1. |
|
103 | 1147 |
self assert:(n1 negated class == SmallInteger). |
1148 |
self assert:((n1 perform:'negated' asSymbol) class == SmallInteger). |
|
1149 |
self assert:(n1 == SmallInteger maxVal). |
|
53 | 1150 |
|
1151 |
" |
|
103 | 1152 |
self basicNew testIntegerMisc |
53 | 1153 |
" |
1154 |
||
1155 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
1156 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
1157 |
! |
|
1158 |
||
151 | 1159 |
testIntegerMisc2 |
1160 |
"misc tests. |
|
1161 |
Notice, the arithmetic tests are both performed via regular sends |
|
1162 |
and via constructed performs. The reason is to test both inlined |
|
1163 |
JIT-compiler code AND the regular methods code." |
|
1164 |
||
1165 |
|n sel| |
|
1166 |
||
1167 |
self assert:(0 fib == 0). |
|
1168 |
self assert:(1 fib == 1). |
|
1169 |
self assert:(2 fib == 1). |
|
1170 |
self assert:(3 fib == 2). |
|
1171 |
self assert:(4 fib == 3). |
|
1172 |
self assert:(5 fib == 5). |
|
1173 |
self assert:(6 fib == 8). |
|
1174 |
self assert:(7 fib == 13). |
|
1175 |
||
1176 |
n := 0. |
|
1177 |
self assert:(n fib == 0). |
|
1178 |
n := 1. |
|
1179 |
self assert:(n fib == 1). |
|
1180 |
n := 2. |
|
1181 |
self assert:(n fib == 1). |
|
1182 |
n := 3. |
|
1183 |
self assert:(n fib == 2). |
|
1184 |
n := 4. |
|
1185 |
self assert:(n fib == 3). |
|
1186 |
n := 5. |
|
1187 |
self assert:(n fib == 5). |
|
1188 |
n := 6. |
|
1189 |
self assert:(n fib == 8). |
|
1190 |
n := 7. |
|
1191 |
self assert:(n fib == 13). |
|
1192 |
||
1193 |
#(0 1 2 3 4 5 6 7) |
|
1194 |
with:#(0 1 1 2 3 5 8 13) |
|
1195 |
do:[:n :rslt | |
|
1196 |
self assert:(n fib == rslt). |
|
1197 |
]. |
|
1198 |
||
1199 |
#(0 1 2 3 4 5 6 7) |
|
1200 |
with:#(0 1 1 2 3 5 8 13) |
|
1201 |
do:[:n :rslt | |
|
206 | 1202 |
self assert:(n fib_recursive == rslt). |
151 | 1203 |
]. |
1204 |
||
1205 |
sel := #fib. |
|
1206 |
self assert:((0 perform:sel) == 0). |
|
1207 |
self assert:((1 perform:sel) == 1). |
|
1208 |
self assert:((2 perform:sel) == 1). |
|
1209 |
self assert:((3 perform:sel) == 2). |
|
1210 |
self assert:((4 perform:sel) == 3). |
|
1211 |
self assert:((5 perform:sel) == 5). |
|
1212 |
self assert:((6 perform:sel) == 8). |
|
1213 |
self assert:((7 perform:sel) == 13). |
|
1214 |
||
1215 |
" |
|
1216 |
self basicNew testIntegerMisc2 |
|
1217 |
" |
|
1218 |
! |
|
1219 |
||
41 | 1220 |
testIntegerShifts |
1221 |
"arithmetic tests. |
|
1222 |
Notice, the arithmetic tests are both performed via regular sends |
|
1223 |
and via constructed performs. The reason is to test both inlined |
|
1224 |
JIT-compiler code AND the regular methods code." |
|
1225 |
||
45 | 1226 |
self testIntegerShifts1. |
1227 |
self testIntegerShifts2. |
|
1228 |
||
103 | 1229 |
self assert:( |
45 | 1230 |
(((0 to:64) collect:[:s | 1 bitShift:s]) |
103 | 1231 |
collect:[:n | n highBit]) = (1 to:65) |
1232 |
). |
|
45 | 1233 |
|
1234 |
1 to:10000 do:[:s | |
|
103 | 1235 |
self assert:( (1 bitShift:s) highBit == (s+1) ) |
45 | 1236 |
]. |
1237 |
1 to:10000 do:[:s | |
|
103 | 1238 |
self assert:( ((1 bitShift:s) - 1) highBit == s ) |
45 | 1239 |
]. |
1240 |
||
1241 |
" |
|
103 | 1242 |
self basicNew testIntegerShifts |
45 | 1243 |
" |
1244 |
||
1245 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
1246 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
1247 |
! |
|
1248 |
||
1249 |
testIntegerShifts1 |
|
1250 |
"arithmetic tests. |
|
1251 |
Notice, the arithmetic tests are both performed via regular sends |
|
1252 |
and via constructed performs. The reason is to test both inlined |
|
1253 |
JIT-compiler code AND the regular methods code." |
|
1254 |
||
41 | 1255 |
|n1 n2 s| |
1256 |
||
1257 |
n1 := 100000. |
|
1258 |
n2 := n1 negated. |
|
1259 |
s := 1. |
|
1260 |
||
103 | 1261 |
self assert:(n1 printString = '100000'). |
1262 |
self assert:(n2 printString = '-100000'). |
|
41 | 1263 |
|
103 | 1264 |
self assert:((n1 bitShift:s) printString = '200000'). |
1265 |
self assert:((n1 bitShift:1) printString = '200000'). |
|
1266 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '200000'). |
|
1267 |
self assert:((n1 perform:'bitShift:' asSymbol with:1) printString = '200000'). |
|
41 | 1268 |
|
1269 |
s := s + 1. |
|
103 | 1270 |
self assert:((n1 bitShift:s) printString = '400000'). |
1271 |
self assert:((n1 bitShift:2) printString = '400000'). |
|
1272 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '400000'). |
|
1273 |
self assert:((n1 perform:'bitShift:' asSymbol with:2) printString = '400000'). |
|
41 | 1274 |
|
1275 |
s := s + 1. |
|
103 | 1276 |
self assert:((n1 bitShift:s) printString = '800000'). |
1277 |
self assert:((n1 bitShift:3) printString = '800000'). |
|
1278 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '800000'). |
|
1279 |
self assert:((n1 perform:'bitShift:' asSymbol with:3) printString = '800000'). |
|
41 | 1280 |
|
1281 |
s := s + 1. |
|
103 | 1282 |
self assert:((n1 bitShift:s) printString = '1600000'). |
1283 |
self assert:((n1 bitShift:4) printString = '1600000'). |
|
1284 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '1600000'). |
|
1285 |
self assert:((n1 perform:'bitShift:' asSymbol with:4) printString = '1600000'). |
|
41 | 1286 |
|
1287 |
s := s + 1. |
|
103 | 1288 |
self assert:((n1 bitShift:s) printString = '3200000'). |
1289 |
self assert:((n1 bitShift:5) printString = '3200000'). |
|
1290 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '3200000'). |
|
1291 |
self assert:((n1 perform:'bitShift:' asSymbol with:5) printString = '3200000'). |
|
41 | 1292 |
|
1293 |
s := s + 1. |
|
103 | 1294 |
self assert:((n1 bitShift:s) printString = '6400000'). |
1295 |
self assert:((n1 bitShift:6) printString = '6400000'). |
|
1296 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '6400000'). |
|
1297 |
self assert:((n1 perform:'bitShift:' asSymbol with:6) printString = '6400000'). |
|
41 | 1298 |
|
1299 |
s := s + 1. |
|
103 | 1300 |
self assert:((n1 bitShift:s) printString = '12800000'). |
1301 |
self assert:((n1 bitShift:7) printString = '12800000'). |
|
1302 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '12800000'). |
|
1303 |
self assert:((n1 perform:'bitShift:' asSymbol with:7) printString = '12800000'). |
|
41 | 1304 |
|
45 | 1305 |
" |
103 | 1306 |
self basicNew testIntegerShifts1 |
45 | 1307 |
" |
1308 |
||
1309 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
1310 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
1311 |
! |
|
1312 |
||
1313 |
testIntegerShifts2 |
|
1314 |
"arithmetic tests. |
|
1315 |
Notice, the arithmetic tests are both performed via regular sends |
|
1316 |
and via constructed performs. The reason is to test both inlined |
|
1317 |
JIT-compiler code AND the regular methods code." |
|
1318 |
||
1319 |
|n1 s| |
|
1320 |
||
41 | 1321 |
n1 := 12800000. |
1322 |
s := -1. |
|
103 | 1323 |
self assert:((n1 bitShift:s) printString = '6400000'). |
1324 |
self assert:((n1 bitShift:-1) printString = '6400000'). |
|
1325 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '6400000'). |
|
1326 |
self assert:((n1 perform:'bitShift:' asSymbol with:-1) printString = '6400000'). |
|
41 | 1327 |
|
1328 |
s := s - 1. |
|
103 | 1329 |
self assert:((n1 bitShift:s) printString = '3200000'). |
1330 |
self assert:((n1 bitShift:-2) printString = '3200000'). |
|
1331 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '3200000'). |
|
1332 |
self assert:((n1 perform:'bitShift:' asSymbol with:-2) printString = '3200000'). |
|
41 | 1333 |
|
1334 |
s := s - 1. |
|
103 | 1335 |
self assert:((n1 bitShift:s) printString = '1600000'). |
1336 |
self assert:((n1 bitShift:-3) printString = '1600000'). |
|
1337 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '1600000'). |
|
1338 |
self assert:((n1 perform:'bitShift:' asSymbol with:-3) printString = '1600000'). |
|
41 | 1339 |
|
1340 |
s := s - 1. |
|
103 | 1341 |
self assert:((n1 bitShift:s) printString = '800000'). |
1342 |
self assert:((n1 bitShift:-4) printString = '800000'). |
|
1343 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '800000'). |
|
1344 |
self assert:((n1 perform:'bitShift:' asSymbol with:-4) printString = '800000'). |
|
41 | 1345 |
|
1346 |
s := s - 1. |
|
103 | 1347 |
self assert:((n1 bitShift:s) printString = '400000'). |
1348 |
self assert:((n1 bitShift:-5) printString = '400000'). |
|
1349 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '400000'). |
|
1350 |
self assert:((n1 perform:'bitShift:' asSymbol with:-5) printString = '400000'). |
|
41 | 1351 |
|
1352 |
s := s - 1. |
|
103 | 1353 |
self assert:((n1 bitShift:s) printString = '200000'). |
1354 |
self assert:((n1 bitShift:-6) printString = '200000'). |
|
1355 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '200000'). |
|
1356 |
self assert:((n1 perform:'bitShift:' asSymbol with:-6) printString = '200000'). |
|
41 | 1357 |
|
1358 |
s := s - 1. |
|
103 | 1359 |
self assert:((n1 bitShift:s) printString = '100000'). |
1360 |
self assert:((n1 bitShift:-7) printString = '100000'). |
|
1361 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '100000'). |
|
1362 |
self assert:((n1 perform:'bitShift:' asSymbol with:-7) printString = '100000'). |
|
41 | 1363 |
|
1364 |
s := s - 1. |
|
103 | 1365 |
self assert:((n1 bitShift:s) printString = '50000'). |
1366 |
self assert:((n1 bitShift:-8) printString = '50000'). |
|
1367 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '50000'). |
|
1368 |
self assert:((n1 perform:'bitShift:' asSymbol with:-8) printString = '50000'). |
|
41 | 1369 |
|
1370 |
s := s - 1. |
|
103 | 1371 |
self assert:((n1 bitShift:s) printString = '25000'). |
1372 |
self assert:((n1 bitShift:-9) printString = '25000'). |
|
1373 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '25000'). |
|
1374 |
self assert:((n1 perform:'bitShift:' asSymbol with:-9) printString = '25000'). |
|
41 | 1375 |
|
1376 |
s := s - 1. |
|
103 | 1377 |
self assert:((n1 bitShift:s) printString = '12500'). |
1378 |
self assert:((n1 bitShift:-10) printString = '12500'). |
|
1379 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '12500'). |
|
1380 |
self assert:((n1 perform:'bitShift:' asSymbol with:-10) printString = '12500'). |
|
41 | 1381 |
|
1382 |
s := s - 1. |
|
103 | 1383 |
self assert:((n1 bitShift:s) printString = '6250'). |
1384 |
self assert:((n1 bitShift:-11) printString = '6250'). |
|
1385 |
self assert:((n1 perform:'bitShift:' asSymbol with:s) printString = '6250'). |
|
1386 |
self assert:((n1 perform:'bitShift:' asSymbol with:-11) printString = '6250'). |
|
41 | 1387 |
|
1388 |
" |
|
103 | 1389 |
self basicNew testIntegerShifts2 |
41 | 1390 |
" |
1391 |
||
1392 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
1393 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
|
1394 |
! |
|
1395 |
||
89 | 1396 |
testIntegerShifts3 |
1397 |
"arithmetic tests. |
|
1398 |
Notice, the arithmetic tests are both performed via regular sends |
|
1399 |
and via constructed performs. The reason is to test both inlined |
|
1400 |
JIT-compiler code AND the regular methods code." |
|
1401 |
||
103 | 1402 |
self assert:( self doConstantIntegerShift == 1). |
89 | 1403 |
|
1404 |
" |
|
103 | 1405 |
self basicNew testIntegerShifts3 |
95 | 1406 |
" |
1407 |
! |
|
89 | 1408 |
|
107 | 1409 |
testIntegerShifts4 |
1410 |
"arithmetic tests. |
|
1411 |
Notice, the arithmetic tests are both performed via regular sends |
|
1412 |
and via constructed performs. The reason is to test both inlined |
|
1413 |
JIT-compiler code AND the regular methods code." |
|
1414 |
||
1415 |
|a| |
|
1416 |
||
1417 |
a := 16r1234. |
|
1418 |
||
1419 |
self assert:( ((a bitShift:-4) bitAnd:16rFF) == 16r23 ). |
|
1420 |
self assert:( ((a bitShift:-8) bitAnd:16rFF) == 16r12 ). |
|
1421 |
self assert:( ((a bitShift:-12) bitAnd:16rFF) == 16r1 ). |
|
1422 |
self assert:( ((a bitShift:-16) bitAnd:16rFF) == 0 ). |
|
1423 |
||
1424 |
"/ should not shift in any sign bits ... |
|
1425 |
a := 16r1FFFFFFF. |
|
1426 |
self assert:( (a bitShift:-4) == 16r1FFFFFF ). |
|
1427 |
a := 16r3FFFFFFF. |
|
1428 |
self assert:( (a bitShift:-4) == 16r3FFFFFF ). |
|
1429 |
a := 16r7FFFFFFF. |
|
1430 |
self assert:( (a bitShift:-4) == 16r7FFFFFF ). |
|
1431 |
a := 16rFFFFFFFF. |
|
1432 |
self assert:( (a bitShift:-4) == 16rFFFFFFF ). |
|
1433 |
a := 16r1FFFFFFFF. |
|
1434 |
self assert:( (a bitShift:-4) == 16r1FFFFFFF ). |
|
1435 |
||
1436 |
a := 16r1FFFFFFF. |
|
1437 |
self assert:( (a bitShift:-8) == 16r1FFFFF ). |
|
1438 |
a := 16r3FFFFFFF. |
|
1439 |
self assert:( (a bitShift:-8) == 16r3FFFFF ). |
|
1440 |
a := 16r7FFFFFFF. |
|
1441 |
self assert:( (a bitShift:-8) == 16r7FFFFF ). |
|
1442 |
a := 16rFFFFFFFF. |
|
1443 |
self assert:( (a bitShift:-8) == 16rFFFFFF ). |
|
1444 |
a := 16r1FFFFFFFF. |
|
1445 |
self assert:( (a bitShift:-8) == 16r1FFFFFF ). |
|
1446 |
||
1447 |
" |
|
1448 |
self basicNew testIntegerShifts4 |
|
1449 |
" |
|
1450 |
! |
|
1451 |
||
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1452 |
testLargeAddition |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1453 |
"general conversion & arithmetic tests. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1454 |
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
|
1455 |
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
|
1456 |
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
|
1457 |
|
19 | 1458 |
|s n1 n2 x| |
13 | 1459 |
|
23 | 1460 |
"Large + Large addition" |
1461 |
self testReading1. |
|
1462 |
||
103 | 1463 |
self assert:((20 factorial + 20 factorial) printString = '4865804016353280000'). |
1464 |
self assert:((20 factorial + 1) printString = '2432902008176640001'). |
|
1465 |
self assert:((20 factorial + 1000) printString = '2432902008176641000'). |
|
23 | 1466 |
|
29 | 1467 |
"Large + Small addition" |
1468 |
||
34 | 1469 |
self testLargeAddition1. |
1470 |
||
1471 |
"Large + Large addition" |
|
1472 |
||
1473 |
self testLargeAddition2. |
|
1474 |
||
1475 |
"Large - small subtraction" |
|
1476 |
||
1477 |
self testLargeAddition3. |
|
1478 |
||
1479 |
" |
|
103 | 1480 |
self basicNew testLargeAddition |
34 | 1481 |
" |
1482 |
||
1483 |
"Modified: / 4.6.1999 / 15:26:55 / cg" |
|
1484 |
! |
|
1485 |
||
1486 |
testLargeAddition1 |
|
1487 |
"general conversion & arithmetic tests. |
|
1488 |
Notice, the arithmetic tests are both performed via regular sends |
|
1489 |
and via constructed performs. The reason is to test both inlined |
|
1490 |
JIT-compiler code AND the regular methods code." |
|
1491 |
||
1492 |
|s n1 n2 x| |
|
1493 |
||
1494 |
"Large + Small addition" |
|
1495 |
||
29 | 1496 |
n1 := 16r3FFFFFFF. n2 := 1. |
103 | 1497 |
self assert:((n1 + n2 ) hexPrintString = '40000000'). |
1498 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000'). |
|
29 | 1499 |
n1 := 16r3FFFFFFFF. n2 := 1. |
103 | 1500 |
self assert:((n1 + n2 ) hexPrintString = '400000000'). |
1501 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000'). |
|
29 | 1502 |
n1 := 16r3FFFFFFFFF. n2 := 1. |
103 | 1503 |
self assert:((n1 + n2 ) hexPrintString = '4000000000'). |
1504 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000'). |
|
29 | 1505 |
n1 := 16r3FFFFFFFFFF. n2 := 1. |
103 | 1506 |
self assert:((n1 + n2 ) hexPrintString = '40000000000'). |
1507 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000000'). |
|
29 | 1508 |
n1 := 16r3FFFFFFFFFFF. n2 := 1. |
103 | 1509 |
self assert:((n1 + n2 ) hexPrintString = '400000000000'). |
1510 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000000'). |
|
29 | 1511 |
n1 := 16r3FFFFFFFFFFFF. n2 := 1. |
103 | 1512 |
self assert:((n1 + n2 ) hexPrintString = '4000000000000'). |
1513 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000000'). |
|
29 | 1514 |
n1 := 16r3FFFFFFFFFFFFF. n2 := 1. |
103 | 1515 |
self assert:((n1 + n2 ) hexPrintString = '40000000000000'). |
1516 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '40000000000000'). |
|
29 | 1517 |
n1 := 16r3FFFFFFFFFFFFFF. n2 := 1. |
103 | 1518 |
self assert:((n1 + n2 ) hexPrintString = '400000000000000'). |
1519 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '400000000000000'). |
|
29 | 1520 |
n1 := 16r3FFFFFFFFFFFFFFF. n2 := 1. |
103 | 1521 |
self assert:((n1 + n2 ) hexPrintString = '4000000000000000'). |
1522 |
self assert:((n1 perform:'+' asSymbol with:n2 ) hexPrintString = '4000000000000000'). |
|
29 | 1523 |
|
34 | 1524 |
" |
103 | 1525 |
self basicNew testLargeAddition1 |
34 | 1526 |
" |
1527 |
||
1528 |
"Modified: / 4.6.1999 / 15:26:55 / cg" |
|
1529 |
! |
|
1530 |
||
1531 |
testLargeAddition2 |
|
1532 |
"general conversion & arithmetic tests. |
|
1533 |
Notice, the arithmetic tests are both performed via regular sends |
|
1534 |
and via constructed performs. The reason is to test both inlined |
|
1535 |
JIT-compiler code AND the regular methods code." |
|
1536 |
||
1537 |
|s n1 n2 x| |
|
1538 |
||
29 | 1539 |
"Large + Large addition" |
23 | 1540 |
|
1541 |
n1 := 16r100000000. n2 := 16r7FFFFFFF. |
|
103 | 1542 |
self assert:((n1 - n2 ) hexPrintString = '80000001'). |
1543 |
self assert:((16r100000000 - n2 ) hexPrintString = '80000001'). |
|
1544 |
self assert:((n1 - 16r7FFFFFFF ) hexPrintString = '80000001'). |
|
1545 |
self assert:((16r100000000 - 16r7FFFFFFF ) hexPrintString = '80000001'). |
|
1546 |
self assert:((n1 perform:'-' asSymbol with:n2 ) hexPrintString = '80000001'). |
|
1547 |
self assert:((16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '80000001'). |
|
1548 |
self assert:((n1 perform:'-' asSymbol with:16r7FFFFFFF ) hexPrintString = '80000001'). |
|
1549 |
self assert:((16r100000000 perform:'-' asSymbol with:16r7FFFFFFF ) hexPrintString = '80000001'). |
|
23 | 1550 |
|
1551 |
n1 := 16r100000000. n2 := 16r80000000. |
|
103 | 1552 |
self assert:((n1 - n2 ) hexPrintString = '80000000'). |
1553 |
self assert:((16r100000000 - n2 ) hexPrintString = '80000000'). |
|
1554 |
self assert:((n1 - 16r80000000 ) hexPrintString = '80000000'). |
|
1555 |
self assert:((16r100000000 - 16r80000000 ) hexPrintString = '80000000'). |
|
1556 |
self assert:((n1 perform:'-' asSymbol with:n2 ) hexPrintString = '80000000'). |
|
1557 |
self assert:((16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '80000000'). |
|
1558 |
self assert:((n1 perform:'-' asSymbol with:16r80000000 ) hexPrintString = '80000000'). |
|
1559 |
self assert:((16r100000000 perform:'-' asSymbol with:16r80000000 ) hexPrintString = '80000000'). |
|
17 | 1560 |
|
1561 |
n1 := 16r100000000. n2 := 16rFFFFFFFF. |
|
103 | 1562 |
self assert:((n1 - n2 ) hexPrintString = '1'). |
1563 |
self assert:((16r100000000 - n2 ) hexPrintString = '1'). |
|
1564 |
self assert:((x := n1 - 16rFFFFFFFF) == 1). |
|
17 | 1565 |
|
103 | 1566 |
self assert:((n1 - 16rFFFFFFFF ) hexPrintString = '1'). |
1567 |
self assert:((16r100000000 - 16rFFFFFFFF ) hexPrintString = '1'). |
|
1568 |
self assert:((n1 perform:'-' asSymbol with:n2 ) hexPrintString = '1'). |
|
1569 |
self assert:((16r100000000 perform:'-' asSymbol with:n2 ) hexPrintString = '1'). |
|
1570 |
self assert:((n1 perform:'-' asSymbol with:16rFFFFFFFF ) hexPrintString = '1'). |
|
1571 |
self assert:((16r100000000 perform:'-' asSymbol with:16rFFFFFFFF ) hexPrintString = '1'). |
|
23 | 1572 |
|
1573 |
n1 := 16r100000000. n2 := 1. |
|
103 | 1574 |
self assert:((n1 - n2) hexPrintString = 'FFFFFFFF'). |
1575 |
self assert:((n1 - n2) hexPrintString = 'FFFFFFFF'). |
|
1576 |
self assert:((16r100000000 - n2) hexPrintString = 'FFFFFFFF'). |
|
1577 |
self assert:((n1 - 1) hexPrintString = 'FFFFFFFF'). |
|
1578 |
self assert:((16r100000000 - 1) hexPrintString = 'FFFFFFFF'). |
|
1579 |
self assert:((n1 perform:'-' asSymbol with:n2) hexPrintString = 'FFFFFFFF'). |
|
1580 |
self assert:((16r100000000 perform:'-' asSymbol with:n2) hexPrintString = 'FFFFFFFF'). |
|
1581 |
self assert:((n1 perform:'-' asSymbol with:1) hexPrintString = 'FFFFFFFF'). |
|
1582 |
self assert:((16r100000000 perform:'-' asSymbol with:1) hexPrintString = 'FFFFFFFF'). |
|
23 | 1583 |
|
1584 |
n1 := 16r100000000. n2 := 16r10000000. |
|
103 | 1585 |
self assert:((n1 - n2) hexPrintString = 'F0000000'). |
1586 |
self assert:((16r100000000 - n2) hexPrintString = 'F0000000'). |
|
1587 |
self assert:((n1 - 16r10000000) hexPrintString = 'F0000000'). |
|
1588 |
self assert:((16r100000000 - 16r10000000) hexPrintString = 'F0000000'). |
|
1589 |
self assert:((n1 perform:'-' asSymbol with:n2) hexPrintString = 'F0000000'). |
|
1590 |
self assert:((16r100000000 perform:'-' asSymbol with:n2) hexPrintString = 'F0000000'). |
|
1591 |
self assert:((n1 perform:'-' asSymbol with:16r10000000) hexPrintString = 'F0000000'). |
|
1592 |
self assert:((16r100000000 perform:'-' asSymbol with:16r10000000) hexPrintString = 'F0000000'). |
|
23 | 1593 |
|
34 | 1594 |
" |
103 | 1595 |
self basicNew testLargeAddition2 |
34 | 1596 |
" |
1597 |
! |
|
1598 |
||
1599 |
testLargeAddition3 |
|
1600 |
"general conversion & arithmetic tests. |
|
1601 |
Notice, the arithmetic tests are both performed via regular sends |
|
1602 |
and via constructed performs. The reason is to test both inlined |
|
1603 |
JIT-compiler code AND the regular methods code." |
|
1604 |
||
1605 |
|s n1 n2 x| |
|
1606 |
||
23 | 1607 |
"Large - small subtraction" |
103 | 1608 |
self assert:((20 factorial + 20 factorial - 1) printString = '4865804016353279999'). |
1609 |
self assert:((20 factorial - 10 factorial + 3628800) printString = '2432902008176640000'). |
|
1610 |
self assert:((20 factorial - 11 factorial + 39916800) printString = '2432902008176640000'). |
|
1611 |
self assert:((20 factorial - 12 factorial + 479001600) printString = '2432902008176640000'). |
|
1612 |
self assert:((20 factorial - 13 factorial + 6227020800) printString = '2432902008176640000'). |
|
1613 |
self assert:((20 factorial - 14 factorial + 87178291200) printString = '2432902008176640000'). |
|
1614 |
self assert:((20 factorial - 15 factorial + 1307674368000) printString = '2432902008176640000'). |
|
1615 |
self assert:((20 factorial - 16 factorial + 20922789888000) printString = '2432902008176640000'). |
|
1616 |
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
|
1617 |
|
103 | 1618 |
self assert:(1000 factorial printString = '402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'). |
51 | 1619 |
|
1620 |
n1 := n2 := 1. |
|
103 | 1621 |
self assert:((1000 factorial + n1 - n2) = 1000 factorial). |
51 | 1622 |
n1 := n2 := 1000. |
103 | 1623 |
self assert:((1000 factorial + n1 - n2) = 1000 factorial). |
51 | 1624 |
n1 := n2 := 16rFFFFFFFF. |
103 | 1625 |
self assert:((1000 factorial + n1 - n2) = 1000 factorial). |
51 | 1626 |
n1 := n2 := 16rFFFFFFFFFFFF. |
103 | 1627 |
self assert:((1000 factorial + n1 - n2) = 1000 factorial). |
51 | 1628 |
n1 := n2 := 16rFFFFFFFFFFFFFFFF. |
103 | 1629 |
self assert:((1000 factorial + n1 - n2) = 1000 factorial). |
51 | 1630 |
n1 := n2 := 1000 factorial. |
103 | 1631 |
self assert:((1000 factorial + n1 - n2) = 1000 factorial). |
51 | 1632 |
|
1633 |
||
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1634 |
" |
103 | 1635 |
self basicNew testLargeAddition3 |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1636 |
" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1637 |
|
52 | 1638 |
"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
|
1639 |
! |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1640 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1641 |
testLargeDivision |
103 | 1642 |
|t v| |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1643 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1644 |
t := 20 factorial. |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1645 |
|
103 | 1646 |
self assert:(t printString = '2432902008176640000'). |
1647 |
self assert:(t \\ 10 == 0). |
|
16 | 1648 |
t := t // 10. |
103 | 1649 |
self assert:(t printString = '243290200817664000'). |
1650 |
self assert:(t \\ 10 == 0). |
|
16 | 1651 |
t := t // 10. |
103 | 1652 |
self assert:(t printString = '24329020081766400'). |
1653 |
self assert:(t \\ 10 == 0). |
|
16 | 1654 |
t := t // 10. |
103 | 1655 |
self assert:(t printString = '2432902008176640'). |
1656 |
self assert:(t \\ 10 == 0). |
|
16 | 1657 |
t := t // 10. |
103 | 1658 |
self assert:(t printString = '243290200817664'). |
1659 |
self assert:(t \\ 10 == 4). |
|
16 | 1660 |
t := t // 10. |
103 | 1661 |
self assert:(t printString = '24329020081766'). |
1662 |
self assert:(t \\ 10 == 6). |
|
16 | 1663 |
t := t // 10. |
103 | 1664 |
self assert:(t printString = '2432902008176'). |
1665 |
self assert:(t \\ 10 == 6). |
|
16 | 1666 |
t := t // 10. |
103 | 1667 |
self assert:(t printString = '243290200817'). |
1668 |
self assert:(t \\ 10 == 7). |
|
16 | 1669 |
t := t // 10. |
103 | 1670 |
self assert:(t printString = '24329020081'). |
1671 |
self assert:(t \\ 10 == 1). |
|
16 | 1672 |
t := t // 10. |
103 | 1673 |
self assert:(t printString = '2432902008'). |
1674 |
self assert:(t \\ 10 == 8). |
|
16 | 1675 |
t := t // 10. |
103 | 1676 |
self assert:(t printString = '243290200'). |
1677 |
self assert:(t \\ 10 == 0). |
|
16 | 1678 |
|
1679 |
||
1680 |
t := 20 factorial. |
|
1681 |
||
103 | 1682 |
self assert:(t printString = '2432902008176640000'). |
1683 |
self assert:(t \\ 1000 == 0). |
|
16 | 1684 |
t := t // 1000. |
103 | 1685 |
self assert:(t printString = '2432902008176640'). |
1686 |
self assert:(t \\ 1000 == 640). |
|
16 | 1687 |
t := t // 1000. |
103 | 1688 |
self assert:(t printString = '2432902008176'). |
1689 |
self assert:(t \\ 1000 == 176). |
|
16 | 1690 |
t := t // 1000. |
103 | 1691 |
self assert:(t printString = '2432902008'). |
1692 |
self assert:(t \\ 1000 == 8). |
|
16 | 1693 |
t := t // 1000. |
103 | 1694 |
self assert:(t printString = '2432902'). |
1695 |
self assert:(t \\ 1000 == 902). |
|
16 | 1696 |
t := t // 1000. |
103 | 1697 |
self assert:(t printString = '2432'). |
1698 |
self assert:(t \\ 1000 == 432). |
|
16 | 1699 |
t := t // 1000. |
103 | 1700 |
self assert:(t == 2). |
1701 |
self assert:(t \\ 1000 == 2). |
|
16 | 1702 |
|
1703 |
||
1704 |
t := 20 factorial. |
|
1705 |
||
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1706 |
"Large // SmallInt division" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1707 |
t := t // 20. |
103 | 1708 |
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
|
1709 |
t := t // 19. |
103 | 1710 |
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
|
1711 |
t := t // 18. |
103 | 1712 |
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
|
1713 |
t := t // 17. |
103 | 1714 |
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
|
1715 |
t := t // 16. |
103 | 1716 |
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
|
1717 |
t := t // 15. |
103 | 1718 |
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
|
1719 |
t := t // 14. |
103 | 1720 |
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
|
1721 |
t := t // 13. |
103 | 1722 |
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
|
1723 |
t := t // 12. |
103 | 1724 |
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
|
1725 |
t := t // 11. |
103 | 1726 |
self assert:(t printString = 10 factorial printString). |
1727 |
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
|
1728 |
|
26 | 1729 |
t := 20 factorial. |
1730 |
t := t + 21 factorial. |
|
1731 |
t absSubtract:21 factorial. |
|
103 | 1732 |
self assert:(t compressed = 20 factorial). |
26 | 1733 |
|
103 | 1734 |
self assert:( |
1735 |
[ |
|
1736 |
|v| |
|
1737 |
v := 100 factorial copy. |
|
1738 |
v absSubtract:99 factorial. |
|
1739 |
v compressed = (100 factorial - 99 factorial). |
|
1740 |
] value). |
|
26 | 1741 |
|
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1742 |
"Large // Large division" |
103 | 1743 |
self assert:((20 factorial // 19 factorial) == 20). |
1744 |
self assert:((20 factorial * 21 // 20 // 21) = (19 factorial)). |
|
1745 |
self assert:((10000 factorial // 9999 factorial) == 10000). |
|
1746 |
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
|
1747 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1748 |
" |
103 | 1749 |
self basicNew testLargeDivision |
12
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1750 |
" |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1751 |
|
26 | 1752 |
"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
|
1753 |
! |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1754 |
|
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1755 |
testLargeMultiplication |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1756 |
|t1| |
29d0f2e59dcb
splitted into smaller methods to avoid JIT-bail-out
Claus Gittinger <cg@exept.de>
parents:
11
diff
changeset
|
1757 |
|
3 | 1758 |
"multiplication" |
1759 |
t1 := 100. |
|
103 | 1760 |
self assert:(t1 * t1 == 10000). |
1761 |
self assert:((t1 perform:'*' asSymbol with:t1) == 10000). |
|
1762 |
self assert:((t1 * t1) printString = '10000'). |
|
1763 |
self assert:((t1 perform:'*' asSymbol with:t1) printString = '10000'). |
|
11 | 1764 |
|
3 | 1765 |
t1 := 1000. |
103 | 1766 |
self assert:(t1 * t1 == 1000000). |
1767 |
self assert:((t1 perform:'*' asSymbol with:t1) == 1000000). |
|
1768 |
self assert:((t1 * t1) printString = '1000000'). |
|
1769 |
self assert:((t1 perform:'*' asSymbol with:t1) printString = '1000000'). |
|
11 | 1770 |
|
3 | 1771 |
t1 := 10000. |
103 | 1772 |
self assert:(t1 * t1 == 100000000). |
1773 |
self assert:((t1 perform:'*' asSymbol with:t1) == 100000000). |
|
1774 |
self assert:((t1 * t1) printString = '100000000'). |
|
1775 |
self assert:((t1 perform:'*' asSymbol with:t1) printString = '100000000'). |
|
11 | 1776 |
|
3 | 1777 |
t1 := 100000. |
1778 |
SmallInteger maxBytes == 4 ifTrue:[ |
|
103 | 1779 |
self assert:(t1 * t1 = 10000000000). |
1780 |
self assert:((t1 perform:'*' asSymbol with:t1) = 10000000000). |
|
3 | 1781 |
]. |
1782 |
SmallInteger maxBytes == 8 ifTrue:[ |
|
103 | 1783 |
self assert:(t1 * t1 == 10000000000). |
1784 |
self assert:((t1 perform:'*' asSymbol with:t1) == 10000000000). |
|
3 | 1785 |
]. |
4 | 1786 |
|
103 | 1787 |
self assert:((t1 * t1) printString = '10000000000'). |
1788 |
self assert:((t1 perform:'*' asSymbol with:t1) printString = '10000000000'). |
|
11 | 1789 |
|
3 | 1790 |
t1 := 1000000. |
103 | 1791 |
self assert:((t1 * t1) printString = '1000000000000'). |
1792 |
self assert:((t1 perform:'*' asSymbol with:t1) printString = '1000000000000'). |
|
11 | 1793 |
|
3 | 1794 |
t1 := 10000000. |
103 | 1795 |
self assert:((t1 * t1) printString = '100000000000000'). |
1796 |
self assert:((t1 perform:'*' asSymbol with:t1) printString = '100000000000000'). |
|
11 | 1797 |
|
3 | 1798 |
t1 := 100000000. |
103 | 1799 |
self assert:((t1 * t1) printString = '10000000000000000'). |
1800 |
self assert:((t1 perform:'*' asSymbol with:t1) printString = '10000000000000000'). |
|
11 | 1801 |
|
3 | 1802 |
t1 := 1000000000. |
103 | 1803 |
self assert:((t1 * t1) printString = '1000000000000000000'). |
1804 |
self assert:((t1 perform:'*' asSymbol with:t1) printString = '1000000000000000000'). |
|
11 | 1805 |
|
2 | 1806 |
|
3 | 1807 |
"Large * SmallInt multiplication" |
103 | 1808 |
self assert:(10 factorial printString = '3628800'). |
1809 |
self assert:(20 factorial printString = '2432902008176640000'). |
|
1810 |
self assert:(100 factorial printString = '93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000'). |
|
1811 |
self assert:(1000 factorial printString = '402387260077093773543702433923003985719374864210714632543799910429938512398629020592044208486969404800479988610197196058631666872994808558901323829669944590997424504087073759918823627727188732519779505950995276120874975462497043601418278094646496291056393887437886487337119181045825783647849977012476632889835955735432513185323958463075557409114262417474349347553428646576611667797396668820291207379143853719588249808126867838374559731746136085379534524221586593201928090878297308431392844403281231558611036976801357304216168747609675871348312025478589320767169132448426236131412508780208000261683151027341827977704784635868170164365024153691398281264810213092761244896359928705114964975419909342221566832572080821333186116811553615836546984046708975602900950537616475847728421889679646244945160765353408198901385442487984959953319101723355556602139450399736280750137837615307127761926849034352625200015888535147331611702103968175921510907788019393178114194545257223865541461062892187960223838971476088506276862967146674697562911234082439208160153780889893964518263243671616762179168909779911903754031274622289988005195444414282012187361745992642956581746628302955570299024324153181617210465832036786906117260158783520751516284225540265170483304226143974286933061690897968482590125458327168226458066526769958652682272807075781391858178889652208164348344825993266043367660176999612831860788386150279465955131156552036093988180612138558600301435694527224206344631797460594682573103790084024432438465657245014402821885252470935190620929023136493273497565513958720559654228749774011413346962715422845862377387538230483865688976461927383814900140767310446640259899490222221765904339901886018566526485061799702356193897017860040811889729918311021171229845901641921068884387121855646124960798722908519296819372388642614839657382291123125024186649353143970137428531926649875337218940694281434118520158014123344828015051399694290153483077644569099073152433278288269864602789864321139083506217095002597389863554277196742822248757586765752344220207573630569498825087968928162753848863396909959826280956121450994871701244516461260379029309120889086942028510640182154399457156805941872748998094254742173582401063677404595741785160829230135358081840096996372524230560855903700624271243416909004153690105933983835777939410970027753472000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'). |
|
2 | 1812 |
|
3 | 1813 |
"Large * Large multiplication" |
103 | 1814 |
self assert:((16r3FFF * 16r3FFF) hexPrintString = 'FFF8001'). |
1815 |
self assert:((16r7FFF * 16r7FFF) hexPrintString = '3FFF0001'). |
|
1816 |
self assert:((16rFFFF * 16rFFFF) hexPrintString = 'FFFE0001'). |
|
1817 |
self assert:((16r3FFFFF * 16r3FFFFF) hexPrintString = 'FFFFF800001'). |
|
1818 |
self assert:((16r7FFFFF * 16r7FFFFF) hexPrintString = '3FFFFF000001'). |
|
1819 |
self assert:((16rFFFFFF * 16rFFFFFF) hexPrintString = 'FFFFFE000001'). |
|
1820 |
self assert:((16r3FFFFFFF * 16r3FFFFFFF) hexPrintString = 'FFFFFFF80000001'). |
|
1821 |
self assert:((16r7FFFFFFF * 16r7FFFFFFF) hexPrintString = '3FFFFFFF00000001'). |
|
1822 |
self assert:((16rFFFFFFFF * 16rFFFFFFFF) hexPrintString = 'FFFFFFFE00000001'). |
|
1823 |
self assert:((16r3FFFFFFFFF * 16r3FFFFFFFFF) hexPrintString = 'FFFFFFFFF8000000001'). |
|
1824 |
self assert:((16r7FFFFFFFFF * 16r7FFFFFFFFF) hexPrintString = '3FFFFFFFFF0000000001'). |
|
1825 |
self assert:((16rFFFFFFFFFF * 16rFFFFFFFFFF) hexPrintString = 'FFFFFFFFFE0000000001'). |
|
1826 |
self assert:((20 factorial * 20 factorial) printString = '5919012181389927685417441689600000000'). |
|
7 | 1827 |
|
1828 |
" |
|
103 | 1829 |
self basicNew testLargeMultiplication |
7 | 1830 |
" |
10 | 1831 |
|
11 | 1832 |
"Modified: / 20.5.1999 / 09:41:19 / cg" |
7 | 1833 |
! |
1834 |
||
19 | 1835 |
testLiteralNumbers |
103 | 1836 |
self assert:(self num_00000000000010000 hexPrintString = '10000'). |
1837 |
self assert:(self num_00000000000100000 hexPrintString = '100000'). |
|
1838 |
self assert:(self num_00000000001000000 hexPrintString = '1000000'). |
|
1839 |
self assert:(self num_00000000010000000 hexPrintString = '10000000'). |
|
1840 |
self assert:(self num_00000000100000000 hexPrintString = '100000000'). |
|
1841 |
self assert:(self num_00000001000000000 hexPrintString = '1000000000'). |
|
1842 |
self assert:(self num_00000010000000000 hexPrintString = '10000000000'). |
|
1843 |
self assert:(self num_00000100000000000 hexPrintString = '100000000000'). |
|
1844 |
self assert:(self num_00001000000000000 hexPrintString = '1000000000000'). |
|
1845 |
self assert:(self num_00010000000000000 hexPrintString = '10000000000000'). |
|
1846 |
self assert:(self num_00100000000000000 hexPrintString = '100000000000000'). |
|
1847 |
self assert:(self num_01000000000000000 hexPrintString = '1000000000000000'). |
|
1848 |
self assert:(self num_10000000000000000 hexPrintString = '10000000000000000'). |
|
19 | 1849 |
|
103 | 1850 |
self assert:(self num_00000000000007FFF hexPrintString = '7FFF'). |
1851 |
self assert:(self num_00000000000008000 hexPrintString = '8000'). |
|
1852 |
self assert:(self num_0000000000000FFFF hexPrintString = 'FFFF'). |
|
1853 |
self assert:(self num_000000000007FFFFF hexPrintString = '7FFFFF'). |
|
1854 |
self assert:(self num_00000000000800000 hexPrintString = '800000'). |
|
1855 |
self assert:(self num_00000000000FFFFFF hexPrintString = 'FFFFFF'). |
|
1856 |
self assert:(self num_0000000007FFFFFFF hexPrintString = '7FFFFFFF'). |
|
1857 |
self assert:(self num_00000000080000000 hexPrintString = '80000000'). |
|
1858 |
self assert:(self num_000000000FFFFFFFF hexPrintString = 'FFFFFFFF'). |
|
1859 |
self assert:(self num_0000000FFFFFFFFFF hexPrintString = 'FFFFFFFFFF'). |
|
1860 |
self assert:(self num_00000FFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFF'). |
|
1861 |
self assert:(self num_000FFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFF'). |
|
1862 |
self assert:(self num_0FFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFF'). |
|
1863 |
self assert:(self num_1FFFFFFFFFFFFFFFF hexPrintString = '1FFFFFFFFFFFFFFFF'). |
|
1864 |
self assert:(self num_20000000000000000 hexPrintString = '20000000000000000'). |
|
1865 |
self assert:(self num_3FFFFFFFFFFFFFFFF hexPrintString = '3FFFFFFFFFFFFFFFF'). |
|
1866 |
self assert:(self num_40000000000000000 hexPrintString = '40000000000000000'). |
|
1867 |
self assert:(self num_7FFFFFFFFFFFFFFFF hexPrintString = '7FFFFFFFFFFFFFFFF'). |
|
1868 |
self assert:(self num_80000000000000000 hexPrintString = '80000000000000000'). |
|
21 | 1869 |
|
103 | 1870 |
self assert:(self num_00000FFFFFFFFFFFE hexPrintString = 'FFFFFFFFFFFE'). |
1871 |
self assert:(self num_00000FFFFFFFFFFFC hexPrintString = 'FFFFFFFFFFFC'). |
|
1872 |
self assert:(self num_00000FFFFFFFFFFF8 hexPrintString = 'FFFFFFFFFFF8'). |
|
1873 |
self assert:(self num_00000FFFFFFFFFFF0 hexPrintString = 'FFFFFFFFFFF0'). |
|
1874 |
self assert:(self num_00000FFFFFFFFFFE0 hexPrintString = 'FFFFFFFFFFE0'). |
|
1875 |
self assert:(self num_00000FFFFFFFFFFC0 hexPrintString = 'FFFFFFFFFFC0'). |
|
1876 |
self assert:(self num_00000FFFFFFFFFF80 hexPrintString = 'FFFFFFFFFF80'). |
|
1877 |
self assert:(self num_00000FFFFFFFFFF00 hexPrintString = 'FFFFFFFFFF00'). |
|
19 | 1878 |
|
103 | 1879 |
self assert:(self num_0000000000FFF0000 hexPrintString = 'FFF0000'). |
22 | 1880 |
|
19 | 1881 |
" |
103 | 1882 |
self basicNew testLiteralNumbers |
19 | 1883 |
" |
1884 |
||
22 | 1885 |
"Modified: / 4.6.1999 / 18:41:09 / cg" |
19 | 1886 |
! |
1887 |
||
112 | 1888 |
testModulu |
1889 |
|a b op| |
|
1890 |
||
1891 |
op := #\\. |
|
1892 |
a := -1. |
|
1893 |
b := 8. |
|
1894 |
self assert:(-1 \\ 8 == 7). |
|
1895 |
self assert:(a \\ 8 == 7). |
|
1896 |
self assert:(-1 \\ b == 7). |
|
1897 |
self assert:(a \\ b == 7). |
|
1898 |
||
1899 |
self assert:((-1 perform:op with: 8) == 7). |
|
1900 |
self assert:((a perform:op with: 8) == 7). |
|
1901 |
self assert:((-1 perform:op with: b) == 7). |
|
1902 |
self assert:((a perform:op with: b) == 7). |
|
1903 |
||
1904 |
a := 1. |
|
1905 |
b := -8. |
|
1906 |
self assert:(1 \\ -8 == -7). |
|
1907 |
self assert:(a \\ -8 == -7). |
|
1908 |
self assert:(1 \\ b == -7). |
|
1909 |
self assert:(a \\ b == -7). |
|
1910 |
||
1911 |
self assert:((1 perform:op with: -8) == -7). |
|
1912 |
self assert:((a perform:op with: -8) == -7). |
|
1913 |
self assert:((1 perform:op with: b) == -7). |
|
1914 |
self assert:((a perform:op with: b) == -7). |
|
1915 |
||
1916 |
a := -1. |
|
1917 |
b := -8. |
|
1918 |
self assert:(-1 \\ -8 == -1). |
|
1919 |
self assert:(a \\ -8 == -1). |
|
1920 |
self assert:(-1 \\ b == -1). |
|
1921 |
self assert:(a \\ b == -1). |
|
1922 |
||
1923 |
self assert:((-1 perform:op with: -8) == -1). |
|
1924 |
self assert:((a perform:op with: -8) == -1). |
|
1925 |
self assert:((-1 perform:op with: b) == -1). |
|
1926 |
self assert:((a perform:op with: b) == -1). |
|
1927 |
||
150 | 1928 |
a := 1. |
1929 |
b := 8. |
|
1930 |
self assert:(1 \\ 8 == 1). |
|
1931 |
self assert:(a \\ 8 == 1). |
|
1932 |
self assert:(1 \\ b == 1). |
|
1933 |
self assert:(a \\ b == 1). |
|
1934 |
||
1935 |
self assert:((1 perform:op with: 8) == 1). |
|
1936 |
self assert:((a perform:op with: 8) == 1). |
|
1937 |
self assert:((1 perform:op with: b) == 1). |
|
1938 |
self assert:((a perform:op with: b) == 1). |
|
1939 |
||
1940 |
||
1941 |
a := -17. |
|
1942 |
b := 8. |
|
1943 |
self assert:(-17 \\ 8 == 7). |
|
1944 |
self assert:(a \\ 8 == 7). |
|
1945 |
self assert:(-17 \\ b == 7). |
|
1946 |
self assert:(a \\ b == 7). |
|
1947 |
||
1948 |
self assert:((-17 perform:op with: 8) == 7). |
|
1949 |
self assert:((a perform:op with: 8) == 7). |
|
1950 |
self assert:((-17 perform:op with: b) == 7). |
|
1951 |
self assert:((a perform:op with: b) == 7). |
|
1952 |
||
1953 |
a := 17. |
|
1954 |
b := -8. |
|
1955 |
self assert:(17 \\ -8 == -7). |
|
1956 |
self assert:(a \\ -8 == -7). |
|
1957 |
self assert:(17 \\ b == -7). |
|
1958 |
self assert:(a \\ b == -7). |
|
1959 |
||
1960 |
self assert:((17 perform:op with: -8) == -7). |
|
1961 |
self assert:((a perform:op with: -8) == -7). |
|
1962 |
self assert:((17 perform:op with: b) == -7). |
|
1963 |
self assert:((a perform:op with: b) == -7). |
|
1964 |
||
1965 |
a := -17. |
|
1966 |
b := -8. |
|
1967 |
self assert:(-17 \\ -8 == -1). |
|
1968 |
self assert:(a \\ -8 == -1). |
|
1969 |
self assert:(-17 \\ b == -1). |
|
1970 |
self assert:(a \\ b == -1). |
|
1971 |
||
1972 |
self assert:((-17 perform:op with: -8) == -1). |
|
1973 |
self assert:((a perform:op with: -8) == -1). |
|
1974 |
self assert:((-17 perform:op with: b) == -1). |
|
1975 |
self assert:((a perform:op with: b) == -1). |
|
1976 |
||
1977 |
a := 17. |
|
1978 |
b := 8. |
|
1979 |
self assert:(17 \\ 8 == 1). |
|
1980 |
self assert:(a \\ 8 == 1). |
|
1981 |
self assert:(17 \\ b == 1). |
|
1982 |
self assert:(a \\ b == 1). |
|
1983 |
||
1984 |
self assert:((17 perform:op with: 8) == 1). |
|
1985 |
self assert:((a perform:op with: 8) == 1). |
|
1986 |
self assert:((17 perform:op with: b) == 1). |
|
1987 |
self assert:((a perform:op with: b) == 1). |
|
1988 |
||
1989 |
||
112 | 1990 |
op := #rem:. |
1991 |
a := -1. |
|
1992 |
b := 8. |
|
1993 |
self assert:((-1 rem: 8) == -1). |
|
1994 |
self assert:((a rem: 8) == -1). |
|
1995 |
self assert:((-1 rem: b) == -1). |
|
1996 |
self assert:((a rem: b) == -1). |
|
1997 |
||
1998 |
self assert:((-1 perform:op with: -8) == -1). |
|
1999 |
self assert:((a perform:op with: -8) == -1). |
|
2000 |
self assert:((-1 perform:op with: b) == -1). |
|
2001 |
self assert:((a perform:op with: b) == -1). |
|
2002 |
||
2003 |
a := 1. |
|
2004 |
b := -8. |
|
2005 |
self assert:((1 rem: -8) == 1). |
|
2006 |
self assert:((a rem: -8) == 1). |
|
2007 |
self assert:((1 rem: b) == 1). |
|
2008 |
self assert:((a rem: b) == 1). |
|
2009 |
||
2010 |
self assert:((1 perform:op with: -8) == 1). |
|
2011 |
self assert:((a perform:op with: -8) == 1). |
|
2012 |
self assert:((1 perform:op with: b) == 1). |
|
2013 |
self assert:((a perform:op with: b) == 1). |
|
2014 |
||
2015 |
a := -1. |
|
2016 |
b := -8. |
|
2017 |
self assert:((-1 rem: -8) == -1). |
|
2018 |
self assert:((a rem: -8) == -1). |
|
2019 |
self assert:((-1 rem: b) == -1). |
|
2020 |
self assert:((a rem: b) == -1). |
|
2021 |
||
2022 |
self assert:((-1 perform:op with: -8) == -1). |
|
2023 |
self assert:((a perform:op with: -8) == -1). |
|
2024 |
self assert:((-1 perform:op with: b) == -1). |
|
2025 |
self assert:((a perform:op with: b) == -1). |
|
2026 |
||
150 | 2027 |
a := 1. |
2028 |
b := 8. |
|
2029 |
self assert:((1 rem: 8) == 1). |
|
2030 |
self assert:((a rem: 8) == 1). |
|
2031 |
self assert:((1 rem: b) == 1). |
|
2032 |
self assert:((a rem: b) == 1). |
|
2033 |
||
2034 |
self assert:((1 perform:op with: 8) == 1). |
|
2035 |
self assert:((a perform:op with: 8) == 1). |
|
2036 |
self assert:((1 perform:op with: b) == 1). |
|
2037 |
self assert:((a perform:op with: b) == 1). |
|
2038 |
||
2039 |
a := -17. |
|
2040 |
b := 8. |
|
2041 |
self assert:((-17 rem: 8) == -1). |
|
2042 |
self assert:((a rem: 8) == -1). |
|
2043 |
self assert:((-17 rem: b) == -1). |
|
2044 |
self assert:((a rem: b) == -1). |
|
2045 |
||
2046 |
self assert:((-17 perform:op with: -8) == -1). |
|
2047 |
self assert:((a perform:op with: -8) == -1). |
|
2048 |
self assert:((-17 perform:op with: b) == -1). |
|
2049 |
self assert:((a perform:op with: b) == -1). |
|
2050 |
||
2051 |
a := 17. |
|
2052 |
b := -8. |
|
2053 |
self assert:((17 rem: -8) == 1). |
|
2054 |
self assert:((a rem: -8) == 1). |
|
2055 |
self assert:((17 rem: b) == 1). |
|
2056 |
self assert:((a rem: b) == 1). |
|
2057 |
||
2058 |
self assert:((17 perform:op with: -8) == 1). |
|
2059 |
self assert:((a perform:op with: -8) == 1). |
|
2060 |
self assert:((17 perform:op with: b) == 1). |
|
2061 |
self assert:((a perform:op with: b) == 1). |
|
2062 |
||
2063 |
a := -17. |
|
2064 |
b := -8. |
|
2065 |
self assert:((-17 rem: -8) == -1). |
|
2066 |
self assert:((a rem: -8) == -1). |
|
2067 |
self assert:((-17 rem: b) == -1). |
|
2068 |
self assert:((a rem: b) == -1). |
|
2069 |
||
2070 |
self assert:((-17 perform:op with: -8) == -1). |
|
2071 |
self assert:((a perform:op with: -8) == -1). |
|
2072 |
self assert:((-17 perform:op with: b) == -1). |
|
2073 |
self assert:((a perform:op with: b) == -1). |
|
2074 |
||
2075 |
a := 17. |
|
2076 |
b := 8. |
|
2077 |
self assert:((17 rem: 8) == 1). |
|
2078 |
self assert:((a rem: 8) == 1). |
|
2079 |
self assert:((17 rem: b) == 1). |
|
2080 |
self assert:((a rem: b) == 1). |
|
2081 |
||
2082 |
self assert:((17 perform:op with: 8) == 1). |
|
2083 |
self assert:((a perform:op with: 8) == 1). |
|
2084 |
self assert:((17 perform:op with: b) == 1). |
|
2085 |
self assert:((a perform:op with: b) == 1). |
|
2086 |
||
112 | 2087 |
" |
2088 |
self basicNew testModulu |
|
2089 |
" |
|
2090 |
! |
|
2091 |
||
7 | 2092 |
testPrinting1 |
103 | 2093 |
self assert:(10 printString = '10'). |
2094 |
self assert:(100 printString = '100'). |
|
2095 |
self assert:(1000 printString = '1000'). |
|
2096 |
self assert:(10000 printString = '10000'). |
|
2097 |
self assert:(100000 printString = '100000'). |
|
2098 |
self assert:(1000000 printString = '1000000'). |
|
2099 |
self assert:(10000000 printString = '10000000'). |
|
2100 |
self assert:(100000000 printString = '100000000'). |
|
2101 |
self assert:(1000000000 printString = '1000000000'). |
|
2102 |
self assert:(10000000000 printString = '10000000000'). |
|
2103 |
self assert:(100000000000 printString = '100000000000'). |
|
2104 |
self assert:(1000000000000 printString = '1000000000000'). |
|
2105 |
self assert:(10000000000000 printString = '10000000000000'). |
|
2106 |
self assert:(100000000000000 printString = '100000000000000'). |
|
2107 |
self assert:(1000000000000000 printString = '1000000000000000'). |
|
2108 |
self assert:(10000000000000000 printString = '10000000000000000'). |
|
2109 |
self assert:(100000000000000000 printString = '100000000000000000'). |
|
7 | 2110 |
|
103 | 2111 |
self assert:(16rF hexPrintString = 'F'). |
2112 |
self assert:(16rFF hexPrintString = 'FF'). |
|
2113 |
self assert:(16rFFF hexPrintString = 'FFF'). |
|
2114 |
self assert:(16rFFFF hexPrintString = 'FFFF'). |
|
2115 |
self assert:(16rFFFFF hexPrintString = 'FFFFF'). |
|
2116 |
self assert:(16rFFFFFF hexPrintString = 'FFFFFF'). |
|
2117 |
self assert:(16rFFFFFFF hexPrintString = 'FFFFFFF'). |
|
2118 |
self assert:(16rFFFFFFFF hexPrintString = 'FFFFFFFF'). |
|
2119 |
self assert:(16rFFFFFFFFF hexPrintString = 'FFFFFFFFF'). |
|
2120 |
self assert:(16rFFFFFFFFFF hexPrintString = 'FFFFFFFFFF'). |
|
2121 |
self assert:(16rFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFF'). |
|
2122 |
self assert:(16rFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFF'). |
|
2123 |
self assert:(16rFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFF'). |
|
2124 |
self assert:(16rFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFF'). |
|
2125 |
self assert:(16rFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFF'). |
|
2126 |
self assert:(16rFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFF'). |
|
2127 |
self assert:(16rFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFF'). |
|
2128 |
self assert:(16rFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFF'). |
|
2129 |
self assert:(16rFFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFFF'). |
|
2130 |
self assert:(16rFFFFFFFFFFFFFFFFFFFF hexPrintString = 'FFFFFFFFFFFFFFFFFFFF'). |
|
40 | 2131 |
|
103 | 2132 |
self assert:(16r10 hexPrintString = '10'). |
2133 |
self assert:(16r100 hexPrintString = '100'). |
|
2134 |
self assert:(16r1000 hexPrintString = '1000'). |
|
2135 |
self assert:(16r10000 hexPrintString = '10000'). |
|
2136 |
self assert:(16r100000 hexPrintString = '100000'). |
|
2137 |
self assert:(16r1000000 hexPrintString = '1000000'). |
|
2138 |
self assert:(16r10000000 hexPrintString = '10000000'). |
|
2139 |
self assert:(16r100000000 hexPrintString = '100000000'). |
|
2140 |
self assert:(16r1000000000 hexPrintString = '1000000000'). |
|
2141 |
self assert:(16r10000000000 hexPrintString = '10000000000'). |
|
2142 |
self assert:(16r100000000000 hexPrintString = '100000000000'). |
|
2143 |
self assert:(16r1000000000000 hexPrintString = '1000000000000'). |
|
2144 |
self assert:(16r10000000000000 hexPrintString = '10000000000000'). |
|
2145 |
self assert:(16r100000000000000 hexPrintString = '100000000000000'). |
|
2146 |
self assert:(16r1000000000000000 hexPrintString = '1000000000000000'). |
|
2147 |
self assert:(16r10000000000000000 hexPrintString = '10000000000000000'). |
|
2148 |
self assert:(16r100000000000000000 hexPrintString = '100000000000000000'). |
|
40 | 2149 |
|
7 | 2150 |
" |
103 | 2151 |
self basicNew testPrinting1 |
7 | 2152 |
" |
40 | 2153 |
|
2154 |
"Modified: / 26.10.1999 / 22:01:35 / stefan" |
|
7 | 2155 |
! |
2156 |
||
2157 |
testReading1 |
|
2158 |
|t| |
|
2159 |
||
103 | 2160 |
self assert:((Integer readFrom:'4865804016353280000') printString = '4865804016353280000'). |
2161 |
self assert:((Integer readFrom:'FFFFFFFF' radix:16) hexPrintString = 'FFFFFFFF'). |
|
2162 |
self assert:((Integer readFrom:'FFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFF'). |
|
2163 |
self assert:((Integer readFrom:'FFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFF'). |
|
2164 |
self assert:((Integer readFrom:'FFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFF'). |
|
2165 |
self assert:((Integer readFrom:'FFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFF'). |
|
2166 |
self assert:((Integer readFrom:'FFFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFFF'). |
|
2167 |
self assert:((Integer readFrom:'FFFFFFFFFFFFFF' radix:16) hexPrintString = 'FFFFFFFFFFFFFF'). |
|
5 | 2168 |
|
103 | 2169 |
self assert:((Integer readFrom:'10000000' radix:16) hexPrintString = '10000000'). |
2170 |
self assert:((Integer readFrom:'100000000' radix:16) hexPrintString = '100000000'). |
|
2171 |
self assert:((Integer readFrom:'1000000000' radix:16) hexPrintString = '1000000000'). |
|
2172 |
self assert:((Integer readFrom:'10000000000' radix:16) hexPrintString = '10000000000'). |
|
2173 |
self assert:((Integer readFrom:'100000000000' radix:16) hexPrintString = '100000000000'). |
|
2174 |
self assert:((Integer readFrom:'1000000000000' radix:16) hexPrintString = '1000000000000'). |
|
2175 |
self assert:((Integer readFrom:'10000000000000' radix:16) hexPrintString = '10000000000000'). |
|
5 | 2176 |
|
2177 |
t := Integer readFrom:'FFFFFFFF' radix:16. |
|
103 | 2178 |
self assert:((t + 1) hexPrintString = '100000000'). |
5 | 2179 |
t := Integer readFrom:'FFFFFFFFF' radix:16. |
103 | 2180 |
self assert:((t + 1) hexPrintString = '1000000000'). |
5 | 2181 |
t := Integer readFrom:'FFFFFFFFFF' radix:16. |
103 | 2182 |
self assert:((t + 1) hexPrintString = '10000000000'). |
5 | 2183 |
t := Integer readFrom:'FFFFFFFFFFF' radix:16. |
103 | 2184 |
self assert:((t + 1) hexPrintString = '100000000000'). |
5 | 2185 |
|
2186 |
t := Integer readFrom:'10000000' radix:16. |
|
103 | 2187 |
self assert:((t + 1) hexPrintString = '10000001'). |
5 | 2188 |
t := Integer readFrom:'100000000' radix:16. |
103 | 2189 |
self assert:((t + 1) hexPrintString = '100000001'). |
5 | 2190 |
t := Integer readFrom:'1000000000' radix:16. |
103 | 2191 |
self assert:((t + 1) hexPrintString = '1000000001'). |
5 | 2192 |
t := Integer readFrom:'10000000000' radix:16. |
103 | 2193 |
self assert:((t + 1) hexPrintString = '10000000001'). |
5 | 2194 |
|
2 | 2195 |
" |
103 | 2196 |
self basicNew testReading1 |
2 | 2197 |
" |
27 | 2198 |
! |
2199 |
||
2200 |
testSmallIntegerArithmetic |
|
2201 |
"arithmetic tests. |
|
2202 |
Notice, the arithmetic tests are both performed via regular sends |
|
2203 |
and via constructed performs. The reason is to test both inlined |
|
2204 |
JIT-compiler code AND the regular methods code." |
|
2205 |
||
2206 |
|s n1 n2 t| |
|
2207 |
||
2208 |
"/ test division and modulu ... |
|
103 | 2209 |
self assert:(1 printString = '1'). |
2210 |
self assert:(10 printString = '10'). |
|
2211 |
self assert:(100 printString = '100'). |
|
2212 |
self assert:(1000 printString = '1000'). |
|
2213 |
self assert:(10000 printString = '10000'). |
|
2214 |
self assert:(100000 printString = '100000'). |
|
27 | 2215 |
|
2216 |
"addition with overflow" |
|
2217 |
||
2218 |
SmallInteger maxBytes == 4 ifTrue:[ |
|
103 | 2219 |
n1 := 16r3FFFFFFF. |
2220 |
n2 := -16r40000000. |
|
27 | 2221 |
] ifFalse:[ |
103 | 2222 |
n1 := 16r3FFFFFFFFFFFFFFF. |
2223 |
n2 := -16r4000000000000000. |
|
27 | 2224 |
]. |
103 | 2225 |
self assert:(n1 class == SmallInteger). |
2226 |
self assert:(n2 class == SmallInteger). |
|
27 | 2227 |
|
103 | 2228 |
self assert:((n1 + 1) class == LargeInteger). |
27 | 2229 |
t := n1 + 1. |
103 | 2230 |
self assert:((t - 1) class == SmallInteger). |
27 | 2231 |
|
103 | 2232 |
self assert:((n2 - 1) class == LargeInteger). |
27 | 2233 |
t := n2 - 1. |
103 | 2234 |
self assert:((t + 1) class == SmallInteger). |
27 | 2235 |
|
103 | 2236 |
self assert:((n1 negated) class == SmallInteger). |
2237 |
self assert:((n2 negated) class == LargeInteger). |
|
2238 |
self assert:((n1 perform:'negated' asSymbol) class == SmallInteger). |
|
2239 |
self assert:((n2 perform:'negated' asSymbol) class == LargeInteger). |
|
27 | 2240 |
|
103 | 2241 |
self assert:((n1 abs == n1)). |
2242 |
self assert:((n2 abs = n2 negated)). |
|
2243 |
self assert:((n1 perform:'abs' asSymbol) == n1). |
|
2244 |
self assert:((n2 perform:'abs' asSymbol) = n2 negated). |
|
28 | 2245 |
|
38 | 2246 |
self testSmallIntegerMultiplication1. |
2247 |
self testSmallIntegerMultiplication1b. |
|
2248 |
self testSmallIntegerMultiplication2. |
|
46 | 2249 |
self testSmallIntegerDivision1. |
38 | 2250 |
|
27 | 2251 |
" |
103 | 2252 |
self basicNew testSmallIntegerArithmetic |
27 | 2253 |
" |
2254 |
||
2255 |
"Created: / 6.6.1999 / 14:47:51 / cg" |
|
33 | 2256 |
"Modified: / 9.6.1999 / 17:49:57 / cg" |
2257 |
! |
|
2258 |
||
46 | 2259 |
testSmallIntegerDivision1 |
2260 |
"division tests. |
|
2261 |
Notice, the arithmetic tests are both performed via regular sends |
|
2262 |
and via constructed performs. The reason is to test both inlined |
|
2263 |
JIT-compiler code AND the regular methods code." |
|
2264 |
||
2265 |
|s n1 n2 t| |
|
2266 |
||
2267 |
n1 := 1000. |
|
2268 |
||
2269 |
"/ truncation towards... |
|
2270 |
||
2271 |
"/ ... negative infinity |
|
2272 |
n2 := 3. |
|
103 | 2273 |
self assert:((n1 // n2) == 333). |
2274 |
self assert:((n1 // n2) printString = '333'). |
|
2275 |
self assert:((n1 perform:'//' asSymbol with:n2) == 333). |
|
46 | 2276 |
|
2277 |
n2 := -3. |
|
103 | 2278 |
self assert:((n1 // n2) == -334). |
2279 |
self assert:((n1 // n2) printString = '-334'). |
|
2280 |
self assert:((n1 perform:'//' asSymbol with:n2) == -334). |
|
46 | 2281 |
|
2282 |
n2 := 3600000. |
|
103 | 2283 |
self assert:((n1 // n2) == 0). |
2284 |
self assert:((n1 // n2) printString = '0'). |
|
2285 |
self assert:((n1 perform:'//' asSymbol with:n2) == 0). |
|
46 | 2286 |
|
2287 |
n2 := -3600000. |
|
103 | 2288 |
self assert:((n1 // n2) == -1). |
2289 |
self assert:((n1 // n2) printString = '-1'). |
|
2290 |
self assert:((n1 perform:'//' asSymbol with:n2) == -1). |
|
46 | 2291 |
|
2292 |
"/ ... zero |
|
2293 |
n2 := 3. |
|
103 | 2294 |
self assert:((n1 quo: n2) == 333). |
2295 |
self assert:((n1 quo: n2) printString = '333'). |
|
2296 |
self assert:((n1 perform:'quo:' asSymbol with:n2) == 333). |
|
46 | 2297 |
|
2298 |
n2 := -3. |
|
103 | 2299 |
self assert:((n1 quo: n2) == -333). |
2300 |
self assert:((n1 quo: n2) printString = '-333'). |
|
2301 |
self assert:((n1 perform:'quo:' asSymbol with:n2) == -333). |
|
46 | 2302 |
|
2303 |
n2 := 3600000. |
|
103 | 2304 |
self assert:((n1 quo: n2) == 0). |
2305 |
self assert:((n1 quo: n2) printString = '0'). |
|
2306 |
self assert:((n1 perform:'quo:' asSymbol with:n2) == 0). |
|
46 | 2307 |
|
2308 |
n2 := -3600000. |
|
103 | 2309 |
self assert:((n1 quo: n2) == 0). |
2310 |
self assert:((n1 quo: n2) printString = '0'). |
|
2311 |
self assert:((n1 perform:'quo:' asSymbol with:n2) == 0). |
|
46 | 2312 |
|
2313 |
" |
|
103 | 2314 |
self basicNew testSmallIntegerDivision1 |
46 | 2315 |
" |
2316 |
||
2317 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
|
2318 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
|
2319 |
! |
|
2320 |
||
33 | 2321 |
testSmallIntegerMultiplication1 |
39 | 2322 |
"multiply tests (var * const). |
33 | 2323 |
Notice, the arithmetic tests are both performed via regular sends |
2324 |
and via constructed performs. The reason is to test both inlined |
|
2325 |
JIT-compiler code AND the regular methods code." |
|
2326 |
||
2327 |
|s n1 n2 t| |
|
2328 |
||
2329 |
n1 := 100000. |
|
2330 |
n2 := n1 negated. |
|
2331 |
||
103 | 2332 |
self assert:(n1 printString = '100000'). |
2333 |
self assert:(n2 printString = '-100000'). |
|
33 | 2334 |
|
103 | 2335 |
self assert:((n1 * 0) printString = '0'). |
2336 |
self assert:((n1 perform:'*' asSymbol with:0) printString = '0'). |
|
33 | 2337 |
|
103 | 2338 |
self assert:((n1 * 1) printString = '100000'). |
2339 |
self assert:((n1 perform:'*' asSymbol with:1) printString = '100000'). |
|
2340 |
self assert:((n2 * 1) printString = '-100000'). |
|
2341 |
self assert:((n2 perform:'*' asSymbol with:1) printString = '-100000'). |
|
33 | 2342 |
|
103 | 2343 |
self assert:((n1 * -1) printString = '-100000'). |
2344 |
self assert:((n1 perform:'*' asSymbol with:-1) printString = '-100000'). |
|
2345 |
self assert:((n2 * -1) printString = '100000'). |
|
2346 |
self assert:((n2 perform:'*' asSymbol with:-1) printString = '100000'). |
|
33 | 2347 |
|
103 | 2348 |
self assert:((n1 * 2) printString = '200000'). |
2349 |
self assert:((n1 perform:'*' asSymbol with:2) printString = '200000'). |
|
2350 |
self assert:((n1 * 3) printString = '300000'). |
|
2351 |
self assert:((n1 perform:'*' asSymbol with:3) printString = '300000'). |
|
2352 |
self assert:((n1 * 4) printString = '400000'). |
|
2353 |
self assert:((n1 perform:'*' asSymbol with:4) printString = '400000'). |
|
2354 |
self assert:((n1 * 5) printString = '500000'). |
|
2355 |
self assert:((n1 perform:'*' asSymbol with:5) printString = '500000'). |
|
2356 |
self assert:((n1 * 6) printString = '600000'). |
|
2357 |
self assert:((n1 perform:'*' asSymbol with:6) printString = '600000'). |
|
2358 |
self assert:((n1 * 7) printString = '700000'). |
|
2359 |
self assert:((n1 perform:'*' asSymbol with:7) printString = '700000'). |
|
2360 |
self assert:((n1 * 8) printString = '800000'). |
|
2361 |
self assert:((n1 perform:'*' asSymbol with:8) printString = '800000'). |
|
2362 |
self assert:((n1 * 9) printString = '900000'). |
|
2363 |
self assert:((n1 perform:'*' asSymbol with:9) printString = '900000'). |
|
2364 |
self assert:((n1 * 10) printString = '1000000'). |
|
2365 |
self assert:((n1 perform:'*' asSymbol with:10) printString = '1000000'). |
|
2366 |
self assert:((n1 * 11) printString = '1100000'). |
|
2367 |
self assert:((n1 perform:'*' asSymbol with:11) printString = '1100000'). |
|
2368 |
self assert:((n1 * 12) printString = '1200000'). |
|
2369 |
self assert:((n1 perform:'*' asSymbol with:12) printString = '1200000'). |
|
2370 |
self assert:((n1 * 13) printString = '1300000'). |
|
2371 |
self assert:((n1 perform:'*' asSymbol with:13) printString = '1300000'). |
|
2372 |
self assert:((n1 * 14) printString = '1400000'). |
|
2373 |
self assert:((n1 perform:'*' asSymbol with:14) printString = '1400000'). |
|
2374 |
self assert:((n1 * 15) printString = '1500000'). |
|
2375 |
self assert:((n1 perform:'*' asSymbol with:15) printString = '1500000'). |
|
2376 |
self assert:((n1 * 16) printString = '1600000'). |
|
2377 |
self assert:((n1 perform:'*' asSymbol with:16) printString = '1600000'). |
|
33 | 2378 |
|
41 | 2379 |
n1 := 1. |
2380 |
n2 := 10. |
|
103 | 2381 |
self assert:((n1 * n2) printString = '10'). |
2382 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10'). |
|
41 | 2383 |
n2 := n2 * 10. |
103 | 2384 |
self assert:((n1 * n2) printString = '100'). |
2385 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100'). |
|
41 | 2386 |
n2 := n2 * 10. |
103 | 2387 |
self assert:((n1 * n2) printString = '1000'). |
2388 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000'). |
|
41 | 2389 |
n2 := n2 * 10. |
103 | 2390 |
self assert:((n1 * n2) printString = '10000'). |
2391 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000'). |
|
41 | 2392 |
n2 := n2 * 10. |
103 | 2393 |
self assert:((n1 * n2) printString = '100000'). |
2394 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000'). |
|
41 | 2395 |
n2 := n2 * 10. |
103 | 2396 |
self assert:((n1 * n2) printString = '1000000'). |
2397 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000'). |
|
41 | 2398 |
n2 := n2 * 10. |
103 | 2399 |
self assert:((n1 * n2) printString = '10000000'). |
2400 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000'). |
|
41 | 2401 |
n2 := n2 * 10. |
103 | 2402 |
self assert:((n1 * n2) printString = '100000000'). |
2403 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000'). |
|
41 | 2404 |
n2 := n2 * 10. |
103 | 2405 |
self assert:((n1 * n2) printString = '1000000000'). |
2406 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000'). |
|
41 | 2407 |
n2 := n2 * 10. |
103 | 2408 |
self assert:((n1 * n2) printString = '10000000000'). |
2409 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000'). |
|
41 | 2410 |
n2 := n2 * 10. |
103 | 2411 |
self assert:((n1 * n2) printString = '100000000000'). |
2412 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000'). |
|
41 | 2413 |
n2 := n2 * 10. |
103 | 2414 |
self assert:((n1 * n2) printString = '1000000000000'). |
2415 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000'). |
|
41 | 2416 |
n2 := n2 * 10. |
103 | 2417 |
self assert:((n1 * n2) printString = '10000000000000'). |
2418 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000000'). |
|
41 | 2419 |
|
2420 |
n1 := 1. |
|
2421 |
n2 := 10. |
|
103 | 2422 |
self assert:((n1 * n2) printString = '10'). |
2423 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10'). |
|
41 | 2424 |
n1 := n1 * 10. |
103 | 2425 |
self assert:((n1 * n2) printString = '100'). |
2426 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100'). |
|
41 | 2427 |
n1 := n1 * 10. |
103 | 2428 |
self assert:((n1 * n2) printString = '1000'). |
2429 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000'). |
|
41 | 2430 |
n1 := n1 * 10. |
103 | 2431 |
self assert:((n1 * n2) printString = '10000'). |
2432 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000'). |
|
41 | 2433 |
n1 := n1 * 10. |
103 | 2434 |
self assert:((n1 * n2) printString = '100000'). |
2435 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000'). |
|
41 | 2436 |
n1 := n1 * 10. |
103 | 2437 |
self assert:((n1 * n2) printString = '1000000'). |
2438 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000'). |
|
41 | 2439 |
n1 := n1 * 10. |
103 | 2440 |
self assert:((n1 * n2) printString = '10000000'). |
2441 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000'). |
|
41 | 2442 |
n1 := n1 * 10. |
103 | 2443 |
self assert:((n1 * n2) printString = '100000000'). |
2444 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000'). |
|
41 | 2445 |
n1 := n1 * 10. |
103 | 2446 |
self assert:((n1 * n2) printString = '1000000000'). |
2447 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000'). |
|
41 | 2448 |
n1 := n1 * 10. |
103 | 2449 |
self assert:((n1 * n2) printString = '10000000000'). |
2450 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000'). |
|
41 | 2451 |
n1 := n1 * 10. |
103 | 2452 |
self assert:((n1 * n2) printString = '100000000000'). |
2453 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000'). |
|
41 | 2454 |
n1 := n1 * 10. |
103 | 2455 |
self assert:((n1 * n2) printString = '1000000000000'). |
2456 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000'). |
|
41 | 2457 |
n1 := n1 * 10. |
103 | 2458 |
self assert:((n1 * n2) printString = '10000000000000'). |
2459 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000000'). |
|
41 | 2460 |
|
2461 |
n1 := 10. |
|
2462 |
n2 := 10. |
|
103 | 2463 |
self assert:((n1 * n2) printString = '100'). |
2464 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100'). |
|
41 | 2465 |
n1 := n1 * 10. |
2466 |
n2 := n2 * 10. |
|
103 | 2467 |
self assert:((n1 * n2) printString = '10000'). |
2468 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000'). |
|
41 | 2469 |
n1 := n1 * 10. |
2470 |
n2 := n2 * 10. |
|
103 | 2471 |
self assert:((n1 * n2) printString = '1000000'). |
2472 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000'). |
|
41 | 2473 |
n1 := n1 * 10. |
2474 |
n2 := n2 * 10. |
|
103 | 2475 |
self assert:((n1 * n2) printString = '100000000'). |
2476 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000'). |
|
41 | 2477 |
n1 := n1 * 10. |
2478 |
n2 := n2 * 10. |
|
103 | 2479 |
self assert:((n1 * n2) printString = '10000000000'). |
2480 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000'). |
|
41 | 2481 |
n1 := n1 * 10. |
2482 |
n2 := n2 * 10. |
|
103 | 2483 |
self assert:((n1 * n2) printString = '1000000000000'). |
2484 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000'). |
|
41 | 2485 |
n1 := n1 * 10. |
2486 |
n2 := n2 * 10. |
|
103 | 2487 |
self assert:((n1 * n2) printString = '100000000000000'). |
2488 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000000'). |
|
41 | 2489 |
n1 := n1 * 10. |
2490 |
n2 := n2 * 10. |
|
103 | 2491 |
self assert:((n1 * n2) printString = '10000000000000000'). |
2492 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000000000'). |
|
41 | 2493 |
n1 := n1 * 10. |
2494 |
n2 := n2 * 10. |
|
103 | 2495 |
self assert:((n1 * n2) printString = '1000000000000000000'). |
2496 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000000000'). |
|
41 | 2497 |
n1 := n1 * 10. |
2498 |
n2 := n2 * 10. |
|
103 | 2499 |
self assert:((n1 * n2) printString = '100000000000000000000'). |
2500 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000000000000'). |
|
41 | 2501 |
n1 := n1 * 10. |
2502 |
n2 := n2 * 10. |
|
103 | 2503 |
self assert:((n1 * n2) printString = '10000000000000000000000'). |
2504 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '10000000000000000000000'). |
|
41 | 2505 |
n1 := n1 * 10. |
2506 |
n2 := n2 * 10. |
|
103 | 2507 |
self assert:((n1 * n2) printString = '1000000000000000000000000'). |
2508 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '1000000000000000000000000'). |
|
41 | 2509 |
n1 := n1 * 10. |
2510 |
n2 := n2 * 10. |
|
103 | 2511 |
self assert:((n1 * n2) printString = '100000000000000000000000000'). |
2512 |
self assert:((n1 perform:'*' asSymbol with:n2) printString = '100000000000000000000000000'). |
|
41 | 2513 |
|
33 | 2514 |
" |
103 | 2515 |
self basicNew testSmallIntegerMultiplication1 |
33 | 2516 |
" |
2517 |
||
32 | 2518 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
33 | 2519 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
34 | 2520 |
! |
2521 |
||
35 | 2522 |
testSmallIntegerMultiplication1b |
39 | 2523 |
"multiply tests (const * var). |
35 | 2524 |
Notice, the arithmetic tests are both performed via regular sends |
2525 |
and via constructed performs. The reason is to test both inlined |
|
2526 |
JIT-compiler code AND the regular methods code." |
|
2527 |
||
2528 |
|s n1 n2 t| |
|
2529 |
||
2530 |
n1 := 100000. |
|
2531 |
n2 := n1 negated. |
|
2532 |
||
103 | 2533 |
self assert:((0 * n1) printString = '0'). |
2534 |
self assert:((0 perform:'*' asSymbol with:n1) printString = '0'). |
|
35 | 2535 |
|
103 | 2536 |
self assert:((1 * n1) printString = '100000'). |
2537 |
self assert:((1 perform:'*' asSymbol with:n1) printString = '100000'). |
|
2538 |
self assert:((1 * n2) printString = '-100000'). |
|
2539 |
self assert:((1 perform:'*' asSymbol with:n2) printString = '-100000'). |
|
35 | 2540 |
|
103 | 2541 |
self assert:((-1 * n1) printString = '-100000'). |
2542 |
self assert:((-1 perform:'*' asSymbol with:n1) printString = '-100000'). |
|
2543 |
self assert:((-1 * n2) printString = '100000'). |
|
2544 |
self assert:((-1 perform:'*' asSymbol with:n2) printString = '100000'). |
|
35 | 2545 |
|
103 | 2546 |
self assert:((2 * n1) printString = '200000'). |
2547 |
self assert:((2 perform:'*' asSymbol with:n1) printString = '200000'). |
|
2548 |
self assert:((3 * n1) printString = '300000'). |
|
2549 |
self assert:((3 perform:'*' asSymbol with:n1) printString = '300000'). |
|
2550 |
self assert:((4 * n1) printString = '400000'). |
|
2551 |
self assert:((4 perform:'*' asSymbol with:n1) printString = '400000'). |
|
2552 |
self assert:((5 * n1) printString = '500000'). |
|
2553 |
self assert:((5 perform:'*' asSymbol with:n1) printString = '500000'). |
|
2554 |
self assert:((6 * n1) printString = '600000'). |
|
2555 |
self assert:((6 perform:'*' asSymbol with:n1) printString = '600000'). |
|
2556 |
self assert:((7 * n1) printString = '700000'). |
|
2557 |
self assert:((7 perform:'*' asSymbol with:n1) printString = '700000'). |
|
2558 |
self assert:((8 * n1) printString = '800000'). |
|
2559 |
self assert:((8 perform:'*' asSymbol with:n1) printString = '800000'). |
|
2560 |
self assert:((9 * n1) printString = '900000'). |
|
2561 |
self assert:((9 perform:'*' asSymbol with:n1) printString = '900000'). |
|
2562 |
self assert:((10 * n1) printString = '1000000'). |
|
2563 |
self assert:((10 perform:'*' asSymbol with:n1) printString = '1000000'). |
|
2564 |
self assert:((11 * n1) printString = '1100000'). |
|
2565 |
self assert:((11 perform:'*' asSymbol with:n1) printString = '1100000'). |
|
35 | 2566 |
|
2567 |
" |
|
103 | 2568 |
self basicNew testSmallIntegerMultiplication1b |
35 | 2569 |
" |
2570 |
||
2571 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
|
2572 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
|
2573 |
! |
|
2574 |
||
34 | 2575 |
testSmallIntegerMultiplication2 |
2576 |
"multiply tests. |
|
2577 |
Notice, the arithmetic tests are both performed via regular sends |
|
2578 |
and via constructed performs. The reason is to test both inlined |
|
2579 |
JIT-compiler code AND the regular methods code." |
|
2580 |
||
2581 |
|s n1 n2 t| |
|
2582 |
||
2583 |
n1 := 100000. |
|
2584 |
n2 := n1 negated. |
|
2585 |
||
103 | 2586 |
self assert:((n1 * 2) printString = '200000'). |
2587 |
self assert:((n1 perform:'*' asSymbol with:2) printString = '200000'). |
|
2588 |
self assert:((n1 * 3) printString = '300000'). |
|
2589 |
self assert:((n1 perform:'*' asSymbol with:3) printString = '300000'). |
|
2590 |
self assert:((n1 * 4) printString = '400000'). |
|
2591 |
self assert:((n1 perform:'*' asSymbol with:4) printString = '400000'). |
|
2592 |
self assert:((n1 * 5) printString = '500000'). |
|
2593 |
self assert:((n1 perform:'*' asSymbol with:5) printString = '500000'). |
|
2594 |
self assert:((n1 * 6) printString = '600000'). |
|
2595 |
self assert:((n1 perform:'*' asSymbol with:6) printString = '600000'). |
|
2596 |
self assert:((n1 * 7) printString = '700000'). |
|
2597 |
self assert:((n1 perform:'*' asSymbol with:7) printString = '700000'). |
|
2598 |
self assert:((n1 * 8) printString = '800000'). |
|
2599 |
self assert:((n1 perform:'*' asSymbol with:8) printString = '800000'). |
|
2600 |
self assert:((n1 * 9) printString = '900000'). |
|
2601 |
self assert:((n1 perform:'*' asSymbol with:9) printString = '900000'). |
|
2602 |
self assert:((n1 * 10) printString = '1000000'). |
|
2603 |
self assert:((n1 perform:'*' asSymbol with:10) printString = '1000000'). |
|
2604 |
self assert:((n1 * 11) printString = '1100000'). |
|
2605 |
self assert:((n1 perform:'*' asSymbol with:11) printString = '1100000'). |
|
2606 |
self assert:((n1 * 12) printString = '1200000'). |
|
2607 |
self assert:((n1 perform:'*' asSymbol with:12) printString = '1200000'). |
|
2608 |
self assert:((n1 * 13) printString = '1300000'). |
|
2609 |
self assert:((n1 perform:'*' asSymbol with:13) printString = '1300000'). |
|
2610 |
self assert:((n1 * 14) printString = '1400000'). |
|
2611 |
self assert:((n1 perform:'*' asSymbol with:14) printString = '1400000'). |
|
2612 |
self assert:((n1 * 15) printString = '1500000'). |
|
2613 |
self assert:((n1 perform:'*' asSymbol with:15) printString = '1500000'). |
|
2614 |
self assert:((n1 * 16) printString = '1600000'). |
|
2615 |
self assert:((n1 perform:'*' asSymbol with:16) printString = '1600000'). |
|
2616 |
self assert:((n1 * 17) printString = '1700000'). |
|
2617 |
self assert:((n1 perform:'*' asSymbol with:17) printString = '1700000'). |
|
2618 |
self assert:((n1 * 18) printString = '1800000'). |
|
2619 |
self assert:((n1 perform:'*' asSymbol with:18) printString = '1800000'). |
|
2620 |
self assert:((n1 * 19) printString = '1900000'). |
|
2621 |
self assert:((n1 perform:'*' asSymbol with:19) printString = '1900000'). |
|
34 | 2622 |
|
2623 |
" |
|
103 | 2624 |
self basicNew testSmallIntegerMultiplication2 |
34 | 2625 |
" |
2626 |
||
2627 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
|
2628 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
|
39 | 2629 |
! |
2630 |
||
2631 |
testSmallIntegerMultiplication3 |
|
2632 |
"multiply tests. |
|
2633 |
Notice, the arithmetic tests are both performed via regular sends |
|
2634 |
and via constructed performs. The reason is to test both inlined |
|
2635 |
JIT-compiler code AND the regular methods code." |
|
2636 |
||
2637 |
|s n1 n2 t| |
|
2638 |
||
2639 |
n1 := 16rFFFF. |
|
2640 |
n2 := n1 negated. |
|
2641 |
||
103 | 2642 |
self assert:((n1 * 2) printString = '131070'). |
2643 |
self assert:((n1 perform:'*' asSymbol with:2) printString = '131070'). |
|
2644 |
self assert:((n2 * 2) printString = '-131070'). |
|
2645 |
self assert:((n2 perform:'*' asSymbol with:2) printString = '-131070'). |
|
39 | 2646 |
|
2647 |
n1 := 16rFFFFFF. |
|
2648 |
n2 := n1 negated. |
|
2649 |
||
103 | 2650 |
self assert:((n1 * 2) printString = '33554430'). |
2651 |
self assert:((n1 perform:'*' asSymbol with:2) printString = '33554430'). |
|
2652 |
self assert:((n2 * 2) printString = '-33554430'). |
|
2653 |
self assert:((n2 perform:'*' asSymbol with:2) printString = '-33554430'). |
|
39 | 2654 |
|
2655 |
n1 := 16r3FFFFFFF. |
|
2656 |
n2 := n1 negated. |
|
2657 |
||
103 | 2658 |
self assert:((n1 * 2) printString = '2147483646'). |
2659 |
self assert:((n1 perform:'*' asSymbol with:2) printString = '2147483646'). |
|
2660 |
self assert:((n2 * 2) printString = '-2147483646'). |
|
2661 |
self assert:((n2 perform:'*' asSymbol with:2) printString = '-2147483646'). |
|
39 | 2662 |
|
2663 |
SmallInteger maxBytes == 4 ifTrue:[ |
|
103 | 2664 |
n1 := 16r3FFFFFFF. |
39 | 2665 |
] ifFalse:[ |
103 | 2666 |
n1 := 16r3FFFFFFFFFFFFFFF. |
39 | 2667 |
]. |
103 | 2668 |
self assert:(n1 class == SmallInteger). |
2669 |
self assert:((n1 * 2) class == LargeInteger). |
|
2670 |
self assert:((n1 perform:'*' asSymbol with:2) class == LargeInteger). |
|
39 | 2671 |
|
2672 |
n1 := SmallInteger maxVal // 11. |
|
103 | 2673 |
self assert:((n1 * 11) class == SmallInteger). |
39 | 2674 |
|
2675 |
n1 := n1 + 1. |
|
103 | 2676 |
self assert:((n1 * 11) class == LargeInteger). |
39 | 2677 |
|
2678 |
" |
|
103 | 2679 |
self basicNew testSmallIntegerMultiplication3 |
39 | 2680 |
" |
2681 |
||
2682 |
"Modified: / 9.6.1999 / 17:47:56 / cg" |
|
2683 |
"Created: / 9.6.1999 / 17:49:45 / cg" |
|
2 | 2684 |
! ! |
2685 |
||
104 | 2686 |
!IntegerTest methodsFor:'tests - concrete bugs'! |
2687 |
||
2688 |
a_rack:rack subrack:subr board:slot port:port channel:chn typeId:aTypeOrSymbol |
|
2689 |
"create an Idn from the given arguments |
|
2690 |
" |
|
2691 |
|hgEnc typ idn |
|
2692 |
eqEnc "{ Class:SmallInteger }" |
|
2693 |
oid "{ Class:SmallInteger }" |
|
2694 |
IDN| |
|
2695 |
||
2696 |
IDN := self class. |
|
2697 |
||
2698 |
eqEnc := rack. |
|
2699 |
||
2700 |
eqEnc > 0 ifFalse:[ |
|
2701 |
eqEnc < 0 ifTrue:[idn := #Dontcare] |
|
2702 |
ifFalse:[port == 256 ifTrue:[idn := #NWNode] |
|
2703 |
ifFalse:[ idn := #Unspecified ]]. |
|
2704 |
||
2705 |
^ idn |
|
2706 |
]. |
|
2707 |
||
2708 |
eqEnc >= 255 ifTrue:[ "/ is a logical resource |
|
2709 |
eqEnc > 255 ifTrue:[ ^ #Unspecified ]. |
|
2710 |
||
2711 |
slot == 0 ifTrue:[ |
|
2712 |
subr == 1 ifTrue:[ ^ #ConnectManager ]. |
|
2713 |
subr == 2 ifTrue:[ ^ #ClockManager ]. |
|
2714 |
]. |
|
2715 |
oid := 4. "/ logical resource |
|
2716 |
] ifFalse:[ |
|
2717 |
oid := 2. "/ equipment |
|
2718 |
]. |
|
2719 |
hgEnc := 0. |
|
2720 |
typ := aTypeOrSymbol. |
|
2721 |
||
2722 |
subr ~~ 0 ifTrue:[ |
|
2723 |
subr > 16r0f ifTrue:[ ^ #Unspecified ]. |
|
2724 |
eqEnc := eqEnc bitOr:(subr bitShift: 8). |
|
2725 |
||
2726 |
slot ~~ 0 ifTrue:[ |
|
2727 |
slot > 16rff ifTrue:[ ^ #Unspecified ]. |
|
2728 |
eqEnc := eqEnc bitOr:(slot bitShift:12). |
|
2729 |
||
2730 |
port ~~ 0 ifTrue:[ |
|
2731 |
port > 16rff ifTrue:[ ^ #Unspecified ]. |
|
2732 |
eqEnc := eqEnc bitOr:(port bitShift:20). |
|
2733 |
||
2734 |
chn ~~ 0 ifTrue:[ |
|
2735 |
chn > 16rfff ifTrue:[ ^ #Unspecified ]. |
|
2736 |
oid := 3. |
|
2737 |
typ := aTypeOrSymbol ? 0. |
|
2738 |
hgEnc := chn. |
|
2739 |
] |
|
2740 |
] |
|
2741 |
] |
|
2742 |
]. |
|
2743 |
||
2744 |
typ notNil ifTrue:[ |
|
2745 |
typ isSymbol ifTrue:[ |
|
2746 |
typ := 0 |
|
2747 |
]. |
|
2748 |
hgEnc := hgEnc bitOr:(typ bitShift:12). |
|
2749 |
hgEnc := hgEnc bitOr:(oid bitShift:20). |
|
2750 |
]. |
|
2751 |
^ #ok. |
|
2752 |
||
2753 |
" |
|
2754 |
self basicNew rack:1 subrack:3 board:5 port:33 channel:8 typeId:7 |
|
2755 |
" |
|
2756 |
! |
|
2757 |
||
2758 |
rack:rack subrack:subr board:slot port:port channel:chn typeId:aTypeOrSymbol |
|
2759 |
"create an Idn from the given arguments |
|
2760 |
" |
|
2761 |
|hgEnc typ idn |
|
2762 |
eqEnc "{ Class:SmallInteger }" |
|
2763 |
oid "{ Class:SmallInteger }"| |
|
2764 |
||
2765 |
eqEnc := rack. |
|
2766 |
||
2767 |
"/ eqEnc > 0 ifFalse:[ |
|
2768 |
"/ eqEnc < 0 ifTrue:[idn := IDN Dontcare] |
|
2769 |
"/ ifFalse:[port == 256 ifTrue:[idn := IDN NWNode] |
|
2770 |
"/ ifFalse:[ idn := IDN Unspecified ]]. |
|
2771 |
"/ |
|
2772 |
"/ ^ self fromIdn:idn |
|
2773 |
"/ ]. |
|
2774 |
||
2775 |
"/ eqEnc >= 255 ifTrue:[ "/ is a logical resource |
|
2776 |
"/ eqEnc > 255 ifTrue:[ ^ self fromIdn:(IDN Unspecified) ]. |
|
2777 |
"/ |
|
2778 |
"/ slot == 0 ifTrue:[ |
|
2779 |
"/ subr == 1 ifTrue:[ ^ self fromIdn:(IDN ConnectManager) ]. |
|
2780 |
"/ subr == 2 ifTrue:[ ^ self fromIdn:(IDN ClockManager) ]. |
|
2781 |
"/ ]. |
|
2782 |
"/ oid := 4. "/ logical resource |
|
2783 |
"/ ] ifFalse:[ |
|
2784 |
"/ oid := 2. "/ equipment |
|
2785 |
"/ ]. |
|
2786 |
"/ hgEnc := 0. |
|
2787 |
"/ typ := aTypeOrSymbol. |
|
2788 |
||
2789 |
subr ~~ 0 ifTrue:[ |
|
2790 |
subr > 16r0f ifTrue:[ ^ nil "self fromIdn:(IDN Unspecified)" ]. |
|
2791 |
eqEnc := eqEnc bitOr:(subr bitShift: 8). |
|
2792 |
||
2793 |
slot ~~ 0 ifTrue:[ |
|
2794 |
slot > 16rff ifTrue:[ ^ nil "self fromIdn:(IDN Unspecified)" ]. |
|
2795 |
eqEnc := eqEnc bitOr:(slot bitShift:12). |
|
2796 |
||
2797 |
port ~~ 0 ifTrue:[ |
|
2798 |
port > 16rff ifTrue:[ ^ self fromIdn:(IDN Unspecified) ]. |
|
2799 |
eqEnc := eqEnc bitOr:(port bitShift:20). |
|
2800 |
||
2801 |
chn ~~ 0 ifTrue:[ |
|
2802 |
chn > 16rfff ifTrue:[ ^ self fromIdn:(IDN Unspecified) ]. |
|
2803 |
oid := 3. |
|
2804 |
typ := aTypeOrSymbol ? 0. |
|
2805 |
hgEnc := chn. |
|
2806 |
] |
|
2807 |
] |
|
2808 |
] |
|
2809 |
]. |
|
2810 |
||
2811 |
typ notNil ifTrue:[ |
|
2812 |
typ isSymbol ifTrue:[ |
|
2813 |
typ := (MDT::MDTCType asNumberType:typ) ? 0 |
|
2814 |
]. |
|
2815 |
hgEnc := hgEnc bitOr:(typ bitShift:12). |
|
2816 |
hgEnc := hgEnc bitOr:(oid bitShift:20). |
|
2817 |
]. |
|
2818 |
^ self basicNew eqEncode:eqEnc hgEncode:hgEnc. |
|
2819 |
||
2820 |
" |
|
2821 |
self basicNew rack:1 subrack:3 board:5 port:33 channel:8 typeId:7 |
|
2822 |
" |
|
2823 |
! ! |
|
2824 |
||
2 | 2825 |
!IntegerTest class methodsFor:'documentation'! |
2826 |
||
2827 |
version |
|
2828 |
^ '$Header$' |
|
2829 |
! ! |