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

Side by Side Diff: test/mjsunit/harmony/destructuring.js

Issue 1704533002: Support rest element pattern with user-defined iterable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/parsing/pattern-rewriter.cc ('k') | test/mjsunit/harmony/destructuring-assignment.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Flags: --harmony-destructuring-bind 5 // Flags: --harmony-destructuring-bind
6 // Flags: --harmony-default-parameters 6 // Flags: --harmony-default-parameters
7 7
8 (function TestObjectLiteralPattern() { 8 (function TestObjectLiteralPattern() {
9 var { x : x, y : y, get, set } = { x : 1, y : 2, get: 3, set: 4 }; 9 var { x : x, y : y, get, set } = { x : 1, y : 2, get: 3, set: 4 };
10 assertEquals(1, x); 10 assertEquals(1, x);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 assertSame(1, a); 496 assertSame(1, a);
497 assertSame(2, b); 497 assertSame(2, b);
498 assertSame(3, c); 498 assertSame(3, c);
499 assertSame(undefined, d); 499 assertSame(undefined, d);
500 assertArrayEquals([], rest); 500 assertArrayEquals([], rest);
501 assertArrayEquals(["1", "2", "3", "done"], log); 501 assertArrayEquals(["1", "2", "3", "done"], log);
502 }()); 502 }());
503 }()); 503 }());
504 504
505 505
506 (function TestRestCustomIterable() {
507 var idx = 0;
508 var iterable = {};
509 var iterator = {
510 next: function() {
511 idx += 1;
512 return {
513 value: idx,
514 done: idx === 4
515 };
516 }
517 };
518 iterable[Symbol.iterator] = function() {
519 return iterator;
520 };
521
522 var [...result] = iterable;
523
524 assertEquals([1, 2, 3], result);
525 }());
526
527
506 (function TestIteratorsLexical() { 528 (function TestIteratorsLexical() {
507 'use strict'; 529 'use strict';
508 var log = []; 530 var log = [];
509 function* f() { 531 function* f() {
510 log.push("1"); 532 log.push("1");
511 yield 1; 533 yield 1;
512 log.push("2"); 534 log.push("2");
513 yield 2; 535 yield 2;
514 log.push("3"); 536 log.push("3");
515 yield 3; 537 yield 3;
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 throw [1, 2, 3]; 1147 throw [1, 2, 3];
1126 } catch ([foo, ...bar]) { 1148 } catch ([foo, ...bar]) {
1127 assertEquals(1, foo); 1149 assertEquals(1, foo);
1128 assertEquals([2, 3], bar); 1150 assertEquals([2, 3], bar);
1129 } 1151 }
1130 1152
1131 assertEquals("hello", foo); 1153 assertEquals("hello", foo);
1132 assertEquals("world", bar); 1154 assertEquals("world", bar);
1133 assertEquals(42, baz); 1155 assertEquals(42, baz);
1134 })(); 1156 })();
OLDNEW
« no previous file with comments | « src/parsing/pattern-rewriter.cc ('k') | test/mjsunit/harmony/destructuring-assignment.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698