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