Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 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 testSpreadIndex() { |
| 6 | var result = [...[17, 42]][1]; |
| 7 | assertEquals(result, 42); |
| 8 | })(); |
| 9 | |
| 10 | (function testSpreadProperty() { |
| 11 | var result = [...[17, 42]].length; |
| 12 | assertEquals(result, 2); |
| 13 | })(); |
| 14 | |
| 15 | (function testSpreadMethodCall() { |
| 16 | var result = [...[17, 42]].join("+"); |
| 17 | assertEquals(result, "17+42"); |
| 18 | })(); |
| 19 | |
| 20 | (function testSpreadSavedMethodCall() { |
| 21 | var x = [...[17, 42]]; |
| 22 | var method = x.join; |
| 23 | var result = method.call(x, "+"); |
| 24 | assertEquals(result, "17+42"); |
| 25 | })(); |
| 26 | |
| 27 | (function testSpreadAsTemplateTag() { |
| 28 | assertThrows(function() { [...[17, 42]] `foo`; }, TypeError) |
| 29 | })(); |