69
|
1 |
"{ Package: 'exept:regression' }"
|
58
|
2 |
|
70
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
95
|
5 |
TestCase subclass:#BlockTest
|
58
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
59
|
9 |
category:'Tests-Regression'
|
58
|
10 |
!
|
|
11 |
|
|
12 |
|
95
|
13 |
!BlockTest methodsFor:'varArgBlocks'!
|
58
|
14 |
|
97
|
15 |
getBlock1
|
|
16 |
|b|
|
|
17 |
|
|
18 |
b := [:arg | Transcript
|
|
19 |
show:'invoked with arg:';
|
|
20 |
showCR:arg
|
|
21 |
].
|
|
22 |
^ b
|
|
23 |
!
|
|
24 |
|
58
|
25 |
getVarArgBlock1
|
|
26 |
|b|
|
|
27 |
|
|
28 |
b := [:argList | Transcript
|
70
|
29 |
show:'invoked with args:';
|
|
30 |
showCR:argList
|
|
31 |
] asVarArgBlock.
|
58
|
32 |
^ b
|
|
33 |
|
|
34 |
|
|
35 |
!
|
|
36 |
|
|
37 |
getVarArgBlock2
|
|
38 |
|b|
|
|
39 |
|
|
40 |
b := [:argList | Transcript
|
70
|
41 |
show:'invoked with args:';
|
|
42 |
showCR:argList.
|
|
43 |
argList
|
|
44 |
] asVarArgBlock.
|
58
|
45 |
^ b
|
|
46 |
|
|
47 |
|
|
48 |
!
|
|
49 |
|
|
50 |
getVarArgBlock3
|
|
51 |
|b|
|
|
52 |
|
|
53 |
b := [:argList | Transcript
|
70
|
54 |
show:'invoked with args:';
|
|
55 |
showCR:argList.
|
|
56 |
argList size
|
|
57 |
] asVarArgBlock.
|
58
|
58 |
^ b
|
|
59 |
|
|
60 |
|
|
61 |
!
|
|
62 |
|
97
|
63 |
testBlock1
|
|
64 |
|b|
|
|
65 |
|
|
66 |
b := self getBlock1.
|
|
67 |
|
|
68 |
b code notNil ifTrue:[
|
|
69 |
Transcript showCR:'before call: *** blocks code is jitted'
|
|
70 |
] ifFalse:[
|
|
71 |
Transcript showCR:'before call: blocks code is NOT jitted'
|
|
72 |
].
|
|
73 |
b value:nil.
|
|
74 |
b code notNil ifTrue:[
|
|
75 |
Transcript showCR:'after call: blocks code is jitted'
|
|
76 |
] ifFalse:[
|
|
77 |
Transcript showCR:'after call: *** blocks code is NOT jitted'
|
|
78 |
].
|
|
79 |
|
|
80 |
b value:#foo.
|
|
81 |
b value:1.
|
|
82 |
b value:2
|
|
83 |
|
|
84 |
"
|
|
85 |
self new testBlock1
|
|
86 |
"
|
|
87 |
!
|
|
88 |
|
58
|
89 |
testVarArgBlock1
|
|
90 |
|b|
|
|
91 |
|
|
92 |
b := self getVarArgBlock1.
|
|
93 |
|
|
94 |
b value.
|
60
|
95 |
b code notNil ifTrue:[
|
95
|
96 |
Transcript showCR:'blocks code is jitted'
|
60
|
97 |
] ifFalse:[
|
95
|
98 |
Transcript showCR:'*** blocks code is NOT jitted'
|
60
|
99 |
].
|
|
100 |
|
|
101 |
b value.
|
58
|
102 |
b value:'arg1'.
|
|
103 |
b value:'arg1' value:'arg2' value:'arg3' value:'arg4'
|
|
104 |
|
|
105 |
"
|
95
|
106 |
self new testVarArgBlock1
|
58
|
107 |
"
|
|
108 |
!
|
|
109 |
|
|
110 |
testVarArgBlock2
|
|
111 |
|b|
|
|
112 |
|
|
113 |
b := self getVarArgBlock2.
|
|
114 |
|
60
|
115 |
b value.
|
|
116 |
b code notNil ifTrue:[
|
95
|
117 |
Transcript showCR:'blocks code is jitted'
|
60
|
118 |
] ifFalse:[
|
95
|
119 |
Transcript showCR:'*** blocks code is NOT jitted'
|
60
|
120 |
].
|
|
121 |
|
95
|
122 |
self assert:( b value = #() ).
|
|
123 |
self assert:( (b value:1) = #(1) ).
|
|
124 |
self assert:( (b value:1 value:2) = #(1 2) ).
|
|
125 |
self assert:( (b value:1 value:2 value:3) = #(1 2 3) ).
|
|
126 |
self assert:( (b value:1 value:2 value:3 value:4) = #(1 2 3 4) ).
|
|
127 |
self assert:( (b valueWithArguments:#(1 2 3 4)) = #(1 2 3 4) ).
|
58
|
128 |
|
95
|
129 |
self assert:( (b perform:#value) = #() ).
|
|
130 |
self assert:( (b perform:#'value:' with:1) = #(1) ).
|
|
131 |
self assert:( (b perform:#'value:value:' with:1 with:2) = #(1 2) ).
|
|
132 |
self assert:( (b perform:#'value:value:value:' with:1 with:2 with:3) = #(1 2 3) ).
|
|
133 |
self assert:( (b perform:#'value:value:value:value:' with:1 with:2 with:3 with:4) = #(1 2 3 4) ).
|
|
134 |
self assert:( (b perform:#'valueWithArguments:' with:#(1 2 3 4)) = #(1 2 3 4) ).
|
58
|
135 |
|
|
136 |
"
|
95
|
137 |
self new testVarArgBlock2
|
58
|
138 |
"
|
|
139 |
!
|
|
140 |
|
|
141 |
testVarArgBlock3
|
|
142 |
|b|
|
|
143 |
|
|
144 |
b := self getVarArgBlock3.
|
|
145 |
|
60
|
146 |
b value.
|
|
147 |
b code notNil ifTrue:[
|
95
|
148 |
Transcript showCR:'blocks code is jitted'
|
60
|
149 |
] ifFalse:[
|
95
|
150 |
Transcript showCR:'*** blocks code is NOT jitted'
|
60
|
151 |
].
|
|
152 |
|
95
|
153 |
self assert:( b value = 0 ).
|
|
154 |
self assert:( (b value:1) = 1 ).
|
|
155 |
self assert:( (b value:1 value:2) = 2 ).
|
|
156 |
self assert:( (b value:1 value:2 value:3) = 3 ).
|
|
157 |
self assert:( (b value:1 value:2 value:3 value:4) = 4 ).
|
|
158 |
self assert:( (b valueWithArguments:#(1 2 3 4)) = 4 ).
|
58
|
159 |
|
95
|
160 |
self assert:( (b perform:#value) = 0 ).
|
|
161 |
self assert:( (b perform:#'value:' with:1) = 1 ).
|
|
162 |
self assert:( (b perform:#'value:value:' with:1 with:2) = 2 ).
|
|
163 |
self assert:( (b perform:#'value:value:value:' with:1 with:2 with:3) = 3 ).
|
|
164 |
self assert:( (b perform:#'value:value:value:value:' with:1 with:2 with:3 with:4) = 4 ).
|
|
165 |
self assert:( (b perform:#'valueWithArguments:' with:#(1 2 3 4)) = 4 ).
|
58
|
166 |
|
|
167 |
"
|
95
|
168 |
self new testVarArgBlock3
|
58
|
169 |
"
|
|
170 |
!
|
|
171 |
|
95
|
172 |
xtestAll
|
|
173 |
self testVarArgBlocks.
|
|
174 |
|
|
175 |
"
|
|
176 |
self new xtestAll
|
|
177 |
"
|
|
178 |
!
|
|
179 |
|
|
180 |
xtestVarArgBlocks
|
58
|
181 |
self testVarArgBlock1.
|
|
182 |
self testVarArgBlock2.
|
|
183 |
self testVarArgBlock3.
|
|
184 |
! !
|
|
185 |
|
|
186 |
!BlockTest class methodsFor:'documentation'!
|
|
187 |
|
|
188 |
version
|
|
189 |
^ '$Header$'
|
|
190 |
! !
|