Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | |
|
adamk
2015/05/08 01:13:34
Nit: update date to 2015 when adding new tests
| |
| 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 --harmony_arrow_functions | |
|
adamk
2015/05/08 01:13:34
Arrow functions aren't far enough along to be reli
| |
| 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( | |
| 25 name => typeof Object.getOwnPropertyDescriptor(object, name).value | |
| 26 == "function" && name != 'constructor'); | |
| 27 } | |
| 28 | |
| 29 var typedArrayMethods = functionProperties(Uint8Array.prototype); | |
| 30 var typedArrayClassMethods = functionProperties(Uint8Array); | |
| 31 | |
| 32 function allEqual(arr) { | |
| 33 return arr.length == 0 || arr.every(x => x === arr[0]); | |
| 34 } | |
| 35 | |
| 36 for (var method of typedArrayMethods) { | |
| 37 assertEquals(true, allEqual( | |
| 38 typedArrayConstructors.map(constructor => | |
| 39 constructor.prototype[method])), | |
| 40 method) | |
| 41 } | |
| 42 | |
| 43 for (var classMethod of typedArrayClassMethods) { | |
| 44 assertEquals(true, | |
| 45 allEqual(typedArrayConstructors.map(constructor => | |
| 46 constructor[method])), | |
| 47 classMethod) | |
| 48 } | |
| OLD | NEW |