310
|
1 |
"{ Package: 'exept:regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#SmallIntegerTest
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-Regression'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!SmallIntegerTest methodsFor:'tests-arithmetic'!
|
|
14 |
|
|
15 |
testDivide
|
|
16 |
self assert: 2 / 1 = 2.
|
|
17 |
self assert: (3 / 2) isFraction.
|
|
18 |
self assert: 4 / 2 = 2.
|
|
19 |
self should: [ 1 / 0 ] raise: ZeroDivide.
|
|
20 |
! !
|
|
21 |
|
|
22 |
!SmallIntegerTest methodsFor:'tests-class protocol'!
|
|
23 |
|
|
24 |
testBasicNew
|
|
25 |
self should: [SmallInteger basicNew] raise: TestResult error.
|
|
26 |
!
|
|
27 |
|
|
28 |
testMaxVal
|
|
29 |
"/ the original code did not check for pointer-size;
|
|
30 |
|
|
31 |
Smalltalk isSmalltalkX ifTrue:[
|
|
32 |
SmallInteger maxBytes == 4 ifTrue:[
|
|
33 |
self should: [SmallInteger maxVal = 16r3FFFFFFF].
|
|
34 |
self should: [SmallInteger maxVal == 16r3FFFFFFF].
|
|
35 |
] ifFalse:[
|
|
36 |
self should: [SmallInteger maxVal = 16r3FFFFFFFFFFFFFFF].
|
|
37 |
self should: [SmallInteger maxVal == 16r3FFFFFFFFFFFFFFF].
|
|
38 |
].
|
|
39 |
] ifFalse:[
|
|
40 |
self should: [SmallInteger maxVal = 16r3FFFFFFF].
|
|
41 |
]
|
|
42 |
!
|
|
43 |
|
|
44 |
testMinVal
|
|
45 |
"/ the original code did not check for pointer-size;
|
|
46 |
|
|
47 |
Smalltalk isSmalltalkX ifTrue:[
|
|
48 |
SmallInteger maxBytes == 4 ifTrue:[
|
|
49 |
self should: [SmallInteger minVal = -16r40000000].
|
|
50 |
self should: [SmallInteger minVal == -16r40000000].
|
|
51 |
] ifFalse:[
|
|
52 |
self should: [SmallInteger minVal = -16r4000000000000000].
|
|
53 |
self should: [SmallInteger minVal == -16r4000000000000000].
|
|
54 |
].
|
|
55 |
] ifFalse:[
|
|
56 |
self should: [SmallInteger minVal = -16r40000000].
|
|
57 |
]
|
|
58 |
!
|
|
59 |
|
|
60 |
testNew
|
|
61 |
self should: [SmallInteger new] raise: TestResult error.
|
|
62 |
! !
|
|
63 |
|
|
64 |
!SmallIntegerTest class methodsFor:'documentation'!
|
|
65 |
|
|
66 |
version
|
|
67 |
^ '$Header$'
|
|
68 |
! !
|