author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 30 Jun 2016 09:02:08 +0100 | |
branch | jv |
changeset 1500 | d406a10b2965 |
parent 1499 | 26a16a04219b |
parent 1447 | 2351db93aa5b |
child 1533 | 94753c163f85 |
permissions | -rw-r--r-- |
1447 | 1 |
"{ Package: 'stx:goodies/regression' }" |
261 | 2 |
|
3 |
"{ NameSpace: RegressionTests }" |
|
4 |
||
5 |
TestCase subclass:#JavaScriptTests |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
1263
57708dac3859
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1241
diff
changeset
|
9 |
category:'tests-Regression-Compilers' |
261 | 10 |
! |
11 |
||
12 |
!JavaScriptTests class methodsFor:'documentation'! |
|
13 |
||
14 |
documentation |
|
15 |
" |
|
16 |
documentation to be added. |
|
17 |
||
18 |
[author:] |
|
1447 | 19 |
cg (cg@FUSI) |
261 | 20 |
|
21 |
[instance variables:] |
|
22 |
||
23 |
[class variables:] |
|
24 |
||
25 |
[see also:] |
|
26 |
||
27 |
" |
|
28 |
! |
|
29 |
||
30 |
history |
|
31 |
"Created: / 12-04-2005 / 11:54:25 / cg" |
|
32 |
! ! |
|
33 |
||
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
34 |
!JavaScriptTests class methodsFor:'queries'! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
35 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
36 |
coveredClassNames |
1447 | 37 |
^ #( |
38 |
JavaScriptParser |
|
39 |
JavaScriptScanner |
|
40 |
JavaScriptCompiler |
|
41 |
) |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
42 |
! ! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
43 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
44 |
!JavaScriptTests methodsFor:'helpers'! |
261 | 45 |
|
1447 | 46 |
doTestEachFromSpec:spec |
47 |
spec do:[:triple | |
|
48 |
|str checkSelectorOrNil valExpected val expectError| |
|
49 |
||
50 |
str := triple first. |
|
51 |
checkSelectorOrNil := triple second. |
|
52 |
expectError := false. |
|
53 |
valExpected := triple third. |
|
54 |
valExpected isArray ifTrue:[ |
|
55 |
valExpected size > 0 ifTrue:[ |
|
56 |
valExpected first == #eval ifTrue:[ |
|
57 |
valExpected := Parser evaluate:valExpected second |
|
58 |
] ifFalse:[ |
|
59 |
valExpected first == #error ifTrue:[ |
|
60 |
expectError := true |
|
61 |
]. |
|
62 |
]. |
|
63 |
]. |
|
64 |
]. |
|
65 |
expectError ifTrue:[ |
|
66 |
self |
|
67 |
should:[ (JavaScriptParser parseExpression:str) evaluate ] |
|
68 |
raise:Error |
|
69 |
] ifFalse:[ |
|
70 |
val := (JavaScriptParser parseExpression:str) evaluate. |
|
71 |
checkSelectorOrNil notNil ifTrue:[ |
|
72 |
self assert:(val perform:checkSelectorOrNil). |
|
73 |
]. |
|
74 |
self assert:(val = valExpected). |
|
75 |
]. |
|
262 | 76 |
] |
77 |
! |
|
78 |
||
1447 | 79 |
doTestEachFunctionFromSpec:spec |
80 |
spec do:[:tuple | |
|
81 |
|source expectError| |
|
82 |
||
83 |
source := tuple first. |
|
84 |
expectError := tuple second. |
|
85 |
||
86 |
expectError ifTrue:[ |
|
87 |
self |
|
88 |
should:[ JavaScriptParser parseFunction:source ] |
|
89 |
raise:Error |
|
90 |
] ifFalse:[ |
|
91 |
JavaScriptParser parseFunction:source. |
|
92 |
]. |
|
700 | 93 |
] |
94 |
! |
|
95 |
||
556 | 96 |
execute:code for:receiver arguments:arguments |
1002
820e29485296
class: RegressionTests::JavaScriptTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
946
diff
changeset
|
97 |
|parser f result| |
820e29485296
class: RegressionTests::JavaScriptTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
946
diff
changeset
|
98 |
|
820e29485296
class: RegressionTests::JavaScriptTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
946
diff
changeset
|
99 |
"/ First, validate the tree |
820e29485296
class: RegressionTests::JavaScriptTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
946
diff
changeset
|
100 |
parser := JavaScriptParser parseMethod: code in: nil. |
820e29485296
class: RegressionTests::JavaScriptTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
946
diff
changeset
|
101 |
self assert: parser tree notNil. |
820e29485296
class: RegressionTests::JavaScriptTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
946
diff
changeset
|
102 |
JavaScriptParseNodeValidator validate: parser tree source: code. |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
103 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
104 |
"/ Transcript showCR:(thisContext sender selector , '...'). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
105 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
106 |
f := JavaScriptCompiler |
1447 | 107 |
compile:code |
108 |
forClass:(receiver class) |
|
109 |
inCategory:nil |
|
110 |
notifying:nil |
|
111 |
install:false. |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
112 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
113 |
"/ f inspect. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
114 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
115 |
self assert:(f ~~ #Error). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
116 |
self assert:(f notNil). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
117 |
|
642 | 118 |
"/ f decompileTo:Transcript. |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
119 |
|
1447 | 120 |
result := f valueWithReceiver:receiver arguments:arguments selector:nil search:nil sender:nil. |
556 | 121 |
^ result |
642 | 122 |
|
123 |
"Modified: / 09-10-2011 / 11:41:51 / cg" |
|
1002
820e29485296
class: RegressionTests::JavaScriptTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
946
diff
changeset
|
124 |
"Modified (format): / 20-09-2013 / 11:56:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
556 | 125 |
! |
126 |
||
127 |
execute:code for:receiver arguments:arguments expect:expectedResult |
|
128 |
|result| |
|
129 |
||
130 |
result := self execute:code for:receiver arguments:arguments. |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
131 |
self assert:(result = expectedResult). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
132 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
133 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
134 |
execute:code for:receiver arguments:arguments expectError:expectedError |
347 | 135 |
|f errorEncountered| |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
136 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
137 |
"/ Transcript showCR:(thisContext sender selector , '...'). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
138 |
|
347 | 139 |
Parser parseErrorSignal handle:[:ex | |
1447 | 140 |
errorEncountered := true. |
347 | 141 |
] do:[ |
1447 | 142 |
f := JavaScriptCompiler |
143 |
compile:code |
|
144 |
forClass:(receiver class) |
|
145 |
inCategory:nil |
|
146 |
notifying:nil |
|
147 |
install:false. |
|
148 |
||
149 |
errorEncountered := (f == #Error). |
|
347 | 150 |
]. |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
151 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
152 |
expectedError == #ParseError ifTrue:[ |
1447 | 153 |
self assert:(errorEncountered). |
154 |
^ self |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
155 |
]. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
156 |
|
347 | 157 |
self assert:(errorEncountered not). |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
158 |
self assert:(f notNil). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
159 |
|
642 | 160 |
"/ f decompileTo:Transcript. |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
161 |
|
1447 | 162 |
self |
163 |
should:[f valueWithReceiver:receiver arguments:arguments] |
|
164 |
raise:expectedError |
|
642 | 165 |
|
166 |
"Modified: / 09-10-2011 / 11:41:57 / cg" |
|
622 | 167 |
! |
168 |
||
731 | 169 |
outputToTranscriptOf:aBlock |
170 |
"yes, globals are bad - that's what we need stuff like this for..." |
|
171 |
||
172 |
|output| |
|
173 |
||
174 |
output := '' writeStream. |
|
175 |
self withTranscriptRedirectedTo:output do:aBlock. |
|
176 |
^ output contents |
|
177 |
! |
|
178 |
||
627 | 179 |
setUp |
622 | 180 |
JavaScriptCompiler isNil ifTrue:[ |
1447 | 181 |
Smalltalk loadPackage:'stx:libjavascript'. |
182 |
JavaScriptParseNodeValidator autoload. |
|
622 | 183 |
]. |
184 |
||
627 | 185 |
"Created: / 09-08-2011 / 23:12:13 / cg" |
1002
820e29485296
class: RegressionTests::JavaScriptTests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
946
diff
changeset
|
186 |
"Modified: / 20-09-2013 / 11:58:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
731 | 187 |
! |
188 |
||
189 |
withTranscriptRedirectedTo:aStream do:aBlock |
|
190 |
"yes, globals are bad - that's what we need stuff like this for..." |
|
191 |
||
192 |
|savedTranscript| |
|
193 |
||
194 |
savedTranscript := Transcript. |
|
195 |
[ |
|
1447 | 196 |
Transcript := aStream. |
197 |
aBlock value. |
|
731 | 198 |
] ensure:[ |
1447 | 199 |
Transcript := savedTranscript |
731 | 200 |
]. |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
201 |
! ! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
202 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
203 |
!JavaScriptTests methodsFor:'tests'! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
204 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
205 |
testArray01 |
1447 | 206 |
self |
207 |
execute:'test(arr) { |
|
208 |
return arr[1]; |
|
209 |
}' |
|
210 |
for:nil |
|
211 |
arguments:#( #(10 20 30) ) |
|
212 |
expect:10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
213 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
214 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
215 |
self run:#testArray01 |
1447 | 216 |
self new testArray01 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
217 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
218 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
219 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
220 |
testArray02 |
1447 | 221 |
self |
222 |
execute:'test(arr) { |
|
223 |
arr[1]; |
|
224 |
}' |
|
225 |
for:nil |
|
226 |
arguments:#( #(10 20 30) ) |
|
227 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
228 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
229 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
230 |
self run:#testArray02 |
1447 | 231 |
self new testArray02 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
232 |
" |
331 | 233 |
|
234 |
"Modified: / 21-02-2007 / 13:02:39 / cg" |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
235 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
236 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
237 |
testArray03 |
1447 | 238 |
self |
239 |
execute:'test(arr, val) { |
|
240 |
arr[1] = val; |
|
241 |
return arr; |
|
242 |
}' |
|
243 |
for:nil |
|
244 |
arguments:#( #(10 20 30) 99 ) deepCopy "deepCopy - this is immutable" |
|
245 |
expect:#(99 20 30) |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
246 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
247 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
248 |
self run:#testArray03 |
1447 | 249 |
self new testArray03 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
250 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
251 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
252 |
|
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
253 |
testArray04 |
1447 | 254 |
self |
255 |
execute:'test() { |
|
256 |
var arr = new Array; |
|
257 |
return arr; |
|
258 |
}' |
|
259 |
for:nil |
|
260 |
arguments:#( ) |
|
261 |
expect:#() |
|
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
262 |
|
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
263 |
" |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
264 |
self run:#testArray04 |
1447 | 265 |
self new testArray04 |
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
266 |
" |
331 | 267 |
|
268 |
"Modified: / 21-02-2007 / 13:03:22 / cg" |
|
269 |
! |
|
270 |
||
271 |
testArray04a |
|
1447 | 272 |
self |
273 |
execute:'test() { |
|
274 |
var arr = new Array; |
|
275 |
return arr; |
|
276 |
}' |
|
277 |
for:nil |
|
278 |
arguments:#( ) |
|
279 |
expect:#() |
|
331 | 280 |
|
281 |
" |
|
282 |
self run:#testArray04a |
|
1447 | 283 |
self new testArray04a |
331 | 284 |
" |
285 |
||
286 |
"Created: / 21-02-2007 / 13:03:39 / cg" |
|
287 |
! |
|
288 |
||
289 |
testArray04b |
|
1447 | 290 |
self |
291 |
execute:'test() { |
|
292 |
var arr = Array.new; |
|
293 |
return arr; |
|
294 |
}' |
|
295 |
for:nil |
|
296 |
arguments:#( ) |
|
297 |
expect:#() |
|
331 | 298 |
|
299 |
" |
|
300 |
self run:#testArray04b |
|
1447 | 301 |
self new testArray04b |
331 | 302 |
" |
303 |
||
304 |
"Created: / 21-02-2007 / 13:03:48 / cg" |
|
305 |
! |
|
306 |
||
307 |
testArray04c |
|
1447 | 308 |
self |
309 |
execute:'test() { |
|
310 |
var arr = Array.new(); |
|
311 |
return arr; |
|
312 |
}' |
|
313 |
for:nil |
|
314 |
arguments:#( ) |
|
315 |
expect:#() |
|
331 | 316 |
|
317 |
" |
|
318 |
self run:#testArray04c |
|
1447 | 319 |
self new testArray04c |
331 | 320 |
" |
321 |
||
322 |
"Created: / 21-02-2007 / 13:04:00 / cg" |
|
323 |
! |
|
324 |
||
325 |
testArray04d |
|
1447 | 326 |
self |
327 |
execute:'test() { |
|
328 |
var arr = new Array(); |
|
329 |
return arr; |
|
330 |
}' |
|
331 |
for:nil |
|
332 |
arguments:#( ) |
|
333 |
expect:#() |
|
331 | 334 |
|
335 |
" |
|
336 |
self run:#testArray04d |
|
1447 | 337 |
self new testArray04d |
331 | 338 |
" |
339 |
||
340 |
"Created: / 21-02-2007 / 13:04:25 / cg" |
|
341 |
! |
|
342 |
||
343 |
testArray06a |
|
1447 | 344 |
self |
345 |
execute:'test() { |
|
346 |
var arr = new Array(5); |
|
347 |
return arr; |
|
348 |
}' |
|
349 |
for:nil |
|
350 |
arguments:#( ) |
|
351 |
expect:#( nil nil nil nil nil ) |
|
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
352 |
|
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
353 |
" |
331 | 354 |
self run:#testArray06a |
1447 | 355 |
self new testArray06a |
331 | 356 |
" |
357 |
||
358 |
"Created: / 21-02-2007 / 13:04:52 / cg" |
|
359 |
! |
|
360 |
||
361 |
testArray06b |
|
1447 | 362 |
self |
363 |
execute:'test() { |
|
364 |
var arr = Array.new(5); |
|
365 |
return arr; |
|
366 |
}' |
|
367 |
for:nil |
|
368 |
arguments:#( ) |
|
369 |
expect:#( nil nil nil nil nil ) |
|
331 | 370 |
|
371 |
" |
|
372 |
self run:#testArray06b |
|
1447 | 373 |
self new testArray06b |
331 | 374 |
" |
375 |
||
376 |
"Created: / 21-02-2007 / 13:05:08 / cg" |
|
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
377 |
! |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
378 |
|
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
379 |
testArray07 |
1447 | 380 |
self |
381 |
execute:'test() { |
|
382 |
var arr = new Array(3); |
|
383 |
arr[1] = 41; |
|
384 |
arr[2] = -5; |
|
385 |
arr[3] = 20; |
|
386 |
return arr; |
|
387 |
}' |
|
388 |
for:nil |
|
389 |
arguments:#() |
|
390 |
expect:#( 41 -5 20 ). |
|
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
391 |
|
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
392 |
" |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
393 |
self run:#testArray07 |
1447 | 394 |
self new testArray07 |
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
395 |
" |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
396 |
! |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
397 |
|
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
398 |
testArray08 |
1447 | 399 |
self |
400 |
execute:'test() { |
|
401 |
var arr = new Array(3); |
|
402 |
arr[1] = 41; |
|
403 |
arr[2] = -5; |
|
404 |
arr[3] = 20; |
|
405 |
return arr; |
|
406 |
}' |
|
407 |
for:nil |
|
408 |
arguments:#( ) |
|
409 |
expect:#( 41 -5 20 ) |
|
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
410 |
|
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
411 |
" |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
412 |
self run:#testArray08 |
1447 | 413 |
self new testArray08 |
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
414 |
" |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
415 |
! |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
416 |
|
331 | 417 |
testArray09 |
1447 | 418 |
self |
419 |
execute:'test() { |
|
420 |
var arr = [1,2,3]; |
|
421 |
return arr; |
|
422 |
}' |
|
423 |
for:nil |
|
424 |
arguments:#( ) |
|
425 |
expect:#( 1 2 3 ) |
|
331 | 426 |
|
427 |
" |
|
428 |
self run:#testArray09 |
|
1447 | 429 |
self new testArray09 |
331 | 430 |
" |
431 |
||
432 |
"Created: / 21-02-2007 / 13:05:48 / cg" |
|
433 |
! |
|
434 |
||
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
435 |
testAssignmentExpression01 |
1447 | 436 |
self |
437 |
execute:'assign(a, b) { |
|
438 |
var x, y; |
|
439 |
||
440 |
x = y = 0; |
|
441 |
x = y = a; |
|
442 |
x = y = b; |
|
443 |
return (x + y); |
|
444 |
}' |
|
445 |
for:nil |
|
446 |
arguments:#(10 20) |
|
447 |
expect:40 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
448 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
449 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
450 |
self run:#testAssignmentExpression01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
451 |
self new testAssignmentExpression01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
452 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
453 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
454 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
455 |
testAssignmentExpression02 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
456 |
"yes, in JS you can change an argument variable" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
457 |
|
1447 | 458 |
self |
459 |
execute:'assign(a, b) { |
|
460 |
var x, y; |
|
461 |
||
462 |
a = x = y = 0; |
|
463 |
return (a + b); |
|
464 |
}' |
|
465 |
for:nil |
|
466 |
arguments:#(10 20) |
|
467 |
expect:20 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
468 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
469 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
470 |
self run:#testAssignmentExpression02 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
471 |
self new testAssignmentExpression02 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
472 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
473 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
474 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
475 |
testCommaExpression01 |
1447 | 476 |
self |
477 |
execute:'comma(a, b, c) { |
|
478 |
return (a , b , c); |
|
479 |
}' |
|
480 |
for:nil |
|
481 |
arguments:#(10 20 30) |
|
482 |
expect:30 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
483 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
484 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
485 |
self run:#testCommaExpression01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
486 |
self new testCommaExpression01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
487 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
488 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
489 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
490 |
testCommaExpression02 |
1447 | 491 |
self |
492 |
execute:'comma(a, b, c) { |
|
493 |
return (a+10 , b+10 , c+10); |
|
494 |
}' |
|
495 |
for:nil |
|
496 |
arguments:#(10 20 30) |
|
497 |
expect:40 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
498 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
499 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
500 |
self run:#testCommaExpression02 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
501 |
self new testCommaExpression02 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
502 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
503 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
504 |
|
320 | 505 |
testComments01 |
1368 | 506 |
|savedTranscript collector expected| |
507 |
||
1447 | 508 |
savedTranscript := Smalltalk at:#Transcript. |
1368 | 509 |
[ |
1447 | 510 |
Smalltalk at:#Transcript put:(collector := '' writeStream). |
1485 | 511 |
self |
512 |
execute:' |
|
513 |
testComments() { |
|
514 |
// Unicode is allowed in comments |
|
515 |
// This is a comment \u0410\u0406\u0414\u0419 |
|
516 |
/* Another comment \u05D0\u2136\u05d3\u05d7 */ |
|
517 |
||
518 |
/**/ // Tiny comment |
|
519 |
/***/ // Also valid |
|
520 |
||
521 |
// Need to test string literals and identifiers |
|
1447 | 522 |
println("All is well in Javascript"); |
1485 | 523 |
return null; |
524 |
} |
|
525 |
' |
|
526 |
for:JavaScriptEnvironment new |
|
527 |
arguments:#( ) |
|
528 |
expect:nil |
|
1368 | 529 |
] ensure:[ |
1447 | 530 |
Smalltalk at:#Transcript put:savedTranscript |
1368 | 531 |
]. |
532 |
||
533 |
expected := String streamContents:[:s | s showCR:'All is well in Javascript']. |
|
534 |
self assert:(collector contents = expected). |
|
1485 | 535 |
|
320 | 536 |
" |
537 |
self run:#testComments01 |
|
1447 | 538 |
self new testComments01 |
320 | 539 |
" |
540 |
! |
|
541 |
||
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
542 |
testConditionalExpression01 |
1447 | 543 |
self |
544 |
execute:'max(a, b) { |
|
545 |
return (a > b) ? a : b; |
|
546 |
}' |
|
547 |
for:nil |
|
548 |
arguments:#(10 20) |
|
549 |
expect:20 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
550 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
551 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
552 |
self run:#testConditionalExpression01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
553 |
self new testConditionalExpression01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
554 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
555 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
556 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
557 |
testConditionalExpression02 |
1447 | 558 |
self |
559 |
execute:'max(a, b) { |
|
560 |
return (a < b) ? a : b; |
|
561 |
}' |
|
562 |
for:nil |
|
563 |
arguments:#(10 20) |
|
564 |
expect:10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
565 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
566 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
567 |
self run:#testConditionalExpression02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
568 |
self new testConditionalExpression02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
569 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
570 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
571 |
|
268 | 572 |
testDoWhile01 |
731 | 573 |
|output| |
574 |
||
575 |
output := self outputToTranscriptOf:[ |
|
1447 | 576 |
self |
577 |
execute:'test(arg) { |
|
578 |
var n; |
|
579 |
||
580 |
n = 1; |
|
581 |
do { |
|
582 |
Transcript.showCR(n); |
|
583 |
} while (++n <= 3); |
|
584 |
return n; |
|
585 |
}' |
|
586 |
for:nil |
|
587 |
arguments:#(5) |
|
588 |
expect:4 |
|
731 | 589 |
]. |
590 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' )) |
|
268 | 591 |
|
592 |
" |
|
593 |
self run:#testDoWhile01 |
|
594 |
self new testDoWhile01 |
|
595 |
" |
|
596 |
! |
|
597 |
||
598 |
testDoWhile02 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
599 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
600 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
601 |
output := self outputToTranscriptOf:[ |
1447 | 602 |
self |
603 |
execute:'test(arg) { |
|
604 |
var n; |
|
605 |
||
606 |
n = 1; |
|
607 |
do { |
|
608 |
Transcript.showCR(n); |
|
609 |
break; |
|
610 |
} while (true); |
|
611 |
return n; |
|
612 |
}' |
|
613 |
for:nil |
|
614 |
arguments:#(5) |
|
615 |
expect:1 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
616 |
]. |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
617 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' )) |
268 | 618 |
|
619 |
" |
|
620 |
self run:#testDoWhile02 |
|
621 |
self new testDoWhile02 |
|
622 |
" |
|
623 |
! |
|
624 |
||
625 |
testDoWhile03 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
626 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
627 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
628 |
output := self outputToTranscriptOf:[ |
1447 | 629 |
self |
630 |
execute:'test(arg) { |
|
631 |
var n; |
|
632 |
||
633 |
n = 1; |
|
634 |
do { |
|
635 |
break; |
|
636 |
Transcript.showCR(n); |
|
637 |
} while (true); |
|
638 |
return n; |
|
639 |
}' |
|
640 |
for:nil |
|
641 |
arguments:#(5) |
|
642 |
expect:1 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
643 |
]. |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
644 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( )) |
268 | 645 |
|
646 |
" |
|
647 |
self run:#testDoWhile03 |
|
648 |
self new testDoWhile03 |
|
649 |
" |
|
650 |
! |
|
651 |
||
652 |
testDoWhile04 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
653 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
654 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
655 |
output := self outputToTranscriptOf:[ |
1447 | 656 |
self |
657 |
execute:'test(arg) { |
|
658 |
var n; |
|
659 |
||
660 |
n = 1; |
|
661 |
do { |
|
662 |
if (++n == 3) continue; |
|
663 |
Transcript.showCR(n); |
|
664 |
} while (n <= 4); |
|
665 |
return n; |
|
666 |
}' |
|
667 |
for:nil |
|
668 |
arguments:#(5) |
|
669 |
expect:5 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
670 |
]. |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
671 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '4' '5' )) |
268 | 672 |
|
673 |
" |
|
674 |
self run:#testDoWhile04 |
|
675 |
self new testDoWhile04 |
|
676 |
" |
|
677 |
! |
|
678 |
||
679 |
testDoWhile05 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
680 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
681 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
682 |
output := self outputToTranscriptOf:[ |
1447 | 683 |
self |
684 |
execute:'test(arg) { |
|
685 |
var n; |
|
686 |
||
687 |
n = 1; |
|
688 |
do { |
|
689 |
if (++n == 3) break; |
|
690 |
Transcript.showCR(n); |
|
691 |
} while (n <= 4); |
|
692 |
return n; |
|
693 |
}' |
|
694 |
for:nil |
|
695 |
arguments:#(5) |
|
696 |
expect:3 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
697 |
]. |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
698 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' )) |
268 | 699 |
|
700 |
" |
|
701 |
self run:#testDoWhile05 |
|
702 |
self new testDoWhile05 |
|
703 |
" |
|
704 |
! |
|
705 |
||
269 | 706 |
testDoWhile06 |
1447 | 707 |
self |
708 |
execute:'test(arg) { |
|
709 |
var n; |
|
710 |
||
711 |
n = 1; |
|
712 |
do |
|
713 |
n += 1; |
|
714 |
while (n < 4); |
|
715 |
return n; |
|
716 |
}' |
|
717 |
for:nil |
|
718 |
arguments:#(5) |
|
719 |
expect:4 |
|
269 | 720 |
|
721 |
" |
|
722 |
self run:#testDoWhile06 |
|
723 |
self new testDoWhile06 |
|
724 |
" |
|
725 |
! |
|
726 |
||
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
727 |
testException01 |
1447 | 728 |
self |
729 |
execute:'test() { |
|
730 |
try { |
|
731 |
return 10; |
|
732 |
} catch(Error); |
|
733 |
return nil; |
|
734 |
}' |
|
735 |
for:nil |
|
736 |
arguments:#( ) |
|
737 |
expect:10 |
|
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
738 |
|
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
739 |
" |
321 | 740 |
self run:#testException01 |
1447 | 741 |
self new testException01 |
321 | 742 |
" |
331 | 743 |
|
744 |
"Modified: / 21-02-2007 / 10:28:50 / cg" |
|
321 | 745 |
! |
746 |
||
747 |
testException02 |
|
1447 | 748 |
self |
749 |
execute:'test() { |
|
750 |
try { |
|
751 |
Error.raise(); |
|
752 |
return 10; |
|
753 |
} catch(Error); |
|
754 |
return nil; |
|
755 |
}' |
|
756 |
for:nil |
|
757 |
arguments:#( ) |
|
758 |
expect:nil |
|
321 | 759 |
|
760 |
" |
|
761 |
self run:#testException02 |
|
1447 | 762 |
self new testException02 |
270
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
763 |
" |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
764 |
! |
de0e19424f61
hex character excapes; switch statement
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
765 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
766 |
testFor01 |
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
767 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
768 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
769 |
output := self outputToTranscriptOf:[ |
1447 | 770 |
self |
771 |
execute:'test(arg) { |
|
772 |
var n; |
|
773 |
||
774 |
for (n = 0; n < 10; n++) { |
|
775 |
Transcript.show("hello "); |
|
776 |
Transcript.showCR(n); |
|
777 |
} |
|
778 |
}' |
|
779 |
for:nil |
|
780 |
arguments:#(5) |
|
781 |
expect:nil |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
782 |
]. |
1447 | 783 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( |
784 |
'hello 0' |
|
785 |
'hello 1' |
|
786 |
'hello 2' |
|
787 |
'hello 3' |
|
788 |
'hello 4' |
|
789 |
'hello 5' |
|
790 |
'hello 6' |
|
791 |
'hello 7' |
|
792 |
'hello 8' |
|
793 |
'hello 9' )) |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
794 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
795 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
796 |
self run:#testFor01 |
1447 | 797 |
self new testFor01 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
798 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
799 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
800 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
801 |
testFor01b |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
802 |
|outStream output| |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
803 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
804 |
outStream := '' writeStream. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
805 |
|
1447 | 806 |
self |
807 |
execute:'test(arg, out) { |
|
808 |
var n; |
|
809 |
||
810 |
for (n = 0; n < arg; n++) { |
|
811 |
out.show("hello "); |
|
812 |
out.showCR(n); |
|
813 |
} |
|
814 |
}' |
|
815 |
for:nil |
|
816 |
arguments:(Array with:4 with:outStream) |
|
817 |
expect:nil. |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
818 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
819 |
output := outStream contents. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
820 |
self assert:(output = 'hello 0 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
821 |
hello 1 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
822 |
hello 2 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
823 |
hello 3 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
824 |
'). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
825 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
826 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
827 |
self run:#testFor01b |
1447 | 828 |
self new testFor01b |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
829 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
830 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
831 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
832 |
testFor01c |
1447 | 833 |
self |
834 |
execute:'test(arg) { |
|
835 |
var n, m; |
|
836 |
||
837 |
for (n = 0, m = 10; n < 10; n++, m--) { |
|
838 |
Transcript.show(n); |
|
839 |
Transcript.show(" -> "); |
|
840 |
Transcript.showCR(m); |
|
841 |
} |
|
842 |
}' |
|
843 |
for:nil |
|
844 |
arguments:#(5) |
|
845 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
846 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
847 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
848 |
self run:#testFor01c |
1447 | 849 |
self new testFor01c |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
850 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
851 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
852 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
853 |
testFor02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
854 |
|outStream output| |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
855 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
856 |
outStream := '' writeStream. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
857 |
|
1447 | 858 |
self |
859 |
execute:'test(arg, out) { |
|
860 |
var n; |
|
861 |
||
862 |
for (n = 0; n < arg; n++) { |
|
863 |
out.show("hello "); |
|
864 |
out.showCR(n); |
|
865 |
} |
|
866 |
}' |
|
867 |
for:nil |
|
868 |
arguments:(Array with:4 with:outStream) |
|
869 |
expect:nil. |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
870 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
871 |
output := outStream contents. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
872 |
self assert:(output = 'hello 0 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
873 |
hello 1 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
874 |
hello 2 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
875 |
hello 3 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
876 |
'). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
877 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
878 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
879 |
self run:#testFor02 |
1447 | 880 |
self new testFor02 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
881 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
882 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
883 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
884 |
testFor02b |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
885 |
|outStream output| |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
886 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
887 |
outStream := '' writeStream. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
888 |
|
1447 | 889 |
self |
890 |
execute:'test(arg, out) { |
|
891 |
var n; |
|
892 |
||
893 |
for (n = 0; n < arg; ) { |
|
894 |
out.show("hello "); |
|
895 |
out.showCR(n++); |
|
896 |
} |
|
897 |
}' |
|
898 |
for:nil |
|
899 |
arguments:(Array with:4 with:outStream) |
|
900 |
expect:nil. |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
901 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
902 |
output := outStream contents. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
903 |
self assert:(output = 'hello 0 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
904 |
hello 1 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
905 |
hello 2 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
906 |
hello 3 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
907 |
'). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
908 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
909 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
910 |
self run:#testFor02b |
1447 | 911 |
self new testFor02b |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
912 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
913 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
914 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
915 |
testFor03b |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
916 |
|outStream output| |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
917 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
918 |
outStream := '' writeStream. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
919 |
|
1447 | 920 |
self |
921 |
execute:'test(arg, out) { |
|
922 |
var n = 0; |
|
923 |
||
924 |
for (; n < arg; ) { |
|
925 |
out.show("hello "); |
|
926 |
out.showCR(n++); |
|
927 |
} |
|
928 |
}' |
|
929 |
for:nil |
|
930 |
arguments:(Array with:4 with:outStream) |
|
931 |
expect:nil. |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
932 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
933 |
output := outStream contents. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
934 |
self assert:(output = 'hello 0 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
935 |
hello 1 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
936 |
hello 2 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
937 |
hello 3 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
938 |
'). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
939 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
940 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
941 |
self run:#testFor03b |
1447 | 942 |
self new testFor03b |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
943 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
944 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
945 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
946 |
testFor04b |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
947 |
|outStream output| |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
948 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
949 |
outStream := '' writeStream. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
950 |
|
1447 | 951 |
self |
952 |
execute:'test(arg, out) { |
|
953 |
var n = 0; |
|
954 |
||
955 |
for (; ; ) { |
|
956 |
if (n >= arg) return; |
|
957 |
out.show("hello "); |
|
958 |
out.showCR(n++); |
|
959 |
} |
|
960 |
}' |
|
961 |
for:nil |
|
962 |
arguments:(Array with:4 with:outStream) |
|
963 |
expect:nil. |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
964 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
965 |
output := outStream contents. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
966 |
self assert:(output = 'hello 0 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
967 |
hello 1 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
968 |
hello 2 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
969 |
hello 3 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
970 |
'). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
971 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
972 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
973 |
self run:#testFor04b |
1447 | 974 |
self new testFor04b |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
975 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
976 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
977 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
978 |
testFor05 |
1368 | 979 |
|savedTranscript collector expected| |
980 |
||
1447 | 981 |
savedTranscript := Smalltalk at:#Transcript. |
1368 | 982 |
[ |
1447 | 983 |
Smalltalk at:#Transcript put:(collector := '' writeStream). |
1485 | 984 |
self |
985 |
execute:'test(arg) { |
|
986 |
for (var n = 0; n < arg; n++) { |
|
987 |
Transcript.showCR(n); |
|
988 |
} |
|
989 |
}' |
|
990 |
for:nil |
|
991 |
arguments:#(5) |
|
992 |
expect:nil |
|
1368 | 993 |
] ensure:[ |
1447 | 994 |
Smalltalk at:#Transcript put:savedTranscript |
1368 | 995 |
]. |
1485 | 996 |
|
1368 | 997 |
expected := String streamContents:[:s | 0 to:4 do:[:n | s showCR:n]]. |
998 |
self assert:(collector contents = expected). |
|
1485 | 999 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1000 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1001 |
self run:#testFor05 |
1447 | 1002 |
self new testFor05 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1003 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1004 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1005 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1006 |
testFor05b |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1007 |
|outStream output| |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1008 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1009 |
outStream := '' writeStream. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1010 |
|
1447 | 1011 |
self |
1012 |
execute:'test(arg, out) { |
|
1013 |
var n = 0; |
|
1014 |
||
1015 |
for (; ; ) { |
|
1016 |
if (n >= arg) break; |
|
1017 |
out.show("hello "); |
|
1018 |
out.showCR(n++); |
|
1019 |
} |
|
1020 |
}' |
|
1021 |
for:nil |
|
1022 |
arguments:(Array with:4 with:outStream) |
|
1023 |
expect:nil. |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1024 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1025 |
output := outStream contents. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1026 |
self assert:(output = 'hello 0 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1027 |
hello 1 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1028 |
hello 2 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1029 |
hello 3 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1030 |
'). |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1031 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1032 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1033 |
self run:#testFor05b |
1447 | 1034 |
self new testFor05b |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1035 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1036 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1037 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1038 |
testFor05c |
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1039 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1040 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1041 |
output := '' writeStream. |
1447 | 1042 |
self |
1043 |
execute:'test(arg, out) { |
|
1044 |
var n = 0; |
|
1045 |
||
1046 |
for (; ; ) { |
|
1047 |
if (n >= arg) break; |
|
1048 |
out.show("hello "); |
|
1049 |
out.showCR(n++); |
|
1050 |
} |
|
1051 |
}' |
|
1052 |
for:nil |
|
1053 |
arguments:(Array with:4 with:output) |
|
1054 |
expect:nil. |
|
1055 |
||
1056 |
self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
|
1057 |
'hello 0' |
|
1058 |
'hello 1' |
|
1059 |
'hello 2' |
|
1060 |
'hello 3')) |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1061 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1062 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1063 |
self run:#testFor05c |
1447 | 1064 |
self new testFor05c |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1065 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1066 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1067 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1068 |
testFor05d |
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1069 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1070 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1071 |
output := '' writeStream. |
1447 | 1072 |
self |
1073 |
execute:'test(arg, out) { |
|
1074 |
var n = 0; |
|
1075 |
||
1076 |
for (; ; ) { |
|
1077 |
n++; |
|
1078 |
if (n >= arg) break; |
|
1079 |
if (n == 2) continue; |
|
1080 |
out.show("hello "); |
|
1081 |
out.showCR(n); |
|
1082 |
} |
|
1083 |
}' |
|
1084 |
for:nil |
|
1085 |
arguments:(Array with:5 with:output) |
|
1086 |
expect:nil. |
|
1087 |
||
1088 |
self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
|
1089 |
'hello 1' |
|
1090 |
'hello 3' |
|
1091 |
'hello 4' )) |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1092 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1093 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1094 |
self run:#testFor05d |
1447 | 1095 |
self new testFor05d |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1096 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1097 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1098 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1099 |
testFor06 |
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1100 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1101 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1102 |
output := '' writeStream. |
1447 | 1103 |
self |
1104 |
execute:'test(arg, out) { |
|
1105 |
for (var n = 0, var m = 10; n < 10; n++, m--) { |
|
1106 |
out.show(n); |
|
1107 |
out.show(" -> "); |
|
1108 |
out.showCR(m); |
|
1109 |
} |
|
1110 |
}' |
|
1111 |
for:nil |
|
1112 |
arguments:(Array with:5 with:output) |
|
1113 |
expect:nil. |
|
1114 |
||
1115 |
self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
|
1116 |
'0 -> 10' |
|
1117 |
'1 -> 9' |
|
1118 |
'2 -> 8' |
|
1119 |
'3 -> 7' |
|
1120 |
'4 -> 6' |
|
1121 |
'5 -> 5' |
|
1122 |
'6 -> 4' |
|
1123 |
'7 -> 3' |
|
1124 |
'8 -> 2' |
|
1125 |
'9 -> 1' |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
1126 |
)) |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1127 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1128 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1129 |
self run:#testFor06 |
1447 | 1130 |
self new testFor06 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1131 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1132 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1133 |
|
946
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1134 |
testFor07 |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1135 |
|output| |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1136 |
|
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1137 |
output := '' writeStream. |
1447 | 1138 |
self |
1139 |
execute:'test(arg, out) { |
|
1140 |
for (var n = 0, var m = 10; n < 10; n++, m--) { |
|
1141 |
if ((n >= 3) && (n <= 6)) { |
|
1142 |
out.show(n); |
|
1143 |
out.show(" -> "); |
|
1144 |
out.showCR(m); |
|
1145 |
} |
|
1146 |
} |
|
1147 |
}' |
|
1148 |
for:nil |
|
1149 |
arguments:(Array with:5 with:output) |
|
1150 |
expect:nil. |
|
1151 |
||
1152 |
self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
|
1153 |
'3 -> 7' |
|
1154 |
'4 -> 6' |
|
1155 |
'5 -> 5' |
|
1156 |
'6 -> 4' |
|
946
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1157 |
)) |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1158 |
|
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1159 |
" |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1160 |
self run:#testFor06 |
1447 | 1161 |
self new testFor06 |
946
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1162 |
" |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1163 |
! |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1164 |
|
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1165 |
testFor08 |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1166 |
|output| |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1167 |
|
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1168 |
output := '' writeStream. |
1447 | 1169 |
self |
1170 |
execute:'test(arg, out) { |
|
1171 |
var x = 10; |
|
1172 |
||
1173 |
for (var n = 0, var m = 10; n < 10; n++, m--) { |
|
1174 |
if ((n >= 3) && (n <= 6)) { |
|
1175 |
if ((n >= 4) && (n <= 5)) { |
|
1176 |
out.show(n); |
|
1177 |
out.show(" -> "); |
|
1178 |
out.showCR(m); |
|
1179 |
} |
|
1180 |
} |
|
1181 |
} |
|
1182 |
}' |
|
1183 |
for:nil |
|
1184 |
arguments:(Array with:5 with:output) |
|
1185 |
expect:nil. |
|
1186 |
||
1187 |
self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
|
1188 |
'4 -> 6' |
|
1189 |
'5 -> 5' |
|
946
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1190 |
)) |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1191 |
|
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1192 |
" |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1193 |
self run:#testFor06 |
1447 | 1194 |
self new testFor06 |
946
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1195 |
" |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1196 |
! |
7eeef810d524
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
945
diff
changeset
|
1197 |
|
343
d999dd5dbee6
preps for for (var in ...) {...}
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
1198 |
testForIn01 |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1199 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1200 |
|
347 | 1201 |
JavaScriptParser forInAllowed ifFalse:[^ self]. |
1202 |
||
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1203 |
output := self outputToTranscriptOf:[ |
1447 | 1204 |
self |
1205 |
execute:'test(arg) { |
|
1206 |
var arr = [ "one", "two", "three" ]; |
|
1207 |
||
1208 |
for (var el in arr) { |
|
1209 |
Transcript.showCR(el); |
|
1210 |
} |
|
1211 |
}' |
|
1212 |
for:nil |
|
1213 |
arguments:#(5) |
|
1214 |
expect:nil |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1215 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1216 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1217 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( 'one' 'two' 'three' )) |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1218 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1219 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1220 |
self run:#testForIn01 |
1447 | 1221 |
self new testForIn01 |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1222 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1223 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1224 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1225 |
testForIn02 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1226 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1227 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1228 |
JavaScriptParser forInAllowed ifFalse:[^ self]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1229 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1230 |
output := '' writeStream. |
1447 | 1231 |
self |
1232 |
execute:'test(arg, output) { |
|
1233 |
var sum = 0; |
|
1234 |
||
1235 |
for (var el in arg) { |
|
1236 |
var last = el; |
|
1237 |
output.showCR(el*el); |
|
1238 |
sum += el; |
|
1239 |
last = sum; |
|
1240 |
} |
|
1241 |
return last; |
|
1242 |
}' |
|
1243 |
for:nil |
|
1244 |
arguments:( Array with:#(1 2 3) with:output) |
|
1245 |
expect:6. |
|
1246 |
||
1247 |
self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
|
1248 |
'1' |
|
1249 |
'4' |
|
1250 |
'9' |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
1251 |
)) |
343
d999dd5dbee6
preps for for (var in ...) {...}
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
1252 |
|
d999dd5dbee6
preps for for (var in ...) {...}
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
1253 |
" |
d999dd5dbee6
preps for for (var in ...) {...}
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
1254 |
self run:#testForIn01 |
1447 | 1255 |
self new testForIn01 |
343
d999dd5dbee6
preps for for (var in ...) {...}
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
1256 |
" |
d999dd5dbee6
preps for for (var in ...) {...}
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
1257 |
! |
d999dd5dbee6
preps for for (var in ...) {...}
Claus Gittinger <cg@exept.de>
parents:
331
diff
changeset
|
1258 |
|
1004
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1259 |
testForIn03 |
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1260 |
|output| |
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1261 |
|
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1262 |
JavaScriptParser forInAllowed ifFalse:[^ self]. |
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1263 |
|
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1264 |
output := '' writeStream. |
1447 | 1265 |
self |
1266 |
execute:'test(arg, output) { |
|
1267 |
var sum = 0; |
|
1268 |
||
1269 |
for (var el in arg) { |
|
1270 |
output.showCR(el*el); |
|
1271 |
if (el == 1) continue; |
|
1272 |
sum += el; |
|
1273 |
if (el == 2) break; |
|
1274 |
} |
|
1275 |
return sum; |
|
1276 |
}' |
|
1277 |
for:nil |
|
1278 |
arguments:( Array with:#(1 2 3) with:output) |
|
1279 |
expect:2. |
|
1280 |
||
1281 |
self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
|
1282 |
'1' |
|
1283 |
'4' |
|
1005
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1284 |
)) |
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1285 |
|
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1286 |
" |
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1287 |
self run:#testForIn01 |
1447 | 1288 |
self new testForIn01 |
1005
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1289 |
" |
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1290 |
! |
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1291 |
|
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1292 |
testForIn04 |
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1293 |
|output| |
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1294 |
|
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1295 |
JavaScriptParser forInAllowed ifFalse:[^ self]. |
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1296 |
|
7359ab263818
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1004
diff
changeset
|
1297 |
output := '' writeStream. |
1447 | 1298 |
self |
1299 |
execute:'test(arg, output) { |
|
1300 |
var sum = 0; |
|
1301 |
||
1302 |
for (var el in arg) { |
|
1303 |
output.showCR(el*el); |
|
1304 |
for (var i in ["a", "b", "c"]) { |
|
1305 |
output.showCR(i); |
|
1306 |
if (i == "b") break; |
|
1307 |
} |
|
1308 |
if (el == 1) continue; |
|
1309 |
sum += el; |
|
1310 |
if (el == 2) break; |
|
1311 |
} |
|
1312 |
return sum; |
|
1313 |
}' |
|
1314 |
for:nil |
|
1315 |
arguments:( Array with:#(1 2 3) with:output) |
|
1316 |
expect:2. |
|
1317 |
||
1318 |
self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
|
1319 |
'1' |
|
1320 |
'a' |
|
1321 |
'b' |
|
1322 |
'4' |
|
1323 |
'a' |
|
1324 |
'b' |
|
1004
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1325 |
)) |
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1326 |
|
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1327 |
" |
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1328 |
self run:#testForIn01 |
1447 | 1329 |
self new testForIn01 |
1004
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1330 |
" |
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1331 |
! |
9021e9f5967b
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
1003
diff
changeset
|
1332 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1333 |
testIf01 |
1447 | 1334 |
self |
1335 |
execute:'max(a, b) { |
|
1336 |
if (a > b) return a; |
|
1337 |
return b; |
|
1338 |
}' |
|
1339 |
for:nil |
|
1340 |
arguments:#(10 20) |
|
1341 |
expect:20 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1342 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1343 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1344 |
self run:#testIf01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1345 |
self new testIf01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1346 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1347 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1348 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1349 |
testIf02 |
1447 | 1350 |
self |
1351 |
execute:'max(a, b) { |
|
1352 |
if (a > b) ; |
|
1353 |
else return b; |
|
1354 |
return a; |
|
1355 |
}' |
|
1356 |
for:nil |
|
1357 |
arguments:#(10 20) |
|
1358 |
expect:20 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1359 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1360 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1361 |
self run:#testIf02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1362 |
self new testIf02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1363 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1364 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1365 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1366 |
testIf03 |
1447 | 1367 |
self |
1368 |
execute:'max(a, b) { |
|
1369 |
if (a > b) return a; |
|
1370 |
else return b; |
|
1371 |
}' |
|
1372 |
for:nil |
|
1373 |
arguments:#(10 20) |
|
1374 |
expect:20 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1375 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1376 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1377 |
self run:#testIf03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1378 |
self new testIf03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1379 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1380 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1381 |
|
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1382 |
testInnerFunctionWithForLoop |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1383 |
|
1368 | 1384 |
|savedTranscript collector expected| |
1385 |
||
1447 | 1386 |
savedTranscript := Smalltalk at:#Transcript. |
1368 | 1387 |
[ |
1447 | 1388 |
Smalltalk at:#Transcript put:(collector := '' writeStream). |
1389 |
||
1485 | 1390 |
self |
1391 |
execute:' |
|
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1392 |
execute() { |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1393 |
function foo() |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1394 |
{ |
1447 | 1395 |
Transcript.show("foo called\n"); |
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1396 |
} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1397 |
|
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1398 |
function bar() |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1399 |
{ |
1447 | 1400 |
Transcript.show("bar called\n"); |
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1401 |
} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1402 |
|
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1403 |
function bla(n) |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1404 |
{ |
1447 | 1405 |
Transcript.show("bla called\n"); |
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1406 |
} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1407 |
|
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1408 |
function test() |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1409 |
{ |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1410 |
|
1447 | 1411 |
foo(); |
1412 |
bar(); |
|
1413 |
var _fecUs; |
|
1414 |
var _fecDs; |
|
1415 |
var _cvUs = Array.new(15); |
|
1416 |
var _cvDs = Array.new(15); |
|
1417 |
var _headerLength = 10; |
|
1418 |
var _headerLength2 = 10; |
|
1419 |
var _raw = Array.new(20); |
|
1420 |
||
1421 |
for(var l=_headerLength+2;l<=_raw.size;l++) |
|
1422 |
{ |
|
1423 |
var x = _raw[l]; |
|
1424 |
if(l!!=_raw.size) |
|
1425 |
{ var y = _raw[l+1]; } |
|
1426 |
||
1427 |
if(_cvUs.size >10 && _cvDs.size>10) |
|
1428 |
{ |
|
1429 |
_fecUs = 15.asInteger - 12.asInteger; |
|
1430 |
_fecDs = 20.asInteger - 13.asInteger; |
|
1431 |
bla(_fecUs); |
|
1432 |
bla(_fecDs); |
|
1433 |
bla(_cvUs); |
|
1434 |
bla(_cvDs); |
|
1435 |
if(_fecUs >=0 && _fecUs >=0) |
|
1436 |
{ |
|
1437 |
Transcript.show("hello\n"); |
|
1438 |
} |
|
1439 |
||
1440 |
} |
|
1441 |
if(_cvUs.size == 5) |
|
1442 |
{ Transcript.show("end\n"); } |
|
1443 |
} |
|
1444 |
Transcript.show("bbb\n"); |
|
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1445 |
} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1446 |
|
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1447 |
test(); |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1448 |
} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1449 |
' |
1485 | 1450 |
for:nil |
1451 |
arguments:#() |
|
1452 |
expect:nil |
|
1368 | 1453 |
] ensure:[ |
1447 | 1454 |
Smalltalk at:#Transcript put:savedTranscript |
1368 | 1455 |
]. |
1456 |
||
1447 | 1457 |
expected := String streamContents:[:s | |
1458 |
s showCR:'foo called'. |
|
1459 |
s showCR:'bar called'. |
|
1460 |
9 timesRepeat:[ |
|
1461 |
s showCR:'bla called'. |
|
1462 |
s showCR:'bla called'. |
|
1463 |
s showCR:'bla called'. |
|
1464 |
s showCR:'bla called'. |
|
1465 |
s showCR:'hello'. |
|
1466 |
]. |
|
1467 |
s showCR:'bbb'. |
|
1468 |
]. |
|
1368 | 1469 |
self assert:(collector contents = expected). |
1485 | 1470 |
|
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1471 |
" |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1472 |
self run:#testVarDeclaration08 |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1473 |
self new testVarDeclaration08 |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1474 |
" |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1475 |
! |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
1476 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1477 |
testLiteralReturn01 |
1447 | 1478 |
self |
1479 |
execute:'function f() { return (0); }' |
|
1480 |
for:nil |
|
1481 |
arguments:#() |
|
1482 |
expect:0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1483 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1484 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1485 |
self run:#testLiteralReturn01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1486 |
self new testLiteralReturn01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1487 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1488 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1489 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1490 |
testLiteralReturn02 |
1447 | 1491 |
self |
1492 |
execute:'function f() { return (0.0); }' |
|
1493 |
for:nil |
|
1494 |
arguments:#() |
|
1495 |
expect:0.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1496 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1497 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1498 |
self run:#testLiteralReturn02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1499 |
self new testLiteralReturn02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1500 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1501 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1502 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1503 |
testLiteralReturn03 |
1447 | 1504 |
self |
1505 |
execute:'function f() { return ("foo"); }' |
|
1506 |
for:nil |
|
1507 |
arguments:#() |
|
1508 |
expect:'foo' |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1509 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1510 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1511 |
self run:#testLiteralReturn03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1512 |
self new testLiteralReturn03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1513 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1514 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1515 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1516 |
testLiteralReturn04 |
1447 | 1517 |
self |
1518 |
execute:'function f() { return (true); }' |
|
1519 |
for:nil |
|
1520 |
arguments:#() |
|
1521 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1522 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1523 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1524 |
self run:#testLiteralReturn04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1525 |
self new testLiteralReturn04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1526 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1527 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1528 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1529 |
testLiteralReturn05 |
1447 | 1530 |
self |
1531 |
execute:'function f() { return (false); }' |
|
1532 |
for:nil |
|
1533 |
arguments:#() |
|
1534 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1535 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1536 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1537 |
self run:#testLiteralReturn05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1538 |
self new testLiteralReturn05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1539 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1540 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1541 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1542 |
testLiteralReturn06 |
1447 | 1543 |
self |
1544 |
execute:'function f() { return (null); }' |
|
1545 |
for:nil |
|
1546 |
arguments:#() |
|
1547 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1548 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1549 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1550 |
self run:#testLiteralReturn06 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1551 |
self new testLiteralReturn06 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1552 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1553 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1554 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1555 |
testLiteralReturn07 |
1447 | 1556 |
self |
1557 |
execute:'function f() { return (nil); }' |
|
1558 |
for:nil |
|
1559 |
arguments:#() |
|
1560 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1561 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1562 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1563 |
self run:#testLiteralReturn07 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1564 |
self new testLiteralReturn07 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1565 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1566 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1567 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1568 |
testLiteralReturn08 |
1447 | 1569 |
self |
1570 |
execute:'function f() { return ("hello"); }' |
|
1571 |
for:nil |
|
1572 |
arguments:#() |
|
1573 |
expect:'hello' |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1574 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1575 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1576 |
self run:#testLiteralReturn08 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1577 |
self new testLiteralReturn08 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1578 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1579 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1580 |
|
556 | 1581 |
testLiterals01 |
1582 |
|t| |
|
1583 |
||
1447 | 1584 |
t := JavaScriptParser |
1585 |
evaluate:' |
|
556 | 1586 |
[ |
1587 |
{"params": {"name": "q"}, "method": "click"}, |
|
1588 |
{"params": {"text": "hello world", "name": "q"}, "method": "type"}, |
|
1589 |
{"params": {"link": "Hallo-Welt-Programm \u2013 Wikipedia"}, "method": "click"}, |
|
1590 |
{"params": {"timeout": "20000"}, "method": "waits.forPageLoad"}, |
|
1591 |
{"params": {"link": "Druckversion", "timeout": "8000"}, "method": "waits.forElement"}, |
|
1592 |
{"params": {"link": "Druckversion"}, "method": "click"}, |
|
1593 |
{"params": {"timeout": "20000"}, "method": "waits.forPageLoad"}, |
|
1594 |
{"params": {"id": "siteSub"}, "method": "asserts.assertNode"} |
|
1595 |
]; |
|
1596 |
'. |
|
1597 |
self assert:(t isArray). |
|
1598 |
self assert:(t size == 8). |
|
1599 |
self assert:(t first class == JavaScriptObject). |
|
1600 |
self assert:((t first at:#method) = 'click'). |
|
1601 |
self assert:((t last at:#method) = 'asserts.assertNode'). |
|
1602 |
||
1603 |
" |
|
1604 |
self run:#testLiterals01 |
|
1605 |
self new testLiterals01 |
|
1606 |
" |
|
1607 |
! |
|
1608 |
||
557 | 1609 |
testLiterals02 |
1610 |
|t| |
|
1611 |
||
1447 | 1612 |
t := JavaScriptParser |
1613 |
evaluate:' |
|
1614 |
[ 1, 2, 3, 4, 5, 6, 7, 8 ]; |
|
1615 |
'. |
|
557 | 1616 |
self assert:(t isArray). |
1617 |
self assert:(t size == 8). |
|
1618 |
self assert:(t = #(1 2 3 4 5 6 7 8)). |
|
1619 |
||
1620 |
" |
|
1621 |
self run:#testLiterals02 |
|
1622 |
self new testLiterals02 |
|
1623 |
" |
|
1624 |
! |
|
1625 |
||
331 | 1626 |
testLocalFunction01 |
1447 | 1627 |
self |
1628 |
execute:'test(arg) { |
|
1629 |
var x ; |
|
1630 |
||
1631 |
function localFunction() { return 10 / arg; }; |
|
1632 |
||
1633 |
x = localFunction() + 1; |
|
1634 |
return x; |
|
1635 |
}' |
|
1636 |
for:nil |
|
1637 |
arguments:#(5) |
|
1638 |
expect:3 |
|
331 | 1639 |
|
1640 |
" |
|
1641 |
self run:#testLocalFunction01 |
|
1642 |
self new testLocalFunction01 |
|
1643 |
" |
|
1644 |
||
1645 |
"Created: / 20-02-2007 / 18:13:19 / cg" |
|
1646 |
"Modified: / 20-02-2007 / 21:35:56 / cg" |
|
1647 |
! |
|
1648 |
||
1649 |
testLocalFunction02 |
|
1447 | 1650 |
self |
1651 |
execute:'test(arg) { |
|
1652 |
var x ; |
|
1653 |
||
1654 |
function localFunction() { return (10 / arg) from test; }; |
|
1655 |
||
1656 |
x = localFunction() + 1; |
|
1657 |
return x; |
|
1658 |
}' |
|
1659 |
for:nil |
|
1660 |
arguments:#(5) |
|
1661 |
expect:2 |
|
331 | 1662 |
|
1663 |
" |
|
1664 |
self run:#testLocalFunction02 |
|
1665 |
self new testLocalFunction02 |
|
1666 |
" |
|
1667 |
||
1668 |
"Created: / 20-02-2007 / 21:36:31 / cg" |
|
1669 |
! |
|
1670 |
||
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1671 |
testNew01 |
1447 | 1672 |
self |
1673 |
execute:'test() { |
|
1674 |
var a; |
|
1675 |
||
1676 |
a = Array.new(5); |
|
1677 |
return a; |
|
1678 |
}' |
|
1679 |
for:nil |
|
1680 |
arguments:#() |
|
1681 |
expect:#(nil nil nil nil nil). |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1682 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1683 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1684 |
self run:#testNew01 |
1447 | 1685 |
self new testNew01 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1686 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1687 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1688 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1689 |
testNew02 |
1447 | 1690 |
self |
1691 |
execute:'test() { |
|
1692 |
var a; |
|
1693 |
||
1694 |
a = new Array(5); |
|
1695 |
return a; |
|
1696 |
}' |
|
1697 |
for:nil |
|
1698 |
arguments:#() |
|
1699 |
expect:#(nil nil nil nil nil). |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1700 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1701 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1702 |
self run:#testNew02 |
1447 | 1703 |
self new testNew02 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1704 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1705 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1706 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1707 |
testNew03 |
1447 | 1708 |
self |
1709 |
execute:'test() { |
|
1710 |
var days; |
|
1711 |
||
1712 |
days = new Array(7); |
|
1713 |
days[1] = "Monday"; |
|
1714 |
days[2] = "Tuesday"; |
|
1715 |
days[3] = "Wednesday"; |
|
1716 |
days[4] = "Thursday"; |
|
1717 |
days[5] = "Friday"; |
|
1718 |
days[6] = "Saturday"; |
|
1719 |
days[7] = "Sunday"; |
|
1720 |
||
1721 |
return days; |
|
1722 |
}' |
|
1723 |
for:nil |
|
1724 |
arguments:#() |
|
1725 |
expect:#('Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' 'Sunday') |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1726 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1727 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1728 |
self run:#testNew03 |
1447 | 1729 |
self new testNew03 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1730 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1731 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1732 |
|
268 | 1733 |
testOperators01_plus |
1447 | 1734 |
self |
1735 |
execute:'expr(a, b) { |
|
1736 |
return (a + 0); |
|
1737 |
}' |
|
1738 |
for:nil |
|
1739 |
arguments:#(10 20) |
|
1740 |
expect:10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1741 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1742 |
" |
268 | 1743 |
self run:#testOperators01_plus |
1744 |
self new testOperators01_plus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1745 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1746 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1747 |
|
268 | 1748 |
testOperators02_plus |
1447 | 1749 |
self |
1750 |
execute:'expr(a, b) { |
|
1751 |
return (a + 1); |
|
1752 |
}' |
|
1753 |
for:nil |
|
1754 |
arguments:#(10 20) |
|
1755 |
expect:11 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1756 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1757 |
" |
268 | 1758 |
self run:#testOperators02_plus |
1759 |
self new testOperators02_plus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1760 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1761 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1762 |
|
268 | 1763 |
testOperators03_minus |
1447 | 1764 |
self |
1765 |
execute:'expr(a, b) { |
|
1766 |
return (a - 1); |
|
1767 |
}' |
|
1768 |
for:nil |
|
1769 |
arguments:#(10 20) |
|
1770 |
expect:9 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1771 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1772 |
" |
268 | 1773 |
self run:#testOperators03_minus |
1774 |
self new testOperators03_minus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1775 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1776 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1777 |
|
268 | 1778 |
testOperators04_plus |
1447 | 1779 |
self |
1780 |
execute:'expr(a, b) { |
|
1781 |
return (a + a); |
|
1782 |
}' |
|
1783 |
for:nil |
|
1784 |
arguments:#(10 20) |
|
1785 |
expect:20 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1786 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1787 |
" |
268 | 1788 |
self run:#testOperators04_plus |
1789 |
self new testOperators04_plus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1790 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1791 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1792 |
|
268 | 1793 |
testOperators05_mul |
1447 | 1794 |
self |
1795 |
execute:'expr(a, b) { |
|
1796 |
return (a * 0); |
|
1797 |
}' |
|
1798 |
for:nil |
|
1799 |
arguments:#(10 20) |
|
1800 |
expect:0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1801 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1802 |
" |
268 | 1803 |
self run:#testOperators05_mul |
1804 |
self new testOperators05_mul |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1805 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1806 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1807 |
|
268 | 1808 |
testOperators06_mul |
1447 | 1809 |
self |
1810 |
execute:'expr(a, b) { |
|
1811 |
return (a * 1); |
|
1812 |
}' |
|
1813 |
for:nil |
|
1814 |
arguments:#(10 20) |
|
1815 |
expect:10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1816 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1817 |
" |
268 | 1818 |
self run:#testOperators06_mul |
1819 |
self new testOperators06_mul |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1820 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1821 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1822 |
|
268 | 1823 |
testOperators07_mul |
1447 | 1824 |
self |
1825 |
execute:'expr(a, b) { |
|
1826 |
return (a * -1); |
|
1827 |
}' |
|
1828 |
for:nil |
|
1829 |
arguments:#(10 20) |
|
1830 |
expect:-10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1831 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1832 |
" |
268 | 1833 |
self run:#testOperators07_mul |
1834 |
self new testOperators07_mul |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1835 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1836 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1837 |
|
268 | 1838 |
testOperators08_mul |
1447 | 1839 |
self |
1840 |
execute:'expr(a, b) { |
|
1841 |
return (a * 10); |
|
1842 |
}' |
|
1843 |
for:nil |
|
1844 |
arguments:#(10 20) |
|
1845 |
expect:100 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1846 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1847 |
" |
268 | 1848 |
self run:#testOperators08_mul |
1849 |
self new testOperators08_mul |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1850 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1851 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1852 |
|
268 | 1853 |
testOperators09_mul |
1447 | 1854 |
self |
1855 |
execute:'expr(a, b) { |
|
1856 |
return (a * a); |
|
1857 |
}' |
|
1858 |
for:nil |
|
1859 |
arguments:#(10 20) |
|
1860 |
expect:100 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1861 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1862 |
" |
268 | 1863 |
self run:#testOperators09_mul |
1864 |
self new testOperators09_mul |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1865 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1866 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1867 |
|
268 | 1868 |
testOperators10_mul |
1447 | 1869 |
self |
1870 |
execute:'expr(a, b) { |
|
1871 |
return (a * b); |
|
1872 |
}' |
|
1873 |
for:nil |
|
1874 |
arguments:#(10 20) |
|
1875 |
expect:200 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1876 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1877 |
" |
268 | 1878 |
self run:#testOperators10_mul |
1879 |
self new testOperators10_mul |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1880 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1881 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1882 |
|
268 | 1883 |
testOperators11_minus |
1447 | 1884 |
self |
1885 |
execute:'expr(a, b) { |
|
1886 |
return (a - b); |
|
1887 |
}' |
|
1888 |
for:nil |
|
1889 |
arguments:#(10 20) |
|
1890 |
expect:-10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1891 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1892 |
" |
268 | 1893 |
self run:#testOperators11_minus |
1894 |
self new testOperators11_minus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1895 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1896 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1897 |
|
268 | 1898 |
testOperators12_unaryMinus |
1447 | 1899 |
self |
1900 |
execute:'expr(a) { |
|
1901 |
return (-a); |
|
1902 |
}' |
|
1903 |
for:nil |
|
1904 |
arguments:#(10) |
|
1905 |
expect:-10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1906 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1907 |
" |
268 | 1908 |
self run:#testOperators12_unaryMinus |
1909 |
self new testOperators12_unaryMinus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1910 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1911 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1912 |
|
268 | 1913 |
testOperators13_minus |
1447 | 1914 |
self |
1915 |
execute:'expr(a, b) { |
|
1916 |
return (a - -b); |
|
1917 |
}' |
|
1918 |
for:nil |
|
1919 |
arguments:#(10 20) |
|
1920 |
expect:30 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1921 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1922 |
" |
268 | 1923 |
self run:#testOperators13_minus |
1924 |
self new testOperators13_minus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1925 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1926 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1927 |
|
268 | 1928 |
testOperators14_unaryMinus |
1447 | 1929 |
self |
1930 |
execute:'expr(a, b) { |
|
1931 |
return (a * -b); |
|
1932 |
}' |
|
1933 |
for:nil |
|
1934 |
arguments:#(10 1) |
|
1935 |
expect:-10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1936 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1937 |
" |
268 | 1938 |
self run:#testOperators14_unaryMinus |
1939 |
self new testOperators14_unaryMinus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1940 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1941 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1942 |
|
268 | 1943 |
testOperators15_div |
1447 | 1944 |
self |
1945 |
execute:'expr(a, b) { |
|
1946 |
return (a / 1.0); |
|
1947 |
}' |
|
1948 |
for:nil |
|
1949 |
arguments:#(10 1) |
|
1950 |
expect:10.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1951 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1952 |
" |
268 | 1953 |
self run:#testOperators15_div |
1954 |
self new testOperators15_div |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1955 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1956 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1957 |
|
268 | 1958 |
testOperators16a_postInc |
1447 | 1959 |
self |
1960 |
execute:'expr(a, b) { |
|
1961 |
return (a++); |
|
1962 |
}' |
|
1963 |
for:nil |
|
1964 |
arguments:#(10 1) |
|
1965 |
expect:10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1966 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1967 |
" |
268 | 1968 |
self run:#testOperators16a_postInc |
1969 |
self new testOperators16a_postInc |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1970 |
" |
331 | 1971 |
|
1972 |
"Modified: / 23-02-2007 / 13:29:51 / cg" |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1973 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1974 |
|
268 | 1975 |
testOperators16b_postInc |
1447 | 1976 |
self |
1977 |
execute:'expr(a, b) { |
|
1978 |
var aa = a; |
|
1979 |
||
1980 |
return (aa++); |
|
1981 |
}' |
|
1982 |
for:nil |
|
1983 |
arguments:#(10 1) |
|
1984 |
expect:10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1985 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1986 |
" |
268 | 1987 |
self run:#testOperators16b_postInc |
1988 |
self new testOperators16b_postInc |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1989 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1990 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
1991 |
|
331 | 1992 |
testOperators16c_postInc |
1447 | 1993 |
self |
1994 |
execute:'expr(a, b) { |
|
1995 |
var t = a++; |
|
1996 |
return (t); |
|
1997 |
}' |
|
1998 |
for:nil |
|
1999 |
arguments:#(10 1) |
|
2000 |
expect:10 |
|
331 | 2001 |
|
2002 |
" |
|
2003 |
self run:#testOperators16c_postInc |
|
2004 |
self new testOperators16c_postInc |
|
2005 |
" |
|
2006 |
||
2007 |
"Created: / 23-02-2007 / 13:30:21 / cg" |
|
2008 |
! |
|
2009 |
||
2010 |
testOperators16d_postInc |
|
1447 | 2011 |
self |
2012 |
execute:'expr(a, b) { |
|
2013 |
var t = a++; |
|
2014 |
return (a); |
|
2015 |
}' |
|
2016 |
for:nil |
|
2017 |
arguments:#(10 1) |
|
2018 |
expect:11 |
|
331 | 2019 |
|
2020 |
" |
|
2021 |
self run:#testOperators16d_postInc |
|
2022 |
self new testOperators16d_postInc |
|
2023 |
" |
|
2024 |
||
2025 |
"Created: / 23-02-2007 / 13:30:32 / cg" |
|
2026 |
! |
|
2027 |
||
2028 |
testOperators16e_postInc |
|
1447 | 2029 |
self |
2030 |
execute:'expr(a, b) { |
|
2031 |
var t = a++; |
|
2032 |
return (b); |
|
2033 |
}' |
|
2034 |
for:nil |
|
2035 |
arguments:#(10 1) |
|
2036 |
expect:1 |
|
331 | 2037 |
|
2038 |
" |
|
2039 |
self run:#testOperators16e_postInc |
|
2040 |
self new testOperators16e_postInc |
|
2041 |
" |
|
2042 |
||
2043 |
"Created: / 23-02-2007 / 13:31:02 / cg" |
|
2044 |
! |
|
2045 |
||
277 | 2046 |
testOperators17a_eq |
1447 | 2047 |
self |
2048 |
execute:'expr(a, b) { |
|
2049 |
return (a == b); |
|
2050 |
}' |
|
2051 |
for:nil |
|
2052 |
arguments:#(10 10) |
|
2053 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2054 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2055 |
" |
277 | 2056 |
self run:#testOperators17a_eq |
2057 |
self new testOperators17a_eq |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2058 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2059 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2060 |
|
277 | 2061 |
testOperators17b_eq |
1447 | 2062 |
self |
2063 |
execute:'expr(a, b) { |
|
2064 |
return (a == b); |
|
2065 |
}' |
|
2066 |
for:nil |
|
2067 |
arguments:#(10 11) |
|
2068 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2069 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2070 |
" |
277 | 2071 |
self run:#testOperators17b_eq |
2072 |
self new testOperators17b_eq |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2073 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2074 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2075 |
|
277 | 2076 |
testOperators17c_ne |
1447 | 2077 |
self |
2078 |
execute:'expr(a, b) { |
|
2079 |
return (a !!= b); |
|
2080 |
}' |
|
2081 |
for:nil |
|
2082 |
arguments:#(10 10) |
|
2083 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2084 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2085 |
" |
277 | 2086 |
self run:#testOperators17c_ne |
2087 |
self new testOperators17c_ne |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2088 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2089 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2090 |
|
277 | 2091 |
testOperators17d_ne |
1447 | 2092 |
self |
2093 |
execute:'expr(a, b) { |
|
2094 |
return (a !!= b); |
|
2095 |
}' |
|
2096 |
for:nil |
|
2097 |
arguments:#(10 11) |
|
2098 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2099 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2100 |
" |
277 | 2101 |
self run:#testOperators17d_ne |
2102 |
self new testOperators17d_ne |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2103 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2104 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2105 |
|
277 | 2106 |
testOperators18a_eq |
1447 | 2107 |
self |
2108 |
execute:'expr(a, b) { |
|
2109 |
return (a == b); |
|
2110 |
}' |
|
2111 |
for:nil |
|
2112 |
arguments:#(10 10.0) |
|
2113 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2114 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2115 |
" |
277 | 2116 |
self run:#testOperators18a_eq |
2117 |
self new testOperators18a_eq |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2118 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2119 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2120 |
|
277 | 2121 |
testOperators18b_ne |
1447 | 2122 |
self |
2123 |
execute:'expr(a, b) { |
|
2124 |
return (a !!= b); |
|
2125 |
}' |
|
2126 |
for:nil |
|
2127 |
arguments:#(10 11.0) |
|
2128 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2129 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2130 |
" |
277 | 2131 |
self run:#testOperators18b_ne |
2132 |
self new testOperators18b_ne |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2133 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2134 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2135 |
|
277 | 2136 |
testOperators19a_identical |
1447 | 2137 |
self |
2138 |
execute:'expr(a, b) { |
|
2139 |
return (a === b); |
|
2140 |
}' |
|
2141 |
for:nil |
|
2142 |
arguments:#(10 10) |
|
2143 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2144 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2145 |
" |
277 | 2146 |
self run:#testOperators19a_identical |
2147 |
self new testOperators19a_identical |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2148 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2149 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2150 |
|
277 | 2151 |
testOperators19b_identical |
1447 | 2152 |
self |
2153 |
execute:'expr(a, b) { |
|
2154 |
return (a === b); |
|
2155 |
}' |
|
2156 |
for:nil |
|
2157 |
arguments:#( 10 10.0 ) |
|
2158 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2159 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2160 |
" |
277 | 2161 |
self run:#testOperators19b_identical |
2162 |
self new testOperators19b_identical |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2163 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2164 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2165 |
|
277 | 2166 |
testOperators19c_notIdentical |
1447 | 2167 |
self |
2168 |
execute:'expr(a, b) { |
|
2169 |
return (a !!== b); |
|
2170 |
}' |
|
2171 |
for:nil |
|
2172 |
arguments:#( 10 10 ) |
|
2173 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2174 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2175 |
" |
277 | 2176 |
self run:#testOperators19c_notIdentical |
2177 |
self new testOperators19c_notIdentical |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2178 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2179 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2180 |
|
277 | 2181 |
testOperators19d_notIdentical |
1447 | 2182 |
self |
2183 |
execute:'expr(a, b) { |
|
2184 |
return (a !!== b); |
|
2185 |
}' |
|
2186 |
for:nil |
|
2187 |
arguments:#( 10 10.0 ) |
|
2188 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2189 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2190 |
" |
277 | 2191 |
self run:#testOperators19d_notIdentical |
2192 |
self new testOperators19d_notIdentical |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2193 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2194 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2195 |
|
277 | 2196 |
testOperators20a_eq |
1447 | 2197 |
self |
2198 |
execute:'expr(a, b) { |
|
2199 |
return (a == b); |
|
2200 |
}' |
|
2201 |
for:nil |
|
2202 |
arguments:#( 'foo' 'foo' ) |
|
2203 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2204 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2205 |
" |
277 | 2206 |
self run:#testOperators20a_eq |
2207 |
self new testOperators20a_eq |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2208 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2209 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2210 |
|
277 | 2211 |
testOperators20b_eq |
1447 | 2212 |
self |
2213 |
execute:'expr(a, b) { |
|
2214 |
return (a == b); |
|
2215 |
}' |
|
2216 |
for:nil |
|
2217 |
arguments:#( 'foo' 'Foo' ) |
|
2218 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2219 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2220 |
" |
277 | 2221 |
self run:#testOperators20b_eq |
2222 |
self new testOperators20b_eq |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2223 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2224 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2225 |
|
277 | 2226 |
testOperators20c_ne |
1447 | 2227 |
self |
2228 |
execute:'expr(a, b) { |
|
2229 |
return (a !!= b); |
|
2230 |
}' |
|
2231 |
for:nil |
|
2232 |
arguments:#( 'foo' 'Foo' ) |
|
2233 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2234 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2235 |
" |
277 | 2236 |
self run:#testOperators20c_ne |
2237 |
self new testOperators20c_ne |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2238 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2239 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2240 |
|
277 | 2241 |
testOperators20d_ne |
1447 | 2242 |
self |
2243 |
execute:'expr(a, b) { |
|
2244 |
return (a !!= b); |
|
2245 |
}' |
|
2246 |
for:nil |
|
2247 |
arguments:#( 'foo' 'foo' ) |
|
2248 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2249 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2250 |
" |
277 | 2251 |
self run:#testOperators20d_ne |
2252 |
self new testOperators20d_ne |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2253 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2254 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2255 |
|
268 | 2256 |
testOperators21a_ne |
1447 | 2257 |
self |
2258 |
execute:'expr(a) { |
|
2259 |
return (a !!= 0); |
|
2260 |
}' |
|
2261 |
for:nil |
|
2262 |
arguments:#('foo') |
|
2263 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2264 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2265 |
" |
268 | 2266 |
self run:#testOperators21a_ne |
2267 |
self new testOperators21a_ne |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2268 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2269 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2270 |
|
268 | 2271 |
testOperators21b_ne |
1447 | 2272 |
self |
2273 |
execute:'expr(a) { |
|
2274 |
return (a !!= 0); |
|
2275 |
}' |
|
2276 |
for:nil |
|
2277 |
arguments:#(0) |
|
2278 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2279 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2280 |
" |
268 | 2281 |
self run:#testOperators21b_ne |
2282 |
self new testOperators21b_ne |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2283 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2284 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2285 |
|
268 | 2286 |
testOperators22a_gt |
1447 | 2287 |
self |
2288 |
execute:'expr(a) { |
|
2289 |
return (a > 0); |
|
2290 |
}' |
|
2291 |
for:nil |
|
2292 |
arguments:#(0) |
|
2293 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2294 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2295 |
" |
268 | 2296 |
self run:#testOperators22a_gt |
2297 |
self new testOperators22a_gt |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2298 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2299 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2300 |
|
268 | 2301 |
testOperators22b_gt |
1447 | 2302 |
self |
2303 |
execute:'expr(a) { |
|
2304 |
return (a > 0); |
|
2305 |
}' |
|
2306 |
for:nil |
|
2307 |
arguments:#(1) |
|
2308 |
expect:true |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2309 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2310 |
" |
268 | 2311 |
self run:#testOperators22b_gt |
2312 |
self new testOperators22b_gt |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2313 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2314 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2315 |
|
277 | 2316 |
testOperators23a_unaryMinus |
1447 | 2317 |
self |
2318 |
execute:'expr(a) { |
|
2319 |
return (-a); |
|
2320 |
}' |
|
2321 |
for:nil |
|
2322 |
arguments:#(1) |
|
2323 |
expect:-1 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2324 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2325 |
" |
277 | 2326 |
self run:#testOperators23a_unaryMinus |
2327 |
self new testOperators23a_unaryMinus |
|
2328 |
" |
|
2329 |
! |
|
2330 |
||
2331 |
testOperators23b_unaryMinus |
|
1447 | 2332 |
self |
2333 |
execute:'expr(a) { |
|
2334 |
return (0 - -a); |
|
2335 |
}' |
|
2336 |
for:nil |
|
2337 |
arguments:#(1) |
|
2338 |
expect:1 |
|
277 | 2339 |
|
2340 |
" |
|
2341 |
self run:#testOperators23b_unaryMinus |
|
2342 |
self new testOperators23b_unaryMinus |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2343 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2344 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2345 |
|
268 | 2346 |
testOperators24a_div |
1447 | 2347 |
self |
2348 |
execute:'expr(a) { |
|
2349 |
return (a / 4); |
|
2350 |
}' |
|
2351 |
for:nil |
|
2352 |
arguments:#(4) |
|
2353 |
expect:1 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2354 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2355 |
" |
268 | 2356 |
self run:#testOperators24a_div |
2357 |
self new testOperators24a_div |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2358 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2359 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2360 |
|
268 | 2361 |
testOperators24b_div |
1447 | 2362 |
self |
2363 |
execute:'expr(a) { |
|
2364 |
return (a / 4.0); |
|
2365 |
}' |
|
2366 |
for:nil |
|
2367 |
arguments:#(4) |
|
2368 |
expect:1.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2369 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2370 |
" |
268 | 2371 |
self run:#testOperators24b_div |
2372 |
self new testOperators24b_div |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2373 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2374 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2375 |
|
268 | 2376 |
testOperators24c_div |
1447 | 2377 |
self |
2378 |
execute:'expr(a) { |
|
2379 |
return (a / 4); |
|
2380 |
}' |
|
2381 |
for:nil |
|
2382 |
arguments:#(4.0) |
|
2383 |
expect:1.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2384 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2385 |
" |
268 | 2386 |
self run:#testOperators24c_div |
2387 |
self new testOperators24c_div |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2388 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2389 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2390 |
|
268 | 2391 |
testOperators24d_div |
1447 | 2392 |
self |
2393 |
execute:'expr(a) { |
|
2394 |
return (a / 4.0); |
|
2395 |
}' |
|
2396 |
for:nil |
|
2397 |
arguments:#(4.0) |
|
2398 |
expect:1.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2399 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2400 |
" |
268 | 2401 |
self run:#testOperators24d_div |
2402 |
self new testOperators24d_div |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2403 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2404 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2405 |
|
268 | 2406 |
testOperators25a_mod |
1447 | 2407 |
self |
2408 |
execute:'expr(a) { |
|
2409 |
return (a % 4); |
|
2410 |
}' |
|
2411 |
for:nil |
|
2412 |
arguments:#(4) |
|
2413 |
expect:0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2414 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2415 |
" |
268 | 2416 |
self run:#testOperators25a_mod |
2417 |
self new testOperators25a_mod |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2418 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2419 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2420 |
|
268 | 2421 |
testOperators25b_mod |
1447 | 2422 |
self |
2423 |
execute:'expr(a) { |
|
2424 |
return (a % 4.0); |
|
2425 |
}' |
|
2426 |
for:nil |
|
2427 |
arguments:#(4) |
|
2428 |
expect:0.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2429 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2430 |
" |
268 | 2431 |
self run:#testOperators25b_mod |
2432 |
self new testOperators25b_mod |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2433 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2434 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2435 |
|
268 | 2436 |
testOperators25c_mod |
1447 | 2437 |
self |
2438 |
execute:'expr(a) { |
|
2439 |
return (a % 4); |
|
2440 |
}' |
|
2441 |
for:nil |
|
2442 |
arguments:#(4.0) |
|
2443 |
expect:0.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2444 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2445 |
" |
268 | 2446 |
self run:#testOperators25c_mod |
2447 |
self new testOperators25c_mod |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2448 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2449 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2450 |
|
268 | 2451 |
testOperators25d_mod |
1447 | 2452 |
self |
2453 |
execute:'expr(a) { |
|
2454 |
return (a % 4.0); |
|
2455 |
}' |
|
2456 |
for:nil |
|
2457 |
arguments:#(4.0) |
|
2458 |
expect:0.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2459 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2460 |
" |
268 | 2461 |
self run:#testOperators25d_mod |
2462 |
self new testOperators25d_mod |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2463 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2464 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2465 |
|
268 | 2466 |
testOperators25e_mod |
1447 | 2467 |
self |
2468 |
execute:'expr(a) { |
|
2469 |
return (a % 4); |
|
2470 |
}' |
|
2471 |
for:nil |
|
2472 |
arguments:#(-4) |
|
2473 |
expect:0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2474 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2475 |
" |
268 | 2476 |
self run:#testOperators25e_mod |
2477 |
self new testOperators25e_mod |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2478 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2479 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2480 |
|
268 | 2481 |
testOperators25f_mod |
1447 | 2482 |
self |
2483 |
execute:'expr(a) { |
|
2484 |
return (a % 4.0); |
|
2485 |
}' |
|
2486 |
for:nil |
|
2487 |
arguments:#(-4) |
|
2488 |
expect:0.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2489 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2490 |
" |
268 | 2491 |
self run:#testOperators25f_mod |
2492 |
self new testOperators25f_mod |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2493 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2494 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2495 |
|
268 | 2496 |
testOperators25g_mod |
1447 | 2497 |
self |
2498 |
execute:'expr(a) { |
|
2499 |
return (a % 4); |
|
2500 |
}' |
|
2501 |
for:nil |
|
2502 |
arguments:#(-4.0) |
|
2503 |
expect:0.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2504 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2505 |
" |
268 | 2506 |
self run:#testOperators25g_mod |
2507 |
self new testOperators25g_mod |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2508 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2509 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2510 |
|
268 | 2511 |
testOperators25h_mod |
1447 | 2512 |
self |
2513 |
execute:'expr(a) { |
|
2514 |
return (a % 4.0); |
|
2515 |
}' |
|
2516 |
for:nil |
|
2517 |
arguments:#(-4.0) |
|
2518 |
expect:0.0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2519 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2520 |
" |
268 | 2521 |
self run:#testOperators25h_mod |
2522 |
self new testOperators25h_mod |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2523 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2524 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2525 |
|
268 | 2526 |
testOperators26a_postInc |
1447 | 2527 |
self |
2528 |
execute:'expr(a) { |
|
2529 |
var x = a; |
|
2530 |
||
2531 |
return (x++); |
|
2532 |
}' |
|
2533 |
for:nil |
|
2534 |
arguments:#(1) |
|
2535 |
expect:1 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2536 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2537 |
" |
268 | 2538 |
self run:#testOperators26a_postInc |
2539 |
self new testOperators26a_postInc |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2540 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2541 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2542 |
|
268 | 2543 |
testOperators26b_postDec |
1447 | 2544 |
self |
2545 |
execute:'expr(a) { |
|
2546 |
var x = a; |
|
2547 |
||
2548 |
return (x--); |
|
2549 |
}' |
|
2550 |
for:nil |
|
2551 |
arguments:#(1) |
|
2552 |
expect:1 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2553 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2554 |
" |
268 | 2555 |
self run:#testOperators26b_postDec |
2556 |
self new testOperators26b_postDec |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2557 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2558 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2559 |
|
268 | 2560 |
testOperators26c_preInc |
1447 | 2561 |
self |
2562 |
execute:'expr(a) { |
|
2563 |
var x = a; |
|
2564 |
||
2565 |
return (++x); |
|
2566 |
}' |
|
2567 |
for:nil |
|
2568 |
arguments:#(1) |
|
2569 |
expect:2 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2570 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2571 |
" |
268 | 2572 |
self run:#testOperators26c_preInc |
2573 |
self new testOperators26c_preInc |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2574 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2575 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2576 |
|
268 | 2577 |
testOperators26d_preDec |
1447 | 2578 |
self |
2579 |
execute:'expr(a) { |
|
2580 |
var x = a; |
|
2581 |
||
2582 |
return (--x); |
|
2583 |
}' |
|
2584 |
for:nil |
|
2585 |
arguments:#(1) |
|
2586 |
expect:0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2587 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2588 |
" |
268 | 2589 |
self run:#testOperators26d_preDec |
2590 |
self new testOperators26d_preDec |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2591 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2592 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2593 |
|
268 | 2594 |
testOperators27a_postInc |
1447 | 2595 |
self |
2596 |
execute:'expr(a) { |
|
2597 |
var x = a; |
|
2598 |
||
2599 |
x++; |
|
2600 |
return (x); |
|
2601 |
}' |
|
2602 |
for:nil |
|
2603 |
arguments:#(1) |
|
2604 |
expect:2 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2605 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2606 |
" |
268 | 2607 |
self run:#testOperators27a_postInc |
2608 |
self new testOperators27a_postInc |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2609 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2610 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2611 |
|
268 | 2612 |
testOperators27b_postDec |
1447 | 2613 |
self |
2614 |
execute:'expr(a) { |
|
2615 |
var x = a; |
|
2616 |
||
2617 |
x--; |
|
2618 |
return (x); |
|
2619 |
}' |
|
2620 |
for:nil |
|
2621 |
arguments:#(1) |
|
2622 |
expect:0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2623 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2624 |
" |
268 | 2625 |
self run:#testOperators27b_postDec |
2626 |
self new testOperators27b_postDec |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2627 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2628 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2629 |
|
268 | 2630 |
testOperators27c_preInc |
1447 | 2631 |
self |
2632 |
execute:'expr(a) { |
|
2633 |
var x = a; |
|
2634 |
||
2635 |
++x; |
|
2636 |
return (x); |
|
2637 |
}' |
|
2638 |
for:nil |
|
2639 |
arguments:#(1) |
|
2640 |
expect:2 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2641 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2642 |
" |
268 | 2643 |
self run:#testOperators27c_preInc |
2644 |
self new testOperators27c_preInc |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2645 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2646 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2647 |
|
268 | 2648 |
testOperators27d_preDec |
1447 | 2649 |
self |
2650 |
execute:'expr(a) { |
|
2651 |
var x = a; |
|
2652 |
||
2653 |
--x; |
|
2654 |
return (x); |
|
2655 |
}' |
|
2656 |
for:nil |
|
2657 |
arguments:#(1) |
|
2658 |
expect:0 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2659 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2660 |
" |
268 | 2661 |
self run:#testOperators27d_preDec |
2662 |
self new testOperators27d_preDec |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2663 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2664 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2665 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2666 |
testOperators27e_postInc |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2667 |
|arr| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2668 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2669 |
arr := (1 to:15) asArray. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2670 |
|
1447 | 2671 |
self |
2672 |
execute:'expr(a) { |
|
2673 |
return (a[10]++); |
|
2674 |
}' |
|
2675 |
for:nil |
|
2676 |
arguments:{ arr } |
|
2677 |
expect:10. |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2678 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2679 |
self assert:(arr = #(1 2 3 4 5 6 7 8 9 11 11 12 13 14 15)) |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2680 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2681 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2682 |
self run:#testOperators27e_postInc |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2683 |
self new testOperators27e_postInc |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2684 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2685 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2686 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2687 |
testOperators27f_preDec |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2688 |
|arr| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2689 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2690 |
arr := (1 to:15) asArray. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2691 |
|
1447 | 2692 |
self |
2693 |
execute:'expr(a) { |
|
2694 |
return (--a[10]); |
|
2695 |
}' |
|
2696 |
for:nil |
|
2697 |
arguments:{ arr } |
|
2698 |
expect:9. |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2699 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2700 |
self assert:(arr = #(1 2 3 4 5 6 7 8 9 9 11 12 13 14 15)) |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2701 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2702 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2703 |
self run:#testOperators27f_preDec |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2704 |
self new testOperators27f_preDec |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2705 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2706 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
2707 |
|
268 | 2708 |
testOperators28_not |
1447 | 2709 |
self |
2710 |
execute:'expr(a) { |
|
2711 |
return (!! a); |
|
2712 |
}' |
|
2713 |
for:nil |
|
2714 |
arguments:#(true) |
|
2715 |
expect:false |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2716 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2717 |
" |
268 | 2718 |
self run:#testOperators28_not |
2719 |
self new testOperators28_not |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2720 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2721 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2722 |
|
276 | 2723 |
testOperators29a_plusAssign |
1447 | 2724 |
self |
2725 |
execute:'expr(a, b, c, d) { |
|
2726 |
var s = 0; |
|
2727 |
s += a; |
|
2728 |
s += b; |
|
2729 |
s += c; |
|
2730 |
s += d; |
|
2731 |
s += 1; |
|
2732 |
return (s); |
|
2733 |
}' |
|
2734 |
for:nil |
|
2735 |
arguments:#( 1 2 3 4 ) |
|
2736 |
expect:11 |
|
276 | 2737 |
|
2738 |
" |
|
2739 |
self run:#testOperators29a_plusAssign |
|
2740 |
self new testOperators29a_plusAssign |
|
2741 |
" |
|
2742 |
! |
|
2743 |
||
2744 |
testOperators29c_minusAssign |
|
1447 | 2745 |
self |
2746 |
execute:'expr(a, b, c, d) { |
|
2747 |
var s = 0; |
|
2748 |
s -= a; |
|
2749 |
s -= b; |
|
2750 |
s -= c; |
|
2751 |
s -= d; |
|
2752 |
s -= 1; |
|
2753 |
return (s); |
|
2754 |
}' |
|
2755 |
for:nil |
|
2756 |
arguments:#( 1 2 3 4 ) |
|
2757 |
expect:-11 |
|
276 | 2758 |
|
2759 |
" |
|
2760 |
self run:#testOperators29c_minusAssign |
|
2761 |
self new testOperators29c_minusAssign |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2762 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2763 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2764 |
|
268 | 2765 |
testOperators30_timesAssign |
1447 | 2766 |
self |
2767 |
execute:'expr(a, b, c, d) { |
|
2768 |
var s = 1; |
|
2769 |
s *= a; |
|
2770 |
s *= b; |
|
2771 |
s *= c; |
|
2772 |
s *= d; |
|
2773 |
s *= 2; |
|
2774 |
return (s); |
|
2775 |
}' |
|
2776 |
for:nil |
|
2777 |
arguments:#( 1 2 3 4 ) |
|
2778 |
expect:48 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2779 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2780 |
" |
268 | 2781 |
self run:#testOperators30_timesAssign |
2782 |
self new testOperators30_timesAssign |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2783 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2784 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2785 |
|
268 | 2786 |
testOperators31a_shiftLeft |
1447 | 2787 |
self |
2788 |
execute:'expr(a) { |
|
2789 |
return (a << 1); |
|
2790 |
}' |
|
2791 |
for:nil |
|
2792 |
arguments:#( 1 ) |
|
2793 |
expect:2 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2794 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2795 |
" |
268 | 2796 |
self run:#testOperators31a_shiftLeft |
2797 |
self new testOperators31a_shiftLeft |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2798 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2799 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2800 |
|
268 | 2801 |
testOperators31b_shiftLeft |
1447 | 2802 |
self |
2803 |
execute:'expr(a) { |
|
2804 |
return (a << 32); |
|
2805 |
}' |
|
2806 |
for:nil |
|
2807 |
arguments:#( 1 ) |
|
2808 |
expect:16r100000000 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2809 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2810 |
" |
268 | 2811 |
self run:#testOperators31b_shiftLeft |
2812 |
self new testOperators31b_shiftLeft |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2813 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2814 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2815 |
|
276 | 2816 |
testOperators31c_shiftLeftAssign |
1447 | 2817 |
self |
2818 |
execute:'expr(a) { |
|
2819 |
var b = a; |
|
2820 |
||
2821 |
b <<= 1; |
|
2822 |
return b; |
|
2823 |
}' |
|
2824 |
for:nil |
|
2825 |
arguments:#( 1 ) |
|
2826 |
expect:2 |
|
276 | 2827 |
|
2828 |
" |
|
2829 |
self run:#testOperators31c_shiftLeftAssign |
|
2830 |
self new testOperators31c_shiftLeftAssign |
|
2831 |
" |
|
2832 |
! |
|
2833 |
||
268 | 2834 |
testOperators32a_shiftRight |
1447 | 2835 |
self |
2836 |
execute:'expr(a) { |
|
2837 |
return (a >> 1); |
|
2838 |
}' |
|
2839 |
for:nil |
|
2840 |
arguments:#( 2 ) |
|
2841 |
expect:1 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2842 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2843 |
" |
268 | 2844 |
self run:#testOperators32a_shiftRight |
2845 |
self new testOperators32a_shiftRight |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2846 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2847 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2848 |
|
277 | 2849 |
testOperators32b_shiftRightAssign |
1447 | 2850 |
self |
2851 |
execute:'expr(a) { |
|
2852 |
var b = a; |
|
2853 |
||
2854 |
b >>= 1; |
|
2855 |
return b; |
|
2856 |
}' |
|
2857 |
for:nil |
|
2858 |
arguments:#( 5 ) |
|
2859 |
expect:2 |
|
277 | 2860 |
|
2861 |
" |
|
2862 |
self run:#testOperators32b_shiftRightAssign |
|
2863 |
self new testOperators32b_shiftRightAssign |
|
2864 |
" |
|
2865 |
! |
|
2866 |
||
2867 |
testOperators33_bitOrAssign |
|
1447 | 2868 |
self |
2869 |
execute:'expr(a, b) { |
|
2870 |
var s = 0; |
|
2871 |
s |= a; |
|
2872 |
s |= b; |
|
2873 |
return (s); |
|
2874 |
}' |
|
2875 |
for:nil |
|
2876 |
arguments:#(1 4) |
|
2877 |
expect:5 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2878 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2879 |
" |
277 | 2880 |
self run:#testOperators33_bitOrAssign |
2881 |
self new testOperators33_bitOrAssign |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2882 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2883 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2884 |
|
277 | 2885 |
testOperators34_bitAndAssign |
1447 | 2886 |
self |
2887 |
execute:'expr(a, b) { |
|
2888 |
var s = 0xFFFF; |
|
2889 |
s &= a; |
|
2890 |
s &= b; |
|
2891 |
return (s); |
|
2892 |
}' |
|
2893 |
for:nil |
|
2894 |
arguments:#(3 5) |
|
2895 |
expect:1 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2896 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2897 |
" |
277 | 2898 |
self run:#testOperators34_bitAndAssign |
2899 |
self new testOperators34_bitAndAssign |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2900 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2901 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2902 |
|
277 | 2903 |
testOperators35a_bitXorAssign |
1447 | 2904 |
self |
2905 |
execute:'expr(a) { |
|
2906 |
var s = 0xFFFF; |
|
2907 |
s ^= a; |
|
2908 |
return (s); |
|
2909 |
}' |
|
2910 |
for:nil |
|
2911 |
arguments:#( 1 ) |
|
2912 |
expect:16rFFFE |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2913 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2914 |
" |
268 | 2915 |
self run:#testOperators35a_xorAssign |
2916 |
self new testOperators35a_xorAssign |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2917 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2918 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2919 |
|
277 | 2920 |
testOperators35b_bitXor |
1447 | 2921 |
self |
2922 |
execute:'expr(a) { |
|
2923 |
var s = 0xFFFF; |
|
2924 |
s = s ^ a; |
|
2925 |
return (s); |
|
2926 |
}' |
|
2927 |
for:nil |
|
2928 |
arguments:#( 1 ) |
|
2929 |
expect:16rFFFE |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2930 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
2931 |
" |
268 | 2932 |
self run:#testOperators35b_xor |
2933 |
self new testOperators35b_xor |
|
2934 |
" |
|
2935 |
! |
|
2936 |
||
2937 |
testOperators36a_mod |
|
1447 | 2938 |
self |
2939 |
execute:'expr(a) { |
|
2940 |
return (a % 2); |
|
2941 |
}' |
|
2942 |
for:nil |
|
2943 |
arguments:#(10) |
|
2944 |
expect:0 |
|
268 | 2945 |
|
2946 |
" |
|
2947 |
self run:#testOperators36a_mod |
|
2948 |
self new testOperators36a_mod |
|
2949 |
" |
|
2950 |
! |
|
2951 |
||
2952 |
testOperators36b_mod |
|
1447 | 2953 |
self |
2954 |
execute:'expr(a) { |
|
2955 |
return (a % 2); |
|
2956 |
}' |
|
2957 |
for:nil |
|
2958 |
arguments:#(9) |
|
2959 |
expect:1 |
|
268 | 2960 |
|
2961 |
" |
|
2962 |
self run:#testOperators36b_mod |
|
2963 |
self new testOperators36b_mod |
|
2964 |
" |
|
2965 |
! |
|
2966 |
||
2967 |
testOperators37a_cond |
|
1447 | 2968 |
self |
2969 |
execute:'expr(a) { |
|
2970 |
return (a ? 1 : 0); |
|
2971 |
}' |
|
2972 |
for:nil |
|
2973 |
arguments:#(true) |
|
2974 |
expect:1 |
|
268 | 2975 |
|
2976 |
" |
|
2977 |
self run:#testOperators37a_cond |
|
2978 |
self new testOperators37a_cond |
|
2979 |
" |
|
2980 |
! |
|
2981 |
||
2982 |
testOperators37b_cond |
|
1447 | 2983 |
self |
2984 |
execute:'expr(a) { |
|
2985 |
return (a ? 1 : 0); |
|
2986 |
}' |
|
2987 |
for:nil |
|
2988 |
arguments:#(false) |
|
2989 |
expect:0 |
|
268 | 2990 |
|
2991 |
" |
|
2992 |
self run:#testOperators37b_cond |
|
2993 |
self new testOperators37b_cond |
|
2994 |
" |
|
2995 |
! |
|
2996 |
||
2997 |
testOperators37c_cond |
|
1447 | 2998 |
self |
2999 |
execute:'expr(a, b) { |
|
3000 |
return (a ? (b ? 0 : 1) : (b ? 2 : 3)); |
|
3001 |
}' |
|
3002 |
for:nil |
|
3003 |
arguments:#(false false) |
|
3004 |
expect:3 |
|
268 | 3005 |
|
3006 |
" |
|
3007 |
self run:#testOperators37c_cond |
|
3008 |
self new testOperators37c_cond |
|
3009 |
" |
|
3010 |
! |
|
3011 |
||
3012 |
testOperators37d_cond |
|
1447 | 3013 |
self |
3014 |
execute:'expr(a) { |
|
3015 |
return (a == 1 ? 2 : 3); |
|
3016 |
}' |
|
3017 |
for:nil |
|
3018 |
arguments:#(1) |
|
3019 |
expect:2 |
|
268 | 3020 |
|
3021 |
" |
|
3022 |
self run:#testOperators37d_cond |
|
3023 |
self new testOperators37d_cond |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3024 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3025 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3026 |
|
277 | 3027 |
testOperators38a_eq |
1447 | 3028 |
self |
3029 |
execute:'expr(a) { |
|
3030 |
return (a == 1); |
|
3031 |
}' |
|
3032 |
for:nil |
|
3033 |
arguments:#(1) |
|
3034 |
expect:true |
|
277 | 3035 |
|
3036 |
" |
|
3037 |
self run:#testOperators38a_eq |
|
3038 |
self new testOperators38a_eq |
|
3039 |
" |
|
3040 |
! |
|
3041 |
||
3042 |
testOperators38b_eq |
|
1447 | 3043 |
self |
3044 |
execute:'expr(a) { |
|
3045 |
return (a == 1); |
|
3046 |
}' |
|
3047 |
for:nil |
|
3048 |
arguments:#(1.0) |
|
3049 |
expect:true |
|
277 | 3050 |
|
3051 |
" |
|
3052 |
self run:#testOperators38b_eq |
|
3053 |
self new testOperators38b_eq |
|
3054 |
" |
|
3055 |
! |
|
3056 |
||
320 | 3057 |
testOperators38c_eq |
1447 | 3058 |
self |
3059 |
execute:'expr(a) { |
|
3060 |
return ( "hello"[1].asString == "h" ); |
|
3061 |
}' |
|
3062 |
for:nil |
|
3063 |
arguments:#(1.0) |
|
3064 |
expect:true |
|
320 | 3065 |
|
3066 |
" |
|
3067 |
self run:#testOperators38c_eq |
|
3068 |
self new testOperators38c_eq |
|
3069 |
" |
|
331 | 3070 |
|
3071 |
"Modified: / 21-02-2007 / 14:12:07 / cg" |
|
320 | 3072 |
! |
3073 |
||
277 | 3074 |
testOperators38c_ne |
1447 | 3075 |
self |
3076 |
execute:'expr(a) { |
|
3077 |
return (a !!= 1); |
|
3078 |
}' |
|
3079 |
for:nil |
|
3080 |
arguments:#(1.0) |
|
3081 |
expect:false |
|
277 | 3082 |
|
3083 |
" |
|
3084 |
self run:#testOperators38c_ne |
|
3085 |
self new testOperators38c_ne |
|
3086 |
" |
|
3087 |
! |
|
3088 |
||
320 | 3089 |
testOperators38d_eq |
1447 | 3090 |
self |
3091 |
execute:'expr(a) { |
|
3092 |
return ("hello"[1] == $''h'' ); |
|
3093 |
}' |
|
3094 |
for:nil |
|
3095 |
arguments:#(1.0) |
|
3096 |
expect:true |
|
320 | 3097 |
|
3098 |
" |
|
3099 |
self run:#testOperators38d_eq |
|
3100 |
self new testOperators38d_eq |
|
3101 |
" |
|
3102 |
! |
|
3103 |
||
277 | 3104 |
testOperators38d_ne |
1447 | 3105 |
self |
3106 |
execute:'expr(a) { |
|
3107 |
return (a !!= 1); |
|
3108 |
}' |
|
3109 |
for:nil |
|
3110 |
arguments:#(2.0) |
|
3111 |
expect:true |
|
277 | 3112 |
|
3113 |
" |
|
3114 |
self run:#testOperators38d_ne |
|
3115 |
self new testOperators38d_ne |
|
3116 |
" |
|
3117 |
! |
|
3118 |
||
331 | 3119 |
testOperators38e_eq |
1447 | 3120 |
self |
3121 |
execute:'expr(a) { |
|
3122 |
return ( "hello"[1] == "h"[1] ); |
|
3123 |
}' |
|
3124 |
for:nil |
|
3125 |
arguments:#(1.0) |
|
3126 |
expect:true |
|
331 | 3127 |
|
3128 |
" |
|
3129 |
self run:#testOperators38e_eq |
|
3130 |
self new testOperators38e_eq |
|
3131 |
" |
|
3132 |
||
3133 |
"Created: / 21-02-2007 / 14:15:14 / cg" |
|
3134 |
! |
|
3135 |
||
3136 |
testOperators38f_eq |
|
1447 | 3137 |
self |
3138 |
execute:'expr(a) { |
|
3139 |
return ( ("hello"[1]).asString == "h" ); |
|
3140 |
}' |
|
3141 |
for:nil |
|
3142 |
arguments:#(1.0) |
|
3143 |
expect:true |
|
331 | 3144 |
|
3145 |
" |
|
3146 |
self run:#testOperators38f_eq |
|
3147 |
self new testOperators38f_eq |
|
3148 |
" |
|
3149 |
||
3150 |
"Created: / 21-02-2007 / 14:16:00 / cg" |
|
3151 |
! |
|
3152 |
||
277 | 3153 |
testOperators39a_identical |
1447 | 3154 |
self |
3155 |
execute:'expr(a) { |
|
3156 |
return (a === 1); |
|
3157 |
}' |
|
3158 |
for:nil |
|
3159 |
arguments:#(1) |
|
3160 |
expect:true |
|
277 | 3161 |
|
3162 |
" |
|
3163 |
self run:#testOperators39a_identical |
|
3164 |
self new testOperators39a_identical |
|
3165 |
" |
|
3166 |
! |
|
3167 |
||
3168 |
testOperators39b_identical |
|
1447 | 3169 |
self |
3170 |
execute:'expr(a) { |
|
3171 |
return (a === 1); |
|
3172 |
}' |
|
3173 |
for:nil |
|
3174 |
arguments:#(1.0) |
|
3175 |
expect:false |
|
277 | 3176 |
|
3177 |
" |
|
3178 |
self run:#testOperators39b_identical |
|
3179 |
self new testOperators39b_identical |
|
3180 |
" |
|
3181 |
! |
|
3182 |
||
3183 |
testOperators39c_notIdentical |
|
1447 | 3184 |
self |
3185 |
execute:'expr(a) { |
|
3186 |
return (a !!== 1); |
|
3187 |
}' |
|
3188 |
for:nil |
|
3189 |
arguments:#(1.0) |
|
3190 |
expect:true |
|
277 | 3191 |
|
3192 |
" |
|
3193 |
self run:#testOperators39c_notIdentical |
|
3194 |
self new testOperators39c_notIdentical |
|
3195 |
" |
|
3196 |
! |
|
3197 |
||
3198 |
testOperators39d_notIdentical |
|
1447 | 3199 |
self |
3200 |
execute:'expr(a) { |
|
3201 |
return (a !!== 1); |
|
3202 |
}' |
|
3203 |
for:nil |
|
3204 |
arguments:#(1) |
|
3205 |
expect:false |
|
277 | 3206 |
|
3207 |
" |
|
3208 |
self run:#testOperators39d_notIdentical |
|
3209 |
self new testOperators39d_notIdentical |
|
3210 |
" |
|
3211 |
! |
|
3212 |
||
3213 |
testOperators40a_bitAnd |
|
1447 | 3214 |
self |
3215 |
execute:'expr(a) { |
|
3216 |
return (a & 1); |
|
3217 |
}' |
|
3218 |
for:nil |
|
3219 |
arguments:#(1) |
|
3220 |
expect:1 |
|
277 | 3221 |
|
3222 |
" |
|
3223 |
self run:#testOperators40a_bitAnd |
|
3224 |
self new testOperators40a_bitAnd |
|
3225 |
" |
|
3226 |
! |
|
3227 |
||
3228 |
testOperators40b_bitAnd |
|
1447 | 3229 |
self |
3230 |
execute:'expr(a) { |
|
3231 |
return (a & 1); |
|
3232 |
}' |
|
3233 |
for:nil |
|
3234 |
arguments:#(7) |
|
3235 |
expect:1 |
|
277 | 3236 |
|
3237 |
" |
|
3238 |
self run:#testOperators40b_bitAnd |
|
3239 |
self new testOperators40b_bitAnd |
|
3240 |
" |
|
3241 |
! |
|
3242 |
||
3243 |
testOperators41a_bitOr |
|
1447 | 3244 |
self |
3245 |
execute:'expr(a) { |
|
3246 |
return (a | 1); |
|
3247 |
}' |
|
3248 |
for:nil |
|
3249 |
arguments:#(6) |
|
3250 |
expect:7 |
|
277 | 3251 |
|
3252 |
" |
|
3253 |
self run:#testOperators41a_bitOr |
|
3254 |
self new testOperators41a_bitOr |
|
3255 |
" |
|
3256 |
! |
|
3257 |
||
3258 |
testOperators42a_bitXor |
|
1447 | 3259 |
self |
3260 |
execute:'expr(a) { |
|
3261 |
return (a ^ 1); |
|
3262 |
}' |
|
3263 |
for:nil |
|
3264 |
arguments:#(7) |
|
3265 |
expect:6 |
|
277 | 3266 |
|
3267 |
" |
|
3268 |
self run:#testOperators42a_bitXor |
|
3269 |
self new testOperators42a_bitXor |
|
3270 |
" |
|
3271 |
! |
|
3272 |
||
3273 |
testOperators43a_bitNot |
|
1447 | 3274 |
self |
3275 |
execute:'expr(a) { |
|
3276 |
return (~a); |
|
3277 |
}' |
|
3278 |
for:nil |
|
3279 |
arguments:#(1) |
|
3280 |
expect:-2 |
|
277 | 3281 |
|
3282 |
" |
|
3283 |
self run:#testOperators43a_bitNot |
|
3284 |
self new testOperators43a_bitNot |
|
3285 |
" |
|
3286 |
! |
|
3287 |
||
278 | 3288 |
testOperators44a_logAnd |
1447 | 3289 |
self |
3290 |
execute:'expr(a, b) { |
|
3291 |
return (a && (b > 5)); |
|
3292 |
}' |
|
3293 |
for:nil |
|
3294 |
arguments:#(true 6) |
|
3295 |
expect:true. |
|
3296 |
||
3297 |
self |
|
3298 |
execute:'expr(a, b) { |
|
3299 |
return (a && (b > 5)); |
|
3300 |
}' |
|
3301 |
for:nil |
|
3302 |
arguments:#(true 5) |
|
3303 |
expect:false. |
|
3304 |
||
3305 |
self |
|
3306 |
execute:'expr(a, b) { |
|
3307 |
return (a > 10 && (b > 5)); |
|
3308 |
}' |
|
3309 |
for:nil |
|
3310 |
arguments:#(10 5) |
|
3311 |
expect:false. |
|
3312 |
||
3313 |
self |
|
3314 |
execute:'expr(a, b) { |
|
3315 |
return (a > 10 && (b > 5)); |
|
3316 |
}' |
|
3317 |
for:nil |
|
3318 |
arguments:#(11 5) |
|
3319 |
expect:false. |
|
3320 |
||
3321 |
self |
|
3322 |
execute:'expr(a, b) { |
|
3323 |
return (a > 10 && (b > 5)); |
|
3324 |
}' |
|
3325 |
for:nil |
|
3326 |
arguments:#(10 6) |
|
3327 |
expect:false. |
|
3328 |
||
3329 |
self |
|
3330 |
execute:'expr(a, b) { |
|
3331 |
return (a > 10 && (b > 5)); |
|
3332 |
}' |
|
3333 |
for:nil |
|
3334 |
arguments:#(11 15) |
|
3335 |
expect:true. |
|
3336 |
||
3337 |
self |
|
3338 |
execute:'expr(a, b) { |
|
3339 |
return (a.size > 10 && (b.size > 5)); |
|
3340 |
}' |
|
3341 |
for:nil |
|
3342 |
arguments:{Array new:10 . Array new:5} |
|
3343 |
expect:false. |
|
3344 |
||
3345 |
self |
|
3346 |
execute:'expr(a, b) { |
|
3347 |
return (a.size > 10 && (b.size > 5)); |
|
3348 |
}' |
|
3349 |
for:nil |
|
3350 |
arguments:{Array new:11 . Array new:5} |
|
3351 |
expect:false. |
|
3352 |
||
3353 |
self |
|
3354 |
execute:'expr(a, b) { |
|
3355 |
return (a.size > 10 && (b.size > 5)); |
|
3356 |
}' |
|
3357 |
for:nil |
|
3358 |
arguments:{Array new:10 . Array new:6} |
|
3359 |
expect:false. |
|
3360 |
||
3361 |
self |
|
3362 |
execute:'expr(a, b) { |
|
3363 |
return (a.size > 10 && (b.size > 5)); |
|
3364 |
}' |
|
3365 |
for:nil |
|
3366 |
arguments:{Array new:11 . Array new:15} |
|
3367 |
expect:true. |
|
278 | 3368 |
|
3369 |
" |
|
3370 |
self run:#testOperators44a_logAnd |
|
3371 |
self new testOperators44a_logAnd |
|
3372 |
" |
|
3373 |
! |
|
3374 |
||
3375 |
testOperators44b_logAnd |
|
3376 |
"the right part of a logical and should not be evaluated, |
|
3377 |
if the left is already false" |
|
3378 |
||
1447 | 3379 |
self |
3380 |
execute:'expr(a, bIn) { |
|
3381 |
var x, b; |
|
3382 |
||
3383 |
b = bIn; |
|
3384 |
x = (a && (b++ > 5)); |
|
3385 |
return b; |
|
3386 |
}' |
|
3387 |
for:nil |
|
3388 |
arguments:#(true 5) |
|
3389 |
expect:6. |
|
3390 |
||
3391 |
self |
|
3392 |
execute:'expr(a, bIn) { |
|
3393 |
var x, b; |
|
3394 |
||
3395 |
b = bIn; |
|
3396 |
x = (a && (b++ > 5)); |
|
3397 |
return b; |
|
3398 |
}' |
|
3399 |
for:nil |
|
3400 |
arguments:#(false 5) |
|
3401 |
expect:5 |
|
278 | 3402 |
|
3403 |
" |
|
3404 |
self run:#testOperators44b_logAnd |
|
3405 |
self new testOperators44b_logAnd |
|
3406 |
" |
|
3407 |
! |
|
3408 |
||
3409 |
testOperators45a_logOr |
|
1447 | 3410 |
self |
3411 |
execute:'expr(a, b) { |
|
3412 |
return (a || (b > 5)); |
|
3413 |
}' |
|
3414 |
for:nil |
|
3415 |
arguments:#(true 6) |
|
3416 |
expect:true. |
|
3417 |
||
3418 |
self |
|
3419 |
execute:'expr(a, b) { |
|
3420 |
return (a || (b > 5)); |
|
3421 |
}' |
|
3422 |
for:nil |
|
3423 |
arguments:#(false 6) |
|
3424 |
expect:true. |
|
3425 |
||
3426 |
self |
|
3427 |
execute:'expr(a, b) { |
|
3428 |
return (a || (b > 5)); |
|
3429 |
}' |
|
3430 |
for:nil |
|
3431 |
arguments:#(false 5) |
|
3432 |
expect:false |
|
278 | 3433 |
|
3434 |
" |
|
3435 |
self run:#testOperators45a_logOr |
|
3436 |
self new testOperators45a_logOr |
|
3437 |
" |
|
3438 |
! |
|
3439 |
||
3440 |
testOperators45b_logOr |
|
3441 |
"the right part of a logical or should not be evaluated, |
|
3442 |
if the left is already true" |
|
3443 |
||
1447 | 3444 |
self |
3445 |
execute:'expr(a, bIn) { |
|
3446 |
var x, b; |
|
3447 |
||
3448 |
b = bIn; |
|
3449 |
x = (a || (b++ > 5)); |
|
3450 |
return b; |
|
3451 |
}' |
|
3452 |
for:nil |
|
3453 |
arguments:#(true 5) |
|
3454 |
expect:5. |
|
3455 |
||
3456 |
self |
|
3457 |
execute:'expr(a, bIn) { |
|
3458 |
var x, b; |
|
3459 |
||
3460 |
b = bIn; |
|
3461 |
x = (a || (b++ > 5)); |
|
3462 |
return b; |
|
3463 |
}' |
|
3464 |
for:nil |
|
3465 |
arguments:#(false 5) |
|
3466 |
expect:6 |
|
278 | 3467 |
|
3468 |
" |
|
3469 |
self run:#testOperators45b_logOr |
|
3470 |
self new testOperators45b_logOr |
|
3471 |
" |
|
3472 |
! |
|
3473 |
||
3474 |
testOperators46_comma |
|
1447 | 3475 |
self |
3476 |
execute:'expr(a, b, c) { |
|
3477 |
var x; |
|
3478 |
||
3479 |
x = a+1, b+1, c+1; |
|
3480 |
return x; |
|
3481 |
}' |
|
3482 |
for:nil |
|
3483 |
arguments:#(1 2 3) |
|
3484 |
expect:4. |
|
3485 |
||
3486 |
self |
|
3487 |
execute:'expr(aIn, bIn, cIn) { |
|
3488 |
var x; |
|
3489 |
var a = aIn; |
|
3490 |
var b = bIn; |
|
3491 |
var c = cIn; |
|
3492 |
||
3493 |
x = ++a , ++b, ++c, a+b+c; |
|
3494 |
return x; |
|
3495 |
}' |
|
3496 |
for:nil |
|
3497 |
arguments:#(1 2 3) |
|
3498 |
expect:9. |
|
3499 |
||
3500 |
self |
|
3501 |
execute:'expr(aIn, bIn, cIn) { |
|
3502 |
var x; |
|
3503 |
var a = aIn; |
|
3504 |
var b = bIn; |
|
3505 |
var c = cIn; |
|
3506 |
||
3507 |
x = a++ , b++, c++, a+b+c; |
|
3508 |
return x; |
|
3509 |
}' |
|
3510 |
for:nil |
|
3511 |
arguments:#(1 2 3) |
|
3512 |
expect:9. |
|
3513 |
||
3514 |
self |
|
3515 |
execute:'expr(aIn, bIn, cIn) { |
|
3516 |
var x; |
|
3517 |
var a = aIn; |
|
3518 |
var b = bIn; |
|
3519 |
var c = cIn; |
|
3520 |
||
3521 |
x = a++ , b++, c++, ++a + ++b + ++c; |
|
3522 |
return x; |
|
3523 |
}' |
|
3524 |
for:nil |
|
3525 |
arguments:#(1 2 3) |
|
3526 |
expect:12. |
|
3527 |
||
3528 |
self |
|
3529 |
execute:'expr(aIn, bIn, cIn) { |
|
3530 |
var x; |
|
3531 |
var a = aIn; |
|
3532 |
var b = bIn; |
|
3533 |
var c = cIn; |
|
3534 |
||
3535 |
x = a++ , b++, c++, a++ + b++ + c++; |
|
3536 |
return x; |
|
3537 |
}' |
|
3538 |
for:nil |
|
3539 |
arguments:#(1 2 3) |
|
3540 |
expect:9. |
|
278 | 3541 |
" |
3542 |
self run:#testOperators46_comma |
|
3543 |
self new testOperators46_comma |
|
3544 |
" |
|
3545 |
! |
|
3546 |
||
321 | 3547 |
testOperators47_asString |
1447 | 3548 |
self |
3549 |
execute:'expr() { |
|
3550 |
return 123.asString; |
|
3551 |
}' |
|
3552 |
for:nil |
|
3553 |
arguments:#() |
|
3554 |
expect:'123'. |
|
3555 |
||
3556 |
self |
|
3557 |
execute:'expr() { |
|
3558 |
return 1.23.asString; |
|
3559 |
}' |
|
3560 |
for:nil |
|
3561 |
arguments:#() |
|
3562 |
expect:'1.23'. |
|
321 | 3563 |
|
3564 |
" |
|
3565 |
self run:#testOperators47_toString |
|
3566 |
self new testOperators47_toString |
|
3567 |
" |
|
3568 |
! |
|
3569 |
||
1295 | 3570 |
testOperators48_isArray |
1447 | 3571 |
self |
3572 |
execute:'expr(arg) { |
|
3573 |
return arg.isArray() ; |
|
3574 |
}' |
|
3575 |
for:nil |
|
3576 |
arguments:#(123) |
|
3577 |
expect:false. |
|
3578 |
||
3579 |
self |
|
3580 |
execute:'expr(arg) { |
|
3581 |
return arg.isArray() ; |
|
3582 |
}' |
|
3583 |
for:nil |
|
3584 |
arguments:#('hello') |
|
3585 |
expect:false. |
|
3586 |
||
3587 |
self |
|
3588 |
execute:'expr(arg) { |
|
3589 |
return arg.isArray() ; |
|
3590 |
}' |
|
3591 |
for:nil |
|
3592 |
arguments:#( (1 2 3) ) |
|
3593 |
expect:true. |
|
1295 | 3594 |
|
3595 |
" |
|
3596 |
self run:#testOperators48_isArray |
|
3597 |
self new testOperators48_isArray |
|
3598 |
" |
|
3599 |
! |
|
3600 |
||
3601 |
testOperators49_concat |
|
1447 | 3602 |
self |
3603 |
execute:'expr(arg1) { |
|
3604 |
return arg1.concat() ; |
|
3605 |
}' |
|
3606 |
for:nil |
|
3607 |
arguments:#( 'a') |
|
3608 |
expect:'a'. |
|
3609 |
||
3610 |
self |
|
3611 |
execute:'expr(arg1, arg2) { |
|
3612 |
return arg1.concat(arg2) ; |
|
3613 |
}' |
|
3614 |
for:nil |
|
3615 |
arguments:#( 'a' 'b') |
|
3616 |
expect:'ab'. |
|
3617 |
||
3618 |
self |
|
3619 |
execute:'expr(arg1, arg2, arg3) { |
|
3620 |
return arg1.concat(arg2, arg3) ; |
|
3621 |
}' |
|
3622 |
for:nil |
|
3623 |
arguments:#( 'a' 'b' 'c' ) |
|
3624 |
expect:'abc'. |
|
3625 |
||
3626 |
self |
|
3627 |
execute:'expr() { |
|
3628 |
return "a".concat("b", "c", "d", "e", "f") ; |
|
3629 |
}' |
|
3630 |
for:nil |
|
3631 |
arguments:nil |
|
3632 |
expect:'abcdef'. |
|
3633 |
||
3634 |
self |
|
3635 |
execute:'expr() { |
|
3636 |
return "a".concat("b", "c", "d", "e", "f", "g") ; |
|
3637 |
}' |
|
3638 |
for:nil |
|
3639 |
arguments:nil |
|
3640 |
expect:'abcdefg'. |
|
3641 |
||
3642 |
self |
|
3643 |
execute:'expr() { |
|
3644 |
return "a".concat("b", "c", "d", "e", "f", "g", "h") ; |
|
3645 |
}' |
|
3646 |
for:nil |
|
3647 |
arguments:nil |
|
3648 |
expect:'abcdefgh'. |
|
3649 |
||
3650 |
self |
|
3651 |
execute:'expr(arg1, arg2, arg3) { |
|
3652 |
return arg1.concat(arg2, arg3) ; |
|
3653 |
}' |
|
3654 |
for:nil |
|
3655 |
arguments:#( (1) (2) (3) ) |
|
3656 |
expect:#(1 2 3). |
|
1295 | 3657 |
|
3658 |
" |
|
3659 |
self run:#testOperators49_concat |
|
3660 |
self new testOperators49_concat |
|
3661 |
" |
|
3662 |
! |
|
3663 |
||
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3664 |
testParserErrors01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3665 |
self should:[ |
1447 | 3666 |
self |
3667 |
execute:'expr(a, ) { |
|
3668 |
return (a == b); |
|
3669 |
}' |
|
3670 |
for:nil |
|
3671 |
arguments:#(10 10) |
|
3672 |
expect:true |
|
878
05ff46227bbf
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
733
diff
changeset
|
3673 |
] raise:ParseError. |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3674 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3675 |
self should:[ |
1447 | 3676 |
self |
3677 |
execute:'expr(a b) { |
|
3678 |
return (a == b); |
|
3679 |
}' |
|
3680 |
for:nil |
|
3681 |
arguments:#(10 10) |
|
3682 |
expect:true |
|
878
05ff46227bbf
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
733
diff
changeset
|
3683 |
] raise:ParseError. |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3684 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3685 |
self should:[ |
1447 | 3686 |
self |
3687 |
execute:'expr(x) { |
|
3688 |
return (x == 1 ?); |
|
3689 |
}' |
|
3690 |
for:nil |
|
3691 |
arguments:#(10 10) |
|
3692 |
expect:true |
|
878
05ff46227bbf
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
733
diff
changeset
|
3693 |
] raise:ParseError. |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3694 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3695 |
self should:[ |
1447 | 3696 |
self |
3697 |
execute:'expr(x) { |
|
3698 |
return (x == 1 ? 1 ); |
|
3699 |
}' |
|
3700 |
for:nil |
|
3701 |
arguments:#(10 10) |
|
3702 |
expect:true |
|
878
05ff46227bbf
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
733
diff
changeset
|
3703 |
] raise:ParseError. |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3704 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3705 |
self should:[ |
1447 | 3706 |
self |
3707 |
execute:'expr(x) { |
|
3708 |
return (x == 1 ? 1 : ); |
|
3709 |
}' |
|
3710 |
for:nil |
|
3711 |
arguments:#(10 10) |
|
3712 |
expect:true |
|
878
05ff46227bbf
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
733
diff
changeset
|
3713 |
] raise:ParseError. |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3714 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3715 |
self should:[ |
1447 | 3716 |
self |
3717 |
execute:'expr(x) { |
|
3718 |
return (x == 1 ? 1 : +); |
|
3719 |
}' |
|
3720 |
for:nil |
|
3721 |
arguments:#(10 10) |
|
3722 |
expect:true |
|
878
05ff46227bbf
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
733
diff
changeset
|
3723 |
] raise:ParseError. |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3724 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3725 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3726 |
self run:#testParserErrors01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3727 |
self new testParserErrors01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3728 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3729 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
3730 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3731 |
testPrecidences01 |
1447 | 3732 |
self |
3733 |
execute:'expr(a, b) { |
|
3734 |
return (a + 4 * 5 + b); |
|
3735 |
}' |
|
3736 |
for:nil |
|
3737 |
arguments:#(10 20) |
|
3738 |
expect:(10 + (4 * 5) + 20) |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3739 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3740 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3741 |
self run:#testPrecidences01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3742 |
self new testPrecidences01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3743 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3744 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3745 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3746 |
testPrecidences02 |
1447 | 3747 |
self |
3748 |
execute:'expr(a, b) { |
|
3749 |
return (a * 4 + b * 5); |
|
3750 |
}' |
|
3751 |
for:nil |
|
3752 |
arguments:#(10 20) |
|
3753 |
expect:140 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3754 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3755 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3756 |
self run:#testPrecidences02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3757 |
self new testPrecidences02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3758 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3759 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3760 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3761 |
testPrecidences03 |
1447 | 3762 |
self |
3763 |
execute:'expr(a, b) { |
|
3764 |
return -(a + b); |
|
3765 |
}' |
|
3766 |
for:nil |
|
3767 |
arguments:#(10 20) |
|
3768 |
expect:-30 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3769 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3770 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3771 |
self run:#testPrecidences03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3772 |
self new testPrecidences03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3773 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3774 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3775 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3776 |
testPrecidences04 |
1447 | 3777 |
self |
3778 |
execute:'expr(a, b) { |
|
3779 |
return -a + b; |
|
3780 |
}' |
|
3781 |
for:nil |
|
3782 |
arguments:#(10 20) |
|
3783 |
expect:10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3784 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3785 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3786 |
self run:#testPrecidences04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3787 |
self new testPrecidences04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3788 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3789 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3790 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3791 |
testPrecidences05 |
1447 | 3792 |
self |
3793 |
execute:'expr(a, b) { |
|
3794 |
return -a + -b; |
|
3795 |
}' |
|
3796 |
for:nil |
|
3797 |
arguments:#(10 20) |
|
3798 |
expect:-30 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3799 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3800 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3801 |
self run:#testPrecidences05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3802 |
self new testPrecidences05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3803 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3804 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3805 |
|
320 | 3806 |
testPrint |
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
3807 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
3808 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
3809 |
output := self outputToTranscriptOf:[ |
1447 | 3810 |
self |
3811 |
execute:' |
|
3812 |
testPrint() { |
|
3813 |
print("1 "); |
|
3814 |
print("2 "); |
|
3815 |
print("3 "); |
|
3816 |
println("4"); |
|
3817 |
return null; |
|
3818 |
} |
|
3819 |
' |
|
3820 |
for:JavaScriptEnvironment new |
|
3821 |
arguments:#( ) |
|
3822 |
expect:nil. |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
3823 |
]. |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
3824 |
self assert:(output = '1 2 3 4\' withCRs). |
320 | 3825 |
|
3826 |
" |
|
3827 |
self run:#testPrint |
|
1447 | 3828 |
self new testPrint |
320 | 3829 |
" |
3830 |
! |
|
3831 |
||
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3832 |
testRecursion01 |
1447 | 3833 |
self |
3834 |
execute:'test(n) { |
|
3835 |
function factorial(n) { |
|
3836 |
if (n > 0) { |
|
3837 |
return n * factorial(n-1); |
|
3838 |
} else { |
|
3839 |
return 1; |
|
3840 |
} |
|
3841 |
}; |
|
3842 |
||
3843 |
return factorial(n); |
|
3844 |
}' |
|
3845 |
for:nil |
|
3846 |
arguments:#(10) |
|
3847 |
expect:(10 factorial) |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3848 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3849 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3850 |
self run:#testRecursion01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3851 |
self new testRecursion01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3852 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3853 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3854 |
"Modified: / 20-04-2005 / 11:55:30 / cg" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3855 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
3856 |
|
268 | 3857 |
testReturn01 |
1447 | 3858 |
self |
3859 |
execute:'test(n) { |
|
3860 |
return 1; |
|
3861 |
}' |
|
3862 |
for:nil |
|
3863 |
arguments:#(10) |
|
3864 |
expect:1 |
|
268 | 3865 |
|
3866 |
" |
|
3867 |
self run:#testReturn01 |
|
3868 |
self new testReturn01 |
|
3869 |
" |
|
3870 |
||
3871 |
"Modified: / 20-04-2005 / 11:55:30 / cg" |
|
3872 |
! |
|
3873 |
||
281 | 3874 |
testReturn02 |
1447 | 3875 |
self |
3876 |
execute:'test(n) { |
|
3877 |
function inner() { return 2 from test; }; |
|
3878 |
||
3879 |
inner(); |
|
3880 |
return 1; |
|
3881 |
}' |
|
3882 |
for:nil |
|
3883 |
arguments:#(10) |
|
3884 |
expect:2 |
|
281 | 3885 |
|
3886 |
" |
|
3887 |
self run:#testReturn02 |
|
3888 |
self new testReturn02 |
|
3889 |
" |
|
3890 |
! |
|
3891 |
||
3892 |
testReturn03 |
|
1447 | 3893 |
self |
3894 |
execute:'test(n) { |
|
3895 |
function inner1() { |
|
3896 |
function inner2() { |
|
3897 |
return 2 from test; |
|
3898 |
}; |
|
3899 |
||
3900 |
inner2(); |
|
3901 |
}; |
|
3902 |
||
3903 |
inner1(); |
|
3904 |
return 1; |
|
3905 |
}' |
|
3906 |
for:nil |
|
3907 |
arguments:#(10) |
|
3908 |
expect:2 |
|
281 | 3909 |
|
3910 |
" |
|
3911 |
self run:#testReturn03 |
|
3912 |
self new testReturn03 |
|
3913 |
" |
|
3914 |
! |
|
3915 |
||
3916 |
testReturn04 |
|
331 | 3917 |
"/ currently fails. |
3918 |
^ self. |
|
3919 |
||
1447 | 3920 |
self |
3921 |
execute:'test(n) { |
|
3922 |
function inner1() { |
|
3923 |
function inner2() { |
|
3924 |
return 2 from inner1; |
|
3925 |
}; |
|
3926 |
||
3927 |
inner2(); |
|
3928 |
}; |
|
3929 |
||
3930 |
inner1(); |
|
3931 |
return 1; |
|
3932 |
}' |
|
3933 |
for:nil |
|
3934 |
arguments:#(10) |
|
3935 |
expectError:#ParseError |
|
281 | 3936 |
|
3937 |
" |
|
3938 |
self run:#testReturn04 |
|
3939 |
self new testReturn04 |
|
3940 |
" |
|
331 | 3941 |
|
3942 |
"Modified: / 21-02-2007 / 15:08:11 / cg" |
|
3943 |
! |
|
3944 |
||
3945 |
testReturn05 |
|
1447 | 3946 |
self |
3947 |
execute:'test(n) { |
|
3948 |
function inner() { return 2; }; |
|
3949 |
||
3950 |
return inner() + 1; |
|
3951 |
}' |
|
3952 |
for:nil |
|
3953 |
arguments:#(10) |
|
3954 |
expect:3 |
|
331 | 3955 |
|
3956 |
" |
|
3957 |
self run:#testReturn05 |
|
3958 |
self new testReturn05 |
|
3959 |
" |
|
3960 |
||
3961 |
"Created: / 21-02-2007 / 15:02:47 / cg" |
|
281 | 3962 |
! |
3963 |
||
575 | 3964 |
testReturnNew01 |
1447 | 3965 |
self |
3966 |
execute:'test() { |
|
3967 |
var someString; |
|
3968 |
||
3969 |
someString = "1234"; |
|
3970 |
return (new Point).x(someString.asInteger()); |
|
3971 |
}' |
|
3972 |
for:nil |
|
3973 |
arguments:#() |
|
3974 |
expect:(Point x:1234 y:nil). |
|
575 | 3975 |
|
3976 |
" |
|
3977 |
self run:#testReturnNew01 |
|
3978 |
self new testReturnNew01 |
|
3979 |
" |
|
3980 |
||
3981 |
"Created: / 01-02-2011 / 15:34:37 / cg" |
|
3982 |
! |
|
3983 |
||
3984 |
testReturnNew02 |
|
632 | 3985 |
|result| |
3986 |
||
1447 | 3987 |
result := self |
3988 |
execute:'test() { |
|
3989 |
var someString; |
|
3990 |
||
3991 |
someString = "1234"; |
|
3992 |
return (new ValueHolder).value(someString.asInteger()); |
|
3993 |
}' |
|
3994 |
for:nil |
|
3995 |
arguments:#(). |
|
632 | 3996 |
|
3997 |
self assert:(result isKindOf:ValueHolder). |
|
3998 |
self assert:(result value = 1234). |
|
575 | 3999 |
|
4000 |
" |
|
4001 |
self run:#testReturnNew02 |
|
4002 |
" |
|
4003 |
||
4004 |
"Created: / 01-02-2011 / 15:35:36 / cg" |
|
4005 |
! |
|
4006 |
||
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4007 |
testScanner01 |
1447 | 4008 |
self |
4009 |
execute:'f() { }' |
|
4010 |
for:nil |
|
4011 |
arguments:#() |
|
4012 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4013 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4014 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4015 |
self run:#testScanner01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4016 |
self new testScanner01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4017 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4018 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4019 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4020 |
testScanner02 |
1447 | 4021 |
self |
4022 |
execute:'f(a) { }' |
|
4023 |
for:nil |
|
4024 |
arguments:#(1) |
|
4025 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4026 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4027 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4028 |
self run:#testScanner02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4029 |
self new testScanner02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4030 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4031 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4032 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4033 |
testScanner03 |
1447 | 4034 |
self |
4035 |
execute:'f(a, b) { }' |
|
4036 |
for:nil |
|
4037 |
arguments:#(1 2) |
|
4038 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4039 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4040 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4041 |
self run:#testScanner03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4042 |
self new testScanner03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4043 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4044 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4045 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4046 |
testScanner04 |
1447 | 4047 |
self |
4048 |
execute:'f(a, b) { return (null); }' |
|
4049 |
for:nil |
|
4050 |
arguments:#(1 2) |
|
4051 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4052 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4053 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4054 |
self run:#testScanner04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4055 |
self new testScanner04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4056 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4057 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4058 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4059 |
testScanner05 |
1447 | 4060 |
self |
4061 |
execute:'f(a, b) { return (null); }' |
|
4062 |
for:nil |
|
4063 |
arguments:#(1) |
|
4064 |
expectError:(Method wongNumberOfArgumentsSignal) |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4065 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4066 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4067 |
self run:#testScanner05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4068 |
self new testScanner05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4069 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4070 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4071 |
"Modified: / 20-04-2005 / 11:53:20 / cg" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4072 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4073 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4074 |
testScanner06 |
1447 | 4075 |
self |
4076 |
execute:'f() { /* a comment */ return (null); }' |
|
4077 |
for:nil |
|
4078 |
arguments:#() |
|
4079 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4080 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4081 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4082 |
self run:#testScanner06 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4083 |
self new testScanner06 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4084 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4085 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4086 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4087 |
testScanner07 |
1447 | 4088 |
self |
4089 |
execute:'f() { // an EOL comment |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4090 |
return (null); }' |
1447 | 4091 |
for:nil |
4092 |
arguments:#() |
|
4093 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4094 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4095 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4096 |
self run:#testScanner07 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4097 |
self new testScanner07 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4098 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4099 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4100 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4101 |
testScanner08 |
1447 | 4102 |
self |
4103 |
execute:'f() { // a comment in an /* an EOL comment |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4104 |
return (null); }' |
1447 | 4105 |
for:nil |
4106 |
arguments:#() |
|
4107 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4108 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4109 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4110 |
self run:#testScanner08 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4111 |
self new testScanner08 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4112 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4113 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4114 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4115 |
testScanner09 |
1447 | 4116 |
self |
4117 |
execute:'f() { // a comment in an /* an EOL */ comment |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4118 |
return (null); }' |
1447 | 4119 |
for:nil |
4120 |
arguments:#() |
|
4121 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4122 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4123 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4124 |
self run:#testScanner09 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4125 |
self new testScanner09 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4126 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4127 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4128 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4129 |
testScanner10 |
1447 | 4130 |
self |
4131 |
execute:'f() { /** a comment */ |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4132 |
return (null); }' |
1447 | 4133 |
for:nil |
4134 |
arguments:#() |
|
4135 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4136 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4137 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4138 |
self run:#testScanner10 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4139 |
self new testScanner10 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4140 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4141 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4142 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4143 |
testScanner11 |
1447 | 4144 |
self |
4145 |
execute:'f() { /**/ |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4146 |
return (null); }' |
1447 | 4147 |
for:nil |
4148 |
arguments:#() |
|
4149 |
expect:nil |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4150 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4151 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4152 |
self run:#testScanner11 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4153 |
self new testScanner11 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4154 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4155 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4156 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4157 |
testScanner12 |
347 | 4158 |
"/ cg: is the comment below legal ? |
4159 |
^ self. "/ assume not |
|
4160 |
||
1447 | 4161 |
self |
4162 |
execute:'f() { /*/ |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4163 |
return (null); }' |
1447 | 4164 |
for:nil |
4165 |
arguments:#() |
|
4166 |
expectError:#ParseError |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4167 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4168 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4169 |
self run:#testScanner12 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4170 |
self new testScanner12 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4171 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4172 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4173 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4174 |
testScanner13 |
347 | 4175 |
"/ cg: is the comment below legal ? |
4176 |
^ self. "/ assume not |
|
4177 |
||
1447 | 4178 |
self |
4179 |
execute:'f_1() { /*/ |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4180 |
return (null); }' |
1447 | 4181 |
for:nil |
4182 |
arguments:#() |
|
4183 |
expectError:#ParseError |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4184 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4185 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4186 |
self run:#testScanner13 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4187 |
self new testScanner13 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4188 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4189 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4190 |
|
276 | 4191 |
testScanner20 |
4192 |
#( |
|
4193 |
||
1447 | 4194 |
' = ' $= |
4195 |
'/* ignored */= ' $= |
|
4196 |
'/* ignored */ = ' $= |
|
4197 |
' + ' $+ |
|
4198 |
' - ' $- |
|
4199 |
' * ' $* |
|
4200 |
' / ' $/ |
|
4201 |
' % ' $% |
|
4202 |
' & ' $& |
|
4203 |
' ^ ' $^ |
|
4204 |
' | ' $| |
|
4205 |
' !! ' $!! |
|
4206 |
' < ' $< |
|
4207 |
' > ' $> |
|
4208 |
||
4209 |
' << ' #'<<' |
|
4210 |
' >> ' #'>>' |
|
4211 |
' == ' #'==' |
|
4212 |
' <= ' #'<=' |
|
4213 |
' >= ' #'>=' |
|
4214 |
' !!= ' #'!!=' |
|
4215 |
' || ' #'||' |
|
4216 |
' && ' #'&&' |
|
4217 |
' ++ ' #'++' |
|
4218 |
' -- ' #'--' |
|
4219 |
||
4220 |
' += ' #'+=' |
|
4221 |
' -= ' #'-=' |
|
4222 |
' *= ' #'*=' |
|
4223 |
' /= ' #'/=' |
|
4224 |
' %= ' #'%=' |
|
4225 |
' &= ' #'&=' |
|
4226 |
' ^= ' #'^=' |
|
4227 |
' |= ' #'|=' |
|
4228 |
||
4229 |
' >>> ' #'>>>' |
|
4230 |
' >>= ' #'>>=' |
|
4231 |
' <<= ' #'<<=' |
|
4232 |
' === ' #'===' |
|
4233 |
' !!== ' #'!!==' |
|
4234 |
||
4235 |
' 1 ' #Integer |
|
4236 |
' 12345 ' #Integer |
|
4237 |
' 1.0 ' #Float |
|
4238 |
' 1e10 ' #Float |
|
4239 |
' 1E10 ' #Float |
|
4240 |
' 1E+10 ' #Float |
|
4241 |
' 1E-10 ' #Float |
|
4242 |
' 1.0d ' #Float |
|
4243 |
' 1. ' #Float |
|
4244 |
"/ ' 1.' #Float |
|
276 | 4245 |
) pairWiseDo:[:src :expectedToken | |
1447 | 4246 |
|scannedToken| |
4247 |
||
4248 |
scannedToken := (JavaScriptScanner for:src) nextToken. |
|
4249 |
self assert:(scannedToken == expectedToken) |
|
276 | 4250 |
]. |
4251 |
||
4252 |
" |
|
4253 |
self run:#testScanner20 |
|
4254 |
self new testScanner20 |
|
4255 |
" |
|
4256 |
! |
|
4257 |
||
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4258 |
testString01 |
1447 | 4259 |
self |
4260 |
execute:'test(str) { |
|
4261 |
return "foo".size; |
|
4262 |
}' |
|
4263 |
for:nil |
|
4264 |
arguments:#( nil ) |
|
4265 |
expect:3 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4266 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4267 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4268 |
self run:#testString01 |
1447 | 4269 |
self new testString01 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4270 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4271 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4272 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4273 |
testString02 |
1447 | 4274 |
self |
4275 |
execute:'test(str) { |
|
4276 |
return str.size(); |
|
4277 |
}' |
|
4278 |
for:nil |
|
4279 |
arguments:#( 'hello' ) |
|
4280 |
expect:5 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4281 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4282 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4283 |
self run:#testString02 |
1447 | 4284 |
self new testString02 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4285 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4286 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4287 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4288 |
testString03 |
1447 | 4289 |
self |
4290 |
execute:'test(str) { |
|
4291 |
return str.size; |
|
4292 |
}' |
|
4293 |
for:nil |
|
4294 |
arguments:#( 'hello' ) |
|
4295 |
expect:5 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4296 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4297 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4298 |
self run:#testString03 |
1447 | 4299 |
self new testString03 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4300 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4301 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
4302 |
|
320 | 4303 |
testString04 |
1447 | 4304 |
self |
4305 |
execute:'test(str) { |
|
4306 |
return str[1]; |
|
4307 |
}' |
|
4308 |
for:nil |
|
4309 |
arguments:#( 'hello' ) |
|
4310 |
expect:$h |
|
320 | 4311 |
|
4312 |
" |
|
4313 |
self run:#testString04 |
|
1447 | 4314 |
self new testString04 |
320 | 4315 |
" |
4316 |
! |
|
4317 |
||
4318 |
testString05 |
|
1447 | 4319 |
self |
4320 |
execute:'test(str) { |
|
4321 |
return str[1] == "h"[1]; |
|
4322 |
}' |
|
4323 |
for:nil |
|
4324 |
arguments:#( 'hello' ) |
|
4325 |
expect:true |
|
320 | 4326 |
|
4327 |
" |
|
4328 |
self run:#testString05 |
|
1447 | 4329 |
self new testString05 |
320 | 4330 |
" |
4331 |
! |
|
4332 |
||
4333 |
testString06 |
|
1447 | 4334 |
self |
4335 |
execute:'test(str) { |
|
4336 |
return str[1] == $''h''; |
|
4337 |
}' |
|
4338 |
for:nil |
|
4339 |
arguments:#( 'hello' ) |
|
4340 |
expect:true |
|
320 | 4341 |
|
4342 |
" |
|
4343 |
self run:#testString06 |
|
1447 | 4344 |
self new testString06 |
320 | 4345 |
" |
4346 |
! |
|
4347 |
||
4348 |
testString07 |
|
1447 | 4349 |
self |
4350 |
execute:'test(str) { |
|
4351 |
return str[1].isLowercase; |
|
4352 |
}' |
|
4353 |
for:nil |
|
4354 |
arguments:#( 'hello' ) |
|
4355 |
expect:true |
|
320 | 4356 |
|
4357 |
" |
|
4358 |
self run:#testString07 |
|
1447 | 4359 |
self new testString07 |
320 | 4360 |
" |
4361 |
! |
|
4362 |
||
1112
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4363 |
testSuper01 |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4364 |
|class1 class2| |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4365 |
|
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4366 |
Class withoutUpdatingChangesDo:[ |
1447 | 4367 |
class1 := Class name:'T1' subclassOf:Object. |
4368 |
class2 := Class name:'T2' subclassOf:class1. |
|
4369 |
||
4370 |
JavaScriptCompiler |
|
4371 |
compile:'foo() { return 1; }' |
|
4372 |
forClass:class1 |
|
4373 |
inCategory:nil |
|
4374 |
notifying:nil |
|
4375 |
install:true. |
|
4376 |
||
4377 |
JavaScriptCompiler |
|
4378 |
compile:'foo() { return 2; }' |
|
4379 |
forClass:class2 |
|
4380 |
inCategory:nil |
|
4381 |
notifying:nil |
|
4382 |
install:true. |
|
4383 |
||
4384 |
JavaScriptCompiler |
|
4385 |
compile:'callFoo() { return foo(); }' |
|
4386 |
forClass:class2 |
|
4387 |
inCategory:nil |
|
4388 |
notifying:nil |
|
4389 |
install:true. |
|
4390 |
||
4391 |
JavaScriptCompiler |
|
4392 |
compile:'callSuperFoo() { return super.foo(); }' |
|
4393 |
forClass:class2 |
|
4394 |
inCategory:nil |
|
4395 |
notifying:nil |
|
4396 |
install:true. |
|
1112
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4397 |
]. |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4398 |
|
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4399 |
self assert:(class2 new callFoo == 2). |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4400 |
self assert:(class2 new callSuperFoo == 1). |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4401 |
|
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4402 |
" |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4403 |
self run:#testSuper01 |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4404 |
self new testSuper01 |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4405 |
" |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4406 |
! |
f462798b6a1d
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
1005
diff
changeset
|
4407 |
|
267 | 4408 |
testSwitch01 |
1447 | 4409 |
self |
4410 |
execute:'test(arg) { |
|
4411 |
switch (arg) { |
|
4412 |
} |
|
4413 |
}' |
|
4414 |
for:nil |
|
4415 |
arguments:#(5) |
|
4416 |
expect:nil |
|
267 | 4417 |
|
4418 |
" |
|
4419 |
self run:#testSwitch01 |
|
1447 | 4420 |
self new testSwitch01 |
267 | 4421 |
" |
4422 |
! |
|
4423 |
||
4424 |
testSwitch02 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4425 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4426 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4427 |
output := self outputToTranscriptOf:[ |
1447 | 4428 |
self |
4429 |
execute:'test(arg) { |
|
4430 |
switch (arg) { |
|
4431 |
Transcript.show("hello "); |
|
4432 |
return 1; |
|
4433 |
} |
|
4434 |
return 0; |
|
4435 |
}' |
|
4436 |
for:nil |
|
4437 |
arguments:#(5) |
|
4438 |
expect:0 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4439 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4440 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( )) |
267 | 4441 |
|
4442 |
" |
|
4443 |
self run:#testSwitch02 |
|
1447 | 4444 |
self new testSwitch02 |
267 | 4445 |
" |
4446 |
! |
|
4447 |
||
4448 |
testSwitch03 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4449 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4450 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4451 |
output := self outputToTranscriptOf:[ |
1447 | 4452 |
self |
4453 |
execute:'test(arg) { |
|
4454 |
switch (arg) { |
|
4455 |
Transcript.show("hello "); |
|
4456 |
Transcript.show("world "); |
|
4457 |
Transcript.cr(); |
|
4458 |
return 1; |
|
4459 |
} |
|
4460 |
return 0; |
|
4461 |
}' |
|
4462 |
for:nil |
|
4463 |
arguments:#(5) |
|
4464 |
expect:0 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4465 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4466 |
self assert:(output asCollectionOfLinesWithReturn asArray = #() ) |
267 | 4467 |
|
4468 |
" |
|
4469 |
self run:#testSwitch03 |
|
1447 | 4470 |
self new testSwitch03 |
267 | 4471 |
" |
4472 |
! |
|
4473 |
||
4474 |
testSwitch04 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4475 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4476 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4477 |
output := self outputToTranscriptOf:[ |
1447 | 4478 |
self |
4479 |
execute:'test(arg) { |
|
4480 |
switch (arg) { |
|
4481 |
default: |
|
4482 |
Transcript.show("hello "); |
|
4483 |
Transcript.show("world "); |
|
4484 |
Transcript.cr(); |
|
4485 |
return 1; |
|
4486 |
} |
|
4487 |
return 0; |
|
4488 |
}' |
|
4489 |
for:nil |
|
4490 |
arguments:#(5) |
|
4491 |
expect:1 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4492 |
]. |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4493 |
self assert:(output = 'hello world \' withCRs). |
267 | 4494 |
|
4495 |
" |
|
4496 |
self run:#testSwitch04 |
|
1447 | 4497 |
self new testSwitch04 |
267 | 4498 |
" |
4499 |
! |
|
4500 |
||
4501 |
testSwitch05 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4502 |
|output| |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4503 |
|
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4504 |
output := self outputToTranscriptOf:[ |
1447 | 4505 |
self |
4506 |
execute:'test(arg) { |
|
4507 |
switch (arg) { |
|
4508 |
default: |
|
4509 |
Transcript.show("hello "); |
|
4510 |
Transcript.show("world "); |
|
4511 |
return 1; |
|
4512 |
Transcript.cr(); |
|
4513 |
} |
|
4514 |
return 0; |
|
4515 |
}' |
|
4516 |
for:nil |
|
4517 |
arguments:#(5) |
|
4518 |
expect:1 |
|
732
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4519 |
]. |
450ab2d5cf8c
redirect and check output (Stdout)
Claus Gittinger <cg@exept.de>
parents:
731
diff
changeset
|
4520 |
self assert:(output = 'hello world '). |
267 | 4521 |
|
4522 |
" |
|
4523 |
self run:#testSwitch05 |
|
1447 | 4524 |
self new testSwitch05 |
267 | 4525 |
" |
4526 |
! |
|
4527 |
||
268 | 4528 |
testSwitch06a |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4529 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4530 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4531 |
output := self outputToTranscriptOf:[ |
1447 | 4532 |
self |
4533 |
execute:'test(arg) { |
|
4534 |
switch (arg) { |
|
4535 |
case 1: |
|
4536 |
Transcript.showCR("one"); |
|
4537 |
return 10; |
|
4538 |
case 2: |
|
4539 |
Transcript.showCR("two"); |
|
4540 |
return 20; |
|
4541 |
} |
|
4542 |
return 0; |
|
4543 |
}' |
|
4544 |
for:nil |
|
4545 |
arguments:#(5) |
|
4546 |
expect:0 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4547 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4548 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( )) |
268 | 4549 |
|
4550 |
" |
|
4551 |
self run:#testSwitch06a |
|
1447 | 4552 |
self new testSwitch06a |
268 | 4553 |
" |
4554 |
! |
|
4555 |
||
4556 |
testSwitch06b |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4557 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4558 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4559 |
output := self outputToTranscriptOf:[ |
1447 | 4560 |
self |
4561 |
execute:'test(arg) { |
|
4562 |
switch (arg) { |
|
4563 |
case 1: |
|
4564 |
Transcript.showCR("one"); |
|
4565 |
return 10; |
|
4566 |
case 2: |
|
4567 |
Transcript.showCR("two"); |
|
4568 |
return 20; |
|
4569 |
} |
|
4570 |
return 0; |
|
4571 |
}' |
|
4572 |
for:nil |
|
4573 |
arguments:#(1) |
|
4574 |
expect:10 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4575 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4576 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( 'one')) |
268 | 4577 |
|
4578 |
" |
|
4579 |
self run:#testSwitch06b |
|
1447 | 4580 |
self new testSwitch06b |
268 | 4581 |
" |
4582 |
! |
|
4583 |
||
4584 |
testSwitch06c |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4585 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4586 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4587 |
output := self outputToTranscriptOf:[ |
1447 | 4588 |
self |
4589 |
execute:'test(arg) { |
|
4590 |
switch (arg) { |
|
4591 |
case 1: |
|
4592 |
Transcript.showCR("one"); |
|
4593 |
return 10; |
|
4594 |
case 2: |
|
4595 |
Transcript.showCR("two"); |
|
4596 |
return 20; |
|
4597 |
} |
|
4598 |
return 0; |
|
4599 |
}' |
|
4600 |
for:nil |
|
4601 |
arguments:#(2) |
|
4602 |
expect:20 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4603 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4604 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( 'two')) |
268 | 4605 |
|
4606 |
" |
|
4607 |
self run:#testSwitch06c |
|
1447 | 4608 |
self new testSwitch06c |
268 | 4609 |
" |
4610 |
! |
|
4611 |
||
4612 |
testSwitch06d |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4613 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4614 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4615 |
output := self outputToTranscriptOf:[ |
1447 | 4616 |
self |
4617 |
execute:'test(arg) { |
|
4618 |
switch (arg) { |
|
4619 |
case "hallo": |
|
4620 |
Transcript.showCR("Hallo"); |
|
4621 |
return 10; |
|
4622 |
case "hello": |
|
4623 |
Transcript.showCR("Hello"); |
|
4624 |
return 20; |
|
4625 |
} |
|
4626 |
return 0; |
|
4627 |
}' |
|
4628 |
for:nil |
|
4629 |
arguments:#('hello') |
|
4630 |
expect:20 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4631 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4632 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( 'Hello')) |
268 | 4633 |
|
4634 |
" |
|
4635 |
self run:#testSwitch06d |
|
1447 | 4636 |
self new testSwitch06d |
268 | 4637 |
" |
4638 |
! |
|
4639 |
||
4640 |
testSwitch06e |
|
1447 | 4641 |
self |
4642 |
execute:'test(arg) { |
|
4643 |
switch (arg) { |
|
4644 |
case 1: |
|
4645 |
Transcript.showCR("Hallo"); |
|
4646 |
return 10; |
|
4647 |
case 2: |
|
4648 |
Transcript.showCR("Hello"); |
|
4649 |
return 20; |
|
4650 |
} |
|
4651 |
return 0; |
|
4652 |
}' |
|
4653 |
for:nil |
|
4654 |
arguments:#(3) |
|
4655 |
expect:0 |
|
268 | 4656 |
|
4657 |
" |
|
4658 |
self run:#testSwitch06e |
|
1447 | 4659 |
self new testSwitch06e |
268 | 4660 |
" |
4661 |
! |
|
4662 |
||
4663 |
testSwitch06f |
|
1447 | 4664 |
self |
4665 |
execute:'test(arg) { |
|
4666 |
var a = 0; |
|
4667 |
switch (arg) { |
|
4668 |
case 1: |
|
4669 |
a = 10; |
|
4670 |
break; |
|
4671 |
case 2: |
|
4672 |
a = 20; |
|
4673 |
break; |
|
4674 |
} |
|
4675 |
return a; |
|
4676 |
}' |
|
4677 |
for:nil |
|
4678 |
arguments:#(1) |
|
4679 |
expect:10 |
|
268 | 4680 |
|
4681 |
" |
|
4682 |
self run:#testSwitch06f |
|
1447 | 4683 |
self new testSwitch06f |
268 | 4684 |
" |
4685 |
! |
|
4686 |
||
4687 |
testSwitch06g |
|
1447 | 4688 |
self |
4689 |
execute:'test(arg) { |
|
4690 |
var a = 0; |
|
4691 |
switch (arg) { |
|
4692 |
case 1: |
|
4693 |
a = 10; |
|
4694 |
break; |
|
4695 |
case 2: |
|
4696 |
a = 20; |
|
4697 |
break; |
|
4698 |
} |
|
4699 |
return a; |
|
4700 |
}' |
|
4701 |
for:nil |
|
4702 |
arguments:#(2) |
|
4703 |
expect:20 |
|
268 | 4704 |
|
4705 |
" |
|
4706 |
self run:#testSwitch06g |
|
1447 | 4707 |
self new testSwitch06g |
268 | 4708 |
" |
4709 |
! |
|
4710 |
||
4711 |
testSwitch06h |
|
1447 | 4712 |
self |
4713 |
execute:'test(arg) { |
|
4714 |
var a = 0; |
|
4715 |
switch (arg) { |
|
4716 |
case 1: |
|
4717 |
a = 10; |
|
4718 |
break; |
|
4719 |
case 2: |
|
4720 |
a = 20; |
|
4721 |
break; |
|
4722 |
} |
|
4723 |
return a; |
|
4724 |
}' |
|
4725 |
for:nil |
|
4726 |
arguments:#(3) |
|
4727 |
expect:0 |
|
268 | 4728 |
|
4729 |
" |
|
4730 |
self run:#testSwitch06h |
|
1447 | 4731 |
self new testSwitch06h |
268 | 4732 |
" |
4733 |
! |
|
4734 |
||
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4735 |
testThrow01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4736 |
"an exception is thrown" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4737 |
|
1447 | 4738 |
self |
4739 |
execute:'test(arg) { |
|
4740 |
var handlerWasCalled = false; |
|
4741 |
||
4742 |
function failingMethod() { |
|
4743 |
throw Error; |
|
4744 |
}; |
|
4745 |
||
4746 |
try { |
|
4747 |
failingMethod(); |
|
4748 |
} catch (Error e) { |
|
4749 |
handlerWasCalled = true; |
|
4750 |
} |
|
4751 |
return handlerWasCalled; |
|
4752 |
}' |
|
4753 |
for:nil |
|
4754 |
arguments:#(0) |
|
4755 |
expect:true |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4756 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4757 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4758 |
self run:#testThrow01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4759 |
self new testThrow01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4760 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4761 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4762 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4763 |
testTryCatch01a |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4764 |
"in this testcase, arg is 5, so no exception should be thrown" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4765 |
|
1447 | 4766 |
self |
4767 |
execute:'test(arg) { |
|
4768 |
var handlerWasCalled = false; |
|
4769 |
||
4770 |
function failingMethod() { |
|
4771 |
return 10 / arg; |
|
4772 |
}; |
|
4773 |
||
4774 |
try { |
|
4775 |
failingMethod(); |
|
4776 |
} catch (Error e) { |
|
4777 |
handlerWasCalled = true; |
|
4778 |
} |
|
4779 |
return handlerWasCalled; |
|
4780 |
}' |
|
4781 |
for:nil |
|
4782 |
arguments:#(5) |
|
4783 |
expect:false |
|
321 | 4784 |
|
4785 |
" |
|
4786 |
self run:#testTryCatch01a |
|
4787 |
self new testTryCatch01a |
|
4788 |
" |
|
4789 |
! |
|
4790 |
||
4791 |
testTryCatch01b |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4792 |
"in this testcase, arg is 0, so an exception should be thrown" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
4793 |
|
1447 | 4794 |
self |
4795 |
execute:'test(arg) { |
|
4796 |
var handlerWasCalled = false; |
|
4797 |
||
4798 |
function failingMethod() { return 10 / arg; }; |
|
4799 |
||
4800 |
try { |
|
4801 |
failingMethod(); |
|
4802 |
} catch (Error e) { |
|
4803 |
handlerWasCalled = true; |
|
4804 |
} |
|
4805 |
return handlerWasCalled; |
|
4806 |
}' |
|
4807 |
for:nil |
|
4808 |
arguments:#(0) |
|
4809 |
expect:true |
|
321 | 4810 |
|
4811 |
" |
|
4812 |
self run:#testTryCatch01b |
|
4813 |
self new testTryCatch01b |
|
4814 |
" |
|
4815 |
! |
|
4816 |
||
4817 |
testTryCatch02a |
|
1447 | 4818 |
self |
4819 |
execute:'test(arg) { |
|
4820 |
var handlerWasCalled = false; |
|
4821 |
||
4822 |
function failingMethod() { return 10 / arg; }; |
|
4823 |
function exceptionRaised() { handlerWasCalled = true; }; |
|
4824 |
||
4825 |
try { |
|
4826 |
failingMethod(); |
|
4827 |
} catch (Error e) { |
|
4828 |
exceptionRaised(); |
|
4829 |
} |
|
4830 |
return handlerWasCalled; |
|
4831 |
}' |
|
4832 |
for:nil |
|
4833 |
arguments:#(5) |
|
4834 |
expect:false |
|
321 | 4835 |
|
4836 |
" |
|
4837 |
self run:#testTryCatch02a |
|
4838 |
self new testTryCatch02a |
|
4839 |
" |
|
4840 |
! |
|
4841 |
||
4842 |
testTryCatch02b |
|
1447 | 4843 |
self |
4844 |
execute:'test(arg) { |
|
4845 |
var handlerWasCalled = false; |
|
4846 |
||
4847 |
function failingMethod() { return 10 / arg; }; |
|
4848 |
function exceptionRaised() { handlerWasCalled = true; }; |
|
4849 |
||
4850 |
try { |
|
4851 |
failingMethod(); |
|
4852 |
} catch (Error e) { |
|
4853 |
exceptionRaised(); |
|
4854 |
} |
|
4855 |
return handlerWasCalled; |
|
4856 |
}' |
|
4857 |
for:nil |
|
4858 |
arguments:#(0) |
|
4859 |
expect:true |
|
321 | 4860 |
|
4861 |
" |
|
4862 |
self run:#testTryCatch02b |
|
4863 |
self new testTryCatch02b |
|
4864 |
" |
|
4865 |
! |
|
4866 |
||
4867 |
testTryCatch03a |
|
1447 | 4868 |
self |
4869 |
execute:'test(arg) { |
|
4870 |
var handlerWasCalled = false; |
|
4871 |
||
4872 |
function failingMethod() { return 10 / arg; }; |
|
4873 |
function exceptionRaised(e) { handlerWasCalled = true; }; |
|
4874 |
||
4875 |
try { |
|
4876 |
failingMethod(); |
|
4877 |
} catch (Error e) { |
|
4878 |
exceptionRaised(e); |
|
4879 |
} |
|
4880 |
return handlerWasCalled; |
|
4881 |
}' |
|
4882 |
for:nil |
|
4883 |
arguments:#(5) |
|
4884 |
expect:false |
|
321 | 4885 |
|
4886 |
" |
|
4887 |
self run:#testTryCatch03a |
|
4888 |
self new testTryCatch03a |
|
4889 |
" |
|
4890 |
! |
|
4891 |
||
4892 |
testTryCatch03b |
|
1447 | 4893 |
self |
4894 |
execute:'test(arg) { |
|
4895 |
var handlerWasCalled = false; |
|
4896 |
||
4897 |
function failingMethod() { return 10 / arg; }; |
|
4898 |
function exceptionRaised(e) { handlerWasCalled = true; }; |
|
4899 |
||
4900 |
try { |
|
4901 |
failingMethod(); |
|
4902 |
} catch (Error e) { |
|
4903 |
exceptionRaised(e); |
|
4904 |
} |
|
4905 |
return handlerWasCalled; |
|
4906 |
}' |
|
4907 |
for:nil |
|
4908 |
arguments:#(0) |
|
4909 |
expect:true |
|
321 | 4910 |
|
4911 |
" |
|
4912 |
self run:#testTryCatch03b |
|
4913 |
self new testTryCatch03b |
|
4914 |
" |
|
4915 |
! |
|
4916 |
||
4917 |
testTryCatch04b |
|
4918 |
self should:[ |
|
4919 |
||
1447 | 4920 |
self |
4921 |
execute:'test(arg) { |
|
4922 |
var handlerWasCalled = false; |
|
4923 |
||
4924 |
function failingMethod() { return 10 / arg; }; |
|
4925 |
function exceptionRaised() { handlerWasCalled = true; }; |
|
4926 |
||
4927 |
try { |
|
4928 |
failingMethod(); |
|
4929 |
} catch (Error e) { |
|
4930 |
exceptionRaised(e); |
|
4931 |
} |
|
4932 |
return handlerWasCalled; |
|
4933 |
}' |
|
4934 |
for:nil |
|
4935 |
arguments:#(0) |
|
4936 |
expect:true |
|
321 | 4937 |
|
4938 |
] raise: Error. |
|
4939 |
||
4940 |
" |
|
4941 |
self run:#testTryCatch04b |
|
4942 |
self new testTryCatch04b |
|
4943 |
" |
|
4944 |
! |
|
4945 |
||
351 | 4946 |
testTryCatchExceptionInfo |
1368 | 4947 |
|savedTranscript collector expected| |
4948 |
||
1447 | 4949 |
savedTranscript := Smalltalk at:#Transcript. |
1368 | 4950 |
[ |
1447 | 4951 |
Smalltalk at:#Transcript put:(collector := '' writeStream). |
4952 |
||
1485 | 4953 |
self |
1447 | 4954 |
execute:' |
1368 | 4955 |
test(arg) { |
4956 |
var handlerWasCalled = false; |
|
4957 |
||
4958 |
function failingMethod() { return 10 / arg; }; |
|
4959 |
||
4960 |
try { |
|
1485 | 4961 |
failingMethod(); |
1368 | 4962 |
} catch (Error e) { |
1485 | 4963 |
println(e.description()); |
4964 |
handlerWasCalled = true; |
|
1368 | 4965 |
} |
1485 | 4966 |
return handlerWasCalled; |
1368 | 4967 |
}' |
1485 | 4968 |
for:JavaScriptEnvironment new |
4969 |
arguments:#(0) |
|
1447 | 4970 |
expect:true. |
1368 | 4971 |
] ensure:[ |
1447 | 4972 |
Smalltalk at:#Transcript put:savedTranscript |
1368 | 4973 |
]. |
4974 |
||
4975 |
expected := String streamContents:[:s | s showCR:'division by zero']. |
|
4976 |
self assert:(collector contents = expected). |
|
351 | 4977 |
|
4978 |
" |
|
4979 |
self run:#testTryCatchExceptionInfo |
|
4980 |
self new testTryCatchExceptionInfo |
|
4981 |
" |
|
4982 |
! |
|
4983 |
||
348
efd32656acce
changed #testTryCatchFinally01
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
4984 |
testTryCatchFinally01 |
1447 | 4985 |
self |
4986 |
execute: |
|
1368 | 4987 |
'test(arg) { |
4988 |
var handlerWasCalled = false; |
|
4989 |
var finallyExecuted = false; |
|
4990 |
||
4991 |
function failingMethod() { return 10 / arg; }; |
|
4992 |
function exceptionRaised() { handlerWasCalled = true; }; |
|
4993 |
||
4994 |
try { |
|
1485 | 4995 |
failingMethod(); |
1368 | 4996 |
} catch (Error e) { |
1485 | 4997 |
exceptionRaised(); |
1368 | 4998 |
} finally { |
1485 | 4999 |
finallyExecuted = true; |
1368 | 5000 |
} |
1485 | 5001 |
return handlerWasCalled && finallyExecuted; |
1368 | 5002 |
}' |
1485 | 5003 |
for:nil |
5004 |
arguments:#(0) |
|
1447 | 5005 |
expect:true. |
1485 | 5006 |
|
348
efd32656acce
changed #testTryCatchFinally01
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
5007 |
" |
efd32656acce
changed #testTryCatchFinally01
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
5008 |
self run:#testTryCatchFinally01 |
efd32656acce
changed #testTryCatchFinally01
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
5009 |
self new testTryCatchFinally01 |
efd32656acce
changed #testTryCatchFinally01
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
5010 |
" |
efd32656acce
changed #testTryCatchFinally01
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
5011 |
! |
efd32656acce
changed #testTryCatchFinally01
Claus Gittinger <cg@exept.de>
parents:
347
diff
changeset
|
5012 |
|
322 | 5013 |
testTryFinally01 |
1368 | 5014 |
|savedTranscript collector expected| |
5015 |
||
1447 | 5016 |
savedTranscript := Smalltalk at:#Transcript. |
1368 | 5017 |
[ |
1447 | 5018 |
Smalltalk at:#Transcript put:(collector := '' writeStream). |
1485 | 5019 |
self |
1447 | 5020 |
execute: |
1368 | 5021 |
'test(arg) { |
5022 |
var handlerWasCalled = false; |
|
5023 |
||
5024 |
println("1"); |
|
1485 | 5025 |
try { |
5026 |
function dummy () { |
|
5027 |
println("2a"); |
|
5028 |
try { |
|
5029 |
println("2b"); |
|
5030 |
return 10 / arg; |
|
5031 |
} finally { |
|
5032 |
println("2c"); |
|
5033 |
handlerWasCalled = true; |
|
5034 |
} |
|
5035 |
}; |
|
5036 |
||
5037 |
println("2"); |
|
5038 |
dummy(); |
|
5039 |
println("3"); |
|
1368 | 5040 |
} catch(Error); |
5041 |
||
5042 |
println("4"); |
|
5043 |
return handlerWasCalled; |
|
5044 |
}' |
|
1485 | 5045 |
for:JavaScriptEnvironment new |
5046 |
arguments:#(0) |
|
5047 |
expect:true |
|
5048 |
||
5049 |
] ensure:[ |
|
5050 |
Smalltalk at:#Transcript put:savedTranscript |
|
5051 |
]. |
|
5052 |
||
5053 |
expected := String streamContents:[:s | |
|
5054 |
s showCR:'1'. |
|
5055 |
s showCR:'2'. |
|
5056 |
s showCR:'2a'. |
|
5057 |
s showCR:'2b'. |
|
5058 |
s showCR:'2c'. |
|
5059 |
s showCR:'4'. |
|
5060 |
]. |
|
5061 |
self assert:(collector contents = expected). |
|
1368 | 5062 |
|
5063 |
] ensure:[ |
|
1447 | 5064 |
Smalltalk at:#Transcript put:savedTranscript |
1368 | 5065 |
]. |
5066 |
||
1447 | 5067 |
expected := String streamContents:[:s | |
5068 |
s showCR:'1'. |
|
5069 |
s showCR:'2'. |
|
5070 |
s showCR:'2a'. |
|
5071 |
s showCR:'2b'. |
|
5072 |
s showCR:'2c'. |
|
5073 |
s showCR:'4'. |
|
5074 |
]. |
|
1368 | 5075 |
self assert:(collector contents = expected). |
322 | 5076 |
|
5077 |
" |
|
5078 |
self run:#testTryFinally01 |
|
5079 |
self new testTryFinally01 |
|
5080 |
" |
|
5081 |
! |
|
5082 |
||
350 | 5083 |
testTryFinally02 |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5084 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5085 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5086 |
output := self outputToTranscriptOf:[ |
1447 | 5087 |
self |
5088 |
execute:'test(arg) { |
|
5089 |
var handler1WasCalled = false; |
|
5090 |
var handler2WasCalled = false; |
|
5091 |
var finallyActionWasEvaluated = false; |
|
5092 |
||
5093 |
println("1"); |
|
5094 |
try { |
|
5095 |
||
5096 |
function dummy () { |
|
5097 |
println("2a"); |
|
5098 |
try { |
|
5099 |
println("2b"); |
|
5100 |
return 10 / arg; |
|
5101 |
} finally { |
|
5102 |
println("2c"); |
|
5103 |
handler1WasCalled = true; |
|
5104 |
} |
|
5105 |
}; |
|
5106 |
||
5107 |
println("2"); |
|
5108 |
dummy(); |
|
5109 |
println("3"); |
|
5110 |
} catch(Error e) { |
|
5111 |
println("e"); |
|
5112 |
handler2WasCalled = true; |
|
5113 |
} finally { |
|
5114 |
println("f"); |
|
5115 |
finallyActionWasEvaluated = true; |
|
5116 |
}; |
|
5117 |
||
5118 |
println("4"); |
|
5119 |
return handler1WasCalled && handler2WasCalled && finallyActionWasEvaluated; |
|
5120 |
}' |
|
5121 |
for:JavaScriptEnvironment new |
|
5122 |
arguments:#(0) |
|
5123 |
expect:true |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5124 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5125 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '2a' '2b' 'e' '2c' 'f' '4')) |
350 | 5126 |
|
5127 |
" |
|
5128 |
self run:#testTryFinally02 |
|
5129 |
self new testTryFinally02 |
|
5130 |
" |
|
5131 |
! |
|
5132 |
||
5133 |
testTryFinally03 |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5134 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5135 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5136 |
output := self outputToTranscriptOf:[ |
1447 | 5137 |
self |
5138 |
execute:'test(arg) { |
|
5139 |
var handlerWasCalled = false; |
|
5140 |
var finallyActionWasEvaluated = false; |
|
5141 |
||
5142 |
println("1"); |
|
5143 |
try { |
|
5144 |
function dummy() {}; |
|
5145 |
||
5146 |
println("2"); |
|
5147 |
dummy(); |
|
5148 |
println("3"); |
|
5149 |
} catch(Error e) { |
|
5150 |
println("e"); |
|
5151 |
handlerWasCalled = true; |
|
5152 |
} finally { |
|
5153 |
println("f"); |
|
5154 |
finallyActionWasEvaluated = true; |
|
5155 |
}; |
|
5156 |
||
5157 |
println("4"); |
|
5158 |
return !!handlerWasCalled && finallyActionWasEvaluated; |
|
5159 |
}' |
|
5160 |
for:JavaScriptEnvironment new |
|
5161 |
arguments:#(0) |
|
5162 |
expect:true |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5163 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5164 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' 'f' '4')) |
350 | 5165 |
|
5166 |
" |
|
5167 |
self run:#testTryFinally03 |
|
5168 |
self new testTryFinally03 |
|
5169 |
" |
|
5170 |
! |
|
5171 |
||
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5172 |
testTypeof01 |
1447 | 5173 |
self |
5174 |
execute:'test(arg) { |
|
5175 |
return typeof(arg); |
|
5176 |
}' |
|
5177 |
for:nil |
|
5178 |
arguments:#(0) |
|
5179 |
expect:'number'. |
|
5180 |
||
5181 |
self |
|
5182 |
execute:'test(arg) { |
|
5183 |
return typeof(arg); |
|
5184 |
}' |
|
5185 |
for:nil |
|
5186 |
arguments:#('foo') |
|
5187 |
expect:'string'. |
|
5188 |
||
5189 |
self |
|
5190 |
execute:'test(arg) { |
|
5191 |
return typeof(arg); |
|
5192 |
}' |
|
5193 |
for:nil |
|
5194 |
arguments:#(true) |
|
5195 |
expect:'boolean'. |
|
5196 |
||
5197 |
self |
|
5198 |
execute:'test(arg) { |
|
5199 |
return typeof(arg); |
|
5200 |
}' |
|
5201 |
for:nil |
|
5202 |
arguments:#(false) |
|
5203 |
expect:'boolean'. |
|
5204 |
||
5205 |
self |
|
5206 |
execute:'test(arg) { |
|
5207 |
return typeof(arg); |
|
5208 |
}' |
|
5209 |
for:nil |
|
5210 |
arguments:#(nil) |
|
5211 |
expect:'undefined'. |
|
5212 |
||
5213 |
self |
|
5214 |
execute:'test(arg) { |
|
5215 |
return typeof(arg); |
|
5216 |
}' |
|
5217 |
for:nil |
|
5218 |
arguments:#( #[1 2 3] ) |
|
5219 |
expect:'object'. |
|
5220 |
||
5221 |
self |
|
5222 |
execute:'test(arg) { |
|
5223 |
return typeof(arg); |
|
5224 |
}' |
|
5225 |
for:nil |
|
5226 |
arguments:#( #(1 2 3) ) |
|
5227 |
expect:'object'. |
|
5228 |
||
5229 |
self |
|
5230 |
execute:'test(arg) { |
|
5231 |
return typeof(arg); |
|
5232 |
}' |
|
5233 |
for:nil |
|
5234 |
arguments:(Array with:(Point new)) |
|
5235 |
expect:'object'. |
|
5236 |
||
5237 |
self |
|
5238 |
execute:'test(arg) { |
|
5239 |
return typeof(arg); |
|
5240 |
}' |
|
5241 |
for:nil |
|
5242 |
arguments:(Array with:Integer) |
|
5243 |
expect:'object'. |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5244 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5245 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5246 |
self run:#testTypeof01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5247 |
self new testTypeof01 |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5248 |
" |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5249 |
! |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5250 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5251 |
testVarDeclaration01 |
1447 | 5252 |
self |
5253 |
execute:'expr(a, b) { |
|
5254 |
var x = 10; |
|
5255 |
||
5256 |
return x; |
|
5257 |
}' |
|
5258 |
for:nil |
|
5259 |
arguments:#(10 20) |
|
5260 |
expect:10 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5261 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5262 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5263 |
self run:#testVarDeclaration01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5264 |
self new testVarDeclaration01 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5265 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5266 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5267 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5268 |
testVarDeclaration02 |
1447 | 5269 |
self |
5270 |
execute:'expr(a, b) { |
|
5271 |
var x = 10; |
|
5272 |
||
5273 |
return (a + x); |
|
5274 |
}' |
|
5275 |
for:nil |
|
5276 |
arguments:#(10 20) |
|
5277 |
expect:20 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5278 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5279 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5280 |
self run:#testVarDeclaration02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5281 |
self new testVarDeclaration02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5282 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5283 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5284 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5285 |
testVarDeclaration03 |
1447 | 5286 |
self |
5287 |
execute:'expr(a, b) { |
|
5288 |
var x = 10; |
|
5289 |
var y = x+10; |
|
5290 |
||
5291 |
return (y); |
|
5292 |
}' |
|
5293 |
for:nil |
|
5294 |
arguments:#(10 20) |
|
5295 |
expect:20 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5296 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5297 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5298 |
self run:#testVarDeclaration03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5299 |
self new testVarDeclaration03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5300 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5301 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5302 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5303 |
testVarDeclaration04 |
1447 | 5304 |
self |
5305 |
execute:'expr(a, b) { |
|
5306 |
var y = x+10; |
|
5307 |
var x = 10; |
|
5308 |
||
5309 |
return (y); |
|
5310 |
}' |
|
5311 |
for:nil |
|
5312 |
arguments:#(10 20) |
|
5313 |
expectError:#ParseError |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5314 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5315 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5316 |
self run:#testVarDeclaration04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5317 |
self new testVarDeclaration04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5318 |
" |
331 | 5319 |
|
5320 |
"Modified: / 23-02-2007 / 16:26:17 / cg" |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5321 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5322 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5323 |
testVarDeclaration05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5324 |
"our JS only allows variables declarations at a blocks top" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5325 |
|
1447 | 5326 |
self |
5327 |
execute:'expr(a, b) { |
|
5328 |
var y = 10; |
|
5329 |
||
5330 |
y = y + 10; |
|
5331 |
||
5332 |
var x = 10; |
|
5333 |
||
5334 |
return (y); |
|
5335 |
}' |
|
5336 |
for:nil |
|
5337 |
arguments:#(10 20) |
|
5338 |
expect:20 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5339 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5340 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5341 |
self run:#testVarDeclaration05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5342 |
self new testVarDeclaration05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5343 |
" |
331 | 5344 |
|
5345 |
"Modified: / 23-02-2007 / 16:25:07 / cg" |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5346 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5347 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5348 |
testVarDeclaration06 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5349 |
|
1447 | 5350 |
self |
5351 |
execute:'expr(x) { |
|
5352 |
var y = x + 20; |
|
5353 |
||
5354 |
return (y); |
|
5355 |
}' |
|
5356 |
for:nil |
|
5357 |
arguments:#(10) |
|
5358 |
expect:30 |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5359 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5360 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5361 |
self run:#testVarDeclaration06 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5362 |
self new testVarDeclaration06 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5363 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5364 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5365 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5366 |
testVarDeclaration07 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5367 |
|
1447 | 5368 |
self |
5369 |
execute:'expr(x) { |
|
5370 |
var x = x + 20; |
|
5371 |
||
5372 |
return (x); |
|
5373 |
}' |
|
5374 |
for:nil |
|
5375 |
arguments:#(10) |
|
5376 |
expectError:Error |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5377 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5378 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5379 |
self run:#testVarDeclaration07 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5380 |
self new testVarDeclaration07 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5381 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5382 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5383 |
|
278 | 5384 |
testVarDeclaration08 |
5385 |
||
1447 | 5386 |
self |
5387 |
execute:'expr(aIn, bIn, cIn) { |
|
5388 |
var a = aIn, b = bIn, c = cIn; |
|
5389 |
||
5390 |
return (a); |
|
5391 |
}' |
|
5392 |
for:nil |
|
5393 |
arguments:#(1 2 3) |
|
5394 |
expect:1 |
|
278 | 5395 |
|
5396 |
" |
|
5397 |
self run:#testVarDeclaration08 |
|
5398 |
self new testVarDeclaration08 |
|
5399 |
" |
|
5400 |
! |
|
5401 |
||
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5402 |
testWhile01 |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5403 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5404 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5405 |
output := self outputToTranscriptOf:[ |
1447 | 5406 |
self |
5407 |
execute:'test(arg) { |
|
5408 |
var n; |
|
5409 |
||
5410 |
n = arg; |
|
5411 |
while (n > 0) { |
|
5412 |
n--; |
|
5413 |
Transcript.showCR("hello"); |
|
5414 |
} |
|
5415 |
}' |
|
5416 |
for:nil |
|
5417 |
arguments:#(5) |
|
5418 |
expect:nil |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5419 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5420 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( 'hello' 'hello' 'hello' 'hello' 'hello' )) |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5421 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5422 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5423 |
self run:#testWhile01 |
1447 | 5424 |
self new testWhile01 |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5425 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5426 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5427 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5428 |
testWhile02 |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5429 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5430 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5431 |
output := self outputToTranscriptOf:[ |
1447 | 5432 |
self |
5433 |
execute:'test(arg) { |
|
5434 |
var n; |
|
5435 |
||
5436 |
n = 1; |
|
5437 |
while (n <= arg) { |
|
5438 |
n++; |
|
5439 |
Transcript.showCR("hello"); |
|
5440 |
} |
|
5441 |
}' |
|
5442 |
for:nil |
|
5443 |
arguments:#(5) |
|
5444 |
expect:nil |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5445 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5446 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( 'hello' 'hello' 'hello' 'hello' 'hello' )) |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5447 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5448 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5449 |
self run:#testWhile02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5450 |
self new testWhile02 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5451 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5452 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5453 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5454 |
testWhile03 |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5455 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5456 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5457 |
output := self outputToTranscriptOf:[ |
1447 | 5458 |
self |
5459 |
execute:'test(arg) { |
|
5460 |
var n; |
|
5461 |
||
5462 |
n = 1; |
|
5463 |
while (n <= arg) { |
|
5464 |
Transcript.showCR(n++); |
|
5465 |
} |
|
5466 |
}' |
|
5467 |
for:nil |
|
5468 |
arguments:#(5) |
|
5469 |
expect:nil |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5470 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5471 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' '4' '5' )) |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5472 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5473 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5474 |
self run:#testWhile03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5475 |
self new testWhile03 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5476 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5477 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5478 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5479 |
testWhile04 |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5480 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5481 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5482 |
output := self outputToTranscriptOf:[ |
1447 | 5483 |
self |
5484 |
execute:'test(arg) { |
|
5485 |
var n; |
|
5486 |
||
5487 |
n = 1; |
|
5488 |
while (n++ <= arg) { |
|
5489 |
Transcript.showCR(n); |
|
5490 |
} |
|
5491 |
}' |
|
5492 |
for:nil |
|
5493 |
arguments:#(5) |
|
5494 |
expect:nil |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5495 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5496 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '3' '4' '5' '6')) |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5497 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5498 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5499 |
self run:#testWhile04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5500 |
self new testWhile04 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5501 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5502 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5503 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5504 |
testWhile04b |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5505 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5506 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5507 |
output := self outputToTranscriptOf:[ |
1447 | 5508 |
self |
5509 |
execute:'test(arg) { |
|
5510 |
var n; |
|
5511 |
||
5512 |
n = 1; |
|
5513 |
while (n++ <= arg) { |
|
5514 |
Transcript.showCR(n); |
|
5515 |
} |
|
5516 |
}' |
|
5517 |
for:nil |
|
5518 |
arguments:#(5) |
|
5519 |
expect:nil |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5520 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5521 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '3' '4' '5' '6')) |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5522 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5523 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5524 |
self run:#testWhile04b |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5525 |
self new testWhile04b |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5526 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5527 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5528 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5529 |
testWhile05 |
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5530 |
|output| |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5531 |
|
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5532 |
output := self outputToTranscriptOf:[ |
1447 | 5533 |
self |
5534 |
execute:'test(arg) { |
|
5535 |
var n; |
|
5536 |
||
5537 |
n = 1; |
|
5538 |
while (n++ <= arg) { |
|
5539 |
if (n == 3) continue; |
|
5540 |
Transcript.showCR(n); |
|
5541 |
} |
|
5542 |
}' |
|
5543 |
for:nil |
|
5544 |
arguments:#(5) |
|
5545 |
expect:nil |
|
733
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5546 |
]. |
0d9c441eba61
a lot of transcript/stdout output redirected and validated
Claus Gittinger <cg@exept.de>
parents:
732
diff
changeset
|
5547 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '4' '5' '6')) |
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5548 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5549 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5550 |
self run:#testWhile05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5551 |
self new testWhile05 |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5552 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5553 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5554 |
|
1195
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5555 |
testWhile06 |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5556 |
" |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5557 |
Tests parsing of a while-loop with no body |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5558 |
" |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5559 |
|output| |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5560 |
|
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5561 |
output := self outputToTranscriptOf:[ |
1447 | 5562 |
self |
5563 |
execute:'test(arg) { |
|
5564 |
var n; |
|
5565 |
||
5566 |
n = 1; |
|
5567 |
while (n++ < arg) { |
|
5568 |
} |
|
5569 |
Transcript.showCR(n); |
|
5570 |
}' |
|
5571 |
for:nil |
|
5572 |
arguments:#(5) |
|
5573 |
expect:nil |
|
1195
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5574 |
]. |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5575 |
self assert:(output asCollectionOfLinesWithReturn asArray = #( '6')) |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5576 |
|
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5577 |
" |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5578 |
self run:#testWhile05 |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5579 |
self new testWhile05 |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5580 |
" |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5581 |
|
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5582 |
"Created: / 17-09-2014 / 14:59:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5583 |
! |
a0079913b716
Added test for empty while-loop.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1112
diff
changeset
|
5584 |
|
261 | 5585 |
test_01_parse_literals |
5586 |
|spec| |
|
5587 |
||
5588 |
spec := #( |
|
1447 | 5589 |
('1' #isInteger 1) |
5590 |
('0' #isInteger 0) |
|
5591 |
('-1' #isInteger -1) |
|
5592 |
('12345678901234567890' #isInteger 12345678901234567890) |
|
5593 |
('0x0' #isInteger 0) |
|
5594 |
('0x1' #isInteger 1) |
|
5595 |
('0xFFFF' #isInteger 16rFFFF) |
|
5596 |
('0xffff' #isInteger 16rFFFF) |
|
5597 |
('0xFFFFFFFFFFFFFFFF' #isInteger 16rFFFFFFFFFFFFFFFF) |
|
5598 |
('0777' #isInteger 8r777) |
|
5599 |
||
5600 |
('1.2345' #isFloat 1.2345) |
|
5601 |
('-1.2345' #isFloat -1.2345) |
|
5602 |
||
5603 |
('nil' #isNil nil) |
|
5604 |
('null' #isNil nil) |
|
5605 |
('true' nil true) |
|
5606 |
('false' nil false) |
|
5607 |
||
5608 |
('"aString"' #isString 'aString' ) |
|
5609 |
('''anotherString''' #isString 'anotherString' ) |
|
5610 |
('''anoth"er"String''' #isString 'anoth"er"String' ) |
|
5611 |
('"anoth''er''String"' #isString 'anoth''er''String' ) |
|
5612 |
('"hello"' #isString 'hello' ) |
|
5613 |
('"\b"' #isString (#eval 'Character backspace asString') ) |
|
5614 |
('"\f"' #isString (#eval 'Character ff asString') ) |
|
5615 |
('"\t"' #isString (#eval 'Character tab asString') ) |
|
5616 |
('"\r"' #isString (#eval 'Character return asString') ) |
|
5617 |
('"\n"' #isString (#eval 'Character nl asString') ) |
|
5618 |
('"\''"' #isString '''' ) |
|
5619 |
('"\""' #isString '"' ) |
|
5620 |
||
5621 |
('[ 1 , 2 , 3]' #isArray #(1 2 3) ) |
|
5622 |
('[1,2,3]' #isArray #(1 2 3) ) |
|
5623 |
('[1,2,3]' #isArray #(1 2 3) ) |
|
5624 |
('["a","b","c"]' #isArray #('a' 'b' 'c') ) |
|
5625 |
('[]' #isArray #() ) |
|
5626 |
('[null]' #isArray #( nil ) ) |
|
5627 |
||
5628 |
('[1,[2,[3]]]' #isArray #(1 (2 (3))) ) |
|
5629 |
||
5630 |
). |
|
261 | 5631 |
|
262 | 5632 |
self doTestEachFromSpec:spec. |
261 | 5633 |
|
5634 |
" |
|
5635 |
self run:#test_01_parse_literals |
|
5636 |
self new test_01_parse_literals |
|
5637 |
" |
|
5638 |
! |
|
5639 |
||
5640 |
test_02_parse_literals2 |
|
5641 |
|spec| |
|
5642 |
||
5643 |
spec := #( |
|
1447 | 5644 |
('"\x00"' #isString (#eval '(Character value:0) asString') ) |
5645 |
('"\x01"' #isString (#eval '(Character value:1) asString') ) |
|
5646 |
('"\x1a"' #isString (#eval '(Character value:16r1a) asString') ) |
|
5647 |
('"\x000"' #isString (#eval '(Character value:0) asString , ''0'' ') ) |
|
5648 |
('"\xgg"' #isString (#error ) ) |
|
5649 |
('"\xg"' #isString (#error ) ) |
|
5650 |
('"\x"' #isString (#error ) ) |
|
5651 |
('"\x0g"' #isString (#error ) ) |
|
5652 |
('"\u1234"' #isString (#eval '(Character value:16r1234) asString ') ) |
|
5653 |
('"\uFFFF"' #isString (#eval '(Character value:16rFFFF) asString ') ) |
|
5654 |
). |
|
261 | 5655 |
|
262 | 5656 |
self doTestEachFromSpec:spec. |
261 | 5657 |
|
5658 |
" |
|
5659 |
self run:#test_02_parse_literals2 |
|
5660 |
self new test_02_parse_literals2 |
|
5661 |
" |
|
262 | 5662 |
! |
5663 |
||
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5664 |
test_03_parse_comments |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5665 |
|spec| |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5666 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5667 |
spec := #( |
1447 | 5668 |
('// ignored |
5669 |
1' #isInteger 1 ) |
|
5670 |
('/* ignored */ 2' #isInteger 2 ) |
|
5671 |
('/* ign//ored */ 3' #isInteger 3 ) |
|
5672 |
). |
|
265
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5673 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5674 |
self doTestEachFromSpec:spec. |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5675 |
|
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5676 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5677 |
self run:#test_03_parse_comments |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5678 |
self new test_03_parse_comments |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5679 |
" |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5680 |
! |
896de964f5e7
merged with JavaScriptCompilerTests
Claus Gittinger <cg@exept.de>
parents:
262
diff
changeset
|
5681 |
|
320 | 5682 |
test_03_parse_literals3 |
5683 |
"character syntax extension" |
|
5684 |
||
5685 |
|spec| |
|
5686 |
||
5687 |
spec := #( |
|
1447 | 5688 |
('$''a''' #isCharacter (#eval '$a ') ) |
5689 |
('$''\n''' #isCharacter (#eval '(Character nl)') ) |
|
5690 |
('$''\r''' #isCharacter (#eval '(Character return)') ) |
|
5691 |
('$''\b''' #isCharacter (#eval '(Character backspace)') ) |
|
5692 |
('$''\x00''' #isCharacter (#eval '(Character value:0)') ) |
|
5693 |
('$''\x01''' #isCharacter (#eval '(Character value:1)') ) |
|
5694 |
('$''\x1a''' #isCharacter (#eval '(Character value:16r1a)') ) |
|
5695 |
('$''\x000''' #isCharacter (#error ) ) |
|
5696 |
('$''\xgg''' #isCharacter (#error ) ) |
|
5697 |
('$''\xg''' #isCharacter (#error ) ) |
|
5698 |
('$''\x''' #isCharacter (#error ) ) |
|
5699 |
('$''\x0g''' #isCharacter (#error ) ) |
|
5700 |
('$''\u1234''' #isCharacter (#eval '(Character value:16r1234) ') ) |
|
5701 |
('$''\uFFFF''' #isCharacter (#eval '(Character value:16rFFFF) ') ) |
|
5702 |
). |
|
320 | 5703 |
|
5704 |
self doTestEachFromSpec:spec. |
|
5705 |
||
5706 |
" |
|
5707 |
self run:#test_03_parse_literals3 |
|
5708 |
self new test_03_parse_literals3 |
|
5709 |
" |
|
5710 |
! |
|
5711 |
||
262 | 5712 |
test_10_parse_expression1 |
5713 |
|spec| |
|
5714 |
||
1447 | 5715 |
spec := #( |
5716 |
('1+1' nil 2 ) |
|
5717 |
('1-1' nil 0 ) |
|
5718 |
('2*2' nil 4 ) |
|
5719 |
('4/2' nil 2 ) |
|
5720 |
('5%3' nil 2 ) |
|
5721 |
('1234567890*1234567890' nil 1524157875019052100 ) |
|
5722 |
('1234567890/1234567890' nil 1 ) |
|
5723 |
('1234567890/1234567890.0' nil 1.0 ) |
|
5724 |
||
5725 |
('1>0' nil true ) |
|
5726 |
('1<0' nil false ) |
|
5727 |
('1<=0' nil false ) |
|
5728 |
('1>=0' nil true ) |
|
5729 |
('1==0' nil false ) |
|
5730 |
('1!!=0' nil true ) |
|
5731 |
('1!!=1' nil false ) |
|
5732 |
||
5733 |
('3&5' nil 1 ) |
|
5734 |
('3|5' nil 7 ) |
|
5735 |
('5^1' nil 4 ) |
|
5736 |
). |
|
262 | 5737 |
self doTestEachFromSpec:spec. |
5738 |
||
5739 |
" |
|
5740 |
self run:#test_10_parse_expression1 |
|
5741 |
self new test_10_parse_expression1 |
|
5742 |
" |
|
652 | 5743 |
|
5744 |
"Modified: / 16-01-2012 / 20:01:53 / cg" |
|
262 | 5745 |
! |
5746 |
||
5747 |
test_11_parse_expression2 |
|
5748 |
|spec| |
|
5749 |
||
1447 | 5750 |
spec := #( |
5751 |
('1=0' nil ( #error ) ) |
|
5752 |
('"abc"[0]' nil ( #error ) ) |
|
5753 |
('"abc"[1]' nil $a ) |
|
5754 |
). |
|
262 | 5755 |
self doTestEachFromSpec:spec. |
5756 |
||
5757 |
" |
|
5758 |
self run:#test_11_parse_expression2 |
|
5759 |
self new test_11_parse_expression2 |
|
5760 |
" |
|
331 | 5761 |
! |
5762 |
||
700 | 5763 |
test_30_parse_methods1 |
5764 |
|spec| |
|
5765 |
||
5766 |
"/ spec is { source shouldErrBoolean } |
|
1447 | 5767 |
spec := #( |
5768 |
(' |
|
700 | 5769 |
execute(in1) { |
5770 |
var t; |
|
5771 |
||
5772 |
Dialog.information((t = in1.value()) == nil ? "nil" : t); |
|
1447 | 5773 |
}' |
700 | 5774 |
false |
1447 | 5775 |
) |
5776 |
||
5777 |
). |
|
700 | 5778 |
self doTestEachFunctionFromSpec:spec. |
5779 |
||
5780 |
" |
|
5781 |
self run:#test_30_parse_methods1 |
|
5782 |
self new test_30_parse_methods1 |
|
5783 |
" |
|
5784 |
! |
|
5785 |
||
1241
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5786 |
test_40_parse_function |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5787 |
| tree | |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5788 |
|
1447 | 5789 |
tree := JavaScriptParser parseExpression:'this.bar("arg1", 1)'. |
1241
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5790 |
self assert: tree selectorPosition = (6 to: 8) |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5791 |
|
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5792 |
"Created: / 17-11-2014 / 13:28:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5793 |
! |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5794 |
|
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5795 |
test_41_parse_function |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5796 |
| tree | |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5797 |
|
1447 | 5798 |
tree := JavaScriptParser parseExpression:'this.bar'. |
1241
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5799 |
self assert: tree selectorPosition = (6 to: 8) |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5800 |
|
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5801 |
"Created: / 17-11-2014 / 13:31:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5802 |
! |
cb241ada2e6f
Added tests for selectorPosition
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1195
diff
changeset
|
5803 |
|
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5804 |
xtestInnerFunctionWithInitializedLocals |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5805 |
|
1447 | 5806 |
self |
5807 |
execute:' |
|
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5808 |
execute() { |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5809 |
function foo() {} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5810 |
function bar() {} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5811 |
|
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5812 |
function test() |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5813 |
{ |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5814 |
|
1447 | 5815 |
foo(); |
5816 |
bar(); |
|
5817 |
var a; |
|
5818 |
var b; |
|
5819 |
var c = Array.new(15); |
|
5820 |
var d = 20; |
|
5821 |
||
5822 |
return [ a , b , c , d ]; |
|
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5823 |
} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5824 |
|
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5825 |
test(); |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5826 |
} |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5827 |
' |
1447 | 5828 |
for:nil |
5829 |
arguments:#() |
|
5830 |
expect:{ nil . nil . (Array new:15) . 20 } |
|
945
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5831 |
|
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5832 |
" |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5833 |
self run:#testInnerFunctionWithInitializedLocals |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5834 |
self new testInnerFunctionWithInitializedLocals |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5835 |
" |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5836 |
! |
339c826fa96c
class: RegressionTests::JavaScriptTests
Claus Gittinger <cg@exept.de>
parents:
878
diff
changeset
|
5837 |
|
331 | 5838 |
xtestNew04 |
1447 | 5839 |
self |
5840 |
execute:'test() { |
|
5841 |
var days; |
|
5842 |
||
5843 |
days = new Array(7,2); |
|
5844 |
days[1,1] = "Monday"; |
|
5845 |
days[2,1] = "Tuesday"; |
|
5846 |
days[3,1] = "Wednesday"; |
|
5847 |
days[4,1] = "Thursday"; |
|
5848 |
days[5,1] = "Friday"; |
|
5849 |
days[6,1] = "Saturday"; |
|
5850 |
days[7,1] = "Sunday"; |
|
5851 |
||
5852 |
return days; |
|
5853 |
}' |
|
5854 |
for:nil |
|
5855 |
arguments:#() |
|
5856 |
expect:#('Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' 'Sunday') |
|
331 | 5857 |
|
5858 |
" |
|
5859 |
self run:#testNew04 |
|
1447 | 5860 |
self new testNew04 |
331 | 5861 |
" |
5862 |
||
5863 |
"Created: / 23-02-2007 / 12:24:50 / cg" |
|
261 | 5864 |
! ! |
5865 |
||
5866 |
!JavaScriptTests class methodsFor:'documentation'! |
|
5867 |
||
631 | 5868 |
version |
5869 |
^ '$Header$' |
|
5870 |
! |
|
5871 |
||
556 | 5872 |
version_CVS |
5873 |
^ '$Header$' |
|
261 | 5874 |
! ! |
878
05ff46227bbf
class: RegressionTests::JavaScriptTests
Stefan Vogel <sv@exept.de>
parents:
733
diff
changeset
|
5875 |