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

Unified Diff: test/mjsunit/es6/classes-subclass-builtins.js

Issue 1541233002: Use ES2015-style TypedArray prototype chain (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test of prototype property descriptor 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/built-in-accessor-names.js ('k') | test/mjsunit/es6/typed-array-iterator.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/classes-subclass-builtins.js
diff --git a/test/mjsunit/es6/classes-subclass-builtins.js b/test/mjsunit/es6/classes-subclass-builtins.js
index e4d44be06adbc3695188430be6eb74674a023ec6..313aad1d8f6190eb7d3624e5572876f548d9eb62 100644
--- a/test/mjsunit/es6/classes-subclass-builtins.js
+++ b/test/mjsunit/es6/classes-subclass-builtins.js
@@ -349,7 +349,43 @@ function TestErrorSubclassing(error) {
})();
-function TestArraySubclassing(array) {
+(function TestArraySubclassing() {
+ class A extends Array {
+ constructor(...args) {
+ assertFalse(new.target === undefined);
+ super(...args);
+ this.a = 42;
+ this.d = 4.2;
+ this.o = {foo:153};
+ }
+ }
+
+ var o = new Array(13);
+ assertTrue(o instanceof Object);
+ assertTrue(o instanceof Array);
+ assertEquals("object", typeof o);
+ checkPrototypeChain(o, [Array, Object]);
+ assertEquals(13, o.length);
+
+ var o = new A(10);
+ assertTrue(o instanceof Object);
+ assertTrue(o instanceof Array);
+ assertTrue(o instanceof A);
+ assertEquals("object", typeof o);
+ checkPrototypeChain(o, [A, Array, Object]);
+ assertEquals(10, o.length);
+ assertEquals(42, o.a);
+ assertEquals(4.2, o.d);
+ assertEquals(153, o.o.foo);
+
+ var o1 = new A(7);
+ assertTrue(%HaveSameMap(o, o1));
+})();
+
+
+var TypedArray = Uint8Array.__proto__;
+
+function TestTypedArraySubclassing(array) {
class A extends array {
constructor(...args) {
assertFalse(new.target === undefined);
@@ -362,17 +398,19 @@ function TestArraySubclassing(array) {
var o = new array(13);
assertTrue(o instanceof Object);
+ assertTrue(o instanceof TypedArray);
assertTrue(o instanceof array);
assertEquals("object", typeof o);
- checkPrototypeChain(o, [array, Object]);
+ checkPrototypeChain(o, [array, TypedArray, Object]);
assertEquals(13, o.length);
var o = new A(10);
assertTrue(o instanceof Object);
+ assertTrue(o instanceof TypedArray);
assertTrue(o instanceof array);
assertTrue(o instanceof A);
assertEquals("object", typeof o);
- checkPrototypeChain(o, [A, array, Object]);
+ checkPrototypeChain(o, [A, array, TypedArray, Object]);
assertEquals(10, o.length);
assertEquals(42, o.a);
assertEquals(4.2, o.d);
@@ -384,16 +422,15 @@ function TestArraySubclassing(array) {
(function() {
- TestArraySubclassing(Array);
- TestArraySubclassing(Int8Array);
- TestArraySubclassing(Uint8Array);
- TestArraySubclassing(Uint8ClampedArray);
- TestArraySubclassing(Int16Array);
- TestArraySubclassing(Uint16Array);
- TestArraySubclassing(Int32Array);
- TestArraySubclassing(Uint32Array);
- TestArraySubclassing(Float32Array);
- TestArraySubclassing(Float64Array);
+ TestTypedArraySubclassing(Int8Array);
+ TestTypedArraySubclassing(Uint8Array);
+ TestTypedArraySubclassing(Uint8ClampedArray);
+ TestTypedArraySubclassing(Int16Array);
+ TestTypedArraySubclassing(Uint16Array);
+ TestTypedArraySubclassing(Int32Array);
+ TestTypedArraySubclassing(Uint32Array);
+ TestTypedArraySubclassing(Float32Array);
+ TestTypedArraySubclassing(Float64Array);
})();
« no previous file with comments | « test/mjsunit/es6/built-in-accessor-names.js ('k') | test/mjsunit/es6/typed-array-iterator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698