Index: test/mjsunit/harmony/destructuring.js |
diff --git a/test/mjsunit/harmony/destructuring.js b/test/mjsunit/harmony/destructuring.js |
index f1e2210a2abb2d3b97ca6532d9b28191666ec79c..a55b4c62506902e2157ca09015998acbe13bbe28 100644 |
--- a/test/mjsunit/harmony/destructuring.js |
+++ b/test/mjsunit/harmony/destructuring.js |
@@ -957,11 +957,85 @@ |
assertEquals(1, ok1(1)); |
function ok2(x) { 'use strict'; { let x = 2; return x; } }; |
assertEquals(2, ok2(1)); |
+}()); |
+ |
+ |
+(function TestShadowingOfParameters() { |
+ function f1({x}) { var x = 2; return x } |
+ assertEquals(2, f1({x: 1})); |
+ function f2({x}) { { var x = 2; } return x; } |
+ assertEquals(2, f2({x: 1})); |
+ function f3({x}) { var y = x; var x = 2; return y; } |
+ assertEquals(1, f3({x: 1})); |
+ function f4({x}) { { var y = x; var x = 2; } return y; } |
+ assertEquals(1, f4({x: 1})); |
+ function f5({x}, g = () => x) { var x = 2; return g(); } |
+ assertEquals(1, f5({x: 1})); |
+ function f6({x}, g = () => x) { { var x = 2; } return g(); } |
+ assertEquals(1, f6({x: 1})); |
+ function f7({x}) { var g = () => x; var x = 2; return g(); } |
+ assertEquals(2, f7({x: 1})); |
+ function f8({x}) { { var g = () => x; var x = 2; } return g(); } |
+ assertEquals(2, f8({x: 1})); |
+ function f9({x}, g = () => eval("x")) { var x = 2; return g(); } |
+ assertEquals(1, f9({x: 1})); |
+ |
+ function f10({x}, y) { var y; return y } |
+ assertEquals(2, f10({x: 6}, 2)); |
+ function f11({x}, y) { var z = y; var y = 2; return z; } |
+ assertEquals(1, f11({x: 6}, 1)); |
+ function f12(y, g = () => y) { var y = 2; return g(); } |
+ assertEquals(1, f12(1)); |
+ function f13({x}, y, [z], v) { var x, y, z; return x*y*z*v } |
+ assertEquals(210, f13({x: 2}, 3, [5], 7)); |
+ |
+ function f20({x}) { function x() { return 2 }; return x(); } |
+ assertEquals(2, f20({x: 1})); |
+ function f21({x}) { { function x() { return 2 } } return x(); } |
+ assertEquals(2, f21({x: 1})); |
+ |
+ var g1 = ({x}) => { var x = 2; return x }; |
+ assertEquals(2, g1({x: 1})); |
+ var g2 = ({x}) => { { var x = 2; } return x; }; |
+ assertEquals(2, g2({x: 1})); |
+ var g3 = ({x}) => { var y = x; var x = 2; return y; }; |
+ assertEquals(1, g3({x: 1})); |
+ var g4 = ({x}) => { { var y = x; var x = 2; } return y; }; |
+ assertEquals(1, g4({x: 1})); |
+ var g5 = ({x}, g = () => x) => { var x = 2; return g(); }; |
+ assertEquals(1, g5({x: 1})); |
+ var g6 = ({x}, g = () => x) => { { var x = 2; } return g(); }; |
+ assertEquals(1, g6({x: 1})); |
+ var g7 = ({x}) => { var g = () => x; var x = 2; return g(); }; |
+ assertEquals(2, g7({x: 1})); |
+ var g8 = ({x}) => { { var g = () => x; var x = 2; } return g(); }; |
+ assertEquals(2, g8({x: 1})); |
+ var g9 = ({x}, g = () => eval("x")) => { var x = 2; return g(); }; |
+ assertEquals(1, g9({x: 1})); |
+ |
+ var g10 = ({x}, y) => { var y; return y }; |
+ assertEquals(2, g10({x: 6}, 2)); |
+ var g11 = ({x}, y) => { var z = y; var y = 2; return z; }; |
+ assertEquals(1, g11({x: 6}, 1)); |
+ var g12 = (y, g = () => y) => { var y = 2; return g(); }; |
+ assertEquals(1, g12(1)); |
+ var g13 = ({x}, y, [z], v) => { var x, y, z; return x*y*z*v }; |
+ assertEquals(210, g13({x: 2}, 3, [5], 7)); |
+ |
+ var g20 = ({x}) => { function x() { return 2 }; return x(); } |
+ assertEquals(2, g20({x: 1})); |
+ var g21 = ({x}) => { { function x() { return 2 } } return x(); } |
+ assertEquals(2, g21({x: 1})); |
- assertThrows("function f({x}) { var x; }; f({});", SyntaxError); |
- assertThrows("function f({x}) { { var x; } }; f({});", SyntaxError); |
assertThrows("'use strict'; function f(x) { let x = 0; }; f({});", SyntaxError); |
assertThrows("'use strict'; function f({x}) { let x = 0; }; f({});", SyntaxError); |
+ assertThrows("'use strict'; function f(x) { const x = 0; }; f({});", SyntaxError); |
+ assertThrows("'use strict'; function f({x}) { const x = 0; }; f({});", SyntaxError); |
+ |
+ assertThrows("'use strict'; let g = (x) => { let x = 0; }; f({});", SyntaxError); |
+ assertThrows("'use strict'; let g = ({x}) => { let x = 0; }; f({});", SyntaxError); |
+ assertThrows("'use strict'; let g = (x) => { const x = 0; }; f({});", SyntaxError); |
+ assertThrows("'use strict'; let g = ({x}) => { const x = 0; }; f({});", SyntaxError); |
}()); |