RegressionTests__JavaScriptTests.st
changeset 1912 f3a22bbf96f7
parent 1911 1cf9739b0abc
child 1914 1c6845cf22c3
--- a/RegressionTests__JavaScriptTests.st	Tue Apr 24 18:33:27 2018 +0200
+++ b/RegressionTests__JavaScriptTests.st	Tue Apr 24 21:35:40 2018 +0200
@@ -141,21 +141,21 @@
     "/ Transcript showCR:(thisContext sender selector , '...').
 
     Parser parseErrorSignal handle:[:ex |
-	errorEncountered := true.
+        errorEncountered := true.
     ] do:[
-	f := JavaScriptCompiler
-	    compile:code
-	    forClass:(receiver class)
-	    inCategory:nil
-	    notifying:nil
-	    install:false.
-
-	errorEncountered := (f == #Error).
+        f := JavaScriptCompiler
+            compile:code
+            forClass:(receiver class)
+            inCategory:nil
+            notifying:nil
+            install:false.
+
+        errorEncountered := (f == #Error).
     ].
 
     expectedError == #ParseError ifTrue:[
-	self assert:(errorEncountered).
-	^ self
+        self assert:(errorEncountered) message:'ParseError expected'.
+        ^ self
     ].
 
     self assert:(errorEncountered not).
@@ -164,8 +164,8 @@
 "/    f decompileTo:Transcript.
 
     self
-	should:[f valueWithReceiver:receiver arguments:arguments]
-	raise:expectedError
+        should:[f valueWithReceiver:receiver arguments:arguments]
+        raise:expectedError
 
     "Modified: / 09-10-2011 / 11:41:57 / cg"
 !
@@ -1686,6 +1686,86 @@
     "
 !
 
+testLetDeclaration01
+    self skipIf:true description:'skipped until let is fully implemented'.
+
+    self
+        execute:'expr(aIn, bIn, cIn) {
+                    if (true) {
+                        let a = aIn, b = bIn, c = cIn;
+                    }
+                    return (a);
+                 }'
+        for:nil
+        arguments:#(1 2 3)
+        expectError:#ParseError
+
+    "
+     self run:#testLetDeclaration01
+     self new testLetDeclaration01
+    "
+!
+
+testLetDeclaration02a
+    self
+        execute:'expr(aIn, bIn, cIn) {
+                    if (true) {
+                        let a = aIn, b = bIn, c = cIn;
+                        return (a+9);
+                    }
+                    return (bIn);
+                 }'
+        for:nil
+        arguments:#(1 2 3)
+        expect:10
+
+    "
+     self run:#testLetDeclaration02a
+     self new testLetDeclaration02a
+    "
+!
+
+testLetDeclaration02b
+    self
+        execute:'expr(aIn, bIn, cIn) {
+                    if (false) {
+                        let a = aIn, b = bIn, c = cIn;
+                        return (a+9);
+                    }
+                    return (bIn);
+                 }'
+        for:nil
+        arguments:#(1 2 3)
+        expect:2
+
+    "
+     self run:#testLetDeclaration02b
+     self new testLetDeclaration02b
+    "
+!
+
+testLetDeclaration02c
+    self skipIf:true description:'skipped until let is fully implemented'.
+
+    self
+        execute:'expr(aIn, bIn, cIn) {
+                    var a = 99;
+                    if (false) {
+                        let a = aIn, b = bIn, c = cIn;
+                        return (a);
+                    }
+                    return (a);
+                 }'
+        for:nil
+        arguments:#(1 2 3)
+        expect:1
+
+    "
+     self run:#testLetDeclaration02c
+     self new testLetDeclaration02c
+    "
+!
+
 testLiteralReturn01
     self
 	execute:'function f() { return (0); }'
@@ -5411,6 +5491,25 @@
     "
 !
 
+testVarDeclaration09
+    "/ javascript has funny var scoping...
+    self
+        execute:'expr(aIn, bIn, cIn) {
+                    if (true) {
+                        var a = aIn, b = bIn, c = cIn;
+                    }
+                    return (a);
+                 }'
+        for:nil
+        arguments:#(1 2 3)
+        expect:1
+
+    "
+     self run:#testVarDeclaration09
+     self new testVarDeclaration09
+    "
+!
+
 testWhile01
     |output|