class: RegressionTests::JavaScriptTests
authorStefan Vogel <sv@exept.de>
Wed, 30 Oct 2013 21:06:17 +0100
changeset 1005 7359ab263818
parent 1004 9021e9f5967b
child 1006 9433a9a7d974
class: RegressionTests::JavaScriptTests added: #testForIn04 changed: #testForIn02 #testForIn03
RegressionTests__JavaScriptTests.st
--- 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'
        ))
 
     "