| 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-assignment --harmony-destructuring-bind | 5 // Flags: --harmony-destructuring-assignment --harmony-destructuring-bind |
| 6 | 6 |
| 7 // script-level tests | 7 // script-level tests |
| 8 var ox, oy = {}, oz; | 8 var ox, oy = {}, oz; |
| 9 ({ | 9 ({ |
| 10 x: ox, | 10 x: ox, |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 it = [g()]; | 398 it = [g()]; |
| 399 assertEquals(it, [ [...y] ] = it); | 399 assertEquals(it, [ [...y] ] = it); |
| 400 assertEquals([undefined, undefined, undefined], y); | 400 assertEquals([undefined, undefined, undefined], y); |
| 401 assertEquals(6, count); | 401 assertEquals(6, count); |
| 402 | 402 |
| 403 it = { a: g() }; | 403 it = { a: g() }; |
| 404 assertEquals(it, { a: [...z] } = it); | 404 assertEquals(it, { a: [...z] } = it); |
| 405 assertEquals([undefined, undefined, undefined], z); | 405 assertEquals([undefined, undefined, undefined], z); |
| 406 assertEquals(9, count); | 406 assertEquals(9, count); |
| 407 })(); | 407 })(); |
| 408 |
| 409 (function cstm() { |
| 410 var idx = 0; |
| 411 var iterable = {}; |
| 412 var iterator = { |
| 413 next: function() { |
| 414 idx += 1; |
| 415 return { |
| 416 value: idx, |
| 417 done: idx > 3 |
| 418 }; |
| 419 } |
| 420 }; |
| 421 iterable[Symbol.iterator] = function() { |
| 422 return iterator; |
| 423 }; |
| 424 var result; |
| 425 |
| 426 [...result] = iterable; |
| 427 |
| 428 assertEquals([1, 2, 3], result); |
| 429 })(); |
| 408 })(); | 430 })(); |
| 409 | 431 |
| 410 (function testRequireObjectCoercible() { | 432 (function testRequireObjectCoercible() { |
| 411 assertThrows(() => ({} = undefined), TypeError); | 433 assertThrows(() => ({} = undefined), TypeError); |
| 412 assertThrows(() => ({} = null), TypeError); | 434 assertThrows(() => ({} = null), TypeError); |
| 413 assertThrows(() => [] = undefined, TypeError); | 435 assertThrows(() => [] = undefined, TypeError); |
| 414 assertThrows(() => [] = null, TypeError); | 436 assertThrows(() => [] = null, TypeError); |
| 415 assertEquals("test", ({} = "test")); | 437 assertEquals("test", ({} = "test")); |
| 416 assertEquals("test", [] = "test"); | 438 assertEquals("test", [] = "test"); |
| 417 assertEquals(123, ({} = 123)); | 439 assertEquals(123, ({} = 123)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 assertEquals(["s", "p", "o", "r", "k"], x.rest); | 495 assertEquals(["s", "p", "o", "r", "k"], x.rest); |
| 474 break; | 496 break; |
| 475 } | 497 } |
| 476 log.push({ firstLetter: x.firstLetter, rest: x.rest }); | 498 log.push({ firstLetter: x.firstLetter, rest: x.rest }); |
| 477 } | 499 } |
| 478 assertEquals([ | 500 assertEquals([ |
| 479 { firstLetter: "\u{1F382}", rest: ["c", "a", "k", "e"] }, | 501 { firstLetter: "\u{1F382}", rest: ["c", "a", "k", "e"] }, |
| 480 { firstLetter: "B", rest: ["p", "u", "p", "p", "y"] }, | 502 { firstLetter: "B", rest: ["p", "u", "p", "p", "y"] }, |
| 481 ], log); | 503 ], log); |
| 482 })(); | 504 })(); |
| OLD | NEW |