| 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 | |
| 7 function ArrayMaker(x) { | 5 function ArrayMaker(x) { |
| 8 return x; | 6 return x; |
| 9 } | 7 } |
| 10 ArrayMaker.prototype = Array.prototype; | 8 ArrayMaker.prototype = Array.prototype; |
| 11 | 9 |
| 12 var arrayConstructors = [ | 10 var arrayConstructors = [ |
| 13 Uint8Array, | 11 Uint8Array, |
| 14 Int8Array, | 12 Int8Array, |
| 15 Uint16Array, | 13 Uint16Array, |
| 16 Int16Array, | 14 Int16Array, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 46 } else { | 44 } else { |
| 47 // Array.reverse works on array-like objects | 45 // Array.reverse works on array-like objects |
| 48 var x = { length: 2, 1: 5 }; | 46 var x = { length: 2, 1: 5 }; |
| 49 a.reverse.call(x); | 47 a.reverse.call(x); |
| 50 assertEquals(2, x.length); | 48 assertEquals(2, x.length); |
| 51 assertFalse(Object.hasOwnProperty(x, '1')); | 49 assertFalse(Object.hasOwnProperty(x, '1')); |
| 52 assertEquals(5, x[0]); | 50 assertEquals(5, x[0]); |
| 53 } | 51 } |
| 54 | 52 |
| 55 assertEquals(0, a.reverse.length); | 53 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 } | |
| 63 } | 54 } |
| OLD | NEW |