| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 })(); |
| OLD | NEW |