Chromium Code Reviews| 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 | |
| 12 var typedArrayConstructors = [ | |
| 13 Uint8Array, | |
| 14 Int8Array, | |
| 15 Uint16Array, | |
| 16 Int16Array, | |
| 17 Uint32Array, | |
| 18 Int32Array, | |
| 19 Uint8ClampedArray, | |
| 20 Float32Array, | |
| 21 Float64Array]; | |
| 22 | |
| 23 function functionProperties(object) { | |
| 24 return Object.getOwnPropertyNames(object).filter(function(name) { | |
| 25 return typeof Object.getOwnPropertyDescriptor(object, name).value | |
| 26 == "function" | |
| 27 && name != 'constructor' && name != 'subarray'; | |
| 28 }); | |
| 29 } | |
| 30 | |
| 31 var typedArrayMethods = functionProperties(Uint8Array.prototype); | |
| 32 var typedArrayClassMethods = functionProperties(Uint8Array); | |
| 33 | |
| 34 function allEqual(arr) { | |
| 35 return arr.length == 0 || arr.every(function(x) {return x === arr[0];}); | |
| 36 } | |
| 37 | |
| 38 for (var method of typedArrayMethods) { | |
| 39 assertEquals(true, allEqual( | |
| 40 typedArrayConstructors.map(function(constructor) { | |
|
arv (Not doing code reviews)
2015/05/08 20:02:03
maybe a nested loop would be cleaner?
for (var me
| |
| 41 return constructor.prototype[method]; | |
| 42 })), method); | |
| 43 } | |
| 44 | |
| 45 for (var classMethod of typedArrayClassMethods) { | |
| 46 assertEquals(true, | |
| 47 allEqual(typedArrayConstructors.map(function(constructor) { | |
| 48 return constructor[method]; | |
| 49 })), classMethod) | |
| 50 } | |
| OLD | NEW |