Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Flags: --harmony-destructuring --harmony-computed-property-names | 5 // Flags: --harmony-destructuring --harmony-computed-property-names |
| 6 // Flags: --harmony-arrow-functions | |
| 6 | 7 |
| 7 (function TestObjectLiteralPattern() { | 8 (function TestObjectLiteralPattern() { |
| 8 var { x : x, y : y } = { x : 1, y : 2 }; | 9 var { x : x, y : y } = { x : 1, y : 2 }; |
| 9 assertEquals(1, x); | 10 assertEquals(1, x); |
| 10 assertEquals(2, y); | 11 assertEquals(2, y); |
| 11 | 12 |
| 12 var {z} = { z : 3 }; | 13 var {z} = { z : 3 }; |
| 13 assertEquals(3, z); | 14 assertEquals(3, z); |
| 14 | 15 |
| 15 | 16 |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 var o = { __proto__:null, 'a1':1, 'b2':2 }; | 680 var o = { __proto__:null, 'a1':1, 'b2':2 }; |
| 680 var sx = ''; | 681 var sx = ''; |
| 681 var sy = ''; | 682 var sy = ''; |
| 682 for (var [x,y] in o) { | 683 for (var [x,y] in o) { |
| 683 sx += x; | 684 sx += x; |
| 684 sy += y; | 685 sy += y; |
| 685 } | 686 } |
| 686 assertEquals('ab', sx); | 687 assertEquals('ab', sx); |
| 687 assertEquals('12', sy); | 688 assertEquals('12', sy); |
| 688 }()); | 689 }()); |
| 690 | |
| 691 | |
| 692 (function TestParameters() { | |
|
rossberg
2015/06/16 17:02:13
Can we have a few more tests? In particular, inclu
Dmitry Lomov (no reviews)
2015/06/19 15:25:14
Done.
| |
| 693 function f({a, b}) { return a - b; } | |
| 694 assertEquals(1, f({a : 6, b : 5})); | |
| 695 | |
| 696 function f1(c, {a, b}) { return c + a - b; } | |
| 697 assertEquals(8, f1(7, {a : 6, b : 5})); | |
| 698 | |
| 699 var g = {a, b} => { return a - b; }; | |
|
arv (Not doing code reviews)
2015/06/16 16:56:36
This should be a SyntaxError. Only when using a si
Dmitry Lomov (no reviews)
2015/06/19 15:25:14
Done.
| |
| 700 assertEquals(1, g({a : 6, b : 5})); | |
| 701 | |
| 702 var g1 = (c, {a, b}) => { return c + a - b; }; | |
| 703 assertEquals(8, g1(7, {a : 6, b : 5})); | |
| 704 | |
| 705 var h = {a, b} => a - b; | |
|
rossberg
2015/06/16 17:02:13
AFAICT this is not legal ES6 syntax, see the gramm
Dmitry Lomov (no reviews)
2015/06/19 15:25:14
Done.
| |
| 706 assertEquals(1, h({a : 6, b : 5})); | |
| 707 | |
| 708 var h1 = (c, {a, b}) => c + a - b; | |
| 709 assertEquals(8, h1(7, {a : 6, b : 5})); | |
| 710 }()); | |
| OLD | NEW |