OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 (function testNestedSpreadsInPatterns() { |
| 6 (function () { |
| 7 var [...[...x]] = [42, 17]; |
| 8 assertArrayEquals([42, 17], x); |
| 9 })(); |
| 10 (function () { |
| 11 let [...[...x]] = [42, 17]; |
| 12 assertArrayEquals([42, 17], x); |
| 13 })(); |
| 14 (function () { |
| 15 const [...[...x]] = [42, 17]; |
| 16 assertArrayEquals([42, 17], x); |
| 17 })(); |
| 18 (function () { |
| 19 var x; [...[...x]] = [42, 17]; |
| 20 assertArrayEquals([42, 17], x); |
| 21 })(); |
| 22 |
| 23 function f1([...[...x]] = [42, 17]) { return x; } |
| 24 assertArrayEquals([42, 17], f1()); |
| 25 assertArrayEquals([1, 2, 3], f1([1, 2, 3])); |
| 26 |
| 27 var f2 = function ([...[...x]] = [42, 17]) { return x; } |
| 28 assertArrayEquals([42, 17], f2()); |
| 29 assertArrayEquals([1, 2, 3], f2([1, 2, 3])); |
| 30 |
| 31 // The following two were failing in debug mode, until v8:5337 was fixed. |
| 32 var f3 = ([...[...x]] = [42, 17]) => { return x; }; |
| 33 assertArrayEquals([42, 17], f3()); |
| 34 assertArrayEquals([1, 2, 3], f3([1, 2, 3])); |
| 35 |
| 36 var f4 = ([...[...x]] = [42, 17]) => x; |
| 37 assertArrayEquals([42, 17], f4()); |
| 38 assertArrayEquals([1, 2, 3], f4([1, 2, 3])); |
| 39 })(); |
OLD | NEW |