| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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-concat-spreadable | 5 // Flags: --harmony-concat-spreadable |
| 6 | 6 |
| 7 (function testArrayConcatArity() { | 7 (function testArrayConcatArity() { |
| 8 "use strict"; | 8 "use strict"; |
| 9 assertEquals(1, Array.prototype.concat.length); | 9 assertEquals(1, Array.prototype.concat.length); |
| 10 })(); | 10 })(); |
| 11 | 11 |
| 12 | 12 |
| 13 (function testArrayConcatNoPrototype() { | 13 (function testArrayConcatNoPrototype() { |
| 14 "use strict"; | 14 "use strict"; |
| 15 assertEquals(void 0, Array.prototype.concat.prototype); | 15 assertEquals(void 0, Array.prototype.concat.prototype); |
| 16 })(); | 16 })(); |
| 17 | 17 |
| 18 | 18 |
| 19 (function testArrayConcatDescriptor() { | 19 (function testArrayConcatDescriptor() { |
| 20 "use strict"; | 20 "use strict"; |
| 21 var desc = Object.getOwnPropertyDescriptor(Array.prototype, 'concat'); | 21 var desc = Object.getOwnPropertyDescriptor(Array.prototype, 'concat'); |
| 22 assertEquals(false, desc.enumerable); | 22 assertEquals(false, desc.enumerable); |
| 23 })(); | 23 })(); |
| 24 | 24 |
| 25 (function testNonConcatSpreadableArray() { |
| 26 "use strict" |
| 27 var array = [1, 2, 3]; |
| 28 assertEquals(array, [].concat(array)); |
| 29 assertEquals(array, array.concat([])); |
| 30 array[Symbol.isConcatSpreadable] = false; |
| 31 assertEquals([[1,2,3]], [].concat(array)); |
| 32 assertEquals([[1,2,3]], array.concat([])); |
| 33 })(); |
| 25 | 34 |
| 26 (function testConcatArrayLike() { | 35 (function testConcatArrayLike() { |
| 27 "use strict"; | 36 "use strict"; |
| 28 var obj = { | 37 var obj = { |
| 29 "length": 6, | 38 "length": 6, |
| 30 "1": "A", | 39 "1": "A", |
| 31 "3": "B", | 40 "3": "B", |
| 32 "5": "C" | 41 "5": "C" |
| 33 }; | 42 }; |
| 34 obj[Symbol.isConcatSpreadable] = true; | 43 obj[Symbol.isConcatSpreadable] = true; |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 arr3.length = 10000; | 708 arr3.length = 10000; |
| 700 for (var i = 0; i < 100; i++) { | 709 for (var i = 0; i < 100; i++) { |
| 701 Object.defineProperty(arr3, i * i, {get: mkGetter(i)}); | 710 Object.defineProperty(arr3, i * i, {get: mkGetter(i)}); |
| 702 expectedTrace[i] = i; | 711 expectedTrace[i] = i; |
| 703 expectedTrace[100 + i] = i; | 712 expectedTrace[100 + i] = i; |
| 704 } | 713 } |
| 705 var r4 = [0].concat(arr3, arr3); | 714 var r4 = [0].concat(arr3, arr3); |
| 706 assertEquals(1 + arr3.length * 2, r4.length); | 715 assertEquals(1 + arr3.length * 2, r4.length); |
| 707 assertEquals(expectedTrace, trace); | 716 assertEquals(expectedTrace, trace); |
| 708 })(); | 717 })(); |
| OLD | NEW |