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 c65818eccaf1e297a25b6ea7fdc60c3011127967..4d640a918c442e6569c9c90b23d2682a341758ea 100644 |
--- a/test/mjsunit/es6/classes-subclass-builtins.js |
+++ b/test/mjsunit/es6/classes-subclass-builtins.js |
@@ -18,6 +18,30 @@ function checkPrototypeChain(object, constructors) { |
(function() { |
+ class A extends Function { |
+ constructor(...args) { |
+ assertTrue(%IsConstructCall()); |
+ super(...args); |
+ this.a = 42; |
+ } |
+ } |
+ |
+ 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); |
+ 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()); |
@@ -294,6 +318,42 @@ 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; |
+ } |
+ } |
+ 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); |
+ |
+ 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()); |