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

Unified 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: 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
« src/parser.cc ('K') | « test/mjsunit/es6/debug-stepnext-for.js ('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 adc3b1c13bdb68882c3a371d0b4f233e3a9c7715..97cc7d016bfe2251a8a16dc23d3f459101259799 100644
--- a/test/mjsunit/harmony/destructuring.js
+++ b/test/mjsunit/harmony/destructuring.js
@@ -656,3 +656,35 @@
assertEquals('ab', sx);
assertEquals('12', sy);
}());
+
+
+(function TestForEachVars() {
+ var a = [{x:1, y:-1}, {x:2,y:-2}, {x:3,y:-3}];
+ var sumX = 0;
+ var sumY = 0;
+ var fs = [];
+ for (var {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 (var i = 0; i < fs.length; i++) {
+ var {fx,fy} = fs[i];
+ assertSame(3, fx());
+ assertSame(-3, fy());
+ }
+
+ 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.
+ o.__proto__ = null;
+ var sx = '';
+ var sy = '';
+ for (var [x,y] in o) {
+ sx += x;
+ sy += y;
+ }
+ assertEquals('ab', sx);
+ assertEquals('12', sy);
+}());
« src/parser.cc ('K') | « 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