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

Unified Diff: test/mjsunit/harmony/destructuring-assignment.js

Issue 1517973002: [es6] support AssignmentPattern as LHS in for-in/of loops (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Centralize the error validation to a single place, to ease confusion Created 5 years 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/cctest/test-parsing.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-assignment.js
diff --git a/test/mjsunit/harmony/destructuring-assignment.js b/test/mjsunit/harmony/destructuring-assignment.js
index d5ba9eef7cd1b6d48efe56108f7df962cd6a9ac4..bc8c424d8b48f4085e2e9c88a9ef03a837221d1f 100644
--- a/test/mjsunit/harmony/destructuring-assignment.js
+++ b/test/mjsunit/harmony/destructuring-assignment.js
@@ -428,3 +428,55 @@ assertEquals(oz, [1, 2, 3, 4, 5]);
assertThrows(() => { ({ a: [ c ] } = { a: [ "nope!" ] }); }, TypeError);
assertEquals("untouchable", c);
})();
+
+(function testForIn() {
+ var log = [];
+ var x = {};
+ var object = {
+ "Apenguin": 1,
+ "\u{1F382}cake": 2,
+ "Bpuppy": 3,
+ "Cspork": 4
+ };
+ for ([x.firstLetter, ...x.rest] in object) {
+ if (x.firstLetter === "A") {
+ assertEquals(["p", "e", "n", "g", "u", "i", "n"], x.rest);
+ continue;
+ }
+ if (x.firstLetter === "C") {
+ assertEquals(["s", "p", "o", "r", "k"], x.rest);
+ break;
+ }
+ log.push({ firstLetter: x.firstLetter, rest: x.rest });
+ }
+ assertEquals([
+ { firstLetter: "\u{1F382}", rest: ["c", "a", "k", "e"] },
+ { firstLetter: "B", rest: ["p", "u", "p", "p", "y"] },
+ ], log);
+})();
+
+(function testForOf() {
+ var log = [];
+ var x = {};
+ var names = [
+ "Apenguin",
+ "\u{1F382}cake",
+ "Bpuppy",
+ "Cspork"
+ ];
+ for ([x.firstLetter, ...x.rest] of names) {
+ if (x.firstLetter === "A") {
+ assertEquals(["p", "e", "n", "g", "u", "i", "n"], x.rest);
+ continue;
+ }
+ if (x.firstLetter === "C") {
+ assertEquals(["s", "p", "o", "r", "k"], x.rest);
+ break;
+ }
+ log.push({ firstLetter: x.firstLetter, rest: x.rest });
+ }
+ assertEquals([
+ { firstLetter: "\u{1F382}", rest: ["c", "a", "k", "e"] },
+ { firstLetter: "B", rest: ["p", "u", "p", "p", "y"] },
+ ], log);
+})();
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698