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

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: Adding test and fixing failures (TypedArray.from and TypedArray.prototype.subarray) 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
« src/typedarray.js ('K') | « src/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 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 }
OLDNEW
« src/typedarray.js ('K') | « src/typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698