RegressionTests__JavaScriptTests.st
changeset 2056 8035eeb80ce2
parent 2054 d0ab59c34c29
child 2057 8d9ddf675f25
--- a/RegressionTests__JavaScriptTests.st	Fri Dec 14 04:35:33 2018 +0000
+++ b/RegressionTests__JavaScriptTests.st	Fri Dec 14 18:57:08 2018 +0100
@@ -436,6 +436,25 @@
     "Created: / 21-02-2007 / 13:05:48 / cg"
 !
 
+testArray10
+    self
+        execute:'test() {
+                    var a = 1;        
+                    var arr = [a,2,3];
+                    return arr;
+                 }'
+        for:nil
+        arguments:#(  )
+        expect:#( 1 2 3 )
+
+    "
+     self run:#testArray10
+     self new testArray10
+    "
+
+    "Created: / 14-12-2018 / 16:35:55 / Claus Gittinger"
+!
+
 testAssignmentExpression01
     self
 	execute:'assign(a, b) {
@@ -1240,30 +1259,32 @@
 
     output := '' writeStream.
     self
-	execute:'test(arg, out) {
-		    for (var n = 0, var m = 10; n < 10; n++, m--) {
-			if ((n >= 3) && (n <= 6)) {
-			    out.show(n);
-			    out.show(" -> ");
-			    out.showCR(m);
-			}
-		    }
-		 }'
-	for:nil
-	arguments:(Array with:5 with:output)
-	expect:nil.
+        execute:'test(arg, out) {
+                    for (var n = 0, var m = 10; n < 10; n++, m--) {
+                        if ((n >= 3) && (n <= 6)) {
+                            out.show(n);
+                            out.show(" -> ");
+                            out.showCR(m);
+                        }
+                    }
+                 }'
+        for:nil
+        arguments:(Array with:5 with:output)
+        expect:nil.
 
     self assert:(output contents asCollectionOfLinesWithReturn asArray = #(
-	'3 -> 7'
-	'4 -> 6'
-	'5 -> 5'
-	'6 -> 4'
+        '3 -> 7'
+        '4 -> 6'
+        '5 -> 5'
+        '6 -> 4'
        ))
 
     "
-     self run:#testFor06
-     self new testFor06
-    "
+     self run:#testFor07
+     self new testFor07
+    "
+
+    "Modified: / 14-12-2018 / 16:15:41 / Claus Gittinger"
 !
 
 testFor08
@@ -1271,32 +1292,34 @@
 
     output := '' writeStream.
     self
-	execute:'test(arg, out) {
-		    var x = 10;
-
-		    for (var n = 0, var m = 10; n < 10; n++, m--) {
-			if ((n >= 3) && (n <= 6)) {
-			    if ((n >= 4) && (n <= 5)) {
-				out.show(n);
-				out.show(" -> ");
-				out.showCR(m);
-			    }
-			}
-		    }
-		 }'
-	for:nil
-	arguments:(Array with:5 with:output)
-	expect:nil.
+        execute:'test(arg, out) {
+                    var x = 10;
+
+                    for (var n = 0, var m = 10; n < 10; n++, m--) {
+                        if ((n >= 3) && (n <= 6)) {
+                            if ((n >= 4) && (n <= 5)) {
+                                out.show(n);
+                                out.show(" -> ");
+                                out.showCR(m);
+                            }
+                        }
+                    }
+                 }'
+        for:nil
+        arguments:(Array with:5 with:output)
+        expect:nil.
 
     self assert:(output contents asCollectionOfLinesWithReturn asArray = #(
-	'4 -> 6'
-	'5 -> 5'
+        '4 -> 6'
+        '5 -> 5'
        ))
 
     "
-     self run:#testFor06
-     self new testFor06
-    "
+     self run:#testFor08
+     self new testFor08
+    "
+
+    "Modified: / 14-12-2018 / 16:15:35 / Claus Gittinger"
 !
 
 testFor09
@@ -1338,11 +1361,51 @@
        )
 
     "
-     self run:#testFor06
-     self new testFor06
+     self run:#testFor09
+     self new testFor09
     "
 
     "Created: / 30-08-2018 / 13:34:30 / Claus Gittinger"
+    "Modified (comment): / 14-12-2018 / 16:15:29 / Claus Gittinger"
+!
+
+testFor10
+    "let in for loop"
+    
+    |output|
+
+    output := '' writeStream.
+    self
+        execute:'test(console) {
+                    var i = 99;
+
+                    console.log("i:"+i);
+                    for (let i = 0; i < 5; i++) {
+                        console.log("  i:"+i);
+                    }
+                    console.log("i:"+i);
+                 }'
+        for:nil
+        arguments:(Array with:output)
+        expect:nil.
+
+    self assert:(output contents = 
+'i:99
+  i:0
+  i:1
+  i:2
+  i:3
+  i:4
+i:99
+'
+       )
+
+    "
+     self run:#testFor10
+     self new testFor10
+    "
+
+    "Created: / 14-12-2018 / 16:15:24 / Claus Gittinger"
 !
 
 testForIn01
@@ -2182,6 +2245,51 @@
     "Created: / 13-12-2018 / 22:52:56 / Claus Gittinger"
 !
 
+testNew05
+    self
+        execute:'test() {
+                    return new String("foo");
+                 }'
+        for:nil
+        arguments:nil
+        expect:'foo'
+
+    "
+     self run:#testNew05
+     self new testNew05
+    "
+
+    "Created: / 14-12-2018 / 16:30:42 / Claus Gittinger"
+!
+
+testNew06
+    |result|
+
+    result := self
+        execute:'test() {
+                    return ([ new String("foo") ,
+                             "foo" ,
+                             "foo" ]);
+                 }'
+        for:nil
+        arguments:nil.
+        
+    self assert:(result size == 3).    
+    self assert:(result first = 'foo').    
+    self assert:(result second = 'foo').    
+    self assert:(result third = 'foo').    
+    self assert:(result first ~~ result second).    
+    self assert:(result first ~~ result third).    
+    self assert:(result second == result third).    
+
+    "
+     self run:#testNew06
+     self new testNew06
+    "
+
+    "Created: / 14-12-2018 / 16:33:42 / Claus Gittinger"
+!
+
 testOperators01_plus
     self
 	execute:'expr(a, b) {