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

Side by Side Diff: test/mjsunit/harmony/destructuring.js

Issue 1149043005: [destructuring] Grand for statement parsing unification. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase feedback Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « test/mjsunit/es6/debug-stepnext-for.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 } 638 }
639 assertSame(6, sumX); 639 assertSame(6, sumX);
640 assertSame(-6, sumY); 640 assertSame(-6, sumY);
641 assertSame(3, fs.length); 641 assertSame(3, fs.length);
642 for (let i = 0; i < fs.length; i++) { 642 for (let i = 0; i < fs.length; i++) {
643 let {fx,fy} = fs[i]; 643 let {fx,fy} = fs[i];
644 assertSame(i+1, fx()); 644 assertSame(i+1, fx());
645 assertSame(-(i+1), fy()); 645 assertSame(-(i+1), fy());
646 } 646 }
647 647
648 var o = { 'a1':1, 'b2':2 }; 648 var o = { __proto__:null, 'a1':1, 'b2':2 };
649 o.__proto__ = null;
650 let sx = ''; 649 let sx = '';
651 let sy = ''; 650 let sy = '';
652 for (let [x,y] in o) { 651 for (let [x,y] in o) {
653 sx += x; 652 sx += x;
654 sy += y; 653 sy += y;
655 } 654 }
656 assertEquals('ab', sx); 655 assertEquals('ab', sx);
657 assertEquals('12', sy); 656 assertEquals('12', sy);
658 }()); 657 }());
658
659
660 (function TestForEachVars() {
661 var a = [{x:1, y:-1}, {x:2,y:-2}, {x:3,y:-3}];
662 var sumX = 0;
663 var sumY = 0;
664 var fs = [];
665 for (var {x,y} of a) {
666 sumX += x;
667 sumY += y;
668 fs.push({fx : function() { return x; }, fy : function() { return y }});
669 }
670 assertSame(6, sumX);
671 assertSame(-6, sumY);
672 assertSame(3, fs.length);
673 for (var i = 0; i < fs.length; i++) {
674 var {fx,fy} = fs[i];
675 assertSame(3, fx());
676 assertSame(-3, fy());
677 }
678
679 var o = { __proto__:null, 'a1':1, 'b2':2 };
680 var sx = '';
681 var sy = '';
682 for (var [x,y] in o) {
683 sx += x;
684 sy += y;
685 }
686 assertEquals('ab', sx);
687 assertEquals('12', sy);
688 }());
OLDNEW
« no previous file with comments | « test/mjsunit/es6/debug-stepnext-for.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698