Index: test/mjsunit/harmony/destructuring.js |
diff --git a/test/mjsunit/harmony/destructuring.js b/test/mjsunit/harmony/destructuring.js |
index 731bc6dbe5c6c3a1b9fc10e80dcde7371c16bfb6..c57dbafda6dbbd90862b11bd6af10e986e7bc2eb 100644 |
--- a/test/mjsunit/harmony/destructuring.js |
+++ b/test/mjsunit/harmony/destructuring.js |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
// |
// Flags: --harmony-destructuring --harmony-computed-property-names |
+// Flags: --harmony-arrow-functions |
(function TestObjectLiteralPattern() { |
var { x : x, y : y } = { x : 1, y : 2 }; |
@@ -686,3 +687,44 @@ |
assertEquals('ab', sx); |
assertEquals('12', sy); |
}()); |
+ |
+ |
+(function TestParameters() { |
+ function f({a, b}) { return a - b; } |
+ assertEquals(1, f({a : 6, b : 5})); |
+ |
+ function f1(c, {a, b}) { return c + a - b; } |
+ assertEquals(8, f1(7, {a : 6, b : 5})); |
+ |
+ function f2({c, d}, {a, b}) { return c - d + a - b; } |
+ assertEquals(7, f2({c : 7, d : 1}, {a : 6, b : 5})); |
+ |
+ function f3([{a, b}]) { return a - b; } |
+ assertEquals(1, f3([{a : 6, b : 5}])); |
+ |
+ var g = ({a, b}) => { return a - b; }; |
+ assertEquals(1, g({a : 6, b : 5})); |
+ |
+ var g1 = (c, {a, b}) => { return c + a - b; }; |
+ assertEquals(8, g1(7, {a : 6, b : 5})); |
+ |
+ var g2 = ({c, d}, {a, b}) => { return c - d + a - b; }; |
+ assertEquals(7, g2({c : 7, d : 1}, {a : 6, b : 5})); |
+ |
+ var g3 = ([{a, b}]) => { return a - b; }; |
+ assertEquals(1, g3([{a : 6, b : 5}])); |
+}()); |
+ |
+ |
+(function TestDuplicatesInParameters() { |
+ assertThrows("'use strict';function f(x,x){}", SyntaxError); |
+ assertThrows("'use strict';function f({x,x}){}", SyntaxError); |
+ assertThrows("'use strict';function f(x, {x}){}", SyntaxError); |
+ assertThrows("'use strict';var f = (x,x) => {};", SyntaxError); |
+ assertThrows("'use strict';var f = ({x,x}) => {};", SyntaxError); |
+ 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); |
+}()); |