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

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

Issue 1152503002: [destructuring] Implement pattern matching in lexcal for-of/for-in. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove commented-out code 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 | « src/parser.cc ('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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 'use strict'; 616 'use strict';
617 log = []; 617 log = [];
618 let [{x, y}, [a, b]] = f(); 618 let [{x, y}, [a, b]] = f();
619 assertSame(1, x); 619 assertSame(1, x);
620 assertSame(2, y); 620 assertSame(2, y);
621 assertSame(42, a); 621 assertSame(42, a);
622 assertSame(27, b); 622 assertSame(27, b);
623 assertArrayEquals(["1", "2"], log); 623 assertArrayEquals(["1", "2"], log);
624 }()); 624 }());
625 }()); 625 }());
626
627
628 (function TestForEachLexical() {
629 'use strict';
630 let a = [{x:1, y:-1}, {x:2,y:-2}, {x:3,y:-3}];
631 let sumX = 0;
632 let sumY = 0;
633 let fs = [];
634 for (let {x,y} of a) {
635 sumX += x;
636 sumY += y;
637 fs.push({fx : function() { return x; }, fy : function() { return y }});
638 }
639 assertSame(6, sumX);
640 assertSame(-6, sumY);
641 assertSame(3, fs.length);
642 for (let i = 0; i < fs.length; i++) {
643 let {fx,fy} = fs[i];
644 assertSame(i+1, fx());
645 assertSame(-(i+1), fy());
646 }
647
648 var o = { 'a1':1, 'b2':2 };
649 o.__proto__ = null;
650 let sx = '';
651 let sy = '';
652 for (let [x,y] in o) {
653 sx += x;
654 sy += y;
655 }
656 assertEquals('ab', sx);
657 assertEquals('12', sy);
658 }());
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698