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