2015-03-09 23:47:06 +00:00
Tests for ES6 class syntax "super"
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
2015-07-31 21:05:19 +00:00
PASS (new Base) instanceof Base
PASS (new Derived) instanceof Derived
2016-03-17 09:46:07 +00:00
PASS (new DerivedWithEval) instanceof DerivedWithEval
2021-01-02 19:27:42 +00:00
PASS (new DerivedWithEval(true)):::ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object.
2015-07-31 21:05:19 +00:00
PASS (new Derived).callBaseMethod():::baseMethodValue
PASS x = (new Derived).callBaseMethod; x():::baseMethodValue
PASS (new Derived).callBaseMethodInGetter:::baseMethodValue
PASS (new Derived).callBaseMethodInSetter = 1; valueInSetter:::baseMethodValue
PASS (new Derived).baseMethodInGetterSetter:::(new Base).baseMethod
PASS (new Derived).baseMethodInGetterSetter = 1; valueInSetter:::(new Base).baseMethod
PASS Derived.staticMethod():::"base3"
PASS (new SecondDerived).chainMethod().toString():::["base", "derived", "secondDerived"].toString()
2016-01-12 03:02:07 +00:00
PASS x = class extends Base { constructor() { super(); } super() {} }
2016-04-22 23:04:55 +00:00
PASS x = class extends Base { constructor() { super(); } method() { super() } }:::SyntaxError: super is not valid in this context.
PASS x = class extends Base { constructor() { super(); } method() { super } }:::SyntaxError: super is not valid in this context.
2020-08-29 07:11:42 +00:00
PASS x = class extends Base { constructor() { super(); } method() { return new super } }:::SyntaxError: Cannot use new with super call.
2015-07-31 21:05:19 +00:00
PASS x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } }
PASS (new x).method1():::ReferenceError: Cannot delete a super property
PASS (new x).method2():::ReferenceError: Cannot delete a super property
2017-01-20 11:43:24 +00:00
PASS (new (class { constructor() { super.property = "ABC"; } })).property === "ABC"
PASS (new (class extends Base { constructor() { super(); super.property = "ABC"; } })).property === "ABC"
PASS (new (class { constructor() { var arr = () => super.property = "ABC"; arr(); } })).property === "ABC"
PASS (new (class { constructor() { var async_arr = async () => super.property = "ABC"; async_arr(); } })).property === "ABC"
PASS (new (class { constructor() { eval('super.property = "ABC"'); } })).property === "ABC"
PASS (new (class { constructor() { var arr = () => eval('super.property = "ABC"'); arr(); } })).property === "ABC"
2015-07-31 21:05:19 +00:00
PASS new (class { constructor() { return undefined; } }) instanceof Object
PASS new (class { constructor() { return 1; } }) instanceof Object
2021-01-02 19:27:42 +00:00
PASS new (class extends Base { constructor() { return undefined } }):::ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object.
2015-07-31 21:05:19 +00:00
PASS new (class extends Base { constructor() { super(); return undefined } }) instanceof Object
PASS x = { }; new (class extends Base { constructor() { return x } });:::x
PASS x instanceof Base
2021-01-02 19:27:42 +00:00
PASS new (class extends Base { constructor() { } }):::ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object.
2015-07-31 21:05:19 +00:00
PASS new (class extends Base { constructor() { return 1; } }):::TypeError: Cannot return a non-object type in the constructor of a derived class.
2021-01-02 19:27:42 +00:00
PASS new (class extends null { constructor() { return undefined } }):::ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object.
2015-10-11 18:46:52 +00:00
PASS new (class extends null { constructor() { super(); return undefined } }):::TypeError: function is not a constructor (evaluating 'super()')
2015-07-31 21:05:19 +00:00
PASS x = { }; new (class extends null { constructor() { return x } });:::x
PASS x instanceof Object
2021-01-02 19:27:42 +00:00
PASS new (class extends null { constructor() { } }):::ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object.
2017-06-20 10:27:41 +00:00
PASS new (class extends null { constructor() { return 1; } }):::TypeError: Cannot return a non-object type in the constructor of a derived class.
2015-10-11 18:46:52 +00:00
PASS new (class extends null { constructor() { super() } }):::TypeError: function is not a constructor (evaluating 'super()')
2016-04-22 23:04:55 +00:00
PASS new (class { constructor() { super() } }):::SyntaxError: super is not valid in this context.
PASS function x() { super(); }:::SyntaxError: super is not valid in this context.
PASS new (class extends Object { constructor() { function x() { super() } } }):::SyntaxError: super is not valid in this context.
PASS new (class extends Object { constructor() { function x() { super.method } } }):::SyntaxError: super is not valid in this context.
PASS function x() { super.method(); }:::SyntaxError: super is not valid in this context.
PASS function x() { super(); }:::SyntaxError: super is not valid in this context.
PASS eval("super.method()"):::SyntaxError: super is not valid in this context.
PASS eval("super()"):::SyntaxError: super is not valid in this context.
PASS (function () { eval("super.method()");})():::SyntaxError: super is not valid in this context.
PASS (function () { eval("super()");})():::SyntaxError: super is not valid in this context.
PASS new (class { constructor() { (function () { eval("super()");})(); } }):::SyntaxError: super is not valid in this context.
PASS (new (class { method() { (function () { eval("super.method()");})(); }})).method():::SyntaxError: super is not valid in this context.
2016-04-26 18:40:41 +00:00
PASS new (class extends Base { constructor() { super(); super();}}):::ReferenceError: 'super()' can't be called more than once in a constructor.
2021-01-02 19:27:42 +00:00
PASS (new class D extends class { m() {}} { constructor() { eval('super["m"]()') } }):::ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object.
PASS new class extends class { m() {}} { constructor() { super["m"](super()) } }:::ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object.
PASS (new class D extends class { m() {}} { constructor(f) { super[f()]() } }(()=>"m")):::ReferenceError: 'super()' must be called in derived constructor before accessing |this| or returning non-object.
2016-04-28 15:12:10 +00:00
PASS (new class D extends class { m() {}} { constructor() { super(); eval('super["m"]()') } })
PASS new class extends class { m() {}} { constructor() { super(); super["m"](super()) } }:::ReferenceError: 'super()' can't be called more than once in a constructor.
PASS (new class D extends class { m() {}} { constructor(f) { super(); super[f()]() } }(()=>"m"))
2015-07-31 21:05:19 +00:00
PASS successfullyParsed
2015-03-09 23:47:06 +00:00
TEST COMPLETE