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