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..4a93d24e21eec2446f1c84848a202bf6f514ad8b |
--- /dev/null |
+++ b/test/mjsunit/harmony/regress/regress-4395.js |
@@ -0,0 +1,58 @@ |
+// 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); |
+ |
+ // Scope chain of named class literals is busted |
+ //((x, y = (new class Y { |
+ // static [x]() { return x } |
+ // z() { return Y[42] } |
+ //})) => assertEquals(42, y.z()))(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(x, a); |
+ assertEquals(y, b); |
+ })(3, 4); |
rossberg
2015/10/16 11:55:41
Perhaps also return x and y and verify on the outs
adamk
2015/10/16 13:38:28
Done (though I just put the test inside the functi
|
+ } |
+})(); |