OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 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 var a = new Array(); | 5 // Slice and splice both try to set the length property of their return |
6 a.constructor = Int32Array; | 6 // value. Add a bogus setter to allow that. |
7 a.length = 1000; // Make the length >= 1000 so UseSparseVariant returns true. | 7 Object.defineProperty(Int32Array.prototype, 'length', { set(v) { } }); |
8 assertThrows(() => a.slice()); | 8 |
| 9 (function testSlice() { |
| 10 var a = new Array(); |
| 11 a.constructor = Int32Array; |
| 12 a.length = 1000; // Make the length >= 1000 so UseSparseVariant returns true. |
| 13 assertTrue(a.slice() instanceof Int32Array); |
| 14 })(); |
| 15 |
| 16 (function testSplice() { |
| 17 var a = new Array(); |
| 18 a.constructor = Int32Array; |
| 19 a.length = 1000; // Make the length >= 1000 so UseSparseVariant returns true. |
| 20 assertTrue(a.splice(1) instanceof Int32Array); |
| 21 })(); |
OLD | NEW |