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