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); |
+})(); |