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 afbc670cae9285ddb01ab7c2eddb33378eecfc0e..44a0049a44e3d7dc137e407c6e0f2c45de284600 100644 |
--- a/test/mjsunit/harmony/block-let-declaration.js |
+++ b/test/mjsunit/harmony/block-let-declaration.js |
@@ -56,11 +56,11 @@ if (true) { |
// an exception in eval code during parsing, before even compiling or executing |
// the code. Thus the generated function is not called here. |
function TestLocalThrows(str, expect) { |
- assertThrows("(function(){ 'use strict'; " + str + "})", expect); |
+ assertThrows("(function(arg){ 'use strict'; " + str + "})", expect); |
} |
function TestLocalDoesNotThrow(str) { |
- assertDoesNotThrow("(function(){ 'use strict'; " + str + "})()"); |
+ assertDoesNotThrow("(function(arg){ 'use strict'; " + str + "})()"); |
} |
// Test let declarations in statement positions. |
@@ -108,6 +108,28 @@ TestLocalDoesNotThrow("for (;false;) var x;"); |
TestLocalDoesNotThrow("switch (true) { case true: var x; }"); |
TestLocalDoesNotThrow("switch (true) { default: var x; }"); |
+// Test that redeclarations of functions are only allowed in outermost scope. |
+TestLocalThrows("{ let f; var f; }"); |
+TestLocalThrows("{ var f; let f; }"); |
+TestLocalThrows("{ function f() {} let f; }"); |
+TestLocalThrows("{ let f; function f() {} }"); |
+TestLocalThrows("{ function f() {} var f; }"); |
+TestLocalThrows("{ var f; function f() {} }"); |
+TestLocalThrows("{ function f() {} function f() {} }"); |
+TestLocalThrows("function f() {} let f;"); |
+TestLocalThrows("let f; function f() {}"); |
+TestLocalDoesNotThrow("function arg() {}"); |
+TestLocalDoesNotThrow("function f() {} var f;"); |
+TestLocalDoesNotThrow("var f; function f() {}"); |
+TestLocalDoesNotThrow("function f() {} function f() {}"); |
+ |
+function g(f) { |
+ function f() { return 1 } |
+ return f() |
+} |
+assertEquals(1, g(function() { return 2 })) |
+ |
+ |
// Test function declarations in source element and |
// sloppy statement positions. |
function f() { |