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