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 var typedArrayConstructors = [ | 7 var typedArrayConstructors = [ |
6 Uint8Array, | 8 Uint8Array, |
7 Int8Array, | 9 Int8Array, |
8 Uint16Array, | 10 Uint16Array, |
9 Int16Array, | 11 Int16Array, |
10 Uint32Array, | 12 Uint32Array, |
11 Int32Array, | 13 Int32Array, |
12 Uint8ClampedArray, | 14 Uint8ClampedArray, |
13 Float32Array, | 15 Float32Array, |
14 Float64Array | 16 Float64Array |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // Shadowing length doesn't affect every, unlike Array.prototype.every | 242 // Shadowing length doesn't affect every, unlike Array.prototype.every |
241 var a = new constructor([1, 2]); | 243 var a = new constructor([1, 2]); |
242 Object.defineProperty(a, 'length', {value: 1}); | 244 Object.defineProperty(a, 'length', {value: 1}); |
243 assertEquals(a.reduce(sum, 0), 3); | 245 assertEquals(a.reduce(sum, 0), 3); |
244 assertEquals(Array.prototype.reduce.call(a, sum, 0), 1); | 246 assertEquals(Array.prototype.reduce.call(a, sum, 0), 1); |
245 assertEquals(a.reduceRight(sum, 0), 3); | 247 assertEquals(a.reduceRight(sum, 0), 3); |
246 assertEquals(Array.prototype.reduceRight.call(a, sum, 0), 1); | 248 assertEquals(Array.prototype.reduceRight.call(a, sum, 0), 1); |
247 | 249 |
248 assertEquals(1, constructor.prototype.reduce.length); | 250 assertEquals(1, constructor.prototype.reduce.length); |
249 assertEquals(1, constructor.prototype.reduceRight.length); | 251 assertEquals(1, constructor.prototype.reduceRight.length); |
| 252 |
| 253 // Detached Operation |
| 254 var tmp = { |
| 255 [Symbol.toPrimitive]() { |
| 256 assertUnreachable("Parameter should not be processed when " + |
| 257 "array.[[ViewedArrayBuffer]] is neutered."); |
| 258 return 0; |
| 259 } |
| 260 }; |
| 261 |
| 262 var array = new constructor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); |
| 263 %ArrayBufferNeuter(array.buffer); |
| 264 assertThrows(() => array.reduce(sum, tmp), TypeError); |
| 265 assertThrows(() => array.reduceRight(sum, tmp), TypeError); |
250 } | 266 } |
OLD | NEW |