47
|
1 |
Object subclass:#CompilerTest
|
|
2 |
instanceVariableNames:''
|
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Tests - Compiler'
|
|
6 |
!
|
|
7 |
|
|
8 |
|
48
|
9 |
!CompilerTest methodsFor:'tests - booleans'!
|
|
10 |
|
|
11 |
testNot1:arg
|
|
12 |
^ arg not
|
|
13 |
|
|
14 |
"
|
49
|
15 |
self new testNot1:true.
|
48
|
16 |
self new testNot1:false.
|
|
17 |
self new testNot1:1234.
|
|
18 |
"
|
|
19 |
!
|
|
20 |
|
|
21 |
testNot2:arg1 _:arg2
|
|
22 |
^ arg1 not & arg2 not
|
|
23 |
|
|
24 |
"
|
|
25 |
self new testNot2:true _:true.
|
|
26 |
self new testNot2:false _:true.
|
|
27 |
self new testNot2:true _:false.
|
|
28 |
self new testNot2:false _:false.
|
|
29 |
|
|
30 |
self new testNot2:false _:1234.
|
|
31 |
self new testNot2:true _:1234.
|
|
32 |
self new testNot2:1234 _:true.
|
|
33 |
self new testNot2:1234 _:false.
|
|
34 |
self new testNot2:1234 _:2345.
|
|
35 |
"
|
|
36 |
! !
|
|
37 |
|
47
|
38 |
!CompilerTest methodsFor:'tests - constant folding'!
|
|
39 |
|
|
40 |
testFloat_pi
|
|
41 |
^ Float pi
|
|
42 |
!
|
|
43 |
|
|
44 |
testFloat_unity
|
|
45 |
^ Float unity
|
|
46 |
!
|
|
47 |
|
|
48 |
testFloat_zero
|
|
49 |
^ Float zero
|
|
50 |
!
|
|
51 |
|
|
52 |
testSmalltalk_if_else_isSmalltalkX
|
|
53 |
Smalltalk isSmalltalkX ifTrue:[
|
|
54 |
^ 'yes'
|
|
55 |
] ifFalse:[
|
|
56 |
^ 'no'
|
|
57 |
]
|
|
58 |
!
|
|
59 |
|
|
60 |
testSmalltalk_if_else_isVisualWorks
|
|
61 |
Smalltalk isVisualWorks ifTrue:[
|
|
62 |
^ 'yes'
|
|
63 |
] ifFalse:[
|
|
64 |
^ 'no'
|
|
65 |
]
|
|
66 |
!
|
|
67 |
|
|
68 |
testSmalltalk_if_isSmalltalkX
|
|
69 |
Smalltalk isSmalltalkX ifTrue:[
|
|
70 |
^ 'yes'
|
|
71 |
].
|
|
72 |
^ 'no'
|
|
73 |
!
|
|
74 |
|
|
75 |
testSmalltalk_if_isSqueak
|
|
76 |
Smalltalk isSqueak ifTrue:[
|
|
77 |
^ 'yes'
|
|
78 |
].
|
|
79 |
^ 'no'
|
|
80 |
!
|
|
81 |
|
|
82 |
testSmalltalk_if_isVisualWorks
|
|
83 |
Smalltalk isVisualWorks ifTrue:[
|
|
84 |
^ 'yes'
|
|
85 |
].
|
|
86 |
^ 'no'
|
|
87 |
!
|
|
88 |
|
|
89 |
testSmalltalk_isSmalltalkX
|
|
90 |
^ Smalltalk isSmalltalkX
|
|
91 |
!
|
|
92 |
|
|
93 |
testSmalltalk_isSqueak
|
|
94 |
^ Smalltalk isSqueak
|
|
95 |
!
|
|
96 |
|
|
97 |
testSmalltalk_isVisualAge
|
|
98 |
^ Smalltalk isVisualAge
|
|
99 |
!
|
|
100 |
|
|
101 |
testSmalltalk_isVisualWorks
|
|
102 |
^ Smalltalk isVisualWorks
|
|
103 |
!
|
|
104 |
|
|
105 |
testUnaryFolding
|
|
106 |
self testFloat_pi ~= (Float perform:#pi) ifTrue:[self halt].
|
|
107 |
self testFloat_unity ~= (Float perform:#unity) ifTrue:[self halt].
|
|
108 |
self testFloat_zero ~= (Float perform:#zero) ifTrue:[self halt].
|
|
109 |
|
|
110 |
self testSmalltalk_isSmalltalkX ~= (Smalltalk perform:#isSmalltalkX) ifTrue:[self halt].
|
|
111 |
self testSmalltalk_isSqueak ~= (Smalltalk perform:#isSqueak) ifTrue:[self halt].
|
|
112 |
self testSmalltalk_isVisualWorks ~= (Smalltalk perform:#isVisualWorks) ifTrue:[self halt].
|
|
113 |
self testSmalltalk_isVisualAge ~= (Smalltalk perform:#isVisualAge) ifTrue:[self halt].
|
|
114 |
|
|
115 |
"
|
|
116 |
self basicNew testUnaryFolding
|
|
117 |
"
|
|
118 |
! !
|
|
119 |
|
|
120 |
!CompilerTest class methodsFor:'documentation'!
|
|
121 |
|
|
122 |
version
|
|
123 |
^ '$Header$'
|
|
124 |
! !
|