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 var typedArrayConstructors = [ | 5 var typedArrayConstructors = [ |
8 Uint8Array, | 6 Uint8Array, |
9 Int8Array, | 7 Int8Array, |
10 Uint16Array, | 8 Uint16Array, |
11 Int16Array, | 9 Int16Array, |
12 Uint32Array, | 10 Uint32Array, |
13 Int32Array, | 11 Int32Array, |
14 Uint8ClampedArray, | 12 Uint8ClampedArray, |
15 Float32Array, | 13 Float32Array, |
16 Float64Array | 14 Float64Array |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // Shadowing length doesn't affect every, unlike Array.prototype.every | 240 // Shadowing length doesn't affect every, unlike Array.prototype.every |
243 var a = new constructor([1, 2]); | 241 var a = new constructor([1, 2]); |
244 Object.defineProperty(a, 'length', {value: 1}); | 242 Object.defineProperty(a, 'length', {value: 1}); |
245 assertEquals(a.reduce(sum, 0), 3); | 243 assertEquals(a.reduce(sum, 0), 3); |
246 assertEquals(Array.prototype.reduce.call(a, sum, 0), 1); | 244 assertEquals(Array.prototype.reduce.call(a, sum, 0), 1); |
247 assertEquals(a.reduceRight(sum, 0), 3); | 245 assertEquals(a.reduceRight(sum, 0), 3); |
248 assertEquals(Array.prototype.reduceRight.call(a, sum, 0), 1); | 246 assertEquals(Array.prototype.reduceRight.call(a, sum, 0), 1); |
249 | 247 |
250 assertEquals(1, constructor.prototype.reduce.length); | 248 assertEquals(1, constructor.prototype.reduce.length); |
251 assertEquals(1, constructor.prototype.reduceRight.length); | 249 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); | |
266 } | 250 } |
OLD | NEW |