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

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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « 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..731bc6dbe5c6c3a1b9fc10e80dcde7371c16bfb6 100644
--- a/test/mjsunit/harmony/destructuring.js
+++ b/test/mjsunit/harmony/destructuring.js
@@ -645,8 +645,7 @@
assertSame(-(i+1), fy());
}
- var o = { 'a1':1, 'b2':2 };
- o.__proto__ = null;
+ var o = { __proto__:null, 'a1':1, 'b2':2 };
let sx = '';
let sy = '';
for (let [x,y] in o) {
@@ -656,3 +655,34 @@
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 = { __proto__:null, 'a1':1, 'b2':2 };
+ var sx = '';
+ var sy = '';
+ for (var [x,y] in o) {
+ sx += x;
+ sy += y;
+ }
+ assertEquals('ab', sx);
+ assertEquals('12', sy);
+}());
« 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