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

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

Issue 1151503002: [destructuring] Implement spread binding patterns. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comments addressed 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 unified diff | Download patch
« src/pattern-rewriter.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | 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 --harmony-computed-property-names 5 // Flags: --harmony-destructuring --harmony-computed-property-names
6 6
7 (function TestObjectLiteralPattern() { 7 (function TestObjectLiteralPattern() {
8 var { x : x, y : y } = { x : 1, y : 2 }; 8 var { x : x, y : y } = { x : 1, y : 2 };
9 assertEquals(1, x); 9 assertEquals(1, x);
10 assertEquals(2, y); 10 assertEquals(2, y);
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 456
457 (function() { 457 (function() {
458 log = []; 458 log = [];
459 // last comma is not an elision, but the comma before the last is. 459 // last comma is not an elision, but the comma before the last is.
460 var [a, b, ,] = f(); 460 var [a, b, ,] = f();
461 assertSame(1, a); 461 assertSame(1, a);
462 assertSame(2, b); 462 assertSame(2, b);
463 assertArrayEquals(["1", "2", "3"], log); 463 assertArrayEquals(["1", "2", "3"], log);
464 }()); 464 }());
465 465
466 (function() {
467 log = [];
468 var [a, ...rest] = f();
469 assertSame(1, a);
470 assertArrayEquals([2,3], rest);
471 assertArrayEquals(["1", "2", "3", "done"], log);
472 }());
473
474 (function() {
475 log = [];
476 var [a, b, c, ...rest] = f();
477 assertSame(1, a);
478 assertSame(2, b);
479 assertSame(3, c);
480 assertArrayEquals([], rest);
481 assertArrayEquals(["1", "2", "3", "done"], log);
482 }());
483
484 (function() {
485 log = [];
486 var [a, b, c, d, ...rest] = f();
487 assertSame(1, a);
488 assertSame(2, b);
489 assertSame(3, c);
490 assertSame(undefined, d);
491 assertArrayEquals([], rest);
492 assertArrayEquals(["1", "2", "3", "done"], log);
493 }());
466 }()); 494 }());
467 495
468 496
469 (function TestIteratorsLexical() { 497 (function TestIteratorsLexical() {
470 'use strict'; 498 'use strict';
471 var log = []; 499 var log = [];
472 function* f() { 500 function* f() {
473 log.push("1"); 501 log.push("1");
474 yield 1; 502 yield 1;
475 log.push("2"); 503 log.push("2");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 554
527 (function() { 555 (function() {
528 log = []; 556 log = [];
529 // last comma is not an elision, but the comma before the last is. 557 // last comma is not an elision, but the comma before the last is.
530 let [a, b, ,] = f(); 558 let [a, b, ,] = f();
531 assertSame(1, a); 559 assertSame(1, a);
532 assertSame(2, b); 560 assertSame(2, b);
533 assertArrayEquals(["1", "2", "3"], log); 561 assertArrayEquals(["1", "2", "3"], log);
534 }()); 562 }());
535 563
564 (function() {
565 log = [];
566 let [a, ...rest] = f();
567 assertSame(1, a);
568 assertArrayEquals([2,3], rest);
569 assertArrayEquals(["1", "2", "3", "done"], log);
570 }());
571
572 (function() {
573 log = [];
574 let [a, b, c, ...rest] = f();
575 assertSame(1, a);
576 assertSame(2, b);
577 assertSame(3, c);
578 assertArrayEquals([], rest);
579 assertArrayEquals(["1", "2", "3", "done"], log);
580 }());
581
582 (function() {
583 log = [];
584 let [a, b, c, d, ...rest] = f();
585 assertSame(1, a);
586 assertSame(2, b);
587 assertSame(3, c);
588 assertSame(undefined, d);
589 assertArrayEquals([], rest);
590 assertArrayEquals(["1", "2", "3", "done"], log);
591 }());
536 }()); 592 }());
537 593
538 (function TestIteratorsRecursive() { 594 (function TestIteratorsRecursive() {
539
540 var log = []; 595 var log = [];
541 function* f() { 596 function* f() {
542 log.push("1"); 597 log.push("1");
543 yield {x : 1, y : 2}; 598 yield {x : 1, y : 2};
544 log.push("2"); 599 log.push("2");
545 yield [42, 27, 30]; 600 yield [42, 27, 30];
546 log.push("3"); 601 log.push("3");
547 yield "abc"; 602 yield "abc";
548 log.push("done"); 603 log.push("done");
549 }; 604 };
(...skipping 11 matching lines...) Expand all
561 'use strict'; 616 'use strict';
562 log = []; 617 log = [];
563 let [{x, y}, [a, b]] = f(); 618 let [{x, y}, [a, b]] = f();
564 assertSame(1, x); 619 assertSame(1, x);
565 assertSame(2, y); 620 assertSame(2, y);
566 assertSame(42, a); 621 assertSame(42, a);
567 assertSame(27, b); 622 assertSame(27, b);
568 assertArrayEquals(["1", "2"], log); 623 assertArrayEquals(["1", "2"], log);
569 }()); 624 }());
570 }()); 625 }());
OLDNEW
« src/pattern-rewriter.cc ('K') | « test/cctest/test-parsing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698