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

Unified Diff: test/mjsunit/harmony/regress/regress-4395.js

Issue 1414283002: [es6] Fix scoping for default parameters in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 2 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
« no previous file with comments | « src/scopes.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/regress/regress-4395.js
diff --git a/test/mjsunit/harmony/regress/regress-4395.js b/test/mjsunit/harmony/regress/regress-4395.js
new file mode 100644
index 0000000000000000000000000000000000000000..09f5bfb733e0679989cda78e40d57868130c4431
--- /dev/null
+++ b/test/mjsunit/harmony/regress/regress-4395.js
@@ -0,0 +1,69 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Flags: --harmony-destructuring --harmony-default-parameters
+
+(function testExpressionTypes() {
+ "use strict";
+ ((x, y = x) => assertEquals(42, y))(42);
+
+ ((x, y = (x)) => assertEquals(42, y))(42);
+ ((x, y = `${x}`) => assertEquals("42", y))(42);
+ ((x, y = x = x + 1) => assertEquals(43, y))(42);
+ ((x, y = x()) => assertEquals(42, y))(() => 42);
+ ((x, y = new x()) => assertEquals(42, y.z))(function() { this.z = 42 });
+ ((x, y = -x) => assertEquals(-42, y))(42);
+ ((x, y = ++x) => assertEquals(43, y))(42);
+ ((x, y = x === 42) => assertTrue(y))(42);
+ ((x, y = (x == 42 ? x : 0)) => assertEquals(42, y))(42);
+
+ ((x, y = function() { return x }) => assertEquals(42, y()))(42);
+ ((x, y = () => x) => assertEquals(42, y()))(42);
+
+ // Literals
+ ((x, y = {z: x}) => assertEquals(42, y.z))(42);
+ ((x, y = {[x]: x}) => assertEquals(42, y[42]))(42);
+ ((x, y = [x]) => assertEquals(42, y[0]))(42);
+ ((x, y = [...x]) => assertEquals(42, y[0]))([42]);
+
+ ((x, y = class {
+ static [x]() { return x }
+ }) => assertEquals(42, y[42]()))(42);
+ ((x, y = (new class {
+ z() { return x }
+ })) => assertEquals(42, y.z()))(42);
+
+ ((x, y = (new class Y {
+ static [x]() { return x }
+ z() { return Y[42]() }
+ })) => assertEquals(42, y.z()))(42);
+
+ ((x, y = (new class {
+ constructor() { this.z = x }
+ })) => assertEquals(42, y.z))(42);
+ ((x, y = (new class Y {
+ constructor() { this.z = x }
+ })) => assertEquals(42, y.z))(42);
+
+ ((x, y = (new class extends x {
+ })) => assertEquals(42, y.z()))(class { z() { return 42 } });
+
+ // Defaults inside destructuring
+ ((x, {y = x}) => assertEquals(42, y))(42, {});
+ ((x, [y = x]) => assertEquals(42, y))(42, []);
+})();
+
+(function testMultiScopeCapture() {
+ "use strict";
+ var x = 1;
+ {
+ let y = 2;
+ ((x, y, a = x, b = y) => {
+ assertEquals(3, x);
+ assertEquals(3, a);
+ assertEquals(4, y);
+ assertEquals(4, b);
+ })(3, 4);
+ }
+})();
« no previous file with comments | « src/scopes.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698