69
|
1 |
"{ Package: 'exept:regression' }"
|
61
|
2 |
|
70
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
47
|
5 |
Object subclass:#CompilerTest
|
61
|
6 |
instanceVariableNames:'value'
|
47
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
59
|
9 |
category:'Tests-Regression'
|
47
|
10 |
!
|
|
11 |
|
|
12 |
|
77
|
13 |
!CompilerTest class methodsFor:'tests argument passing'!
|
|
14 |
|
|
15 |
ret0
|
|
16 |
^ 0
|
|
17 |
|
|
18 |
"
|
|
19 |
self ret0
|
78
|
20 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self ret0] ]
|
77
|
21 |
"
|
|
22 |
!
|
|
23 |
|
|
24 |
ret1
|
|
25 |
^ 1
|
|
26 |
|
|
27 |
"
|
|
28 |
self ret1
|
78
|
29 |
1000000 timesRepeat:[self ret1]
|
|
30 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self ret1] ]
|
|
31 |
"
|
|
32 |
!
|
|
33 |
|
|
34 |
retArg1:arg
|
|
35 |
^ arg
|
|
36 |
|
|
37 |
"
|
|
38 |
self retArg1:1
|
|
39 |
1000000 timesRepeat:[self retArg1:1]
|
|
40 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg1:1] ]
|
|
41 |
"
|
|
42 |
!
|
|
43 |
|
|
44 |
retArg2:arg1 _:arg2
|
|
45 |
^ arg2
|
|
46 |
|
|
47 |
"
|
|
48 |
self retArg2:1 _:2
|
|
49 |
1000000 timesRepeat:[self retArg2:1 _:2]
|
|
50 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg2:1 _:2] ]
|
|
51 |
"
|
|
52 |
!
|
|
53 |
|
|
54 |
retArg3:arg1 _:arg2 _:arg3
|
|
55 |
^ arg3
|
|
56 |
|
|
57 |
"
|
|
58 |
self retArg3:1 _:2 _:3
|
|
59 |
1000000 timesRepeat:[self retArg3:1 _:2 _:3]
|
|
60 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg3:1 _:2 _:3] ]
|
|
61 |
"
|
|
62 |
!
|
|
63 |
|
|
64 |
retArg4:arg1 _:arg2 _:arg3 _:arg4
|
|
65 |
^ arg4
|
|
66 |
|
|
67 |
"
|
|
68 |
self retArg4:1 _:2 _:3 _:4
|
|
69 |
1000000 timesRepeat:[self retArg4:1 _:2 _:3 _:4]
|
|
70 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg4:1 _:2 _:3 _:4] ]
|
|
71 |
"
|
|
72 |
!
|
|
73 |
|
79
|
74 |
retArg5:arg1 _:arg2 _:arg3 _:arg4 _:arg5
|
|
75 |
^ arg5
|
|
76 |
|
|
77 |
"
|
|
78 |
self retArg5:1 _:2 _:3 _:4 _:5
|
|
79 |
1000000 timesRepeat:[self retArg5:1 _:2 _:3 _:4 _:5]
|
|
80 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retArg5:1 _:2 _:3 _:4 _:5] ]
|
|
81 |
"
|
|
82 |
!
|
|
83 |
|
78
|
84 |
retLiteral1
|
|
85 |
^ 'hello'
|
|
86 |
|
|
87 |
"
|
|
88 |
self retLiteral1
|
|
89 |
1000000 timesRepeat:[self retLiteral1]
|
|
90 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retLiteral1] ]
|
77
|
91 |
"
|
|
92 |
!
|
|
93 |
|
|
94 |
retM1
|
|
95 |
^ -1
|
|
96 |
|
|
97 |
"
|
|
98 |
self retM1
|
78
|
99 |
1000000 timesRepeat:[self retM1]
|
|
100 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retM1] ]
|
77
|
101 |
"
|
|
102 |
!
|
|
103 |
|
|
104 |
retSelf
|
|
105 |
^ self
|
|
106 |
|
|
107 |
"
|
|
108 |
self retSelf
|
78
|
109 |
1000000 timesRepeat:[self retSelf]
|
|
110 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self retSelf] ]
|
77
|
111 |
"
|
|
112 |
! !
|
|
113 |
|
61
|
114 |
!CompilerTest methodsFor:'helpers'!
|
|
115 |
|
81
|
116 |
size
|
|
117 |
^ 1
|
|
118 |
!
|
|
119 |
|
61
|
120 |
value:something
|
|
121 |
value := something
|
|
122 |
! !
|
|
123 |
|
50
|
124 |
!CompilerTest methodsFor:'test - inlined'!
|
|
125 |
|
|
126 |
test_even:arg
|
|
127 |
^ arg even
|
|
128 |
|
|
129 |
"
|
|
130 |
self new test_even:nil
|
|
131 |
self new test_even:123
|
|
132 |
self new test_even:122
|
|
133 |
self new test_even:(100 factorial)
|
|
134 |
"
|
|
135 |
!
|
|
136 |
|
|
137 |
test_isInteger:arg
|
|
138 |
^ arg isInteger
|
|
139 |
|
|
140 |
"
|
|
141 |
self new test_isInteger:nil
|
|
142 |
self new test_isInteger:123
|
|
143 |
self new test_isInteger:(100 factorial)
|
|
144 |
"
|
|
145 |
!
|
|
146 |
|
|
147 |
test_isNotInteger:arg
|
|
148 |
^ arg isInteger not
|
|
149 |
|
|
150 |
"
|
|
151 |
self new test_isNotInteger:nil
|
|
152 |
self new test_isNotInteger:123
|
|
153 |
self new test_isNotInteger:(100 factorial)
|
|
154 |
"
|
|
155 |
!
|
|
156 |
|
74
|
157 |
test_max1:arg1 _:arg2
|
|
158 |
^ arg1 max:arg2
|
|
159 |
|
|
160 |
"
|
|
161 |
self new test_max1:nil _:nil
|
|
162 |
self new test_max1:1 _:nil
|
|
163 |
self new test_max1:nil _:1
|
|
164 |
self new test_max1:1 _:2
|
|
165 |
self new test_max1:2 _:1
|
|
166 |
|
|
167 |
self new test_max1:1.0 _:nil
|
|
168 |
self new test_max1:nil _:1.0
|
|
169 |
self new test_max1:1.0 _:2.0
|
|
170 |
self new test_max1:2.0 _:1.0
|
|
171 |
|
|
172 |
self new test_max1:1.0 _:2
|
|
173 |
self new test_max1:2.0 _:1
|
|
174 |
self new test_max1:1 _:2.0
|
|
175 |
self new test_max1:2 _:1.0
|
|
176 |
"
|
|
177 |
!
|
|
178 |
|
|
179 |
test_max2:arg
|
|
180 |
^ 1 max:arg
|
|
181 |
|
|
182 |
"
|
|
183 |
self new test_max2:nil
|
|
184 |
self new test_max2:0
|
|
185 |
self new test_max2:1
|
|
186 |
self new test_max2:2
|
|
187 |
|
|
188 |
self new test_max2:0.0
|
|
189 |
self new test_max2:1.0
|
|
190 |
self new test_max2:2.0
|
|
191 |
"
|
|
192 |
!
|
|
193 |
|
|
194 |
test_max3:arg
|
|
195 |
|var|
|
|
196 |
|
|
197 |
var := Array new:10.
|
|
198 |
^ 1 max:arg
|
|
199 |
|
|
200 |
"
|
|
201 |
self new test_max3:nil
|
|
202 |
self new test_max3:0
|
|
203 |
self new test_max3:1
|
|
204 |
self new test_max3:2
|
|
205 |
|
|
206 |
self new test_max3:0.0
|
|
207 |
self new test_max3:1.0
|
|
208 |
self new test_max3:2.0
|
|
209 |
"
|
|
210 |
!
|
|
211 |
|
|
212 |
test_max4:arg
|
|
213 |
|var|
|
|
214 |
|
|
215 |
var := Array new:10.
|
|
216 |
^ arg max:1
|
|
217 |
|
|
218 |
"
|
|
219 |
self new test_max4:nil
|
|
220 |
self new test_max4:0
|
|
221 |
self new test_max4:1
|
|
222 |
self new test_max4:2
|
|
223 |
|
|
224 |
self new test_max4:0.0
|
|
225 |
self new test_max4:1.0
|
|
226 |
self new test_max4:2.0
|
|
227 |
"
|
|
228 |
!
|
|
229 |
|
73
|
230 |
test_min1:arg1 _:arg2
|
|
231 |
^ arg1 min:arg2
|
|
232 |
|
|
233 |
"
|
|
234 |
self new test_min1:nil _:nil
|
|
235 |
self new test_min1:1 _:nil
|
|
236 |
self new test_min1:nil _:1
|
|
237 |
self new test_min1:1 _:2
|
|
238 |
self new test_min1:2 _:1
|
|
239 |
|
|
240 |
self new test_min1:1.0 _:nil
|
|
241 |
self new test_min1:nil _:1.0
|
|
242 |
self new test_min1:1.0 _:2.0
|
|
243 |
self new test_min1:2.0 _:1.0
|
|
244 |
|
|
245 |
self new test_min1:1.0 _:2
|
|
246 |
self new test_min1:2.0 _:1
|
|
247 |
self new test_min1:1 _:2.0
|
|
248 |
self new test_min1:2 _:1.0
|
|
249 |
"
|
|
250 |
!
|
|
251 |
|
|
252 |
test_min2:arg
|
|
253 |
^ 1 min:arg
|
|
254 |
|
|
255 |
"
|
|
256 |
self new test_min2:nil
|
|
257 |
self new test_min2:0
|
|
258 |
self new test_min2:1
|
|
259 |
self new test_min2:2
|
|
260 |
|
|
261 |
self new test_min2:0.0
|
|
262 |
self new test_min2:1.0
|
|
263 |
self new test_min2:2.0
|
|
264 |
"
|
|
265 |
!
|
|
266 |
|
|
267 |
test_min3:arg
|
|
268 |
|var|
|
|
269 |
|
|
270 |
var := Array new:10.
|
|
271 |
^ 1 min:arg
|
|
272 |
|
|
273 |
"
|
|
274 |
self new test_min3:nil
|
|
275 |
self new test_min3:0
|
|
276 |
self new test_min3:1
|
|
277 |
self new test_min3:2
|
|
278 |
|
|
279 |
self new test_min3:0.0
|
|
280 |
self new test_min3:1.0
|
|
281 |
self new test_min3:2.0
|
|
282 |
"
|
|
283 |
!
|
|
284 |
|
|
285 |
test_min4:arg
|
|
286 |
|var|
|
|
287 |
|
|
288 |
var := Array new:10.
|
|
289 |
^ arg min:1
|
|
290 |
|
|
291 |
"
|
|
292 |
self new test_min4:nil
|
|
293 |
self new test_min4:0
|
|
294 |
self new test_min4:1
|
|
295 |
self new test_min4:2
|
|
296 |
|
|
297 |
self new test_min4:0.0
|
|
298 |
self new test_min4:1.0
|
|
299 |
self new test_min4:2.0
|
|
300 |
"
|
|
301 |
!
|
|
302 |
|
50
|
303 |
test_odd:arg
|
|
304 |
^ arg odd
|
|
305 |
|
|
306 |
"
|
|
307 |
self new test_odd:nil
|
|
308 |
self new test_odd:123
|
|
309 |
self new test_odd:122
|
|
310 |
self new test_odd:(100 factorial)
|
|
311 |
"
|
61
|
312 |
!
|
|
313 |
|
|
314 |
test_size
|
|
315 |
^ value size
|
|
316 |
|
|
317 |
"
|
|
318 |
(self new value:(Array new:2)) test_size
|
|
319 |
(self new value:(OrderedCollection new:2)) test_size
|
|
320 |
"
|
50
|
321 |
! !
|
|
322 |
|
48
|
323 |
!CompilerTest methodsFor:'tests - booleans'!
|
|
324 |
|
50
|
325 |
testAnd:arg1 _:arg2
|
|
326 |
^ arg1 & arg2
|
|
327 |
|
|
328 |
"
|
|
329 |
self new testAnd:true _:true.
|
|
330 |
self new testAnd:true _:false.
|
|
331 |
self new testAnd:false _:true.
|
|
332 |
self new testAnd:false _:false.
|
|
333 |
self new testAnd:false _:nil.
|
|
334 |
self new testAnd:true _:nil.
|
|
335 |
self new testAnd:nil _:false.
|
|
336 |
self new testAnd:nil _:true.
|
|
337 |
self new testAnd:1234 _:true.
|
|
338 |
self new testAnd:1234 _:false.
|
|
339 |
self new testAnd:true _:1234.
|
|
340 |
self new testAnd:false _:1234.
|
|
341 |
"
|
|
342 |
!
|
|
343 |
|
48
|
344 |
testNot1:arg
|
|
345 |
^ arg not
|
|
346 |
|
|
347 |
"
|
49
|
348 |
self new testNot1:true.
|
48
|
349 |
self new testNot1:false.
|
|
350 |
self new testNot1:1234.
|
|
351 |
"
|
|
352 |
!
|
|
353 |
|
|
354 |
testNot2:arg1 _:arg2
|
|
355 |
^ arg1 not & arg2 not
|
|
356 |
|
|
357 |
"
|
|
358 |
self new testNot2:true _:true.
|
|
359 |
self new testNot2:false _:true.
|
|
360 |
self new testNot2:true _:false.
|
|
361 |
self new testNot2:false _:false.
|
|
362 |
|
|
363 |
self new testNot2:false _:1234.
|
|
364 |
self new testNot2:true _:1234.
|
|
365 |
self new testNot2:1234 _:true.
|
|
366 |
self new testNot2:1234 _:false.
|
|
367 |
self new testNot2:1234 _:2345.
|
|
368 |
"
|
50
|
369 |
!
|
|
370 |
|
|
371 |
testOr:arg1 _:arg2
|
|
372 |
^ arg1 | arg2
|
|
373 |
|
|
374 |
"
|
|
375 |
self new testOr:true _:true.
|
|
376 |
self new testOr:true _:false.
|
|
377 |
self new testOr:false _:true.
|
|
378 |
self new testOr:false _:false.
|
|
379 |
self new testOr:false _:nil.
|
|
380 |
self new testOr:true _:nil.
|
|
381 |
self new testOr:nil _:false.
|
|
382 |
self new testOr:nil _:true.
|
|
383 |
self new testOr:1234 _:true.
|
|
384 |
self new testOr:1234 _:false.
|
|
385 |
self new testOr:true _:1234.
|
|
386 |
self new testOr:false _:1234.
|
|
387 |
"
|
48
|
388 |
! !
|
|
389 |
|
62
|
390 |
!CompilerTest methodsFor:'tests - conditions'!
|
|
391 |
|
|
392 |
testIf1:val
|
|
393 |
|x|
|
|
394 |
|
65
|
395 |
x := #foo.
|
|
396 |
x := (val == #CursorRight or:[val == #CursorDown]) ifTrue:[1].
|
62
|
397 |
^ x
|
|
398 |
|
|
399 |
"
|
|
400 |
self new testIf1:#CursorRight
|
|
401 |
self new testIf1:#CursorDown
|
64
|
402 |
self new testIf1:#Foo
|
|
403 |
self new testIf1:#CursorUp
|
|
404 |
self new testIf1:nil
|
62
|
405 |
self new testIf1:1
|
|
406 |
"
|
63
|
407 |
!
|
|
408 |
|
|
409 |
testIf2:val
|
|
410 |
|x|
|
|
411 |
|
65
|
412 |
x := #foo.
|
|
413 |
x := (val == #CursorRight or:[val == #CursorDown]) ifTrue:1.
|
63
|
414 |
^ x
|
|
415 |
|
|
416 |
"
|
|
417 |
self new testIf2:#CursorRight
|
|
418 |
self new testIf2:#CursorDown
|
|
419 |
self new testIf2:#Foo
|
|
420 |
self new testIf2:#CursorUp
|
|
421 |
self new testIf2:nil
|
|
422 |
self new testIf2:1
|
|
423 |
"
|
65
|
424 |
!
|
|
425 |
|
|
426 |
testIf3:val
|
|
427 |
|x|
|
|
428 |
|
|
429 |
x := #foo.
|
|
430 |
x := (val isInteger) ifTrue:1.
|
|
431 |
^ x
|
|
432 |
|
|
433 |
"
|
|
434 |
self new testIf3:#CursorRight
|
|
435 |
self new testIf3:#CursorDown
|
|
436 |
self new testIf3:#Foo
|
|
437 |
self new testIf3:#CursorUp
|
|
438 |
self new testIf3:nil
|
|
439 |
self new testIf3:1
|
|
440 |
"
|
|
441 |
!
|
|
442 |
|
67
|
443 |
testIf4:val
|
|
444 |
^ val isNil
|
|
445 |
|
|
446 |
"
|
|
447 |
self new testIf4:#CursorRight
|
|
448 |
self new testIf4:1
|
|
449 |
self new testIf4:nil
|
|
450 |
"
|
|
451 |
!
|
|
452 |
|
66
|
453 |
testIf4:val1 with:val2
|
|
454 |
^ (val1 == nil and:[val2 == nil])
|
|
455 |
|
|
456 |
"
|
|
457 |
self new testIf4:#CursorRight with:#CursorDown
|
|
458 |
self new testIf4:#CursorRight with:nil
|
|
459 |
self new testIf4:nil with:#CursorDown
|
|
460 |
self new testIf4:nil with:nil
|
|
461 |
"
|
|
462 |
!
|
|
463 |
|
67
|
464 |
testIf5:val
|
|
465 |
^ val isNil ifTrue:[1]
|
|
466 |
|
|
467 |
"
|
|
468 |
self new testIf5:#CursorRight
|
|
469 |
self new testIf5:1
|
|
470 |
self new testIf5:nil
|
|
471 |
"
|
|
472 |
!
|
|
473 |
|
66
|
474 |
testIf5:val1 with:val2
|
|
475 |
^ (val1 isNil and:[val2 isNil])
|
|
476 |
|
|
477 |
"
|
|
478 |
self new testIf5:#CursorRight with:#CursorDown
|
|
479 |
self new testIf5:#CursorRight with:nil
|
|
480 |
self new testIf5:nil with:#CursorDown
|
|
481 |
self new testIf5:nil with:nil
|
|
482 |
"
|
|
483 |
!
|
|
484 |
|
67
|
485 |
testIf6:val
|
|
486 |
^ val isNil ifTrue:1
|
|
487 |
|
|
488 |
"
|
|
489 |
self new testIf6:#CursorRight
|
|
490 |
self new testIf6:1
|
|
491 |
self new testIf6:nil
|
|
492 |
"
|
|
493 |
!
|
|
494 |
|
68
|
495 |
testIf6b:val
|
|
496 |
val isNil ifTrue:1
|
|
497 |
|
|
498 |
"
|
|
499 |
self new testIf6b:#CursorRight
|
|
500 |
self new testIf6b:1
|
|
501 |
self new testIf6b:nil
|
|
502 |
"
|
|
503 |
!
|
|
504 |
|
|
505 |
testIf6c:val
|
|
506 |
val isNil ifTrue:[1]
|
|
507 |
|
|
508 |
"
|
|
509 |
self new testIf6c:#CursorRight
|
|
510 |
self new testIf6c:1
|
|
511 |
self new testIf6c:nil
|
|
512 |
"
|
|
513 |
!
|
|
514 |
|
|
515 |
testIf6d:val
|
|
516 |
^ val isNil ifTrue:val
|
|
517 |
|
|
518 |
"
|
|
519 |
self new testIf6d:#CursorRight
|
|
520 |
self new testIf6d:1
|
|
521 |
self new testIf6d:nil
|
|
522 |
"
|
|
523 |
!
|
|
524 |
|
|
525 |
testIf6e:val
|
|
526 |
^ val isNil ifFalse:val
|
|
527 |
|
|
528 |
"
|
|
529 |
self new testIf6e:['hello']
|
|
530 |
self new testIf6e:('hello' asValue)
|
|
531 |
self new testIf6e:#CursorRight
|
|
532 |
self new testIf6e:1
|
|
533 |
self new testIf6e:nil
|
|
534 |
"
|
|
535 |
!
|
|
536 |
|
67
|
537 |
testIf7:val
|
|
538 |
^ val ? 1
|
|
539 |
|
|
540 |
"
|
|
541 |
self new testIf7:#CursorRight
|
|
542 |
self new testIf7:1
|
|
543 |
self new testIf7:nil
|
|
544 |
"
|
|
545 |
!
|
|
546 |
|
65
|
547 |
testIfElse1:val
|
|
548 |
|x|
|
|
549 |
|
|
550 |
x := (val == #CursorRight or:[val == #CursorDown]) ifTrue:[1] ifFalse:[-1].
|
|
551 |
^ x
|
|
552 |
|
|
553 |
"
|
|
554 |
self new testIfElse1:#CursorRight
|
|
555 |
self new testIfElse1:#CursorDown
|
|
556 |
self new testIfElse1:#Foo
|
|
557 |
self new testIfElse1:#CursorUp
|
|
558 |
self new testIfElse1:nil
|
|
559 |
self new testIfElse1:1
|
|
560 |
"
|
|
561 |
!
|
|
562 |
|
|
563 |
testIfElse2:val
|
|
564 |
|x|
|
|
565 |
|
|
566 |
x := (val == #CursorRight or:[val == #CursorDown]) ifTrue:1 ifFalse:-1.
|
|
567 |
^ x
|
|
568 |
|
|
569 |
"
|
|
570 |
self new testIfElse2:#CursorRight
|
|
571 |
self new testIfElse2:#CursorDown
|
|
572 |
self new testIfElse2:#Foo
|
|
573 |
self new testIfElse2:#CursorUp
|
|
574 |
self new testIfElse2:nil
|
|
575 |
self new testIfElse2:1
|
|
576 |
"
|
|
577 |
!
|
|
578 |
|
|
579 |
testIfElse3:val
|
|
580 |
|x|
|
|
581 |
|
|
582 |
x := (val == #CursorRight or:[val isInteger]) ifTrue:1 ifFalse:-1.
|
|
583 |
^ x
|
|
584 |
|
|
585 |
"
|
|
586 |
self new testIfElse3:#CursorRight
|
|
587 |
self new testIfElse3:#CursorDown
|
|
588 |
self new testIfElse3:#Foo
|
|
589 |
self new testIfElse3:#CursorUp
|
|
590 |
self new testIfElse3:nil
|
|
591 |
self new testIfElse3:1
|
|
592 |
"
|
|
593 |
!
|
|
594 |
|
|
595 |
testIfElse4:val
|
|
596 |
|x|
|
|
597 |
|
|
598 |
x := #foo.
|
|
599 |
x := (val isInteger) ifTrue:1 ifFalse:-1.
|
|
600 |
^ x
|
|
601 |
|
|
602 |
"
|
|
603 |
self new testIfElse4:#CursorRight
|
|
604 |
self new testIfElse4:#CursorDown
|
|
605 |
self new testIfElse4:#Foo
|
|
606 |
self new testIfElse4:#CursorUp
|
|
607 |
self new testIfElse4:nil
|
|
608 |
self new testIfElse4:1
|
|
609 |
"
|
68
|
610 |
!
|
|
611 |
|
|
612 |
testIfElse5:val
|
|
613 |
|x|
|
|
614 |
|
|
615 |
x := #foo.
|
|
616 |
x := val ifNil:1 ifNotNil:-1.
|
|
617 |
^ x
|
|
618 |
|
|
619 |
"
|
|
620 |
self new testIfElse5:#CursorUp
|
|
621 |
self new testIfElse5:nil
|
|
622 |
self new testIfElse5:1
|
|
623 |
"
|
|
624 |
!
|
|
625 |
|
|
626 |
testIfElse6:val
|
|
627 |
|x|
|
|
628 |
|
|
629 |
x := #foo.
|
|
630 |
x := val ifNil:[1] ifNotNil:[-1].
|
|
631 |
^ x
|
|
632 |
|
|
633 |
"
|
|
634 |
self new testIfElse6:#CursorUp
|
|
635 |
self new testIfElse6:nil
|
|
636 |
self new testIfElse6:1
|
|
637 |
"
|
|
638 |
!
|
|
639 |
|
|
640 |
testIfElse7:val with:val1 with:val2
|
|
641 |
|x|
|
|
642 |
|
|
643 |
x := #foo.
|
|
644 |
x := val ifNil:val1 ifNotNil:val2.
|
|
645 |
^ x
|
|
646 |
|
|
647 |
"
|
|
648 |
self new testIfElse7:#CursorUp with:1 with:2
|
|
649 |
self new testIfElse7:nil with:1 with:2
|
|
650 |
self new testIfElse7:1 with:1 with:2
|
|
651 |
"
|
62
|
652 |
! !
|
|
653 |
|
47
|
654 |
!CompilerTest methodsFor:'tests - constant folding'!
|
|
655 |
|
|
656 |
testFloat_pi
|
|
657 |
^ Float pi
|
|
658 |
!
|
|
659 |
|
|
660 |
testFloat_unity
|
|
661 |
^ Float unity
|
|
662 |
!
|
|
663 |
|
|
664 |
testFloat_zero
|
|
665 |
^ Float zero
|
|
666 |
!
|
|
667 |
|
|
668 |
testSmalltalk_if_else_isSmalltalkX
|
|
669 |
Smalltalk isSmalltalkX ifTrue:[
|
59
|
670 |
^ 'yes'
|
47
|
671 |
] ifFalse:[
|
59
|
672 |
^ 'no'
|
47
|
673 |
]
|
|
674 |
!
|
|
675 |
|
|
676 |
testSmalltalk_if_else_isVisualWorks
|
|
677 |
Smalltalk isVisualWorks ifTrue:[
|
59
|
678 |
^ 'yes'
|
47
|
679 |
] ifFalse:[
|
59
|
680 |
^ 'no'
|
47
|
681 |
]
|
|
682 |
!
|
|
683 |
|
|
684 |
testSmalltalk_if_isSmalltalkX
|
|
685 |
Smalltalk isSmalltalkX ifTrue:[
|
59
|
686 |
^ 'yes'
|
47
|
687 |
].
|
|
688 |
^ 'no'
|
|
689 |
!
|
|
690 |
|
|
691 |
testSmalltalk_if_isSqueak
|
|
692 |
Smalltalk isSqueak ifTrue:[
|
59
|
693 |
^ 'yes'
|
47
|
694 |
].
|
|
695 |
^ 'no'
|
|
696 |
!
|
|
697 |
|
|
698 |
testSmalltalk_if_isVisualWorks
|
|
699 |
Smalltalk isVisualWorks ifTrue:[
|
59
|
700 |
^ 'yes'
|
47
|
701 |
].
|
|
702 |
^ 'no'
|
|
703 |
!
|
|
704 |
|
|
705 |
testSmalltalk_isSmalltalkX
|
|
706 |
^ Smalltalk isSmalltalkX
|
|
707 |
!
|
|
708 |
|
|
709 |
testSmalltalk_isSqueak
|
|
710 |
^ Smalltalk isSqueak
|
|
711 |
!
|
|
712 |
|
|
713 |
testSmalltalk_isVisualAge
|
|
714 |
^ Smalltalk isVisualAge
|
|
715 |
!
|
|
716 |
|
|
717 |
testSmalltalk_isVisualWorks
|
|
718 |
^ Smalltalk isVisualWorks
|
|
719 |
!
|
|
720 |
|
|
721 |
testUnaryFolding
|
|
722 |
self testFloat_pi ~= (Float perform:#pi) ifTrue:[self halt].
|
|
723 |
self testFloat_unity ~= (Float perform:#unity) ifTrue:[self halt].
|
|
724 |
self testFloat_zero ~= (Float perform:#zero) ifTrue:[self halt].
|
|
725 |
|
|
726 |
self testSmalltalk_isSmalltalkX ~= (Smalltalk perform:#isSmalltalkX) ifTrue:[self halt].
|
|
727 |
self testSmalltalk_isSqueak ~= (Smalltalk perform:#isSqueak) ifTrue:[self halt].
|
|
728 |
self testSmalltalk_isVisualWorks ~= (Smalltalk perform:#isVisualWorks) ifTrue:[self halt].
|
|
729 |
self testSmalltalk_isVisualAge ~= (Smalltalk perform:#isVisualAge) ifTrue:[self halt].
|
|
730 |
|
|
731 |
"
|
|
732 |
self basicNew testUnaryFolding
|
|
733 |
"
|
|
734 |
! !
|
|
735 |
|
81
|
736 |
!CompilerTest methodsFor:'tests context setup'!
|
|
737 |
|
|
738 |
retArgWithFrameA:arg
|
|
739 |
|a b c|
|
|
740 |
|
|
741 |
a := 0.
|
|
742 |
b := 1.
|
|
743 |
c := 2.
|
|
744 |
^ arg
|
|
745 |
|
|
746 |
"
|
|
747 |
self new retArgWithFrameA:999
|
|
748 |
"
|
|
749 |
!
|
|
750 |
|
|
751 |
retLocal
|
|
752 |
|a|
|
|
753 |
|
|
754 |
a := 0.
|
|
755 |
^ a
|
79
|
756 |
|
81
|
757 |
"
|
|
758 |
self new retLocal
|
|
759 |
1000000 timesRepeat:[self new retInstVar]
|
|
760 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ]
|
|
761 |
"
|
|
762 |
|
|
763 |
"
|
|
764 |
|i|
|
|
765 |
|
|
766 |
i := self new.
|
|
767 |
i instVarAt:1 put:12345.
|
|
768 |
i retInstVar
|
|
769 |
"
|
|
770 |
|
|
771 |
"
|
|
772 |
|i|
|
|
773 |
i := self new.
|
|
774 |
i instVarAt:1 put:12345.
|
|
775 |
1000000 timesRepeat:[i retInstVar]
|
|
776 |
"
|
79
|
777 |
|
|
778 |
"
|
81
|
779 |
|i|
|
|
780 |
i := self new.
|
|
781 |
i instVarAt:1 put:12345.
|
|
782 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ]
|
|
783 |
"
|
|
784 |
|
|
785 |
|
|
786 |
!
|
|
787 |
|
|
788 |
retLocalB
|
|
789 |
|a b c|
|
|
790 |
|
|
791 |
a := 0.
|
|
792 |
b := 1.
|
|
793 |
c := 2.
|
|
794 |
^ a
|
|
795 |
|
|
796 |
"
|
|
797 |
self new retLocalB
|
|
798 |
1000000 timesRepeat:[self new retInstVar]
|
|
799 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ]
|
|
800 |
"
|
|
801 |
|
|
802 |
"
|
|
803 |
|i|
|
|
804 |
|
|
805 |
i := self new.
|
|
806 |
i instVarAt:1 put:12345.
|
|
807 |
i retInstVar
|
|
808 |
"
|
|
809 |
|
|
810 |
"
|
|
811 |
|i|
|
|
812 |
i := self new.
|
|
813 |
i instVarAt:1 put:12345.
|
|
814 |
1000000 timesRepeat:[i retInstVar]
|
|
815 |
"
|
|
816 |
|
|
817 |
"
|
|
818 |
|i|
|
|
819 |
i := self new.
|
|
820 |
i instVarAt:1 put:12345.
|
|
821 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ]
|
|
822 |
"
|
|
823 |
|
|
824 |
|
|
825 |
!
|
|
826 |
|
|
827 |
retLocalC
|
|
828 |
|a b c|
|
|
829 |
|
|
830 |
a := 0.
|
|
831 |
b := 1.
|
|
832 |
c := 2.
|
|
833 |
^ b
|
|
834 |
|
|
835 |
"
|
|
836 |
self new retLocalC
|
79
|
837 |
1000000 timesRepeat:[self new retInstVar]
|
|
838 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ]
|
|
839 |
"
|
|
840 |
|
|
841 |
"
|
|
842 |
|i|
|
|
843 |
|
|
844 |
i := self new.
|
|
845 |
i instVarAt:1 put:12345.
|
|
846 |
i retInstVar
|
|
847 |
"
|
|
848 |
|
|
849 |
"
|
|
850 |
|i|
|
|
851 |
i := self new.
|
|
852 |
i instVarAt:1 put:12345.
|
|
853 |
1000000 timesRepeat:[i retInstVar]
|
|
854 |
"
|
|
855 |
|
|
856 |
"
|
|
857 |
|i|
|
|
858 |
i := self new.
|
|
859 |
i instVarAt:1 put:12345.
|
|
860 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ]
|
|
861 |
"
|
|
862 |
|
|
863 |
|
|
864 |
!
|
|
865 |
|
81
|
866 |
retLocalD
|
|
867 |
|a b c|
|
|
868 |
|
|
869 |
a := 0.
|
|
870 |
b := 1.
|
|
871 |
c := 2.
|
|
872 |
^ c
|
|
873 |
|
|
874 |
"
|
|
875 |
self new retLocalD
|
|
876 |
1000000 timesRepeat:[self new retInstVar]
|
|
877 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ]
|
|
878 |
"
|
|
879 |
|
|
880 |
"
|
|
881 |
|i|
|
|
882 |
|
|
883 |
i := self new.
|
|
884 |
i instVarAt:1 put:12345.
|
|
885 |
i retInstVar
|
|
886 |
"
|
|
887 |
|
|
888 |
"
|
|
889 |
|i|
|
|
890 |
i := self new.
|
|
891 |
i instVarAt:1 put:12345.
|
|
892 |
1000000 timesRepeat:[i retInstVar]
|
|
893 |
"
|
|
894 |
|
|
895 |
"
|
|
896 |
|i|
|
|
897 |
i := self new.
|
|
898 |
i instVarAt:1 put:12345.
|
|
899 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ]
|
|
900 |
"
|
|
901 |
|
|
902 |
|
|
903 |
!
|
|
904 |
|
|
905 |
retLocalE
|
|
906 |
|a b c|
|
80
|
907 |
|
|
908 |
a := 0.
|
81
|
909 |
b := 1.
|
|
910 |
c := 2.
|
|
911 |
^ self
|
|
912 |
|
|
913 |
"
|
|
914 |
self new retLocalE
|
|
915 |
1000000 timesRepeat:[self new retInstVar]
|
|
916 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ]
|
|
917 |
"
|
|
918 |
|
|
919 |
"
|
|
920 |
|i|
|
|
921 |
|
|
922 |
i := self new.
|
|
923 |
i instVarAt:1 put:12345.
|
|
924 |
i retInstVar
|
|
925 |
"
|
|
926 |
|
|
927 |
"
|
|
928 |
|i|
|
|
929 |
i := self new.
|
|
930 |
i instVarAt:1 put:12345.
|
|
931 |
1000000 timesRepeat:[i retInstVar]
|
|
932 |
"
|
|
933 |
|
|
934 |
"
|
|
935 |
|i|
|
|
936 |
i := self new.
|
|
937 |
i instVarAt:1 put:12345.
|
|
938 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ]
|
|
939 |
"
|
|
940 |
|
|
941 |
|
|
942 |
!
|
|
943 |
|
|
944 |
testContextA
|
|
945 |
ObjectMemory dumpObject:thisContext
|
|
946 |
|
|
947 |
"
|
|
948 |
self new testContextA
|
|
949 |
"
|
|
950 |
|
|
951 |
!
|
|
952 |
|
|
953 |
testContextB
|
|
954 |
ObjectMemory dumpObject:thisContext sender
|
|
955 |
|
|
956 |
"
|
|
957 |
self new testContextB
|
|
958 |
"
|
|
959 |
|
|
960 |
!
|
|
961 |
|
|
962 |
testContextC
|
|
963 |
thisContext fullPrintAll
|
79
|
964 |
|
|
965 |
"
|
81
|
966 |
self new testContextC
|
|
967 |
"
|
|
968 |
|
|
969 |
!
|
|
970 |
|
|
971 |
testSend0
|
|
972 |
^ 9999
|
|
973 |
!
|
|
974 |
|
|
975 |
testSend0B:arg
|
|
976 |
^ arg
|
|
977 |
!
|
|
978 |
|
|
979 |
testSend1
|
|
980 |
^ self testSend0
|
|
981 |
|
|
982 |
"
|
|
983 |
self new testSend1
|
|
984 |
"
|
|
985 |
|
|
986 |
!
|
|
987 |
|
|
988 |
testSend1B
|
|
989 |
^ self testSend0B:1234
|
|
990 |
|
|
991 |
"
|
|
992 |
self new testSend1B
|
|
993 |
"
|
|
994 |
|
|
995 |
!
|
|
996 |
|
|
997 |
testSend1C:arg
|
|
998 |
^ self testSend0B:arg
|
|
999 |
|
|
1000 |
"
|
|
1001 |
self new testSend1C:9998
|
|
1002 |
"
|
|
1003 |
!
|
|
1004 |
|
|
1005 |
testSend2
|
|
1006 |
self testContextB
|
|
1007 |
|
|
1008 |
"
|
|
1009 |
self new testSend2
|
|
1010 |
"
|
|
1011 |
|
|
1012 |
!
|
|
1013 |
|
|
1014 |
testSend3
|
|
1015 |
self testContextC
|
|
1016 |
|
|
1017 |
"
|
|
1018 |
self new testSend3
|
|
1019 |
"
|
|
1020 |
|
|
1021 |
! !
|
|
1022 |
|
|
1023 |
!CompilerTest methodsFor:'tests entry'!
|
|
1024 |
|
|
1025 |
ilcMissCheck
|
|
1026 |
|
|
1027 |
|
|
1028 |
|
|
1029 |
"
|
|
1030 |
(Array with:self new with:nil) do:[:el | el size printCR.].
|
|
1031 |
"
|
|
1032 |
|
|
1033 |
|
|
1034 |
|
|
1035 |
! !
|
|
1036 |
|
|
1037 |
!CompilerTest methodsFor:'tests instvar access'!
|
|
1038 |
|
|
1039 |
retInstVar
|
|
1040 |
^ value
|
|
1041 |
|
|
1042 |
"
|
|
1043 |
self new retInstVar
|
80
|
1044 |
1000000 timesRepeat:[self new retInstVar]
|
|
1045 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new retInstVar] ]
|
79
|
1046 |
"
|
|
1047 |
|
|
1048 |
"
|
|
1049 |
|i|
|
|
1050 |
|
|
1051 |
i := self new.
|
|
1052 |
i instVarAt:1 put:12345.
|
80
|
1053 |
i retInstVar
|
|
1054 |
"
|
|
1055 |
|
|
1056 |
"
|
|
1057 |
|i|
|
|
1058 |
i := self new.
|
|
1059 |
i instVarAt:1 put:12345.
|
|
1060 |
1000000 timesRepeat:[i retInstVar]
|
|
1061 |
"
|
|
1062 |
|
|
1063 |
"
|
|
1064 |
|i|
|
|
1065 |
i := self new.
|
|
1066 |
i instVarAt:1 put:12345.
|
|
1067 |
Time millisecondsToRun:[ 1000000 timesRepeat:[i retInstVar] ]
|
|
1068 |
"
|
|
1069 |
|
|
1070 |
|
|
1071 |
!
|
|
1072 |
|
|
1073 |
setInstVarA
|
|
1074 |
value := 123
|
|
1075 |
|
|
1076 |
"
|
|
1077 |
self new setInstVarA; instVarAt:1
|
|
1078 |
1000000 timesRepeat:[self new setInstVarA]
|
|
1079 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new setInstVarA] ]
|
|
1080 |
"
|
|
1081 |
|
|
1082 |
"
|
|
1083 |
|i|
|
|
1084 |
|
|
1085 |
i := self new.
|
|
1086 |
i instVarAt:1 put:12345.
|
|
1087 |
i setInstVarA.
|
79
|
1088 |
i instVarAt:1
|
|
1089 |
"
|
|
1090 |
|
|
1091 |
|
|
1092 |
|
80
|
1093 |
!
|
|
1094 |
|
|
1095 |
setInstVarB
|
|
1096 |
value := 'hello'
|
|
1097 |
|
|
1098 |
"
|
|
1099 |
self new setInstVarB; instVarAt:1
|
|
1100 |
1000000 timesRepeat:[self new setInstVarB]
|
|
1101 |
Time millisecondsToRun:[ 1000000 timesRepeat:[self new setInstVarB] ]
|
|
1102 |
"
|
|
1103 |
|
|
1104 |
"
|
|
1105 |
|i|
|
|
1106 |
|
|
1107 |
i := self new.
|
|
1108 |
i instVarAt:1 put:12345.
|
|
1109 |
i setInstVarB.
|
|
1110 |
i instVarAt:1
|
|
1111 |
"
|
|
1112 |
|
|
1113 |
|
|
1114 |
|
79
|
1115 |
! !
|
|
1116 |
|
47
|
1117 |
!CompilerTest class methodsFor:'documentation'!
|
|
1118 |
|
|
1119 |
version
|
|
1120 |
^ '$Header$'
|
|
1121 |
! !
|