OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var typedArrayConstructors = [ |
| 6 Uint8Array, |
| 7 Int8Array, |
| 8 Uint16Array, |
| 9 Int16Array, |
| 10 Uint32Array, |
| 11 Int32Array, |
| 12 Uint8ClampedArray, |
| 13 Float32Array, |
| 14 Float64Array |
| 15 ]; |
| 16 |
| 17 var descriptor = { get: function() { throw new Error("accessed length"); } }; |
| 18 |
| 19 for (var constructor of typedArrayConstructors) { |
| 20 var differentConstructor = |
| 21 constructor === Uint8Array ? Int8Array : Uint8Array; |
| 22 var target = new constructor(16); |
| 23 Object.defineProperty(target, "length", descriptor); |
| 24 |
| 25 var sameBuffer = new differentConstructor(target.buffer, 0, 2); |
| 26 Object.defineProperty(sameBuffer, "length", descriptor); |
| 27 target.set(sameBuffer); |
| 28 |
| 29 var differentBuffer = new differentConstructor(16); |
| 30 Object.defineProperty(differentBuffer, "length", descriptor); |
| 31 target.set(differentBuffer); |
| 32 |
| 33 var array = [0, 1, 2]; |
| 34 target.set(array); |
| 35 } |
OLD | NEW |