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 | 6 |
7 (function TestObjectLiteralPattern() { | 7 (function TestObjectLiteralPattern() { |
8 var { x : x, y : y } = { x : 1, y : 2 }; | 8 var { x : x, y : y } = { x : 1, y : 2 }; |
9 assertEquals(1, x); | 9 assertEquals(1, x); |
10 assertEquals(2, y); | 10 assertEquals(2, y); |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 o.__proto__ = null; | 649 o.__proto__ = null; |
650 let sx = ''; | 650 let sx = ''; |
651 let sy = ''; | 651 let sy = ''; |
652 for (let [x,y] in o) { | 652 for (let [x,y] in o) { |
653 sx += x; | 653 sx += x; |
654 sy += y; | 654 sy += y; |
655 } | 655 } |
656 assertEquals('ab', sx); | 656 assertEquals('ab', sx); |
657 assertEquals('12', sy); | 657 assertEquals('12', sy); |
658 }()); | 658 }()); |
659 | |
660 | |
661 (function TestForEachVars() { | |
662 var a = [{x:1, y:-1}, {x:2,y:-2}, {x:3,y:-3}]; | |
663 var sumX = 0; | |
664 var sumY = 0; | |
665 var fs = []; | |
666 for (var {x,y} of a) { | |
667 sumX += x; | |
668 sumY += y; | |
669 fs.push({fx : function() { return x; }, fy : function() { return y }}); | |
670 } | |
671 assertSame(6, sumX); | |
672 assertSame(-6, sumY); | |
673 assertSame(3, fs.length); | |
674 for (var i = 0; i < fs.length; i++) { | |
675 var {fx,fy} = fs[i]; | |
676 assertSame(3, fx()); | |
677 assertSame(-3, fy()); | |
678 } | |
679 | |
680 var o = { 'a1':1, 'b2':2 }; | |
arv (Not doing code reviews)
2015/05/21 16:37:01
var o = {__proto__: null, ...};
Dmitry Lomov (no reviews)
2015/05/21 17:07:33
Done.
| |
681 o.__proto__ = null; | |
682 var sx = ''; | |
683 var sy = ''; | |
684 for (var [x,y] in o) { | |
685 sx += x; | |
686 sy += y; | |
687 } | |
688 assertEquals('ab', sx); | |
689 assertEquals('12', sy); | |
690 }()); | |
OLD | NEW |