47
|
1 |
Object subclass:#CompilerTest
|
|
2 |
instanceVariableNames:''
|
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
59
|
5 |
category:'Tests-Regression'
|
47
|
6 |
!
|
|
7 |
|
|
8 |
|
50
|
9 |
!CompilerTest methodsFor:'test - inlined'!
|
|
10 |
|
|
11 |
test_even:arg
|
|
12 |
^ arg even
|
|
13 |
|
|
14 |
"
|
|
15 |
self new test_even:nil
|
|
16 |
self new test_even:123
|
|
17 |
self new test_even:122
|
|
18 |
self new test_even:(100 factorial)
|
|
19 |
"
|
|
20 |
!
|
|
21 |
|
|
22 |
test_isInteger:arg
|
|
23 |
^ arg isInteger
|
|
24 |
|
|
25 |
"
|
|
26 |
self new test_isInteger:nil
|
|
27 |
self new test_isInteger:123
|
|
28 |
self new test_isInteger:(100 factorial)
|
|
29 |
"
|
|
30 |
!
|
|
31 |
|
|
32 |
test_isNotInteger:arg
|
|
33 |
^ arg isInteger not
|
|
34 |
|
|
35 |
"
|
|
36 |
self new test_isNotInteger:nil
|
|
37 |
self new test_isNotInteger:123
|
|
38 |
self new test_isNotInteger:(100 factorial)
|
|
39 |
"
|
|
40 |
!
|
|
41 |
|
|
42 |
test_odd:arg
|
|
43 |
^ arg odd
|
|
44 |
|
|
45 |
"
|
|
46 |
self new test_odd:nil
|
|
47 |
self new test_odd:123
|
|
48 |
self new test_odd:122
|
|
49 |
self new test_odd:(100 factorial)
|
|
50 |
"
|
|
51 |
! !
|
|
52 |
|
48
|
53 |
!CompilerTest methodsFor:'tests - booleans'!
|
|
54 |
|
50
|
55 |
testAnd:arg1 _:arg2
|
|
56 |
^ arg1 & arg2
|
|
57 |
|
|
58 |
"
|
|
59 |
self new testAnd:true _:true.
|
|
60 |
self new testAnd:true _:false.
|
|
61 |
self new testAnd:false _:true.
|
|
62 |
self new testAnd:false _:false.
|
|
63 |
self new testAnd:false _:nil.
|
|
64 |
self new testAnd:true _:nil.
|
|
65 |
self new testAnd:nil _:false.
|
|
66 |
self new testAnd:nil _:true.
|
|
67 |
self new testAnd:1234 _:true.
|
|
68 |
self new testAnd:1234 _:false.
|
|
69 |
self new testAnd:true _:1234.
|
|
70 |
self new testAnd:false _:1234.
|
|
71 |
"
|
|
72 |
!
|
|
73 |
|
48
|
74 |
testNot1:arg
|
|
75 |
^ arg not
|
|
76 |
|
|
77 |
"
|
49
|
78 |
self new testNot1:true.
|
48
|
79 |
self new testNot1:false.
|
|
80 |
self new testNot1:1234.
|
|
81 |
"
|
|
82 |
!
|
|
83 |
|
|
84 |
testNot2:arg1 _:arg2
|
|
85 |
^ arg1 not & arg2 not
|
|
86 |
|
|
87 |
"
|
|
88 |
self new testNot2:true _:true.
|
|
89 |
self new testNot2:false _:true.
|
|
90 |
self new testNot2:true _:false.
|
|
91 |
self new testNot2:false _:false.
|
|
92 |
|
|
93 |
self new testNot2:false _:1234.
|
|
94 |
self new testNot2:true _:1234.
|
|
95 |
self new testNot2:1234 _:true.
|
|
96 |
self new testNot2:1234 _:false.
|
|
97 |
self new testNot2:1234 _:2345.
|
|
98 |
"
|
50
|
99 |
!
|
|
100 |
|
|
101 |
testOr:arg1 _:arg2
|
|
102 |
^ arg1 | arg2
|
|
103 |
|
|
104 |
"
|
|
105 |
self new testOr:true _:true.
|
|
106 |
self new testOr:true _:false.
|
|
107 |
self new testOr:false _:true.
|
|
108 |
self new testOr:false _:false.
|
|
109 |
self new testOr:false _:nil.
|
|
110 |
self new testOr:true _:nil.
|
|
111 |
self new testOr:nil _:false.
|
|
112 |
self new testOr:nil _:true.
|
|
113 |
self new testOr:1234 _:true.
|
|
114 |
self new testOr:1234 _:false.
|
|
115 |
self new testOr:true _:1234.
|
|
116 |
self new testOr:false _:1234.
|
|
117 |
"
|
48
|
118 |
! !
|
|
119 |
|
47
|
120 |
!CompilerTest methodsFor:'tests - constant folding'!
|
|
121 |
|
|
122 |
testFloat_pi
|
|
123 |
^ Float pi
|
|
124 |
!
|
|
125 |
|
|
126 |
testFloat_unity
|
|
127 |
^ Float unity
|
|
128 |
!
|
|
129 |
|
|
130 |
testFloat_zero
|
|
131 |
^ Float zero
|
|
132 |
!
|
|
133 |
|
|
134 |
testSmalltalk_if_else_isSmalltalkX
|
|
135 |
Smalltalk isSmalltalkX ifTrue:[
|
59
|
136 |
^ 'yes'
|
47
|
137 |
] ifFalse:[
|
59
|
138 |
^ 'no'
|
47
|
139 |
]
|
|
140 |
!
|
|
141 |
|
|
142 |
testSmalltalk_if_else_isVisualWorks
|
|
143 |
Smalltalk isVisualWorks ifTrue:[
|
59
|
144 |
^ 'yes'
|
47
|
145 |
] ifFalse:[
|
59
|
146 |
^ 'no'
|
47
|
147 |
]
|
|
148 |
!
|
|
149 |
|
|
150 |
testSmalltalk_if_isSmalltalkX
|
|
151 |
Smalltalk isSmalltalkX ifTrue:[
|
59
|
152 |
^ 'yes'
|
47
|
153 |
].
|
|
154 |
^ 'no'
|
|
155 |
!
|
|
156 |
|
|
157 |
testSmalltalk_if_isSqueak
|
|
158 |
Smalltalk isSqueak ifTrue:[
|
59
|
159 |
^ 'yes'
|
47
|
160 |
].
|
|
161 |
^ 'no'
|
|
162 |
!
|
|
163 |
|
|
164 |
testSmalltalk_if_isVisualWorks
|
|
165 |
Smalltalk isVisualWorks ifTrue:[
|
59
|
166 |
^ 'yes'
|
47
|
167 |
].
|
|
168 |
^ 'no'
|
|
169 |
!
|
|
170 |
|
|
171 |
testSmalltalk_isSmalltalkX
|
|
172 |
^ Smalltalk isSmalltalkX
|
|
173 |
!
|
|
174 |
|
|
175 |
testSmalltalk_isSqueak
|
|
176 |
^ Smalltalk isSqueak
|
|
177 |
!
|
|
178 |
|
|
179 |
testSmalltalk_isVisualAge
|
|
180 |
^ Smalltalk isVisualAge
|
|
181 |
!
|
|
182 |
|
|
183 |
testSmalltalk_isVisualWorks
|
|
184 |
^ Smalltalk isVisualWorks
|
|
185 |
!
|
|
186 |
|
|
187 |
testUnaryFolding
|
|
188 |
self testFloat_pi ~= (Float perform:#pi) ifTrue:[self halt].
|
|
189 |
self testFloat_unity ~= (Float perform:#unity) ifTrue:[self halt].
|
|
190 |
self testFloat_zero ~= (Float perform:#zero) ifTrue:[self halt].
|
|
191 |
|
|
192 |
self testSmalltalk_isSmalltalkX ~= (Smalltalk perform:#isSmalltalkX) ifTrue:[self halt].
|
|
193 |
self testSmalltalk_isSqueak ~= (Smalltalk perform:#isSqueak) ifTrue:[self halt].
|
|
194 |
self testSmalltalk_isVisualWorks ~= (Smalltalk perform:#isVisualWorks) ifTrue:[self halt].
|
|
195 |
self testSmalltalk_isVisualAge ~= (Smalltalk perform:#isVisualAge) ifTrue:[self halt].
|
|
196 |
|
|
197 |
"
|
|
198 |
self basicNew testUnaryFolding
|
|
199 |
"
|
|
200 |
! !
|
|
201 |
|
|
202 |
!CompilerTest class methodsFor:'documentation'!
|
|
203 |
|
|
204 |
version
|
|
205 |
^ '$Header$'
|
|
206 |
! !
|