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