author | Patrik Svestka <patrik.svestka@gmail.com> |
Wed, 20 Oct 2021 13:26:34 +0200 | |
branch | jv |
changeset 2604 | d6d5dfaa3e00 |
parent 2602 | 1e701f1808a7 |
permissions | -rwxr-xr-x |
1447 | 1 |
"{ Package: 'stx:goodies/regression' }" |
61 | 2 |
|
70 | 3 |
"{ NameSpace: RegressionTests }" |
4 |
||
113 | 5 |
TestCase subclass:#CompilerTest |
61 | 6 |
instanceVariableNames:'value' |
47 | 7 |
classVariableNames:'' |
8 |
poolDictionaries:'' |
|
1162 | 9 |
category:'tests-Regression-Compilers' |
47 | 10 |
! |
11 |
||
188 | 12 |
Object subclass:#DummyClass |
13 |
instanceVariableNames:'applicationModel service request' |
|
14 |
classVariableNames:'' |
|
15 |
poolDictionaries:'' |
|
16 |
privateIn:CompilerTest |
|
17 |
! |
|
18 |
||
577 | 19 |
Object subclass:#Schedule |
20 |
instanceVariableNames:'state' |
|
21 |
classVariableNames:'' |
|
22 |
poolDictionaries:'' |
|
23 |
privateIn:CompilerTest |
|
24 |
! |
|
25 |
||
26 |
Object subclass:#State |
|
27 |
instanceVariableNames:'state' |
|
28 |
classVariableNames:'' |
|
29 |
poolDictionaries:'' |
|
30 |
privateIn:CompilerTest::Schedule |
|
31 |
! |
|
32 |
||
33 |
||
34 |
!CompilerTest class methodsFor:'helpers'! |
|
35 |
||
36 |
compile:code |
|
668 | 37 |
Class withoutUpdatingChangesDo:[ |
1447 | 38 |
^ Compiler |
39 |
compile:code |
|
40 |
forClass:self |
|
41 |
install:false. |
|
668 | 42 |
]. |
577 | 43 |
! ! |
47 | 44 |
|
88 | 45 |
!CompilerTest class methodsFor:'tests - constants'! |
46 |
||
47 |
test_int1024 |
|
48 |
^ 1024 |
|
49 |
||
50 |
" |
|
51 |
self test_int1024 |
|
52 |
" |
|
53 |
||
54 |
! |
|
55 |
||
56 |
test_int1048576 |
|
57 |
^ 1048576 |
|
58 |
! |
|
59 |
||
60 |
test_int128 |
|
61 |
^ 128 |
|
62 |
||
63 |
" |
|
64 |
self test_int128 |
|
65 |
" |
|
66 |
! |
|
67 |
||
68 |
test_int131072 |
|
69 |
^ 131072 |
|
70 |
! |
|
71 |
||
72 |
test_int16384 |
|
73 |
^ 16384 |
|
74 |
||
75 |
" |
|
76 |
self test_int16384 |
|
77 |
" |
|
78 |
||
79 |
! |
|
80 |
||
81 |
test_int2048 |
|
82 |
^ 2048 |
|
83 |
||
84 |
" |
|
85 |
self test_int2048 |
|
86 |
" |
|
87 |
||
88 |
! |
|
89 |
||
90 |
test_int2097152 |
|
91 |
^ 2097152 |
|
92 |
! |
|
93 |
||
94 |
test_int256 |
|
95 |
^ 256 |
|
96 |
||
97 |
" |
|
98 |
self test_int256 |
|
99 |
" |
|
100 |
||
101 |
! |
|
102 |
||
103 |
test_int262144 |
|
104 |
^ 262144 |
|
105 |
! |
|
106 |
||
107 |
test_int32768 |
|
108 |
^ 32768 |
|
109 |
||
110 |
" |
|
111 |
self test_int32768 |
|
112 |
" |
|
113 |
||
114 |
! |
|
115 |
||
116 |
test_int4096 |
|
117 |
^ 4096 |
|
118 |
||
119 |
" |
|
120 |
self test_int4096 |
|
121 |
" |
|
122 |
||
123 |
! |
|
124 |
||
125 |
test_int512 |
|
126 |
^ 512 |
|
127 |
||
128 |
" |
|
129 |
self test_int512 |
|
130 |
" |
|
131 |
||
132 |
! |
|
133 |
||
134 |
test_int524288 |
|
135 |
^ 524288 |
|
136 |
! |
|
137 |
||
138 |
test_int65536 |
|
139 |
^ 65536 |
|
140 |
||
141 |
" |
|
142 |
self test_int65536 |
|
143 |
" |
|
144 |
||
145 |
! |
|
146 |
||
147 |
test_int8192 |
|
148 |
^ 8192 |
|
149 |
||
150 |
" |
|
151 |
self test_int8192 |
|
152 |
" |
|
153 |
||
154 |
! |
|
155 |
||
156 |
test_intM128 |
|
157 |
^ -128 |
|
158 |
! ! |
|
159 |
||
77 | 160 |
!CompilerTest class methodsFor:'tests argument passing'! |
161 |
||
162 |
ret0 |
|
163 |
^ 0 |
|
164 |
||
165 |
" |
|
166 |
self ret0 |
|
648 | 167 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self ret0] ] |
77 | 168 |
" |
169 |
! |
|
170 |
||
171 |
ret1 |
|
172 |
^ 1 |
|
173 |
||
174 |
" |
|
175 |
self ret1 |
|
78 | 176 |
1000000 timesRepeat:[self ret1] |
648 | 177 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self ret1] ] |
78 | 178 |
" |
179 |
! |
|
180 |
||
181 |
retArg1:arg |
|
182 |
^ arg |
|
183 |
||
184 |
" |
|
185 |
self retArg1:1 |
|
186 |
1000000 timesRepeat:[self retArg1:1] |
|
187 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg1:1] ] |
|
188 |
" |
|
189 |
! |
|
190 |
||
191 |
retArg2:arg1 _:arg2 |
|
192 |
^ arg2 |
|
193 |
||
194 |
" |
|
648 | 195 |
self retArg2:1 _:2 |
78 | 196 |
1000000 timesRepeat:[self retArg2:1 _:2] |
648 | 197 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg2:1 _:2] ] |
78 | 198 |
" |
199 |
! |
|
200 |
||
201 |
retArg3:arg1 _:arg2 _:arg3 |
|
202 |
^ arg3 |
|
203 |
||
204 |
" |
|
648 | 205 |
self retArg3:1 _:2 _:3 |
206 |
1000000 timesRepeat:[self retArg3:1 _:2 _:3] |
|
207 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg3:1 _:2 _:3] ] |
|
78 | 208 |
" |
209 |
! |
|
210 |
||
211 |
retArg4:arg1 _:arg2 _:arg3 _:arg4 |
|
212 |
^ arg4 |
|
213 |
||
214 |
" |
|
648 | 215 |
self retArg4:1 _:2 _:3 _:4 |
216 |
1000000 timesRepeat:[self retArg4:1 _:2 _:3 _:4] |
|
217 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg4:1 _:2 _:3 _:4] ] |
|
78 | 218 |
" |
219 |
! |
|
220 |
||
79 | 221 |
retArg5:arg1 _:arg2 _:arg3 _:arg4 _:arg5 |
222 |
^ arg5 |
|
223 |
||
224 |
" |
|
648 | 225 |
self retArg5:1 _:2 _:3 _:4 _:5 |
226 |
1000000 timesRepeat:[self retArg5:1 _:2 _:3 _:4 _:5] |
|
227 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg5:1 _:2 _:3 _:4 _:5] ] |
|
79 | 228 |
" |
229 |
! |
|
230 |
||
78 | 231 |
retLiteral1 |
232 |
^ 'hello' |
|
233 |
||
234 |
" |
|
235 |
self retLiteral1 |
|
236 |
1000000 timesRepeat:[self retLiteral1] |
|
237 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retLiteral1] ] |
|
77 | 238 |
" |
239 |
! |
|
240 |
||
241 |
retM1 |
|
242 |
^ -1 |
|
243 |
||
244 |
" |
|
245 |
self retM1 |
|
78 | 246 |
1000000 timesRepeat:[self retM1] |
648 | 247 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retM1] ] |
77 | 248 |
" |
249 |
! |
|
250 |
||
251 |
retSelf |
|
252 |
^ self |
|
253 |
||
254 |
" |
|
255 |
self retSelf |
|
78 | 256 |
1000000 timesRepeat:[self retSelf] |
648 | 257 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retSelf] ] |
77 | 258 |
" |
259 |
! ! |
|
260 |
||
61 | 261 |
!CompilerTest methodsFor:'helpers'! |
262 |
||
568 | 263 |
callEnsureWith2Returns |
264 |
[ |
|
648 | 265 |
^ false |
568 | 266 |
] ensure:[ |
648 | 267 |
^ true |
568 | 268 |
]. |
269 |
^ nil |
|
270 |
||
271 |
"Created: / 24-08-2010 / 12:51:50 / cg" |
|
272 |
! |
|
273 |
||
569
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
274 |
callEnsureWithException |
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
275 |
[ |
1447 | 276 |
ProceedableError raiseRequest |
569
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
277 |
] ensure:[ |
1447 | 278 |
^ true |
569
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
279 |
]. |
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
280 |
^ nil |
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
281 |
|
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
282 |
"Created: / 24-08-2010 / 12:54:07 / cg" |
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
283 |
! |
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
284 |
|
668 | 285 |
compile:someCode |
286 |
|m| |
|
287 |
||
288 |
m := self class compile:someCode. |
|
289 |
self assert:(m notNil and:[m ~~ #Error]). |
|
290 |
^ m |
|
291 |
! |
|
292 |
||
81 | 293 |
size |
294 |
^ 1 |
|
295 |
! |
|
296 |
||
61 | 297 |
value:something |
298 |
value := something |
|
299 |
! ! |
|
300 |
||
48 | 301 |
!CompilerTest methodsFor:'tests - booleans'! |
302 |
||
113 | 303 |
_testAnd:arg1 _:arg2 |
50 | 304 |
^ arg1 & arg2 |
305 |
||
306 |
" |
|
648 | 307 |
self new _testAnd:true _:true. |
308 |
self new _testAnd:true _:false. |
|
309 |
self new _testAnd:false _:true. |
|
310 |
self new _testAnd:false _:false. |
|
311 |
self new _testAnd:false _:nil. |
|
312 |
self new _testAnd:true _:nil. |
|
113 | 313 |
self new _testAnd:nil _:false. |
314 |
self new _testAnd:nil _:true. |
|
315 |
self new _testAnd:1234 _:true. |
|
316 |
self new _testAnd:1234 _:false. |
|
648 | 317 |
self new _testAnd:true _:1234. |
318 |
self new _testAnd:false _:1234. |
|
113 | 319 |
" |
320 |
! |
|
321 |
||
322 |
_testNot1:arg |
|
323 |
^ arg not |
|
324 |
||
325 |
" |
|
648 | 326 |
self new _testNot1:true. |
113 | 327 |
self new _testNot1:false. |
328 |
self new _testNot1:1234. |
|
50 | 329 |
" |
330 |
! |
|
331 |
||
113 | 332 |
_testNot2:arg1 _:arg2 |
333 |
^ arg1 not & arg2 not |
|
48 | 334 |
|
335 |
" |
|
648 | 336 |
self new _testNot2:true _:true. |
113 | 337 |
self new _testNot2:false _:true. |
338 |
self new _testNot2:true _:false. |
|
339 |
self new _testNot2:false _:false. |
|
340 |
||
341 |
self new _testNot2:false _:1234. |
|
342 |
self new _testNot2:true _:1234. |
|
343 |
self new _testNot2:1234 _:true. |
|
344 |
self new _testNot2:1234 _:false. |
|
345 |
self new _testNot2:1234 _:2345. |
|
346 |
" |
|
347 |
! |
|
348 |
||
349 |
_testNot3:arg1 _:arg2 |
|
350 |
^ arg1 not | arg2 not |
|
351 |
||
352 |
" |
|
648 | 353 |
self new _testNot3:true _:true. |
113 | 354 |
self new _testNot3:false _:true. |
355 |
self new _testNot3:true _:false. |
|
356 |
self new _testNot3:false _:false. |
|
357 |
||
358 |
self new _testNot3:false _:1234. |
|
359 |
self new _testNot3:true _:1234. |
|
360 |
self new _testNot3:1234 _:true. |
|
361 |
self new _testNot3:1234 _:false. |
|
362 |
self new _testNot3:1234 _:2345. |
|
48 | 363 |
" |
364 |
! |
|
365 |
||
113 | 366 |
_testOr:arg1 _:arg2 |
367 |
^ arg1 | arg2 |
|
48 | 368 |
|
369 |
" |
|
648 | 370 |
self new _testOr:true _:true. |
371 |
self new _testOr:true _:false. |
|
372 |
self new _testOr:false _:true. |
|
373 |
self new _testOr:false _:false. |
|
374 |
self new _testOr:false _:nil. |
|
375 |
self new _testOr:true _:nil. |
|
113 | 376 |
self new _testOr:nil _:false. |
377 |
self new _testOr:nil _:true. |
|
378 |
self new _testOr:1234 _:true. |
|
379 |
self new _testOr:1234 _:false. |
|
648 | 380 |
self new _testOr:true _:1234. |
381 |
self new _testOr:false _:1234. |
|
113 | 382 |
" |
383 |
! |
|
48 | 384 |
|
113 | 385 |
testAnd |
386 |
self assert:( ( self _testAnd:true _:true ) == true ). |
|
387 |
self assert:( ( self _testAnd:true _:false ) == false ). |
|
388 |
self assert:( ( self _testAnd:false _:true ) == false ). |
|
389 |
self assert:( ( self _testAnd:false _:false ) == false ). |
|
390 |
||
391 |
self assert:( ( self _testAnd:false _:nil ) == false ). |
|
392 |
self assert:( ( self _testAnd:true _:nil ) == nil ). |
|
393 |
self assert:( ( self _testAnd:false _:1234 ) == false ). |
|
394 |
self assert:( ( self _testAnd:true _:1234 ) == 1234 ). |
|
395 |
self should:[ self _testAnd:nil _:false ] raise:Error. |
|
396 |
self should:[ self _testAnd:nil _:true ] raise:Error. |
|
397 |
self should:[ self _testAnd:1234 _:false ] raise:Error. |
|
398 |
self should:[ self _testAnd:1234 _:true ] raise:Error. |
|
399 |
||
400 |
" |
|
401 |
self new testAnd |
|
48 | 402 |
" |
50 | 403 |
! |
404 |
||
113 | 405 |
testNot |
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
406 |
|compiledMethod skipStc| |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
407 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
408 |
self assert:( ( self _testNot1:true ) == false ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
409 |
self assert:( ( self _testNot1:false ) == true ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
410 |
|
2602
1e701f1808a7
Fix `CompilerTest >> testNot` after cherry-picking from 84348e65ca8d in d0679511ef19
Jan Vrany <jan.vrany@labware.com>
parents:
2599
diff
changeset
|
411 |
compiledMethod := self class compiledMethodAt:#'_testNot1:'. |
1e701f1808a7
Fix `CompilerTest >> testNot` after cherry-picking from 84348e65ca8d in d0679511ef19
Jan Vrany <jan.vrany@labware.com>
parents:
2599
diff
changeset
|
412 |
skipStc := (compiledMethod notNil |
1e701f1808a7
Fix `CompilerTest >> testNot` after cherry-picking from 84348e65ca8d in d0679511ef19
Jan Vrany <jan.vrany@labware.com>
parents:
2599
diff
changeset
|
413 |
and:[compiledMethod byteCode isNil]) ifTrue:[ |
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
414 |
"/ stc-compiled code handles #not slightly differently |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
415 |
"/ (does not raise an error) |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
416 |
'CompilerTest >> testNot1: non-boolean cases skipped due to stc limitations' infoPrintCR. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
417 |
] ifFalse:[ |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
418 |
self should:[ self _testNot1:nil ] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
419 |
self should:[ self _testNot1:1234 ] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
420 |
]. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
421 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
422 |
self assert:( ( self _testNot2:true _:true) == false ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
423 |
self assert:( ( self _testNot2:false _:true) == false ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
424 |
self assert:( ( self _testNot2:true _:false) == false ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
425 |
self assert:( ( self _testNot2:false _:false) == true ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
426 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
427 |
compiledMethod := self class compiledMethodAt:#'_testNot2:_:'. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
428 |
skipStc := (compiledMethod notNil |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
429 |
and:[compiledMethod byteCode isNil]) ifTrue:[ |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
430 |
"/ stc-compiled code handles not slightly differently |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
431 |
"/ (does not raise an error) |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
432 |
'CompilerTest >> testNot2: non-boolean cases skipped due to stc limitations' infoPrintCR. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
433 |
] ifFalse:[ |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
434 |
self should:[ self _testNot2:false _:1234] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
435 |
self should:[ self _testNot2:true _:1234] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
436 |
self should:[ self _testNot2:1234 _:false] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
437 |
self should:[ self _testNot2:1234 _:true] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
438 |
self should:[ self _testNot2:1234 _:1234] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
439 |
self should:[ self _testNot2:nil _:false] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
440 |
self should:[ self _testNot2:nil _:true] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
441 |
self should:[ self _testNot2:nil _:1234] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
442 |
]. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
443 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
444 |
self assert:( ( self _testNot3:true _:true) == false ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
445 |
self assert:( ( self _testNot3:false _:true) == true ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
446 |
self assert:( ( self _testNot3:true _:false) == true ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
447 |
self assert:( ( self _testNot3:false _:false) == true ). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
448 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
449 |
compiledMethod := self class compiledMethodAt:#'_testNot3:_:'. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
450 |
skipStc := (compiledMethod notNil |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
451 |
and:[compiledMethod byteCode isNil]) ifTrue:[ |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
452 |
"/ stc-compiled code handles not slightly differently |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
453 |
"/ (does not raise an error) |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
454 |
'CompilerTest >> testNot3: non-boolean cases skipped due to stc limitations' infoPrintCR. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
455 |
] ifFalse:[ |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
456 |
self should:[ self _testNot3:false _:1234] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
457 |
self should:[ self _testNot3:true _:1234] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
458 |
self should:[ self _testNot3:1234 _:false] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
459 |
self should:[ self _testNot3:1234 _:true] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
460 |
self should:[ self _testNot3:1234 _:1234] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
461 |
self should:[ self _testNot3:nil _:false] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
462 |
self should:[ self _testNot3:nil _:true] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
463 |
self should:[ self _testNot3:nil _:1234] raise:Error. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
464 |
]. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
465 |
|
50 | 466 |
" |
113 | 467 |
self new testNot |
468 |
" |
|
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
469 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
470 |
"Modified: / 12-10-2017 / 14:35:05 / cg" |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
471 |
"Modified (format): / 06-05-2019 / 14:09:47 / Claus Gittinger" |
113 | 472 |
! |
473 |
||
474 |
testOr |
|
475 |
self assert:( ( self _testOr:true _:true ) == true ). |
|
476 |
self assert:( ( self _testOr:true _:false ) == true ). |
|
477 |
self assert:( ( self _testOr:false _:true ) == true ). |
|
478 |
self assert:( ( self _testOr:false _:false ) == false ). |
|
479 |
||
480 |
self assert:( ( self _testOr:false _:nil ) == nil ). |
|
481 |
self assert:( ( self _testOr:true _:nil ) == true ). |
|
482 |
self assert:( ( self _testOr:false _:1234 ) == 1234 ). |
|
483 |
self assert:( ( self _testOr:true _:1234 ) == true ). |
|
484 |
self should:[ self _testOr:nil _:false ] raise:Error. |
|
485 |
self should:[ self _testOr:nil _:true ] raise:Error. |
|
486 |
self should:[ self _testOr:1234 _:false ] raise:Error. |
|
487 |
self should:[ self _testOr:1234 _:true ] raise:Error. |
|
488 |
||
489 |
" |
|
490 |
self new testOr |
|
50 | 491 |
" |
48 | 492 |
! ! |
493 |
||
62 | 494 |
!CompilerTest methodsFor:'tests - conditions'! |
495 |
||
113 | 496 |
_testIf1:val |
62 | 497 |
|x| |
498 |
||
65 | 499 |
x := #foo. |
500 |
x := (val == #CursorRight or:[val == #CursorDown]) ifTrue:[1]. |
|
62 | 501 |
^ x |
502 |
||
503 |
" |
|
113 | 504 |
self new _testIf1:#CursorRight |
505 |
self new _testIf1:#CursorDown |
|
648 | 506 |
self new _testIf1:#Foo |
507 |
self new _testIf1:#CursorUp |
|
508 |
self new _testIf1:nil |
|
509 |
self new _testIf1:1 |
|
62 | 510 |
" |
63 | 511 |
! |
512 |
||
648 | 513 |
_testIf2:val |
63 | 514 |
|x| |
515 |
||
65 | 516 |
x := #foo. |
517 |
x := (val == #CursorRight or:[val == #CursorDown]) ifTrue:1. |
|
63 | 518 |
^ x |
519 |
||
520 |
" |
|
113 | 521 |
self new _testIf2:#CursorRight |
522 |
self new _testIf2:#CursorDown |
|
648 | 523 |
self new _testIf2:#Foo |
524 |
self new _testIf2:#CursorUp |
|
525 |
self new _testIf2:nil |
|
526 |
self new _testIf2:1 |
|
63 | 527 |
" |
65 | 528 |
! |
529 |
||
648 | 530 |
_testIf3:val |
65 | 531 |
|x| |
532 |
||
533 |
x := #foo. |
|
113 | 534 |
x := val isInteger ifTrue:1. |
65 | 535 |
^ x |
536 |
||
537 |
" |
|
113 | 538 |
self new _testIf3:#CursorRight |
539 |
self new _testIf3:#CursorDown |
|
648 | 540 |
self new _testIf3:#Foo |
541 |
self new _testIf3:#CursorUp |
|
542 |
self new _testIf3:nil |
|
543 |
self new _testIf3:1 |
|
65 | 544 |
" |
545 |
! |
|
546 |
||
648 | 547 |
_testIf4:val |
67 | 548 |
^ val isNil |
549 |
||
550 |
" |
|
648 | 551 |
self new _testIf4:#CursorRight |
552 |
self new _testIf4:1 |
|
553 |
self new _testIf4:nil |
|
67 | 554 |
" |
555 |
! |
|
556 |
||
648 | 557 |
_testIf4:val1 with:val2 |
113 | 558 |
^ val1 == nil and:[val2 == nil] |
66 | 559 |
|
560 |
" |
|
648 | 561 |
self new _testIf4:#CursorRight with:#CursorDown |
562 |
self new _testIf4:#CursorRight with:nil |
|
113 | 563 |
self new _testIf4:nil with:#CursorDown |
564 |
self new _testIf4:nil with:nil |
|
66 | 565 |
" |
566 |
! |
|
567 |
||
648 | 568 |
_testIf5:val |
113 | 569 |
^ val isNil ifTrue:[ |
648 | 570 |
1 |
113 | 571 |
] |
67 | 572 |
|
573 |
" |
|
648 | 574 |
self new _testIf5:#CursorRight |
575 |
self new _testIf5:1 |
|
576 |
self new _testIf5:nil |
|
67 | 577 |
" |
578 |
! |
|
579 |
||
648 | 580 |
_testIf5:val1 with:val2 |
113 | 581 |
^ val1 isNil and:[val2 isNil] |
66 | 582 |
|
583 |
" |
|
648 | 584 |
self new _testIf5:#CursorRight with:#CursorDown |
585 |
self new _testIf5:#CursorRight with:nil |
|
113 | 586 |
self new _testIf5:nil with:#CursorDown |
587 |
self new _testIf5:nil with:nil |
|
66 | 588 |
" |
589 |
! |
|
590 |
||
648 | 591 |
_testIf6:val |
67 | 592 |
^ val isNil ifTrue:1 |
593 |
||
594 |
" |
|
648 | 595 |
self new _testIf6:#CursorRight |
596 |
self new _testIf6:1 |
|
597 |
self new _testIf6:nil |
|
67 | 598 |
" |
599 |
! |
|
600 |
||
648 | 601 |
_testIf6b:val |
68 | 602 |
val isNil ifTrue:1 |
603 |
||
604 |
" |
|
648 | 605 |
self new _testIf6b:#CursorRight |
606 |
self new _testIf6b:1 |
|
607 |
self new _testIf6b:nil |
|
68 | 608 |
" |
609 |
! |
|
610 |
||
648 | 611 |
_testIf6c:val |
113 | 612 |
val isNil ifTrue:[ |
648 | 613 |
1 |
614 |
||
615 |
" |
|
616 |
self new _testIf6c:#CursorRight |
|
617 |
self new _testIf6c:1 |
|
618 |
self new _testIf6c:nil |
|
619 |
" |
|
113 | 620 |
] |
68 | 621 |
! |
622 |
||
648 | 623 |
_testIf6d:val |
68 | 624 |
^ val isNil ifTrue:val |
625 |
||
626 |
" |
|
648 | 627 |
self new _testIf6d:#CursorRight |
628 |
self new _testIf6d:1 |
|
629 |
self new _testIf6d:nil |
|
68 | 630 |
" |
631 |
! |
|
632 |
||
648 | 633 |
_testIf6e:val |
68 | 634 |
^ val isNil ifFalse:val |
635 |
||
636 |
" |
|
648 | 637 |
self new _testIf6e:['hello'] |
638 |
self new _testIf6e:('hello' asValue) |
|
639 |
self new _testIf6e:#CursorRight |
|
640 |
self new _testIf6e:1 |
|
641 |
self new _testIf6e:nil |
|
68 | 642 |
" |
643 |
! |
|
644 |
||
648 | 645 |
_testIf7:val |
67 | 646 |
^ val ? 1 |
647 |
||
648 |
" |
|
648 | 649 |
self new _testIf7:#CursorRight |
650 |
self new _testIf7:1 |
|
651 |
self new _testIf7:nil |
|
67 | 652 |
" |
653 |
! |
|
654 |
||
648 | 655 |
_testIfElse1:val |
65 | 656 |
|x| |
657 |
||
113 | 658 |
x := (val == #CursorRight or:[val == #CursorDown]) ifTrue:[ |
648 | 659 |
1 |
660 |
] ifFalse:[-1]. |
|
65 | 661 |
^ x |
662 |
||
663 |
" |
|
113 | 664 |
self new _testIfElse1:#CursorRight |
665 |
self new _testIfElse1:#CursorDown |
|
648 | 666 |
self new _testIfElse1:#Foo |
667 |
self new _testIfElse1:#CursorUp |
|
668 |
self new _testIfElse1:nil |
|
669 |
self new _testIfElse1:1 |
|
65 | 670 |
" |
671 |
! |
|
672 |
||
648 | 673 |
_testIfElse2:val |
65 | 674 |
|x| |
675 |
||
676 |
x := (val == #CursorRight or:[val == #CursorDown]) ifTrue:1 ifFalse:-1. |
|
677 |
^ x |
|
678 |
||
679 |
" |
|
113 | 680 |
self new _testIfElse2:#CursorRight |
681 |
self new _testIfElse2:#CursorDown |
|
648 | 682 |
self new _testIfElse2:#Foo |
683 |
self new _testIfElse2:#CursorUp |
|
684 |
self new _testIfElse2:nil |
|
685 |
self new _testIfElse2:1 |
|
65 | 686 |
" |
687 |
! |
|
688 |
||
648 | 689 |
_testIfElse3:val |
65 | 690 |
|x| |
691 |
||
692 |
x := (val == #CursorRight or:[val isInteger]) ifTrue:1 ifFalse:-1. |
|
693 |
^ x |
|
694 |
||
695 |
" |
|
648 | 696 |
self new _testIfElse3:#CursorRight |
697 |
self new _testIfElse3:#CursorDown |
|
698 |
self new _testIfElse3:#Foo |
|
699 |
self new _testIfElse3:#CursorUp |
|
700 |
self new _testIfElse3:nil |
|
701 |
self new _testIfElse3:1 |
|
65 | 702 |
" |
703 |
! |
|
704 |
||
648 | 705 |
_testIfElse4:val |
65 | 706 |
|x| |
707 |
||
708 |
x := #foo. |
|
113 | 709 |
x := val isInteger ifTrue:1 ifFalse:-1. |
65 | 710 |
^ x |
711 |
||
712 |
" |
|
648 | 713 |
self new _testIfElse4:#CursorRight |
714 |
self new _testIfElse4:#CursorDown |
|
715 |
self new _testIfElse4:#Foo |
|
716 |
self new _testIfElse4:#CursorUp |
|
717 |
self new _testIfElse4:nil |
|
718 |
self new _testIfElse4:1 |
|
65 | 719 |
" |
68 | 720 |
! |
721 |
||
648 | 722 |
_testIfElse5:val |
68 | 723 |
|x| |
724 |
||
725 |
x := #foo. |
|
726 |
x := val ifNil:1 ifNotNil:-1. |
|
727 |
^ x |
|
728 |
||
729 |
" |
|
648 | 730 |
self new _testIfElse5:#CursorUp |
731 |
self new _testIfElse5:nil |
|
732 |
self new _testIfElse5:1 |
|
68 | 733 |
" |
734 |
! |
|
735 |
||
648 | 736 |
_testIfElse6:val |
68 | 737 |
|x| |
738 |
||
739 |
x := #foo. |
|
740 |
x := val ifNil:[1] ifNotNil:[-1]. |
|
741 |
^ x |
|
742 |
||
743 |
" |
|
648 | 744 |
self new _testIfElse6:#CursorUp |
745 |
self new _testIfElse6:nil |
|
746 |
self new _testIfElse6:1 |
|
68 | 747 |
" |
748 |
! |
|
749 |
||
648 | 750 |
_testIfElse7:val with:val1 with:val2 |
68 | 751 |
|x| |
752 |
||
753 |
x := #foo. |
|
754 |
x := val ifNil:val1 ifNotNil:val2. |
|
755 |
^ x |
|
756 |
||
757 |
" |
|
648 | 758 |
self new _testIfElse7:#CursorUp with:1 with:2 |
759 |
self new _testIfElse7:nil with:1 with:2 |
|
760 |
self new _testIfElse7:1 with:1 with:2 |
|
113 | 761 |
" |
762 |
! |
|
763 |
||
764 |
testIf |
|
765 |
self assert:(self _testIf1:#CursorRight) == 1. |
|
766 |
self assert:(self _testIf1:#CursorDown) == 1. |
|
767 |
self assert:(self _testIf1:#Foo) == nil. |
|
768 |
self assert:(self _testIf1:#CursorUp) == nil. |
|
769 |
self assert:(self _testIf1:nil) == nil. |
|
770 |
self assert:(self _testIf1:1) == nil. |
|
771 |
||
772 |
self assert:(self _testIf2:#CursorRight) == 1. |
|
773 |
self assert:(self _testIf2:#CursorDown) == 1. |
|
774 |
self assert:(self _testIf2:#Foo) == nil. |
|
775 |
self assert:(self _testIf2:#CursorUp) == nil. |
|
776 |
self assert:(self _testIf2:nil) == nil. |
|
777 |
self assert:(self _testIf2:1) == nil. |
|
778 |
||
779 |
self assert:(self _testIf3:#CursorRight) == nil. |
|
780 |
self assert:(self _testIf3:#CursorDown) == nil. |
|
781 |
self assert:(self _testIf3:#Foo) == nil. |
|
782 |
self assert:(self _testIf3:#CursorUp) == nil. |
|
783 |
self assert:(self _testIf3:nil) == nil. |
|
784 |
self assert:(self _testIf3:1) == 1. |
|
785 |
||
786 |
self assert:(self _testIf4:#CursorRight) == false. |
|
787 |
self assert:(self _testIf4:nil) == true. |
|
788 |
self assert:(self _testIf4:1) == false. |
|
789 |
||
790 |
self assert:(self _testIf4:#CursorRight with:#CursorDown) == false. |
|
791 |
self assert:(self _testIf4:#CursorRight with:nil) == false. |
|
792 |
self assert:(self _testIf4:nil with:#CursorDown) == false. |
|
793 |
self assert:(self _testIf4:nil with:nil) == true. |
|
794 |
||
795 |
self assert:(self _testIf5:#CursorRight) == nil. |
|
796 |
self assert:(self _testIf5:nil) == 1. |
|
797 |
self assert:(self _testIf5:1) == nil. |
|
798 |
||
799 |
self assert:(self _testIf5:#CursorRight with:#CursorDown) == false. |
|
800 |
self assert:(self _testIf5:#CursorRight with:nil) == false. |
|
801 |
self assert:(self _testIf5:nil with:#CursorDown) == false. |
|
802 |
self assert:(self _testIf5:nil with:nil) == true. |
|
803 |
||
804 |
self assert:(self _testIf6:#CursorRight) == nil. |
|
805 |
self assert:(self _testIf6:nil) == 1. |
|
806 |
self assert:(self _testIf6:1) == nil. |
|
807 |
self assert:(self _testIf6d:#CursorRight) == nil. |
|
808 |
self assert:(self _testIf6d:nil) == nil. |
|
809 |
self assert:(self _testIf6d:1) == nil. |
|
810 |
self assert:(self _testIf6e:#CursorRight) == #CursorRight. |
|
811 |
self assert:(self _testIf6e:nil) == nil. |
|
812 |
self assert:(self _testIf6e:1) == 1. |
|
813 |
self assert:(self _testIf7:#CursorRight) == #CursorRight. |
|
814 |
self assert:(self _testIf7:nil) == 1. |
|
815 |
self assert:(self _testIf7:1) == 1. |
|
816 |
||
817 |
self assert:(self _testIfElse1:#CursorRight) == 1. |
|
818 |
self assert:(self _testIfElse1:#CursorDown) == 1. |
|
819 |
self assert:(self _testIfElse1:#Foo) == -1. |
|
820 |
self assert:(self _testIfElse1:#CursorUp) == -1. |
|
821 |
self assert:(self _testIfElse1:nil) == -1. |
|
822 |
self assert:(self _testIfElse1:1) == -1. |
|
823 |
||
824 |
self assert:(self _testIfElse2:#CursorRight) == 1. |
|
825 |
self assert:(self _testIfElse2:#CursorDown) == 1. |
|
826 |
self assert:(self _testIfElse2:#Foo) == -1. |
|
827 |
self assert:(self _testIfElse2:#CursorUp) == -1. |
|
828 |
self assert:(self _testIfElse2:nil) == -1. |
|
829 |
self assert:(self _testIfElse2:1) == -1. |
|
830 |
||
831 |
self assert:(self _testIfElse3:#CursorRight) == 1. |
|
832 |
self assert:(self _testIfElse3:#CursorDown) == -1. |
|
833 |
self assert:(self _testIfElse3:#Foo) == -1. |
|
834 |
self assert:(self _testIfElse3:#CursorUp) == -1. |
|
835 |
self assert:(self _testIfElse3:nil) == -1. |
|
836 |
self assert:(self _testIfElse3:1) == 1. |
|
837 |
||
838 |
self assert:(self _testIfElse4:#CursorRight) == -1. |
|
839 |
self assert:(self _testIfElse4:#CursorDown) == -1. |
|
840 |
self assert:(self _testIfElse4:#Foo) == -1. |
|
841 |
self assert:(self _testIfElse4:#CursorUp) == -1. |
|
842 |
self assert:(self _testIfElse4:nil) == -1. |
|
843 |
self assert:(self _testIfElse4:1) == 1. |
|
844 |
||
845 |
self assert:(self _testIfElse5:#CursorUp) == -1. |
|
846 |
self assert:(self _testIfElse5:nil) == 1. |
|
847 |
self assert:(self _testIfElse5:1) == -1. |
|
848 |
||
849 |
self assert:(self _testIfElse6:#CursorUp) == -1. |
|
850 |
self assert:(self _testIfElse6:nil) == 1. |
|
851 |
self assert:(self _testIfElse6:1) == -1. |
|
852 |
||
853 |
self assert:(self _testIfElse7:#CursorUp with:1 with:2) == 2. |
|
854 |
self assert:(self _testIfElse7:nil with:1 with:2) == 1. |
|
855 |
self assert:(self _testIfElse7:1 with:1 with:2) == 2. |
|
856 |
||
857 |
" |
|
858 |
self basicNew testIf |
|
68 | 859 |
" |
62 | 860 |
! ! |
861 |
||
47 | 862 |
!CompilerTest methodsFor:'tests - constant folding'! |
863 |
||
113 | 864 |
_testFloat_pi |
47 | 865 |
^ Float pi |
866 |
! |
|
867 |
||
113 | 868 |
_testFloat_unity |
47 | 869 |
^ Float unity |
870 |
! |
|
871 |
||
113 | 872 |
_testFloat_zero |
47 | 873 |
^ Float zero |
874 |
! |
|
875 |
||
113 | 876 |
_testSmalltalk_if_else_isSmalltalkX |
47 | 877 |
Smalltalk isSmalltalkX ifTrue:[ |
648 | 878 |
^ 'yes' |
113 | 879 |
] ifFalse:[^ 'no'] |
47 | 880 |
! |
881 |
||
113 | 882 |
_testSmalltalk_if_else_isVisualWorks |
47 | 883 |
Smalltalk isVisualWorks ifTrue:[ |
648 | 884 |
^ 'yes' |
113 | 885 |
] ifFalse:[^ 'no'] |
47 | 886 |
! |
887 |
||
113 | 888 |
_testSmalltalk_if_isSmalltalkX |
47 | 889 |
Smalltalk isSmalltalkX ifTrue:[ |
648 | 890 |
^ 'yes' |
113 | 891 |
]. |
892 |
^ 'no' |
|
893 |
! |
|
894 |
||
895 |
_testSmalltalk_if_isSqueak |
|
896 |
Smalltalk isSqueak ifTrue:[ |
|
648 | 897 |
^ 'yes' |
47 | 898 |
]. |
899 |
^ 'no' |
|
900 |
! |
|
901 |
||
113 | 902 |
_testSmalltalk_if_isVisualWorks |
47 | 903 |
Smalltalk isVisualWorks ifTrue:[ |
648 | 904 |
^ 'yes' |
47 | 905 |
]. |
906 |
^ 'no' |
|
907 |
! |
|
908 |
||
113 | 909 |
_testSmalltalk_isSmalltalkX |
47 | 910 |
^ Smalltalk isSmalltalkX |
911 |
! |
|
912 |
||
113 | 913 |
_testSmalltalk_isSqueak |
47 | 914 |
^ Smalltalk isSqueak |
915 |
! |
|
916 |
||
113 | 917 |
_testSmalltalk_isVisualAge |
47 | 918 |
^ Smalltalk isVisualAge |
919 |
! |
|
920 |
||
113 | 921 |
_testSmalltalk_isVisualWorks |
47 | 922 |
^ Smalltalk isVisualWorks |
923 |
! |
|
924 |
||
113 | 925 |
_testUnaryFolding |
926 |
self _testFloat_pi ~= (Float perform:#pi) ifTrue:[ |
|
648 | 927 |
self halt |
113 | 928 |
]. |
929 |
self _testFloat_unity ~= (Float perform:#unity) ifTrue:[ |
|
648 | 930 |
self halt |
113 | 931 |
]. |
932 |
self _testFloat_zero ~= (Float perform:#zero) ifTrue:[ |
|
648 | 933 |
self halt |
113 | 934 |
]. |
935 |
self _testSmalltalk_isSmalltalkX ~= (Smalltalk perform:#isSmalltalkX) ifTrue:[ |
|
648 | 936 |
self halt |
113 | 937 |
]. |
938 |
self _testSmalltalk_isSqueak ~= (Smalltalk perform:#isSqueak) ifTrue:[ |
|
648 | 939 |
self halt |
113 | 940 |
]. |
941 |
self _testSmalltalk_isVisualWorks ~= (Smalltalk perform:#isVisualWorks) ifTrue:[ |
|
648 | 942 |
self halt |
113 | 943 |
]. |
944 |
self _testSmalltalk_isVisualAge ~= (Smalltalk perform:#isVisualAge) ifTrue:[ |
|
648 | 945 |
self halt |
113 | 946 |
] |
47 | 947 |
|
948 |
" |
|
113 | 949 |
self basicNew _testUnaryFolding |
47 | 950 |
" |
951 |
! ! |
|
952 |
||
568 | 953 |
!CompilerTest methodsFor:'tests - context setup'! |
954 |
||
955 |
_testContextA |
|
956 |
ObjectMemory dumpObject:thisContext |
|
957 |
||
958 |
" |
|
648 | 959 |
self new _testContextA |
568 | 960 |
" |
961 |
! |
|
962 |
||
963 |
_testContextB |
|
964 |
ObjectMemory dumpObject:thisContext sender |
|
965 |
||
966 |
" |
|
648 | 967 |
self new _testContextB |
568 | 968 |
" |
969 |
! |
|
970 |
||
971 |
_testContextC |
|
972 |
thisContext fullPrintAll |
|
973 |
||
974 |
" |
|
648 | 975 |
self new _testContextC |
568 | 976 |
" |
977 |
! |
|
978 |
||
979 |
_testContextD |
|
980 |
self _testContextB |
|
981 |
||
982 |
" |
|
648 | 983 |
self new _testContextD |
568 | 984 |
" |
985 |
! |
|
986 |
||
987 |
_testContextE |
|
988 |
^ thisContext sender |
|
989 |
||
990 |
" |
|
648 | 991 |
self new _testContextE |
568 | 992 |
" |
993 |
! |
|
994 |
||
995 |
_testContextF |
|
996 |
^ self _testContextE |
|
997 |
||
998 |
" |
|
648 | 999 |
self new _testContextF |
568 | 1000 |
" |
1001 |
! |
|
1002 |
||
1003 |
_testSend0 |
|
1004 |
^ 9999 |
|
1005 |
! |
|
1006 |
||
648 | 1007 |
_testSend0B:arg |
568 | 1008 |
^ arg |
1009 |
! |
|
1010 |
||
1011 |
_testSend1 |
|
1012 |
^ self _testSend0 |
|
1013 |
||
1014 |
" |
|
648 | 1015 |
self new testSend1 |
568 | 1016 |
" |
1017 |
! |
|
1018 |
||
1019 |
_testSend1B |
|
1020 |
^ self _testSend0B:1234 |
|
1021 |
||
1022 |
" |
|
648 | 1023 |
self new testSend1B |
568 | 1024 |
" |
1025 |
! |
|
1026 |
||
648 | 1027 |
_testSend1C:arg |
568 | 1028 |
^ self _testSend0B:arg |
1029 |
||
1030 |
" |
|
648 | 1031 |
self new testSend1C:9998 |
568 | 1032 |
" |
1033 |
! |
|
1034 |
||
1035 |
_testSend2 |
|
1036 |
self _testContextB |
|
1037 |
||
1038 |
" |
|
648 | 1039 |
self new testSend2 |
568 | 1040 |
" |
1041 |
! |
|
1042 |
||
1043 |
_testSend3 |
|
1044 |
self _testContextC |
|
1045 |
||
1046 |
" |
|
648 | 1047 |
self new testSend3 |
568 | 1048 |
" |
1049 |
! |
|
1050 |
||
1051 |
retArgWithFrameA:arg |
|
1052 |
|a b c| |
|
1053 |
||
1054 |
a := 0. |
|
1055 |
b := 1. |
|
1056 |
c := 2. |
|
1057 |
^ arg |
|
1058 |
||
1059 |
" |
|
648 | 1060 |
self new retArgWithFrameA:999 |
568 | 1061 |
" |
1062 |
! |
|
1063 |
||
1064 |
retArgWithFrameB:arg |
|
1065 |
|a b c| |
|
1066 |
||
1067 |
a := 0. |
|
1068 |
b := 1. |
|
1069 |
c := 2. |
|
1070 |
self retSelf. |
|
1071 |
||
1072 |
^ arg |
|
1073 |
||
1074 |
" |
|
648 | 1075 |
self new retArgWithFrameB:9999 |
568 | 1076 |
" |
1077 |
! |
|
1078 |
||
1079 |
retLocal |
|
1080 |
|a| |
|
1081 |
||
1082 |
a := 0. |
|
1083 |
^ a |
|
1084 |
||
1085 |
" |
|
648 | 1086 |
self new retLocal |
1087 |
1000000 timesRepeat:[self new retInstVar] |
|
1088 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ] |
|
568 | 1089 |
" |
1090 |
||
1091 |
" |
|
1092 |
|i| |
|
1093 |
||
1094 |
i := self new. |
|
1095 |
i instVarAt:1 put:12345. |
|
648 | 1096 |
i retInstVar |
568 | 1097 |
" |
1098 |
||
1099 |
" |
|
1100 |
|i| |
|
1101 |
i := self new. |
|
1102 |
i instVarAt:1 put:12345. |
|
648 | 1103 |
1000000 timesRepeat:[i retInstVar] |
568 | 1104 |
" |
1105 |
||
1106 |
" |
|
1107 |
|i| |
|
1108 |
i := self new. |
|
1109 |
i instVarAt:1 put:12345. |
|
648 | 1110 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ] |
568 | 1111 |
" |
1112 |
||
1113 |
||
1114 |
! |
|
1115 |
||
1116 |
retLocalB |
|
1117 |
|a b c| |
|
1118 |
||
1119 |
a := 0. |
|
1120 |
b := 1. |
|
1121 |
c := 2. |
|
1122 |
^ a |
|
1123 |
||
1124 |
" |
|
648 | 1125 |
self new retLocalB |
1126 |
1000000 timesRepeat:[self new retLocalB] |
|
1127 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ] |
|
1128 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retLocalB] ] |
|
568 | 1129 |
" |
1130 |
||
1131 |
" |
|
1132 |
|i| |
|
1133 |
||
1134 |
i := self new. |
|
1135 |
i instVarAt:1 put:12345. |
|
648 | 1136 |
i retInstVar |
568 | 1137 |
" |
1138 |
||
1139 |
" |
|
1140 |
|i| |
|
1141 |
i := self new. |
|
1142 |
i instVarAt:1 put:12345. |
|
648 | 1143 |
1000000 timesRepeat:[i retInstVar] |
568 | 1144 |
" |
1145 |
||
1146 |
" |
|
1147 |
|i| |
|
1148 |
i := self new. |
|
1149 |
i instVarAt:1 put:12345. |
|
648 | 1150 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ] |
568 | 1151 |
" |
1152 |
||
1153 |
||
1154 |
! |
|
1155 |
||
1156 |
retLocalC |
|
1157 |
|a b c| |
|
1158 |
||
1159 |
a := 0. |
|
1160 |
b := 1. |
|
1161 |
c := 2. |
|
1162 |
^ b |
|
1163 |
||
1164 |
" |
|
648 | 1165 |
self new retLocalC |
1166 |
1000000 timesRepeat:[self new retInstVar] |
|
1167 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ] |
|
568 | 1168 |
" |
1169 |
||
1170 |
" |
|
1171 |
|i| |
|
1172 |
||
1173 |
i := self new. |
|
1174 |
i instVarAt:1 put:12345. |
|
648 | 1175 |
i retInstVar |
568 | 1176 |
" |
1177 |
||
1178 |
" |
|
1179 |
|i| |
|
1180 |
i := self new. |
|
1181 |
i instVarAt:1 put:12345. |
|
648 | 1182 |
1000000 timesRepeat:[i retInstVar] |
568 | 1183 |
" |
1184 |
||
1185 |
" |
|
1186 |
|i| |
|
1187 |
i := self new. |
|
1188 |
i instVarAt:1 put:12345. |
|
648 | 1189 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ] |
568 | 1190 |
" |
1191 |
||
1192 |
||
1193 |
! |
|
1194 |
||
1195 |
retLocalD |
|
1196 |
|a b c| |
|
1197 |
||
1198 |
a := 0. |
|
1199 |
b := 1. |
|
1200 |
c := 2. |
|
1201 |
^ c |
|
1202 |
||
1203 |
" |
|
648 | 1204 |
self new retLocalD |
1205 |
1000000 timesRepeat:[self new retInstVar] |
|
1206 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ] |
|
568 | 1207 |
" |
1208 |
||
1209 |
" |
|
1210 |
|i| |
|
1211 |
||
1212 |
i := self new. |
|
1213 |
i instVarAt:1 put:12345. |
|
648 | 1214 |
i retInstVar |
568 | 1215 |
" |
1216 |
||
1217 |
" |
|
1218 |
|i| |
|
1219 |
i := self new. |
|
1220 |
i instVarAt:1 put:12345. |
|
648 | 1221 |
1000000 timesRepeat:[i retInstVar] |
568 | 1222 |
" |
1223 |
||
1224 |
" |
|
1225 |
|i| |
|
1226 |
i := self new. |
|
1227 |
i instVarAt:1 put:12345. |
|
648 | 1228 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ] |
568 | 1229 |
" |
1230 |
||
1231 |
||
1232 |
! |
|
1233 |
||
1234 |
retLocalE |
|
1235 |
|a b c| |
|
1236 |
||
1237 |
a := 0. |
|
1238 |
b := 1. |
|
1239 |
c := 2. |
|
1240 |
^ self |
|
1241 |
||
1242 |
" |
|
648 | 1243 |
self new retLocalE |
1244 |
1000000 timesRepeat:[self new retInstVar] |
|
1245 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ] |
|
568 | 1246 |
" |
1247 |
||
1248 |
" |
|
1249 |
|i| |
|
1250 |
||
1251 |
i := self new. |
|
1252 |
i instVarAt:1 put:12345. |
|
648 | 1253 |
i retInstVar |
568 | 1254 |
" |
1255 |
||
1256 |
" |
|
1257 |
|i| |
|
1258 |
i := self new. |
|
1259 |
i instVarAt:1 put:12345. |
|
648 | 1260 |
1000000 timesRepeat:[i retInstVar] |
568 | 1261 |
" |
1262 |
||
1263 |
" |
|
1264 |
|i| |
|
1265 |
i := self new. |
|
1266 |
i instVarAt:1 put:12345. |
|
648 | 1267 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ] |
568 | 1268 |
" |
1269 |
||
1270 |
||
1271 |
! |
|
1272 |
||
1273 |
retLocalF |
|
1274 |
|a b c| |
|
1275 |
||
1276 |
a := 0. |
|
1277 |
b := 1. |
|
1278 |
c := 2. |
|
1279 |
self retSelf. |
|
1280 |
||
1281 |
^ a |
|
1282 |
||
1283 |
" |
|
648 | 1284 |
self new retLocalF |
568 | 1285 |
" |
1286 |
||
1287 |
||
1288 |
||
1289 |
! |
|
1290 |
||
1291 |
retLocalG |
|
1292 |
|a b c| |
|
1293 |
||
1294 |
a := 0. |
|
1295 |
b := 1. |
|
1296 |
c := 2. |
|
1297 |
self retSelf. |
|
1298 |
||
1299 |
^ b |
|
1300 |
||
1301 |
" |
|
648 | 1302 |
self new retLocalG |
568 | 1303 |
" |
1304 |
||
1305 |
||
1306 |
||
1307 |
! |
|
1308 |
||
1309 |
retLocalH |
|
1310 |
|a b c| |
|
1311 |
||
1312 |
a := 0. |
|
1313 |
b := 1. |
|
1314 |
c := 2. |
|
1315 |
self retSelf. |
|
1316 |
||
1317 |
^ c |
|
1318 |
||
1319 |
" |
|
648 | 1320 |
self new retLocalH |
568 | 1321 |
" |
1322 |
||
1323 |
||
1324 |
||
1325 |
! |
|
1326 |
||
1327 |
retSelf |
|
1328 |
||
1329 |
||
1330 |
! ! |
|
1331 |
||
1332 |
!CompilerTest methodsFor:'tests - entry'! |
|
1333 |
||
1334 |
ilcMissCheck |
|
1335 |
||
1336 |
||
1337 |
||
1338 |
" |
|
648 | 1339 |
(Array with:self new with:nil) do:[:el | el size printCR.]. |
568 | 1340 |
" |
1341 |
||
1342 |
||
1343 |
||
1344 |
! ! |
|
1345 |
||
87 | 1346 |
!CompilerTest methodsFor:'tests - inlined'! |
1347 |
||
648 | 1348 |
_test_even:arg |
87 | 1349 |
^ arg even |
1350 |
||
1351 |
" |
|
648 | 1352 |
self new _test_even:nil |
113 | 1353 |
self new _test_even:123 |
1354 |
self new _test_even:122 |
|
1355 |
self new _test_even:(100 factorial) |
|
87 | 1356 |
" |
1357 |
! |
|
1358 |
||
648 | 1359 |
_test_isInteger:arg |
87 | 1360 |
^ arg isInteger |
1361 |
||
1362 |
" |
|
648 | 1363 |
self new _test_isInteger:nil |
113 | 1364 |
self new _test_isInteger:123 |
1365 |
self new _test_isInteger:(100 factorial) |
|
87 | 1366 |
" |
1367 |
! |
|
1368 |
||
648 | 1369 |
_test_isNotInteger:arg |
87 | 1370 |
^ arg isInteger not |
1371 |
||
1372 |
" |
|
648 | 1373 |
self new _test_isNotInteger:nil |
113 | 1374 |
self new _test_isNotInteger:123 |
1375 |
self new _test_isNotInteger:(100 factorial) |
|
87 | 1376 |
" |
1377 |
! |
|
1378 |
||
648 | 1379 |
_test_max1:arg1 _:arg2 |
87 | 1380 |
^ arg1 max:arg2 |
1381 |
||
1382 |
" |
|
648 | 1383 |
self new _test_max1:nil _:nil |
1384 |
self new _test_max1:1 _:nil |
|
1385 |
self new _test_max1:nil _:1 |
|
1386 |
self new _test_max1:1 _:2 |
|
1387 |
self new _test_max1:2 _:1 |
|
1388 |
||
1389 |
self new _test_max1:1.0 _:nil |
|
1390 |
self new _test_max1:nil _:1.0 |
|
1391 |
self new _test_max1:1.0 _:2.0 |
|
1392 |
self new _test_max1:2.0 _:1.0 |
|
1393 |
||
1394 |
self new _test_max1:1.0 _:2 |
|
1395 |
self new _test_max1:2.0 _:1 |
|
1396 |
self new _test_max1:1 _:2.0 |
|
1397 |
self new _test_max1:2 _:1.0 |
|
87 | 1398 |
" |
1399 |
! |
|
1400 |
||
648 | 1401 |
_test_max2:arg |
87 | 1402 |
^ 1 max:arg |
1403 |
||
1404 |
" |
|
648 | 1405 |
self new _test_max2:nil |
1406 |
self new _test_max2:0 |
|
1407 |
self new _test_max2:1 |
|
1408 |
self new _test_max2:2 |
|
1409 |
||
1410 |
self new _test_max2:0.0 |
|
1411 |
self new _test_max2:1.0 |
|
1412 |
self new _test_max2:2.0 |
|
87 | 1413 |
" |
1414 |
! |
|
1415 |
||
648 | 1416 |
_test_max3:arg |
87 | 1417 |
|var| |
1418 |
||
1419 |
var := Array new:10. |
|
1420 |
^ 1 max:arg |
|
1421 |
||
1422 |
" |
|
648 | 1423 |
self new _test_max3:nil |
1424 |
self new _test_max3:0 |
|
1425 |
self new _test_max3:1 |
|
1426 |
self new _test_max3:2 |
|
1427 |
||
1428 |
self new _test_max3:0.0 |
|
1429 |
self new _test_max3:1.0 |
|
1430 |
self new _test_max3:2.0 |
|
87 | 1431 |
" |
1432 |
! |
|
1433 |
||
648 | 1434 |
_test_max4:arg |
87 | 1435 |
|var| |
1436 |
||
1437 |
var := Array new:10. |
|
1438 |
^ arg max:1 |
|
1439 |
||
1440 |
" |
|
648 | 1441 |
self new _test_max4:nil |
1442 |
self new _test_max4:0 |
|
1443 |
self new _test_max4:1 |
|
1444 |
self new _test_max4:2 |
|
1445 |
||
1446 |
self new _test_max4:0.0 |
|
1447 |
self new _test_max4:1.0 |
|
1448 |
self new _test_max4:2.0 |
|
87 | 1449 |
" |
1450 |
! |
|
1451 |
||
648 | 1452 |
_test_min1:arg1 _:arg2 |
87 | 1453 |
^ arg1 min:arg2 |
1454 |
||
1455 |
" |
|
648 | 1456 |
self new _test_min1:nil _:nil |
1457 |
self new _test_min1:1 _:nil |
|
1458 |
self new _test_min1:nil _:1 |
|
1459 |
self new _test_min1:1 _:2 |
|
1460 |
self new _test_min1:2 _:1 |
|
1461 |
||
1462 |
self new _test_min1:1.0 _:nil |
|
1463 |
self new _test_min1:nil _:1.0 |
|
1464 |
self new _test_min1:1.0 _:2.0 |
|
1465 |
self new _test_min1:2.0 _:1.0 |
|
1466 |
||
1467 |
self new _test_min1:1.0 _:2 |
|
1468 |
self new _test_min1:2.0 _:1 |
|
1469 |
self new _test_min1:1 _:2.0 |
|
1470 |
self new _test_min1:2 _:1.0 |
|
87 | 1471 |
" |
1472 |
! |
|
1473 |
||
648 | 1474 |
_test_min2:arg |
87 | 1475 |
^ 1 min:arg |
1476 |
||
1477 |
" |
|
648 | 1478 |
self new _test_min2:nil |
1479 |
self new _test_min2:0 |
|
1480 |
self new _test_min2:1 |
|
1481 |
self new _test_min2:2 |
|
1482 |
||
1483 |
self new _test_min2:0.0 |
|
1484 |
self new _test_min2:1.0 |
|
1485 |
self new _test_min2:2.0 |
|
87 | 1486 |
" |
1487 |
! |
|
1488 |
||
648 | 1489 |
_test_min3:arg |
87 | 1490 |
|var| |
1491 |
||
1492 |
var := Array new:10. |
|
1493 |
^ 1 min:arg |
|
1494 |
||
1495 |
" |
|
648 | 1496 |
self new _test_min3:nil |
1497 |
self new _test_min3:0 |
|
1498 |
self new _test_min3:1 |
|
1499 |
self new _test_min3:2 |
|
1500 |
||
1501 |
self new _test_min3:0.0 |
|
1502 |
self new _test_min3:1.0 |
|
1503 |
self new _test_min3:2.0 |
|
87 | 1504 |
" |
1505 |
! |
|
1506 |
||
648 | 1507 |
_test_min4:arg |
87 | 1508 |
|var| |
1509 |
||
1510 |
var := Array new:10. |
|
1511 |
^ arg min:1 |
|
1512 |
||
1513 |
" |
|
648 | 1514 |
self new _test_min4:nil |
1515 |
self new _test_min4:0 |
|
1516 |
self new _test_min4:1 |
|
1517 |
self new _test_min4:2 |
|
1518 |
||
1519 |
self new _test_min4:0.0 |
|
1520 |
self new _test_min4:1.0 |
|
1521 |
self new _test_min4:2.0 |
|
87 | 1522 |
" |
1523 |
! |
|
1524 |
||
648 | 1525 |
_test_odd:arg |
87 | 1526 |
^ arg odd |
1527 |
||
1528 |
" |
|
648 | 1529 |
self new _test_odd:nil |
1530 |
self new _test_odd:123 |
|
1531 |
self new _test_odd:122 |
|
1532 |
self new _test_odd:(100 factorial) |
|
87 | 1533 |
" |
1534 |
! |
|
1535 |
||
113 | 1536 |
_test_size |
87 | 1537 |
^ value size |
1538 |
||
1539 |
" |
|
113 | 1540 |
(self new value:(Array new:2)) _test_size |
1541 |
(self new value:(OrderedCollection new:2)) _test_size |
|
1542 |
" |
|
1543 |
! ! |
|
1544 |
||
568 | 1545 |
!CompilerTest methodsFor:'tests - instvar access'! |
1546 |
||
1547 |
retInstVar |
|
1548 |
^ value |
|
1549 |
||
1550 |
" |
|
648 | 1551 |
self new retInstVar |
1552 |
1000000 timesRepeat:[self new retInstVar] |
|
1553 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ] |
|
568 | 1554 |
" |
1555 |
||
1556 |
" |
|
1557 |
|i| |
|
1558 |
||
1559 |
i := self new. |
|
1560 |
i instVarAt:1 put:12345. |
|
648 | 1561 |
i retInstVar |
568 | 1562 |
" |
1563 |
||
1564 |
" |
|
1565 |
|i| |
|
1566 |
i := self new. |
|
1567 |
i instVarAt:1 put:12345. |
|
648 | 1568 |
1000000 timesRepeat:[i retInstVar] |
568 | 1569 |
" |
1570 |
||
1571 |
" |
|
1572 |
|i| |
|
1573 |
i := self new. |
|
1574 |
i instVarAt:1 put:12345. |
|
648 | 1575 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ] |
568 | 1576 |
" |
1577 |
||
1578 |
||
1579 |
! |
|
1580 |
||
1581 |
setInstVarA |
|
1582 |
value := 123 |
|
1583 |
||
1584 |
" |
|
648 | 1585 |
self new setInstVarA; instVarAt:1 |
1586 |
1000000 timesRepeat:[self new setInstVarA] |
|
1587 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new setInstVarA] ] |
|
568 | 1588 |
" |
1589 |
||
1590 |
" |
|
1591 |
|i| |
|
1592 |
||
1593 |
i := self new. |
|
1594 |
i instVarAt:1 put:12345. |
|
1595 |
i setInstVarA. |
|
648 | 1596 |
i instVarAt:1 |
568 | 1597 |
" |
1598 |
||
1599 |
||
1600 |
||
1601 |
! |
|
1602 |
||
1603 |
setInstVarB |
|
1604 |
value := 'hello' |
|
1605 |
||
1606 |
" |
|
648 | 1607 |
self new setInstVarB; instVarAt:1 |
1608 |
1000000 timesRepeat:[self new setInstVarB] |
|
1609 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new setInstVarB] ] |
|
568 | 1610 |
" |
1611 |
||
1612 |
" |
|
1613 |
|i| |
|
1614 |
||
1615 |
i := self new. |
|
1616 |
i instVarAt:1 put:12345. |
|
1617 |
i setInstVarB. |
|
648 | 1618 |
i instVarAt:1 |
568 | 1619 |
" |
1620 |
||
1621 |
||
1622 |
||
1623 |
! ! |
|
1624 |
||
1625 |
!CompilerTest methodsFor:'tests - literals'! |
|
1626 |
||
1627 |
testLiterals |
|
1628 |
" |
|
1629 |
self new testLiterals |
|
1630 |
" |
|
1631 |
|m| |
|
1632 |
||
1633 |
"/ literals must be present, even if code has been optimized away |
|
1634 |
"/ (otherwise, searches do not work correctly) |
|
1635 |
||
648 | 1636 |
m := self compile:'foo:arg |v| ^ (v ~~ 0) not'. |
568 | 1637 |
self assert:(m literals includesIdentical:#'~~'). |
1638 |
self assert:(m literals includesIdentical:#'not'). |
|
1639 |
||
648 | 1640 |
m := self compile:'foo:arg |v| ^ (v == 0) not'. |
568 | 1641 |
self assert:(m literals includesIdentical:#'=='). |
1642 |
self assert:(m literals includesIdentical:#'not'). |
|
1643 |
||
1644 |
||
648 | 1645 |
m := self compile:'foo:arg ^ arg not'. |
568 | 1646 |
self assert:(m literals includesIdentical:#'not'). |
1647 |
||
648 | 1648 |
m := self compile:'foo:arg ^ arg notNil'. |
568 | 1649 |
self assert:(m literals includesIdentical:#'notNil'). |
648 | 1650 |
m := self compile:'foo:arg ^ arg isNil'. |
568 | 1651 |
self assert:(m literals includesIdentical:#'isNil'). |
1652 |
||
1653 |
||
648 | 1654 |
m := self compile:'foo:arg |v| v := v+1'. |
568 | 1655 |
self assert:(m literals includesIdentical:#'+'). |
1656 |
||
648 | 1657 |
m := self compile:'foo:arg |v| v := v-1'. |
568 | 1658 |
self assert:(m literals includesIdentical:#'-'). |
1659 |
||
1660 |
||
648 | 1661 |
m := self compile:'foo:arg |v| v := v not'. |
568 | 1662 |
self assert:(m literals includesIdentical:#'not'). |
1663 |
||
1664 |
||
648 | 1665 |
m := self compile:'foo:arg ^ arg ifTrue:1'. |
568 | 1666 |
self assert:(m literals includesIdentical:#'ifTrue:'). |
1667 |
||
648 | 1668 |
m := self compile:'foo:arg ^ arg ifFalse:1'. |
568 | 1669 |
self assert:(m literals includesIdentical:#'ifFalse:'). |
1670 |
||
648 | 1671 |
m := self compile:'foo:arg ^ arg ifTrue:1 ifFalse:2'. |
568 | 1672 |
self assert:(m literals includesIdentical:#'ifTrue:ifFalse:'). |
1673 |
||
648 | 1674 |
m := self compile:'foo:arg ^ arg ifFalse:1 ifTrue:2'. |
568 | 1675 |
self assert:(m literals includesIdentical:#'ifFalse:ifTrue:'). |
1676 |
||
1677 |
||
648 | 1678 |
m := self compile:'foo:arg ^ arg isNil ifTrue:1'. |
568 | 1679 |
self assert:(m literals includesIdentical:#'ifTrue:'). |
1680 |
self assert:(m literals includesIdentical:#'isNil'). |
|
1681 |
||
648 | 1682 |
m := self compile:'foo:arg ^ arg isNil ifFalse:1'. |
568 | 1683 |
self assert:(m literals includesIdentical:#'ifFalse:'). |
1684 |
self assert:(m literals includesIdentical:#'isNil'). |
|
1685 |
||
648 | 1686 |
m := self compile:'foo:arg ^ arg isNil ifTrue:1 ifFalse:2'. |
568 | 1687 |
self assert:(m literals includesIdentical:#'ifTrue:ifFalse:'). |
1688 |
self assert:(m literals includesIdentical:#'isNil'). |
|
1689 |
||
648 | 1690 |
m := self compile:'foo:arg ^ arg isNil ifFalse:1 ifTrue:2'. |
568 | 1691 |
self assert:(m literals includesIdentical:#'ifFalse:ifTrue:'). |
1692 |
self assert:(m literals includesIdentical:#'isNil'). |
|
1693 |
||
1694 |
||
648 | 1695 |
m := self compile:'foo:arg ^ arg notNil ifTrue:1'. |
568 | 1696 |
self assert:(m literals includesIdentical:#'ifTrue:'). |
1697 |
self assert:(m literals includesIdentical:#'notNil'). |
|
1698 |
||
648 | 1699 |
m := self compile:'foo:arg ^ arg notNil ifFalse:1'. |
568 | 1700 |
self assert:(m literals includesIdentical:#'ifFalse:'). |
1701 |
self assert:(m literals includesIdentical:#'notNil'). |
|
1702 |
||
648 | 1703 |
m := self compile:'foo:arg ^ arg notNil ifTrue:1 ifFalse:2'. |
568 | 1704 |
self assert:(m literals includesIdentical:#'ifTrue:ifFalse:'). |
1705 |
self assert:(m literals includesIdentical:#'notNil'). |
|
1706 |
||
648 | 1707 |
m := self compile:'foo:arg ^ arg notNil ifFalse:1 ifTrue:2'. |
568 | 1708 |
self assert:(m literals includesIdentical:#'ifFalse:ifTrue:'). |
1709 |
self assert:(m literals includesIdentical:#'notNil'). |
|
1710 |
||
1711 |
||
648 | 1712 |
m := self compile:'foo:arg ^ arg not ifTrue:1'. |
568 | 1713 |
self assert:(m literals includesIdentical:#'ifTrue:'). |
1714 |
self assert:(m literals includesIdentical:#'not'). |
|
1715 |
||
648 | 1716 |
m := self compile:'foo:arg ^ arg not ifFalse:1'. |
568 | 1717 |
self assert:(m literals includesIdentical:#'ifFalse:'). |
1718 |
self assert:(m literals includesIdentical:#'not'). |
|
1719 |
||
648 | 1720 |
m := self compile:'foo:arg ^ arg not ifTrue:1 ifFalse:2'. |
568 | 1721 |
self assert:(m literals includesIdentical:#'ifTrue:ifFalse:'). |
1722 |
self assert:(m literals includesIdentical:#'not'). |
|
1723 |
||
648 | 1724 |
m := self compile:'foo:arg ^ arg not ifFalse:1 ifTrue:2'. |
568 | 1725 |
self assert:(m literals includesIdentical:#'ifFalse:ifTrue:'). |
1726 |
self assert:(m literals includesIdentical:#'not'). |
|
1727 |
||
1728 |
||
648 | 1729 |
m := self compile:'foo:arg ^ arg and:[true]'. |
568 | 1730 |
self assert:(m literals includesIdentical:#'and:'). |
1731 |
||
648 | 1732 |
m := self compile:'foo:arg ^ arg not and:[true]'. |
568 | 1733 |
self assert:(m literals includesIdentical:#'and:'). |
1734 |
self assert:(m literals includesIdentical:#'not'). |
|
1735 |
||
648 | 1736 |
m := self compile:'foo:arg ^ arg or:[true]'. |
568 | 1737 |
self assert:(m literals includesIdentical:#'or:'). |
1738 |
||
648 | 1739 |
m := self compile:'foo:arg ^ arg not or:[true]'. |
568 | 1740 |
self assert:(m literals includesIdentical:#'or:'). |
1741 |
self assert:(m literals includesIdentical:#'not'). |
|
1742 |
||
648 | 1743 |
m := self compile:'foo:arg ^ (arg or:[true]) ifTrue:[1234]'. |
568 | 1744 |
self assert:(m literals includesIdentical:#'or:'). |
1745 |
self assert:(m literals includesIdentical:#'ifTrue:'). |
|
1746 |
||
648 | 1747 |
m := self compile:'foo:arg ^ (arg or:[true]) ifFalse:[1234]'. |
568 | 1748 |
self assert:(m literals includesIdentical:#'or:'). |
1749 |
self assert:(m literals includesIdentical:#'ifFalse:'). |
|
1750 |
||
648 | 1751 |
m := self compile:'foo:arg ^ (arg or:[true]) ifTrue:1 ifFalse:2'. |
568 | 1752 |
self assert:(m literals includesIdentical:#'or:'). |
1753 |
self assert:(m literals includesIdentical:#'ifTrue:ifFalse:'). |
|
1754 |
||
648 | 1755 |
m := self compile:'foo:arg ^ (arg or:[true]) ifFalse:1 ifTrue:2'. |
568 | 1756 |
self assert:(m literals includesIdentical:#'or:'). |
1757 |
self assert:(m literals includesIdentical:#'ifFalse:ifTrue:'). |
|
1758 |
||
1759 |
||
648 | 1760 |
m := self compile:'foo:arg ^ [ ] loop'. |
568 | 1761 |
self assert:(m literals includesIdentical:#'loop'). |
1762 |
||
648 | 1763 |
m := self compile:'foo:arg ^ [ ] repeat'. |
568 | 1764 |
self assert:(m literals includesIdentical:#'repeat'). |
1765 |
||
648 | 1766 |
m := self compile:'foo:arg ^ arg ? 123'. |
568 | 1767 |
self assert:(m literals includesIdentical:#'?'). |
1768 |
||
1769 |
" |
|
1770 |
self new testLiterals |
|
1771 |
" |
|
1772 |
! ! |
|
1773 |
||
188 | 1774 |
!CompilerTest methodsFor:'tests - method calls'! |
1775 |
||
189 | 1776 |
addDumpingMethodForSelfIsLostBug |
1777 |
|code mthd| |
|
1778 |
||
648 | 1779 |
code := |
1780 |
'_x |
|
190 | 1781 |
"/ ObjectMemory dumpSender. |
189 | 1782 |
"/ request nextPutAll: ''a''. |
648 | 1783 |
ObjectMemory garbageCollect. |
189 | 1784 |
ObjectMemory dumpSender. |
1785 |
"/ request nextPutAll: ''b''. |
|
1786 |
'. |
|
1787 |
||
1788 |
Class withoutUpdatingChangesDo:[ |
|
648 | 1789 |
mthd := (Smalltalk at:#Compiler) |
1790 |
compile:code |
|
1791 |
in:DummyClass |
|
1792 |
notifying:nil |
|
1793 |
ifFail:[self error]. |
|
189 | 1794 |
]. |
1795 |
^ mthd |
|
1796 |
! |
|
1797 |
||
1798 |
addHaltingMethodForSelfIsLostBug |
|
1799 |
|code mthd| |
|
1800 |
||
648 | 1801 |
code := |
1802 |
'_x |
|
189 | 1803 |
request nextPutAll: ''a''. |
1804 |
self halt. |
|
648 | 1805 |
ObjectMemory garbageCollect. |
189 | 1806 |
self halt. |
1807 |
request nextPutAll: ''b''. |
|
1808 |
'. |
|
1809 |
||
1810 |
Class withoutUpdatingChangesDo:[ |
|
648 | 1811 |
mthd := (Smalltalk at:#Compiler) |
1812 |
compile:code |
|
1813 |
in:DummyClass |
|
1814 |
notifying:nil |
|
1815 |
ifFail:[self error]. |
|
189 | 1816 |
]. |
1817 |
^ mthd |
|
1818 |
! |
|
1819 |
||
188 | 1820 |
addMethodForSelfIsLostBug |
1821 |
|code mthd| |
|
1822 |
||
648 | 1823 |
code := |
1824 |
'_x |
|
188 | 1825 |
request nextPutAll: ''a''. |
648 | 1826 |
ObjectMemory garbageCollect. |
188 | 1827 |
request nextPutAll: ''b''. |
1828 |
'. |
|
1829 |
||
1830 |
Class withoutUpdatingChangesDo:[ |
|
648 | 1831 |
mthd := (Smalltalk at:#Compiler) |
1832 |
compile:code |
|
1833 |
in:DummyClass |
|
1834 |
notifying:nil |
|
1835 |
ifFail:[self error]. |
|
188 | 1836 |
]. |
1837 |
^ mthd |
|
1838 |
! |
|
1839 |
||
1840 |
removeMethodForSelfIsLostBug |
|
1841 |
Class withoutUpdatingChangesDo:[ |
|
648 | 1842 |
DummyClass removeSelector:#'_x'. |
188 | 1843 |
]. |
1844 |
! |
|
1845 |
||
648 | 1846 |
test_selfIsLost1 |
188 | 1847 |
|mthd rcvr retVal str| |
1848 |
||
1849 |
str := '' writeStream. |
|
1850 |
||
1851 |
mthd := self addMethodForSelfIsLostBug. |
|
1852 |
self removeMethodForSelfIsLostBug. |
|
1853 |
rcvr := DummyClass new. |
|
1854 |
rcvr request:str. |
|
1855 |
retVal := mthd valueWithReceiver:rcvr arguments:#(). |
|
191 | 1856 |
self assert:(retVal == rcvr). |
1857 |
self assert:(str contents = 'ab'). |
|
188 | 1858 |
|
1859 |
" |
|
1860 |
self new test_selfIsLost1 |
|
1861 |
" |
|
1862 |
! |
|
1863 |
||
648 | 1864 |
test_selfIsLost2 |
188 | 1865 |
|mthd rcvr retVal str| |
1866 |
||
1867 |
str := '' writeStream. |
|
1868 |
||
1869 |
mthd := self addMethodForSelfIsLostBug. |
|
1870 |
rcvr := DummyClass new. |
|
1871 |
rcvr request:str. |
|
1872 |
||
1873 |
retVal := rcvr perform:#'_x'. |
|
1874 |
||
1875 |
self removeMethodForSelfIsLostBug. |
|
1876 |
||
191 | 1877 |
self assert:(retVal == rcvr). |
1878 |
self assert:(str contents = 'ab'). |
|
1879 |
||
188 | 1880 |
" |
1881 |
self new test_selfIsLost2 |
|
1882 |
" |
|
1883 |
! |
|
1884 |
||
648 | 1885 |
test_selfIsLost3 |
188 | 1886 |
|mthd rcvr retVal| |
1887 |
||
1888 |
mthd := DummyClass compiledMethodAt:#'_y0'. |
|
1889 |
||
1890 |
rcvr := DummyClass new. |
|
1891 |
||
1892 |
retVal := mthd valueWithReceiver:rcvr arguments:#(). |
|
1893 |
self assert:(retVal == rcvr). |
|
1894 |
||
1895 |
" |
|
1896 |
self new test_selfIsLost3 |
|
1897 |
" |
|
1898 |
! |
|
1899 |
||
648 | 1900 |
test_selfIsLost4 |
188 | 1901 |
|mthd rcvr retVal| |
1902 |
||
1903 |
mthd := DummyClass compiledMethodAt:#'_y1:'. |
|
1904 |
||
1905 |
rcvr := DummyClass new. |
|
1906 |
||
1907 |
retVal := mthd valueWithReceiver:rcvr arguments:(Array with:rcvr). |
|
191 | 1908 |
self assert:(retVal == rcvr). |
188 | 1909 |
|
1910 |
" |
|
1911 |
self new test_selfIsLost4 |
|
1912 |
" |
|
189 | 1913 |
! |
1914 |
||
648 | 1915 |
xtest_selfIsLost5 |
189 | 1916 |
|mthd rcvr retVal str| |
1917 |
||
1918 |
str := '' writeStream. |
|
1919 |
||
1920 |
mthd := self addHaltingMethodForSelfIsLostBug. |
|
1921 |
self removeMethodForSelfIsLostBug. |
|
1922 |
rcvr := DummyClass new. |
|
1923 |
rcvr request:str. |
|
1924 |
retVal := mthd valueWithReceiver:rcvr arguments:#(). |
|
1925 |
||
1926 |
" |
|
1927 |
self new xtest_selfIsLost5 |
|
1928 |
" |
|
1929 |
! |
|
1930 |
||
648 | 1931 |
xtest_selfIsLost6 |
189 | 1932 |
|mthd rcvr retVal str| |
1933 |
||
1934 |
str := '' writeStream. |
|
1935 |
||
1936 |
mthd := self addDumpingMethodForSelfIsLostBug. |
|
1937 |
self removeMethodForSelfIsLostBug. |
|
1938 |
rcvr := DummyClass new. |
|
1939 |
rcvr request:str. |
|
1940 |
retVal := mthd valueWithReceiver:rcvr arguments:#(). |
|
1941 |
||
1942 |
" |
|
1943 |
self new xtest_selfIsLost6 |
|
1944 |
" |
|
188 | 1945 |
! ! |
1946 |
||
113 | 1947 |
!CompilerTest methodsFor:'tests - parsing'! |
1948 |
||
1949 |
testParseBadLiteral |
|
668 | 1950 |
self should:[self class compile:'foo ^ #( a b ( c d (' ] raise:Parser parseErrorSignal. |
1951 |
self should:[self class compile:'foo ^ #( a b ( c d ()'] raise:Parser parseErrorSignal. |
|
1952 |
self should:[self class compile:'foo ^ #( a b ( c d ())'] raise:Parser parseErrorSignal. |
|
1953 |
self assert:((self class compile:'foo ^ #( a b ( c d ()))') ~~ #Error). |
|
113 | 1954 |
|
1955 |
" |
|
1956 |
self new testParseBadLiteral |
|
87 | 1957 |
" |
318 | 1958 |
! |
1959 |
||
1960 |
testParseExtendedSyntax |
|
1961 |
|compiler val| |
|
1962 |
||
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1963 |
"/ no longer: extended string syntax now needs a prefix |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1964 |
|
318 | 1965 |
compiler := Parser new. |
1966 |
val := compiler evaluate:' ''12\t34'' '. |
|
1967 |
self assert:( val = '12\t34' ) . |
|
1968 |
val := compiler evaluate:' ''12\u161634'' '. |
|
1969 |
self assert:( val = '12\u161634' ) . |
|
1970 |
||
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1971 |
"/ compiler parserFlags allowExtendedSTXSyntax:true. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1972 |
"/ val := compiler evaluate:' ''12\t34'' '. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1973 |
"/ self assert:( val = ('12' , Character tab , '34' )) . |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1974 |
"/ val := compiler evaluate:' ''12\u161634'' '. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1975 |
"/ self assert:( val = ('12' , (Character value:16r1616) , '34' )) . |
318 | 1976 |
|
1977 |
" |
|
1978 |
self new testParseExtendedSyntax |
|
1979 |
" |
|
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1980 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1981 |
"Modified (format): / 23-05-2019 / 13:50:37 / Claus Gittinger" |
686 | 1982 |
! |
1983 |
||
1984 |
xtestParseAllMethodsInTheSystem |
|
1985 |
|parser| |
|
1986 |
||
1987 |
Smalltalk allClassesDo:[:eachClass | |
|
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1988 |
Transcript showCR:'parsing all in ',eachClass name. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1989 |
eachClass instAndClassMethodsDo:[:mthd | |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1990 |
parser := Parser parseMethod:(mthd source) in:(mthd mclass). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1991 |
self assert:(parser ~~ #Error |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1992 |
and:[parser tree ~= #Error |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1993 |
and:[parser hasError ~~ true]]). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
1994 |
]. |
686 | 1995 |
]. |
1996 |
||
1997 |
" |
|
1998 |
self new xtestParseAllMethodsInTheSystem |
|
1999 |
" |
|
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2000 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2001 |
"Modified: / 23-05-2019 / 09:28:31 / Claus Gittinger" |
686 | 2002 |
! |
2003 |
||
2004 |
xtestRecompileAllMethodsInTheSystem |
|
2005 |
|parser| |
|
2006 |
||
2007 |
Smalltalk allClassesDo:[:eachClass | |
|
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2008 |
Transcript showCR:'parsing all in ',eachClass name. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2009 |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2010 |
parser := Parser parseMethod:(mthd source) in:(mthd mclass). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2011 |
self assert:(parser ~~ #Error |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2012 |
and:[parser tree ~= #Error |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2013 |
and:[parser hasError ~~ true]]). |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2014 |
parser hasPrimitiveCode ifFalse:[ |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2015 |
mthd mclass recompile:sel |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2016 |
]. |
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2017 |
]. |
686 | 2018 |
]. |
2019 |
||
2020 |
" |
|
2021 |
self new xtestRecompileAllMethodsInTheSystem |
|
2022 |
" |
|
2599
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2023 |
|
d0679511ef19
Cherry-picked `CompilerTest` from 84348e65ca8d:
Jan Vrany <jan.vrany@labware.com>
parents:
1500
diff
changeset
|
2024 |
"Modified: / 23-05-2019 / 09:28:34 / Claus Gittinger" |
87 | 2025 |
! ! |
2026 |
||
328 | 2027 |
!CompilerTest methodsFor:'tests - return'! |
2028 |
||
2029 |
test_bad_return2 |
|
659 | 2030 |
|w a p| |
329 | 2031 |
|
2032 |
w := ParserFlags warnAboutPossibleSTCCompilationProblems. |
|
2033 |
a := ParserFlags allowPossibleSTCCompilationProblems. |
|
659 | 2034 |
p := ParserFlags warnPlausibilityChecks. |
329 | 2035 |
|
2036 |
[ |
|
1447 | 2037 |
ParserFlags warnPlausibilityChecks:true. |
2038 |
ParserFlags warnAboutPossibleSTCCompilationProblems:true. |
|
2039 |
ParserFlags allowPossibleSTCCompilationProblems:false. |
|
2040 |
self should:[ |
|
2041 |
self |
|
2042 |
compile:' |
|
328 | 2043 |
foo:arg |
668 | 2044 |
^ arg |
2045 |
ifTrue:[^ 1] |
|
2046 |
ifFalse:[2] |
|
328 | 2047 |
' |
1447 | 2048 |
] |
2049 |
raise:Parser parseErrorSignal |
|
329 | 2050 |
] ensure:[ |
1447 | 2051 |
ParserFlags warnAboutPossibleSTCCompilationProblems:w. |
2052 |
ParserFlags allowPossibleSTCCompilationProblems:a. |
|
2053 |
ParserFlags warnPlausibilityChecks:p. |
|
329 | 2054 |
]. |
328 | 2055 |
|
2056 |
"Created: / 16-11-2006 / 14:08:48 / cg" |
|
2057 |
! |
|
2058 |
||
2059 |
test_bad_return3 |
|
329 | 2060 |
|w a setOfSignals| |
2061 |
||
2062 |
w := ParserFlags warnAboutPossibleSTCCompilationProblems. |
|
2063 |
a := ParserFlags allowPossibleSTCCompilationProblems. |
|
2064 |
||
2065 |
[ |
|
1447 | 2066 |
ParserFlags warnAboutPossibleSTCCompilationProblems:false. |
2067 |
ParserFlags allowPossibleSTCCompilationProblems:true. |
|
2068 |
||
2069 |
setOfSignals := SignalSet with:(Parser parseErrorSignal) with:(Parser parseWarningSignal). |
|
2070 |
self |
|
2071 |
shouldnt: |
|
2072 |
[ |
|
2073 |
self |
|
2074 |
compile:' |
|
328 | 2075 |
foo:arg |
648 | 2076 |
^ arg |
1447 | 2077 |
ifTrue:[^ 1] |
2078 |
ifFalse:[2] |
|
328 | 2079 |
' |
1447 | 2080 |
] |
2081 |
raise:setOfSignals. |
|
329 | 2082 |
] ensure:[ |
1447 | 2083 |
ParserFlags warnAboutPossibleSTCCompilationProblems:w. |
2084 |
ParserFlags allowPossibleSTCCompilationProblems:a. |
|
329 | 2085 |
] |
328 | 2086 |
|
2087 |
"Created: / 16-11-2006 / 14:33:29 / cg" |
|
2088 |
! |
|
2089 |
||
2090 |
test_good_return1 |
|
2091 |
|setOfPossibleExceptions| |
|
2092 |
||
877
6e000c4a4faa
class: RegressionTests::CompilerTest
Stefan Vogel <sv@exept.de>
parents:
686
diff
changeset
|
2093 |
setOfPossibleExceptions := SignalSet with:ParseWarning with:ParseError. |
648 | 2094 |
self |
1447 | 2095 |
shouldnt: |
2096 |
[ |
|
2097 |
self |
|
2098 |
compile:' |
|
328 | 2099 |
foo:arg |
648 | 2100 |
arg |
1447 | 2101 |
ifTrue:[^ 1] |
2102 |
ifFalse:[^ 2] |
|
328 | 2103 |
' |
1447 | 2104 |
] |
2105 |
raise:setOfPossibleExceptions. |
|
328 | 2106 |
|
2107 |
"Created: / 16-11-2006 / 14:16:53 / cg" |
|
2108 |
! |
|
2109 |
||
2110 |
test_good_return2 |
|
2111 |
|setOfPossibleExceptions| |
|
2112 |
||
587 | 2113 |
setOfPossibleExceptions := SignalSet with:(Parser parseWarningSignal) with:(Parser parseErrorSignal). |
648 | 2114 |
self |
1447 | 2115 |
shouldnt: |
2116 |
[ |
|
2117 |
self |
|
2118 |
compile:' |
|
328 | 2119 |
foo:arg |
648 | 2120 |
^ arg |
1447 | 2121 |
ifTrue:[1] |
2122 |
ifFalse:[2] |
|
328 | 2123 |
' |
1447 | 2124 |
] |
2125 |
raise:setOfPossibleExceptions. |
|
328 | 2126 |
|
2127 |
"Created: / 16-11-2006 / 14:41:45 / cg" |
|
2128 |
! ! |
|
2129 |
||
84 | 2130 |
!CompilerTest methodsFor:'tests - sends'! |
2131 |
||
2132 |
m1 |
|
2133 |
^ 123 |
|
2134 |
! |
|
2135 |
||
85 | 2136 |
m10 |
2137 |
^ self m9 |
|
2138 |
||
2139 |
" |
|
2140 |
self new m10 |
|
2141 |
" |
|
2142 |
! |
|
2143 |
||
2144 |
m11 |
|
2145 |
^ self m10 |
|
2146 |
||
2147 |
" |
|
2148 |
self new m11 |
|
2149 |
" |
|
2150 |
! |
|
2151 |
||
2152 |
m12 |
|
2153 |
^ self m11 |
|
2154 |
||
2155 |
" |
|
2156 |
self new m12 |
|
2157 |
" |
|
2158 |
! |
|
2159 |
||
2160 |
m13 |
|
2161 |
^ self m12 |
|
2162 |
||
2163 |
" |
|
2164 |
self new m13 |
|
2165 |
" |
|
2166 |
! |
|
2167 |
||
2168 |
m14 |
|
2169 |
^ self m13 |
|
2170 |
||
2171 |
" |
|
2172 |
self new m14 |
|
2173 |
" |
|
2174 |
! |
|
2175 |
||
2176 |
m15 |
|
2177 |
^ self m14 |
|
2178 |
||
2179 |
" |
|
2180 |
self new m15 |
|
2181 |
" |
|
2182 |
! |
|
2183 |
||
2184 |
m16 |
|
2185 |
^ self m15 |
|
2186 |
||
2187 |
" |
|
2188 |
self new m16 |
|
2189 |
" |
|
2190 |
! |
|
2191 |
||
84 | 2192 |
m2 |
2193 |
^ self m1 |
|
2194 |
! |
|
2195 |
||
2196 |
m3 |
|
2197 |
^ self m2 |
|
2198 |
! |
|
2199 |
||
2200 |
m4 |
|
2201 |
^ self m3 |
|
2202 |
! |
|
2203 |
||
2204 |
m5 |
|
2205 |
^ self m4 |
|
2206 |
! |
|
2207 |
||
2208 |
m6 |
|
2209 |
^ self m5 |
|
2210 |
! |
|
2211 |
||
2212 |
m7 |
|
2213 |
^ self m6 |
|
2214 |
||
2215 |
" |
|
2216 |
self new m7 |
|
2217 |
" |
|
85 | 2218 |
! |
2219 |
||
2220 |
m8 |
|
2221 |
^ self m7 |
|
2222 |
||
2223 |
" |
|
2224 |
self new m8 |
|
2225 |
" |
|
2226 |
! |
|
2227 |
||
2228 |
m9 |
|
2229 |
^ self m8 |
|
2230 |
||
2231 |
" |
|
2232 |
self new m9 |
|
2233 |
" |
|
84 | 2234 |
! ! |
2235 |
||
568 | 2236 |
!CompilerTest methodsFor:'tests - specials'! |
2237 |
||
2238 |
testEnsure |
|
2239 |
self assert:(self callEnsureWith2Returns = true). |
|
2240 |
||
569
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
2241 |
Error handle:[:ex | |
648 | 2242 |
ex proceed |
569
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
2243 |
] do:[ |
648 | 2244 |
self assert:(self callEnsureWithException = true). |
569
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
2245 |
]. |
e16012b59e29
added: #callEnsureWithException
Claus Gittinger <cg@exept.de>
parents:
568
diff
changeset
|
2246 |
|
568 | 2247 |
"Created: / 24-08-2010 / 12:51:27 / cg" |
213
9764b38bebf5
test for all literals to be present in the method
Claus Gittinger <cg@exept.de>
parents:
191
diff
changeset
|
2248 |
! ! |
9764b38bebf5
test for all literals to be present in the method
Claus Gittinger <cg@exept.de>
parents:
191
diff
changeset
|
2249 |
|
577 | 2250 |
!CompilerTest methodsFor:'tests - stc compilation'! |
2251 |
||
2252 |
testCodeForMethodVarAccess |
|
2253 |
"compile this with stc - some gcc versions generate wrong code for it (result is nil)" |
|
2254 |
||
2255 |
|results renderNone allSchedules overallCount passedCount inconclusiveCount failedCount| |
|
2256 |
||
2257 |
self x_executeBlock:[ |
|
648 | 2258 |
|localResults localPassedCount localInconclusiveCount| |
2259 |
||
2260 |
allSchedules := self x_generateSchedules. |
|
2261 |
||
2262 |
overallCount := allSchedules size. |
|
2263 |
(renderNone := (overallCount == 0)) ifFalse:[ |
|
2264 |
results := allSchedules collect:[:ts | ts getStateOfLastRun]. |
|
2265 |
||
2266 |
passedCount := results count:[:state | state isSuccess]. |
|
2267 |
inconclusiveCount := results count:[:state | state isInconclusive]. |
|
2268 |
||
2269 |
failedCount := overallCount - passedCount - inconclusiveCount. |
|
2270 |
] |
|
577 | 2271 |
]. |
2272 |
! |
|
2273 |
||
2274 |
x_executeBlock:aBlock |
|
2275 |
aBlock value |
|
2276 |
! |
|
2277 |
||
2278 |
x_generateSchedules |
|
648 | 2279 |
^ OrderedCollection |
2280 |
with:(Schedule new state:#failed) |
|
2281 |
with:(Schedule new state:#passed) |
|
2282 |
with:(Schedule new state:#passed) |
|
2283 |
with:(Schedule new state:#failed) |
|
2284 |
with:(Schedule new state:#inconclusive) |
|
2285 |
with:(Schedule new state:#inconclusive) |
|
2286 |
with:(Schedule new state:#inconclusive) |
|
2287 |
with:(Schedule new state:#failed) |
|
577 | 2288 |
! ! |
2289 |
||
188 | 2290 |
!CompilerTest::DummyClass methodsFor:'accessing'! |
2291 |
||
2292 |
_y0 |
|
2293 |
ObjectMemory garbageCollect. |
|
2294 |
^ self. |
|
2295 |
! |
|
2296 |
||
2297 |
_y1:arg1 |
|
2298 |
ObjectMemory garbageCollect. |
|
2299 |
^ arg1. |
|
2300 |
! |
|
2301 |
||
2302 |
request:something |
|
2303 |
"set the value of the instance variable 'request' (automatically generated)" |
|
2304 |
||
2305 |
request := something. |
|
2306 |
! ! |
|
2307 |
||
577 | 2308 |
!CompilerTest::Schedule methodsFor:'accessing'! |
2309 |
||
2310 |
getStateOfLastRun |
|
2311 |
^ State new state:state |
|
2312 |
! |
|
2313 |
||
2314 |
state:aSymbol |
|
2315 |
state := aSymbol |
|
2316 |
! ! |
|
2317 |
||
2318 |
!CompilerTest::Schedule::State methodsFor:'accessing'! |
|
2319 |
||
2320 |
state |
|
2321 |
^ state |
|
2322 |
! |
|
2323 |
||
2324 |
state:something |
|
2325 |
state := something. |
|
2326 |
! ! |
|
2327 |
||
2328 |
!CompilerTest::Schedule::State methodsFor:'queries'! |
|
2329 |
||
2330 |
isInconclusive |
|
2331 |
^ state == #inconclusive |
|
2332 |
! |
|
2333 |
||
2334 |
isSuccess |
|
2335 |
^ state == #passed |
|
2336 |
! ! |
|
2337 |
||
47 | 2338 |
!CompilerTest class methodsFor:'documentation'! |
2339 |
||
568 | 2340 |
version_CVS |
2341 |
^ '$Header$' |
|
47 | 2342 |
! ! |
877
6e000c4a4faa
class: RegressionTests::CompilerTest
Stefan Vogel <sv@exept.de>
parents:
686
diff
changeset
|
2343 |