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