class: RegressionTests::JavaScriptTests
added: #testForIn04
changed:
#testForIn02
#testForIn03
--- a/RegressionTests__JavaScriptTests.st Wed Oct 30 13:06:30 2013 +0100
+++ b/RegressionTests__JavaScriptTests.st Wed Oct 30 21:06:17 2013 +0100
@@ -1209,10 +1209,12 @@
var sum = 0;
for (var el in arg) {
+ var last = el;
output.showCR(el*el);
sum += el;
+ last = sum;
}
- return sum;
+ return last;
}'
for:nil
arguments:( Array with:#(1 2 3) with:output)
@@ -1255,7 +1257,47 @@
self assert:(output contents asCollectionOfLinesWithReturn asArray = #(
'1'
'4'
- '9'
+ ))
+
+ "
+ self run:#testForIn01
+ self new testForIn01
+ "
+!
+
+testForIn04
+ |output|
+
+ JavaScriptParser forInAllowed ifFalse:[^ self].
+
+ output := '' writeStream.
+ self
+ execute:'test(arg, output) {
+ var sum = 0;
+
+ for (var el in arg) {
+ output.showCR(el*el);
+ for (var i in ["a", "b", "c"]) {
+ output.showCR(i);
+ if (i == "b") break;
+ }
+ if (el == 1) continue;
+ sum += el;
+ if (el == 2) break;
+ }
+ return sum;
+ }'
+ for:nil
+ arguments:( Array with:#(1 2 3) with:output)
+ expect:2.
+
+ self assert:(output contents asCollectionOfLinesWithReturn asArray = #(
+ '1'
+ 'a'
+ 'b'
+ '4'
+ 'a'
+ 'b'
))
"