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: --allow-natives-syntax |
| 6 |
5 function ArrayMaker(x) { | 7 function ArrayMaker(x) { |
6 return x; | 8 return x; |
7 } | 9 } |
8 ArrayMaker.prototype = Array.prototype; | 10 ArrayMaker.prototype = Array.prototype; |
9 | 11 |
10 var arrayConstructors = [ | 12 var arrayConstructors = [ |
11 Uint8Array, | 13 Uint8Array, |
12 Int8Array, | 14 Int8Array, |
13 Uint16Array, | 15 Uint16Array, |
14 Int16Array, | 16 Int16Array, |
(...skipping 29 matching lines...) Expand all Loading... |
44 } else { | 46 } else { |
45 // Array.reverse works on array-like objects | 47 // Array.reverse works on array-like objects |
46 var x = { length: 2, 1: 5 }; | 48 var x = { length: 2, 1: 5 }; |
47 a.reverse.call(x); | 49 a.reverse.call(x); |
48 assertEquals(2, x.length); | 50 assertEquals(2, x.length); |
49 assertFalse(Object.hasOwnProperty(x, '1')); | 51 assertFalse(Object.hasOwnProperty(x, '1')); |
50 assertEquals(5, x[0]); | 52 assertEquals(5, x[0]); |
51 } | 53 } |
52 | 54 |
53 assertEquals(0, a.reverse.length); | 55 assertEquals(0, a.reverse.length); |
| 56 |
| 57 // Detached Operation |
| 58 if (constructor != ArrayMaker) { |
| 59 var array = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| 60 %ArrayBufferNeuter(array.buffer); |
| 61 assertThrows(() => array.reverse(), TypeError); |
| 62 } |
54 } | 63 } |
OLD | NEW |