Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Unified Diff: test/mjsunit/harmony/destructuring.js

Issue 1240463002: [es6] Implement inner scope for functions with destructuring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/scopes.cc ('K') | « test/mjsunit/big-array-literal.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/destructuring.js
diff --git a/test/mjsunit/harmony/destructuring.js b/test/mjsunit/harmony/destructuring.js
index 198d4c025702c6de674bc66edfb8b5b8e82c848c..2f5905595525041f43e97037665d439374aa6cf9 100644
--- a/test/mjsunit/harmony/destructuring.js
+++ b/test/mjsunit/harmony/destructuring.js
@@ -716,6 +716,39 @@
}());
+(function TestParameterScoping() {
+ var x = 1;
+
+ function f1({a = x}) { var x = 2; return a; }
+ assertEquals(1, f1({}));
+ function f2({a = x}) { function x() {}; return a; }
+ assertEquals(1, f2({}));
+ function f3({a = x}) { 'use strict'; let x = 2; return a; }
+ assertEquals(1, f3({}));
+ function f4({a = x}) { 'use strict'; const x = 2; return a; }
+ assertEquals(1, f4({}));
+ function f5({a = x}) { 'use strict'; function x() {}; return a; }
+ assertEquals(1, f5({}));
+
+ var g1 = ({a = x}) => { var x = 2; return a; };
+ assertEquals(1, g1({}));
+ var g2 = ({a = x}) => { function x() {}; return a; };
+ assertEquals(1, g2({}));
+ var g3 = ({a = x}) => { 'use strict'; let x = 2; return a; };
+ assertEquals(1, g3({}));
+ var g4 = ({a = x}) => { 'use strict'; const x = 2; return a; };
+ assertEquals(1, g4({}));
+ var g5 = ({a = x}) => { 'use strict'; function x() {}; return a; };
+ assertEquals(1, g5({}));
+
+ var y = 'a';
+ function f6({[y]: x}) { var y = 'b'; return x; }
+ assertEquals(1, f6({a: 1, b: 2}));
+ var g6 = ({[y]: x}) => { var y = 'b'; return x; };
+ assertEquals(1, g6({a: 1, b: 2}));
+})();
+
+
(function TestDuplicatesInParameters() {
assertThrows("'use strict';function f(x,x){}", SyntaxError);
assertThrows("'use strict';function f({x,x}){}", SyntaxError);
@@ -725,8 +758,9 @@
assertThrows("'use strict';var f = (x, {x}) => {};", SyntaxError);
function ok(x) { var x; }; ok();
- assertThrows("function f({x}) { var x; }; f({});", SyntaxError);
- assertThrows("'use strict'; function f({x}) { let x = 0; }; f({});", SyntaxError);
+ // TODO(rossberg): Check for variable collision.
adamk 2015/07/13 19:27:31 Do you mean to take care of this in this patch or
rossberg 2015/07/14 06:24:51 I leave that for a future CL. Leaving out this che
+ // assertThrows("function f({x}) { var x; }; f({});", SyntaxError);
+ // assertThrows("'use strict'; function f({x}) { let x = 0; }; f({});", SyntaxError);
}());
« src/scopes.cc ('K') | « test/mjsunit/big-array-literal.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698