| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Flags: --harmony-arrays | |
| 6 | |
| 7 // Test that the methods for different TypedArray types have the same | |
| 8 // identity. | |
| 9 // TODO(dehrenberg): Test that the TypedArray proto hierarchy is set | |
| 10 // up properly. | |
| 11 // TODO(dehrenberg): subarray is currently left out because that still | |
| 12 // uses per-type methods. When that's fixed, stop leaving it out. | |
| 13 | |
| 14 var typedArrayConstructors = [ | |
| 15 Uint8Array, | |
| 16 Int8Array, | |
| 17 Uint16Array, | |
| 18 Int16Array, | |
| 19 Uint32Array, | |
| 20 Int32Array, | |
| 21 Uint8ClampedArray, | |
| 22 Float32Array, | |
| 23 Float64Array]; | |
| 24 | |
| 25 function functionProperties(object) { | |
| 26 return Object.getOwnPropertyNames(object).filter(function(name) { | |
| 27 return typeof Object.getOwnPropertyDescriptor(object, name).value | |
| 28 == "function" | |
| 29 && name != 'constructor' && name != 'subarray'; | |
| 30 }); | |
| 31 } | |
| 32 | |
| 33 var typedArrayMethods = functionProperties(Uint8Array.prototype); | |
| 34 var typedArrayClassMethods = functionProperties(Uint8Array); | |
| 35 | |
| 36 for (var constructor of typedArrayConstructors) { | |
| 37 for (var method of typedArrayMethods) { | |
| 38 assertEquals(constructor.prototype[method], | |
| 39 Uint8Array.prototype[method], method); | |
| 40 } | |
| 41 for (var classMethod of typedArrayClassMethods) { | |
| 42 assertEquals(constructor[method], Uint8Array[method], classMethod); | |
| 43 } | |
| 44 } | |
| OLD | NEW |