Chromium Code Reviews| Index: test/mjsunit/harmony/typedarray-proto.js |
| diff --git a/test/mjsunit/harmony/typedarray-proto.js b/test/mjsunit/harmony/typedarray-proto.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bf18fdf82cf4b5c380a3014919417247e2520748 |
| --- /dev/null |
| +++ b/test/mjsunit/harmony/typedarray-proto.js |
| @@ -0,0 +1,48 @@ |
| +// 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
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Flags: --harmony-arrays --harmony_arrow_functions |
|
adamk
2015/05/08 01:13:34
Arrow functions aren't far enough along to be reli
|
| + |
| +// Test that the methods for different TypedArray types have the same |
| +// identity. |
| +// TODO(dehrenberg): Test that the TypedArray proto hierarchy is set |
| +// up properly. |
| + |
| +var typedArrayConstructors = [ |
| + Uint8Array, |
| + Int8Array, |
| + Uint16Array, |
| + Int16Array, |
| + Uint32Array, |
| + Int32Array, |
| + Uint8ClampedArray, |
| + Float32Array, |
| + Float64Array]; |
| + |
| +function functionProperties(object) { |
| + return Object.getOwnPropertyNames(object).filter( |
| + name => typeof Object.getOwnPropertyDescriptor(object, name).value |
| + == "function" && name != 'constructor'); |
| +} |
| + |
| +var typedArrayMethods = functionProperties(Uint8Array.prototype); |
| +var typedArrayClassMethods = functionProperties(Uint8Array); |
| + |
| +function allEqual(arr) { |
| + return arr.length == 0 || arr.every(x => x === arr[0]); |
| +} |
| + |
| +for (var method of typedArrayMethods) { |
| + assertEquals(true, allEqual( |
| + typedArrayConstructors.map(constructor => |
| + constructor.prototype[method])), |
| + method) |
| +} |
| + |
| +for (var classMethod of typedArrayClassMethods) { |
| + assertEquals(true, |
| + allEqual(typedArrayConstructors.map(constructor => |
| + constructor[method])), |
| + classMethod) |
| +} |