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

Unified Diff: test/mjsunit/es6/typedarray-proto.js

Issue 1558663002: Reland of Use ES2015-style TypedArray prototype chain (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « test/mjsunit/es6/typedarray-of.js ('k') | test/mjsunit/get-prototype-of.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/typedarray-proto.js
diff --git a/test/mjsunit/es6/typedarray-proto.js b/test/mjsunit/es6/typedarray-proto.js
index 558cb0ad7a25304b19c8d9fb41e893eba2c6195f..0bd90d13b404ca7befbac7817c8e688addf51f39 100644
--- a/test/mjsunit/es6/typedarray-proto.js
+++ b/test/mjsunit/es6/typedarray-proto.js
@@ -4,12 +4,10 @@
// Test that the methods for different TypedArray types have the same
// identity.
-// TODO(dehrenberg): Test that the TypedArray proto hierarchy is set
-// up properly.
-// TODO(dehrenberg): subarray is currently left out because that still
-// uses per-type methods. When that's fixed, stop leaving it out.
-var typedArrayConstructors = [
+'use strict';
+
+let typedArrayConstructors = [
Uint8Array,
Int8Array,
Uint16Array,
@@ -20,6 +18,18 @@
Float32Array,
Float64Array];
+let TypedArray = Uint8Array.__proto__;
+let TypedArrayPrototype = TypedArray.prototype;
+
+assertEquals(TypedArray.__proto__, Function.prototype);
+assertEquals(TypedArrayPrototype.__proto__, Object.prototype);
+
+// There are extra own class properties due to it simply being a function
+let classProperties = new Set([
+ "length", "name", "arguments", "caller", "prototype", "BYTES_PER_ELEMENT"
+]);
+let instanceProperties = new Set(["BYTES_PER_ELEMENT", "constructor", "prototype"]);
+
function functionProperties(object) {
return Object.getOwnPropertyNames(object).filter(function(name) {
return typeof Object.getOwnPropertyDescriptor(object, name).value
@@ -28,15 +38,33 @@
});
}
-var typedArrayMethods = functionProperties(Uint8Array.prototype);
-var typedArrayClassMethods = functionProperties(Uint8Array);
+let typedArrayMethods = functionProperties(Uint8Array.prototype);
+let typedArrayClassMethods = functionProperties(Uint8Array);
-for (var constructor of typedArrayConstructors) {
- for (var method of typedArrayMethods) {
- assertEquals(constructor.prototype[method],
- Uint8Array.prototype[method], method);
+for (let constructor of typedArrayConstructors) {
+ for (let property of Object.getOwnPropertyNames(constructor.prototype)) {
+ assertTrue(instanceProperties.has(property), property);
}
- for (var classMethod of typedArrayClassMethods) {
- assertEquals(constructor[method], Uint8Array[method], classMethod);
+ for (let property of Object.getOwnPropertyNames(constructor)) {
+ assertTrue(classProperties.has(property), property);
}
}
+
+// Abstract %TypedArray% class can't be constructed directly
+
+assertThrows(() => new TypedArray(), TypeError);
+
+// The "prototype" property is nonconfigurable, nonenumerable, nonwritable,
+// both for %TypedArray% and for all subclasses
+
+let desc = Object.getOwnPropertyDescriptor(TypedArray, "prototype");
+assertFalse(desc.writable);
+assertFalse(desc.configurable);
+assertFalse(desc.enumerable);
+
+for (let constructor of typedArrayConstructors) {
+ let desc = Object.getOwnPropertyDescriptor(constructor, "prototype");
+ assertFalse(desc.writable);
+ assertFalse(desc.configurable);
+ assertFalse(desc.enumerable);
+}
« no previous file with comments | « test/mjsunit/es6/typedarray-of.js ('k') | test/mjsunit/get-prototype-of.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698