equal
deleted
inserted
replaced
3 classVariableNames:'' |
3 classVariableNames:'' |
4 poolDictionaries:'' |
4 poolDictionaries:'' |
5 category:'Tests - Numbers' |
5 category:'Tests - Numbers' |
6 ! |
6 ! |
7 |
7 |
|
8 |
|
9 !IntegerTest class methodsFor:'misc'! |
|
10 |
|
11 testPlus1_a:arg |
|
12 ^ arg + 1 |
|
13 |
|
14 " |
|
15 (self testPlus1_a:SmallInteger maxVal) = 1073741824 |
|
16 " |
|
17 ! |
|
18 |
|
19 testPlus1_b:arg |
|
20 ^ arg perform:#+ with:1 |
|
21 |
|
22 " |
|
23 (self testPlus1_b:SmallInteger maxVal) == 1073741824 |
|
24 " |
|
25 ! ! |
8 |
26 |
9 !IntegerTest class methodsFor:'private'! |
27 !IntegerTest class methodsFor:'private'! |
10 |
28 |
11 test:aBlock |
29 test:aBlock |
12 aBlock value == true ifFalse:[ |
30 aBlock value == true ifFalse:[ |
70 halfMax := 16r2000000000000000. |
88 halfMax := 16r2000000000000000. |
71 ]. |
89 ]. |
72 |
90 |
73 "arithmetic overFlow checks" |
91 "arithmetic overFlow checks" |
74 |
92 |
|
93 "/ self test:[(maxVal + 1) inspect.maxValPlus1 inspect. true]. |
75 self test:[maxVal + 1 = maxValPlus1]. |
94 self test:[maxVal + 1 = maxValPlus1]. |
76 self test:[minVal - 1 = minValMinus1]. |
95 self test:[minVal - 1 = minValMinus1]. |
77 |
96 |
78 self test:[(halfMax + halfMax) = maxValPlus1]. |
97 self test:[(halfMax + halfMax) = maxValPlus1]. |
79 self test:[(halfMin + halfMin) == minVal]. |
98 self test:[(halfMin + halfMin) == minVal]. |
101 self test:[t1 * t1 ~~ 10000000000]. |
120 self test:[t1 * t1 ~~ 10000000000]. |
102 ]. |
121 ]. |
103 SmallInteger maxBytes == 8 ifTrue:[ |
122 SmallInteger maxBytes == 8 ifTrue:[ |
104 self test:[t1 * t1 == 10000000000]. |
123 self test:[t1 * t1 == 10000000000]. |
105 ]. |
124 ]. |
|
125 |
|
126 self test:[(t1 perform:'*' asSymbol with:t1) printString = '10000000000']. |
106 self test:[(t1 * t1) printString = '10000000000']. |
127 self test:[(t1 * t1) printString = '10000000000']. |
107 t1 := 1000000. |
128 t1 := 1000000. |
108 self test:[(t1 * t1) printString = '1000000000000']. |
129 self test:[(t1 * t1) printString = '1000000000000']. |
109 t1 := 10000000. |
130 t1 := 10000000. |
110 self test:[(t1 * t1) printString = '100000000000000']. |
131 self test:[(t1 * t1) printString = '100000000000000']. |