| 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-arrays | 5 // Flags: --harmony-arrays |
| 6 | 6 |
| 7 var typedArrayConstructors = [ | 7 var typedArrayConstructors = [ |
| 8 Uint8Array, | 8 Uint8Array, |
| 9 Int8Array, | 9 Int8Array, |
| 10 Uint16Array, | 10 Uint16Array, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 assertThrows('new constructor([]).findIndex(null)', TypeError); | 169 assertThrows('new constructor([]).findIndex(null)', TypeError); |
| 170 assertThrows('new constructor([]).findIndex(undefined)', TypeError); | 170 assertThrows('new constructor([]).findIndex(undefined)', TypeError); |
| 171 assertThrows('new constructor([]).findIndex(0)', TypeError); | 171 assertThrows('new constructor([]).findIndex(0)', TypeError); |
| 172 assertThrows('new constructor([]).findIndex(true)', TypeError); | 172 assertThrows('new constructor([]).findIndex(true)', TypeError); |
| 173 assertThrows('new constructor([]).findIndex(false)', TypeError); | 173 assertThrows('new constructor([]).findIndex(false)', TypeError); |
| 174 assertThrows('new constructor([]).findIndex("")', TypeError); | 174 assertThrows('new constructor([]).findIndex("")', TypeError); |
| 175 assertThrows('new constructor([]).findIndex({})', TypeError); | 175 assertThrows('new constructor([]).findIndex({})', TypeError); |
| 176 assertThrows('new constructor([]).findIndex([])', TypeError); | 176 assertThrows('new constructor([]).findIndex([])', TypeError); |
| 177 assertThrows('new constructor([]).findIndex(/\d+/)', TypeError); | 177 assertThrows('new constructor([]).findIndex(/\d+/)', TypeError); |
| 178 | 178 |
| 179 // Shadowing length doesn't affect findIndex, unlike Array.prototype.findIndex |
| 180 a = new constructor([1, 2]); |
| 181 Object.defineProperty(a, 'length', {value: 1}); |
| 182 var x = 0; |
| 183 assertEquals(a.findIndex(function(elt) { x += elt; return false; }), -1); |
| 184 assertEquals(x, 3); |
| 185 assertEquals(Array.prototype.findIndex.call(a, |
| 186 function(elt) { x += elt; return false; }), -1); |
| 187 assertEquals(x, 4); |
| 188 |
| 179 } | 189 } |
| OLD | NEW |