class-syntax-super-expected.txt 4.12 KB
Newer Older
arv's avatar
arv committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Tests for ES6 class syntax "super"

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS (new Base) instanceof Base is true
PASS (new Derived) instanceof Derived is true
PASS (new Derived).callBaseMethod() is baseMethodValue
PASS x = (new Derived).callBaseMethod; x() is baseMethodValue
PASS (new Derived).callBaseMethodInGetter is baseMethodValue
PASS (new Derived).callBaseMethodInSetter = 1; valueInSetter is baseMethodValue
PASS (new Derived).baseMethodInGetterSetter is (new Base).baseMethod
PASS (new Derived).baseMethodInGetterSetter = 1; valueInSetter is (new Base).baseMethod
PASS Derived.staticMethod() is "base3"
PASS (new SecondDerived).chainMethod() is ["base", "derived", "secondDerived"]
PASS x = class extends Base { constructor() { super(); } super() {} } did not throw exception.
PASS x = class extends Base { constructor() { super(); } method() { super() } } threw exception SyntaxError: 'super' keyword unexpected here.
PASS x = class extends Base { constructor() { super(); } method() { super } } threw exception SyntaxError: 'super' keyword unexpected here.
PASS x = class extends Base { constructor() { super(); } method() { return new super } } threw exception SyntaxError: 'super' keyword unexpected here.
PASS x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } } did not throw exception.
PASS (new x).method1() threw exception ReferenceError: Unsupported reference to 'super'.
PASS (new x).method2() threw exception ReferenceError: Unsupported reference to 'super'.
PASS new (class { constructor() { return undefined; } }) instanceof Object is true
PASS new (class { constructor() { return 1; } }) instanceof Object is true
25
PASS new (class extends Base { constructor() { return undefined } }) threw exception ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor.
arv's avatar
arv committed
26 27 28
PASS new (class extends Base { constructor() { super(); return undefined } }) instanceof Object is true
PASS x = { }; new (class extends Base { constructor() { return x } }); is x
PASS x instanceof Base is false
29
PASS new (class extends Base { constructor() { } }) threw exception ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor.
arv's avatar
arv committed
30
PASS new (class extends Base { constructor() { return 1; } }) threw exception TypeError: Derived constructors may only return object or undefined.
31
PASS new (class extends null { constructor() { return undefined } }) threw exception ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor.
32
PASS new (class extends null { constructor() { super(); return undefined } }) threw exception TypeError: Super constructor null of anonymous class is not a constructor.
arv's avatar
arv committed
33 34
PASS x = { }; new (class extends null { constructor() { return x } }); is x
PASS x instanceof Object is true
35
PASS new (class extends null { constructor() { } }) threw exception ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor.
arv's avatar
arv committed
36
PASS new (class extends null { constructor() { return 1; } }) threw exception TypeError: Derived constructors may only return object or undefined.
37
PASS new (class extends null { constructor() { super() } }) threw exception TypeError: Super constructor null of anonymous class is not a constructor.
arv's avatar
arv committed
38 39 40 41 42 43 44 45 46
PASS new (class { constructor() { super() } }) threw exception SyntaxError: 'super' keyword unexpected here.
PASS function x() { super(); } threw exception SyntaxError: 'super' keyword unexpected here.
PASS new (class extends Object { constructor() { function x() { super() } } }) threw exception SyntaxError: 'super' keyword unexpected here.
PASS new (class extends Object { constructor() { function x() { super.method } } }) threw exception SyntaxError: 'super' keyword unexpected here.
PASS function x() { super.method(); } threw exception SyntaxError: 'super' keyword unexpected here.
PASS function x() { super(); } threw exception SyntaxError: 'super' keyword unexpected here.
PASS successfullyParsed is true

TEST COMPLETE