Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/mjsunit/harmony/typedarray-proto.js

Issue 1126313003: Make one copy for all TypedArray methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Leave out subarray; improve tests Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/harmony-typedarray.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « src/harmony-typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698