Index: test/mjsunit/harmony/block-let-declaration.js |
diff --git a/test/mjsunit/harmony/block-let-declaration.js b/test/mjsunit/harmony/block-let-declaration.js |
index 49b63481a0bf025de0566fe21455e2f0bc185808..c7e5cf90562288a420a58fcf3f819029992554df 100644 |
--- a/test/mjsunit/harmony/block-let-declaration.js |
+++ b/test/mjsunit/harmony/block-let-declaration.js |
@@ -55,11 +55,59 @@ function TestLocalDoesNotThrow(str) { |
assertDoesNotThrow("(function(){" + str + "})()"); |
Lasse Reichstein
2011/09/21 10:29:34
But keep the call here. It should never fail, not
Steven
2011/09/21 12:03:28
Done.
|
} |
-// Unprotected statement |
+// Test let declarations statement positions. |
TestLocalThrows("if (true) let x;", SyntaxError); |
+TestLocalThrows("if (true) {} else let x;", SyntaxError); |
TestLocalThrows("do let x; while (false)", SyntaxError); |
TestLocalThrows("while (false) let x;", SyntaxError); |
+TestLocalThrows("label: let x;", SyntaxError); |
+TestLocalThrows("for (;false;) let x;", SyntaxError); |
+TestLocalThrows("switch (true) { case true: let x; }", SyntaxError); |
+TestLocalThrows("switch (true) { default: let x; }", SyntaxError); |
+// Test var declarations statement positions. |
TestLocalDoesNotThrow("if (true) var x;"); |
+TestLocalDoesNotThrow("if (true) {} else var x;"); |
TestLocalDoesNotThrow("do var x; while (false)"); |
TestLocalDoesNotThrow("while (false) var x;"); |
+TestLocalDoesNotThrow("label: var x;"); |
+TestLocalDoesNotThrow("for (;false;) var x;"); |
+TestLocalDoesNotThrow("switch (true) { case true: var x; }"); |
+TestLocalDoesNotThrow("switch (true) { default: var x; }"); |
+ |
+// Test function declarations in source element and |
+// non-strict statement positions. |
Lasse Reichstein
2011/09/21 10:29:34
Can you have a non-strict statement position in ha
Steven
2011/09/21 12:03:28
Indeed the harmony proposals actually take the ES5
|
+function f() { |
+ // Non-strict source element positions. |
+ function g0() { |
+ "use strict"; |
+ // Strict source element positions. |
+ function h() { } |
+ { |
+ function h1() { } |
+ } |
+ } |
+ { |
+ function g1() { } |
+ } |
+ // Non-strict statement positions. |
+ if (true) function g2() { } |
+ if (true) {} else function g3() { } |
+ do function g4() { } while (false) |
+ while (false) function g5() { } |
+ label: function g6() { } |
+ for (;false;) function g7() { } |
+ switch (true) { case true: function g8() { } } |
+ switch (true) { default: function g9() { } } |
+ |
+} |
Lasse Reichstein
2011/09/21 10:29:34
Call f here, to ensure that it isn't lazily compil
Steven
2011/09/21 12:03:28
Done.
|
+ |
+// Test function declarations in statement position in strict mode. |
+TestLocalThrows("function f() { 'use strict'; if (true) function g() {}", SyntaxError); |
+TestLocalThrows("function f() { 'use strict'; if (true) {} else function g() {}", SyntaxError); |
+TestLocalThrows("function f() { 'use strict'; do function g() {} while (false)", SyntaxError); |
+TestLocalThrows("function f() { 'use strict'; while (false) function g() {}", SyntaxError); |
+TestLocalThrows("function f() { 'use strict'; label: function g() {}", SyntaxError); |
+TestLocalThrows("function f() { 'use strict'; for (;false;) function g() {}", SyntaxError); |
+TestLocalThrows("function f() { 'use strict'; switch (true) { case true: function g() {} }", SyntaxError); |
+TestLocalThrows("function f() { 'use strict'; switch (true) { default: function g() {} }", SyntaxError); |