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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/destructuring.js
diff --git a/test/mjsunit/harmony/destructuring.js b/test/mjsunit/harmony/destructuring.js
index 11a0bebcbfb29ac17d10d81a89de56e82b49d387..adc3b1c13bdb68882c3a371d0b4f233e3a9c7715 100644
--- a/test/mjsunit/harmony/destructuring.js
+++ b/test/mjsunit/harmony/destructuring.js
@@ -623,3 +623,36 @@
assertArrayEquals(["1", "2"], log);
}());
}());
+
+
+(function TestForEachLexical() {
+ 'use strict';
+ let a = [{x:1, y:-1}, {x:2,y:-2}, {x:3,y:-3}];
+ let sumX = 0;
+ let sumY = 0;
+ let fs = [];
+ for (let {x,y} of a) {
+ sumX += x;
+ sumY += y;
+ fs.push({fx : function() { return x; }, fy : function() { return y }});
+ }
+ assertSame(6, sumX);
+ assertSame(-6, sumY);
+ assertSame(3, fs.length);
+ for (let i = 0; i < fs.length; i++) {
+ let {fx,fy} = fs[i];
+ assertSame(i+1, fx());
+ assertSame(-(i+1), fy());
+ }
+
+ var o = { 'a1':1, 'b2':2 };
+ o.__proto__ = null;
+ let sx = '';
+ let sy = '';
+ for (let [x,y] in o) {
+ sx += x;
+ sy += y;
+ }
+ assertEquals('ab', sx);
+ assertEquals('12', sy);
+}());
« 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