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

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

Issue 1415683007: Reland "[es6] Fix Function and GeneratorFunction built-ins subclassing." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@fix-subclass
Patch Set: Improved test Created 5 years, 1 month 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/runtime/runtime-object.cc ('k') | test/mjsunit/regress/regress-function-constructor-receiver.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 540486379f34df04bda51cde43bd970a7e04e7a4..afd0c03db22352ac97db9a16427a6af13f353c36 100644
--- a/test/mjsunit/es6/classes-subclass-builtins.js
+++ b/test/mjsunit/es6/classes-subclass-builtins.js
@@ -18,6 +18,32 @@ function checkPrototypeChain(object, constructors) {
(function() {
+ class A extends Function {
+ constructor(...args) {
+ assertTrue(%IsConstructCall());
+ super(...args);
+ this.a = 42;
+ this.d = 4.2;
+ }
+ }
+
+ var o = new A("this.foo = 153;");
+ assertTrue(o instanceof Object);
+ assertTrue(o instanceof Function);
+ assertTrue(o instanceof A);
+ assertEquals("function", typeof o);
+ checkPrototypeChain(o, [A, Function, Object]);
+ assertEquals(42, o.a);
+ assertEquals(4.2, o.d);
+ var oo = new o();
+ assertEquals(153, oo.foo);
+
+ var o1 = new A("return 312;");
+ assertTrue(%HaveSameMap(o, o1));
+})();
+
+
+(function() {
class A extends Boolean {
constructor(...args) {
assertTrue(%IsConstructCall());
@@ -325,6 +351,44 @@ function TestArraySubclassing(array) {
(function() {
+ // TODO(ishell): remove once GeneratorFunction is available.
+ var GeneratorFunction = (function*() {}).__proto__.constructor;
+ class A extends GeneratorFunction {
+ constructor(...args) {
+ assertTrue(%IsConstructCall());
+ super(...args);
+ this.a = 42;
+ this.d = 4.2;
+ }
+ }
+ var generator_func = new A("var index = 0; while (index < 5) { yield ++index; }");
+ assertTrue(generator_func instanceof Object);
+ assertTrue(generator_func instanceof Function);
+ assertTrue(generator_func instanceof GeneratorFunction);
+ assertTrue(generator_func instanceof A);
+ assertEquals("function", typeof generator_func);
+ checkPrototypeChain(generator_func, [A, GeneratorFunction, Function, Object]);
+ assertEquals(42, generator_func.a);
+ assertEquals(4.2, generator_func.d);
+
+ var o = new generator_func();
+ assertTrue(o instanceof Object);
+ assertTrue(o instanceof generator_func);
+ assertEquals("object", typeof o);
+
+ assertPropertiesEqual({done: false, value: 1}, o.next());
+ assertPropertiesEqual({done: false, value: 2}, o.next());
+ assertPropertiesEqual({done: false, value: 3}, o.next());
+ assertPropertiesEqual({done: false, value: 4}, o.next());
+ assertPropertiesEqual({done: false, value: 5}, o.next());
+ assertPropertiesEqual({done: true, value: undefined}, o.next());
+
+ var generator_func1 = new A("return 0;");
+ assertTrue(%HaveSameMap(generator_func, generator_func1));
+})();
+
+
+(function() {
class A extends Boolean {
constructor() {
assertTrue(%IsConstructCall());
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | test/mjsunit/regress/regress-function-constructor-receiver.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698