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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/harmony-typedarray.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c7e55d4cf6f62e1baa52f441464650b243c92ba2
--- /dev/null
+++ b/test/mjsunit/harmony/typedarray-proto.js
@@ -0,0 +1,50 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-arrays
+
+// 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(function(name) {
+ return typeof Object.getOwnPropertyDescriptor(object, name).value
+ == "function"
+ && name != 'constructor' && name != 'subarray';
+ });
+}
+
+var typedArrayMethods = functionProperties(Uint8Array.prototype);
+var typedArrayClassMethods = functionProperties(Uint8Array);
+
+function allEqual(arr) {
+ return arr.length == 0 || arr.every(function(x) {return x === arr[0];});
+}
+
+for (var method of typedArrayMethods) {
+ assertEquals(true, allEqual(
+ 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
+ return constructor.prototype[method];
+ })), method);
+}
+
+for (var classMethod of typedArrayClassMethods) {
+ assertEquals(true,
+ allEqual(typedArrayConstructors.map(function(constructor) {
+ return constructor[method];
+ })), classMethod)
+}
« 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