blob: b45b6b7ad21a1b2d4e0c861a85ca30564b497674 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001Tests for ES6 class syntax "super"
2
3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4
5
6PASS (new Base) instanceof Base is true
7PASS (new Derived) instanceof Derived is true
8PASS (new Derived).callBaseMethod() is baseMethodValue
9PASS x = (new Derived).callBaseMethod; x() is baseMethodValue
10PASS (new Derived).callBaseMethodInGetter is baseMethodValue
11PASS (new Derived).callBaseMethodInSetter = 1; valueInSetter is baseMethodValue
12PASS (new Derived).baseMethodInGetterSetter is (new Base).baseMethod
13PASS (new Derived).baseMethodInGetterSetter = 1; valueInSetter is (new Base).baseMethod
14PASS Derived.staticMethod() is "base3"
15PASS (new SecondDerived).chainMethod() is ["base", "derived", "secondDerived"]
16PASS x = class extends Base { constructor() { super(); } super() {} } did not throw exception.
17PASS x = class extends Base { constructor() { super(); } method() { super() } } threw exception SyntaxError: 'super' keyword unexpected here.
18PASS x = class extends Base { constructor() { super(); } method() { super } } threw exception SyntaxError: 'super' keyword unexpected here.
19PASS x = class extends Base { constructor() { super(); } method() { return new super } } threw exception SyntaxError: 'super' keyword unexpected here.
20PASS x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } } did not throw exception.
21PASS (new x).method1() threw exception ReferenceError: Unsupported reference to 'super'.
22PASS (new x).method2() threw exception ReferenceError: Unsupported reference to 'super'.
23PASS new (class { constructor() { return undefined; } }) instanceof Object is true
24PASS new (class { constructor() { return 1; } }) instanceof Object is true
25PASS new (class extends Base { constructor() { return undefined } }) threw exception ReferenceError: this is not defined.
26PASS new (class extends Base { constructor() { super(); return undefined } }) instanceof Object is true
27PASS x = { }; new (class extends Base { constructor() { return x } }); is x
28PASS x instanceof Base is false
29PASS new (class extends Base { constructor() { } }) threw exception ReferenceError: this is not defined.
30PASS new (class extends Base { constructor() { return 1; } }) threw exception TypeError: Derived constructors may only return object or undefined.
31PASS new (class extends null { constructor() { return undefined } }) threw exception ReferenceError: this is not defined.
32PASS new (class extends null { constructor() { super(); return undefined } }) threw exception TypeError: super is not a constructor.
33PASS x = { }; new (class extends null { constructor() { return x } }); is x
34PASS x instanceof Object is true
35PASS new (class extends null { constructor() { } }) threw exception ReferenceError: this is not defined.
36PASS new (class extends null { constructor() { return 1; } }) threw exception TypeError: Derived constructors may only return object or undefined.
37PASS new (class extends null { constructor() { super() } }) threw exception TypeError: super is not a constructor.
38PASS new (class { constructor() { super() } }) threw exception SyntaxError: 'super' keyword unexpected here.
39PASS function x() { super(); } threw exception SyntaxError: 'super' keyword unexpected here.
40PASS new (class extends Object { constructor() { function x() { super() } } }) threw exception SyntaxError: 'super' keyword unexpected here.
41PASS new (class extends Object { constructor() { function x() { super.method } } }) threw exception SyntaxError: 'super' keyword unexpected here.
42PASS function x() { super.method(); } threw exception SyntaxError: 'super' keyword unexpected here.
43PASS function x() { super(); } threw exception SyntaxError: 'super' keyword unexpected here.
44PASS successfullyParsed is true
45
46TEST COMPLETE