| Tests for ES6 class syntax "extends" |
| |
| On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". |
| |
| |
| PASS (new Base) instanceof Base |
| PASS Object.getPrototypeOf(new Base):::Base.prototype |
| PASS (new Derived) instanceof Derived |
| PASS Object.getPrototypeOf(new Derived):::Derived.prototype |
| PASS Object.getPrototypeOf(Derived.prototype):::Base.prototype |
| PASS (new Derived).baseMethod():::"base" |
| PASS (new Derived).overridenMethod():::"derived" |
| PASS Derived.staticBaseMethod():::"base" |
| PASS Derived.staticOverridenMethod():::"derived" |
| PASS x = class extends:::SyntaxError: Unexpected end of script |
| PASS x = class extends:::SyntaxError: Unexpected end of script |
| PASS x = class extends Base {:::SyntaxError: Unexpected end of script |
| PASS x = class extends Base { } |
| PASS x = class extends Base { constructor() { } } |
| PASS x.__proto__:::Base |
| PASS Object.getPrototypeOf(x):::Base |
| PASS x.prototype.__proto__:::Base.prototype |
| PASS Object.getPrototypeOf(x.prototype):::Base.prototype |
| PASS x = class extends null { constructor() { } }; x.__proto__:::Function.prototype |
| PASS x.__proto__:::Function.prototype |
| PASS x = class extends 3 { constructor() { } }; x.__proto__:::TypeError: The superclass is not an object. |
| PASS x = class extends "abc" { constructor() { } }; x.__proto__:::TypeError: The superclass is not an object. |
| PASS baseWithBadPrototype = function () {}; baseWithBadPrototype.prototype = 3; new baseWithBadPrototype |
| PASS x = class extends baseWithBadPrototype { constructor() { } }:::TypeError: The value of the superclass's prototype property is not an object. |
| PASS baseWithBadPrototype.prototype = "abc" |
| PASS x = class extends baseWithBadPrototype { constructor() { } }:::TypeError: The value of the superclass's prototype property is not an object. |
| PASS baseWithBadPrototype.prototype = null; x = class extends baseWithBadPrototype { constructor() { } } |
| PASS x = 1; c = class extends ++x { constructor() { } };:::SyntaxError: Unexpected token '++' |
| PASS x = 1; c = class extends x++ { constructor() { } };:::SyntaxError: Unexpected token '++'. Expected opening '{' at the start of a class body. |
| PASS x = 1; c = class extends (++x) { constructor() { } };:::TypeError: The superclass is not an object. |
| PASS x = 1; c = class extends (x++) { constructor() { } };:::TypeError: The superclass is not an object. |
| PASS x = 1; try { c = class extends (++x) { constructor() { } } } catch (e) { }; x:::2 |
| PASS x = 1; try { c = class extends (x++) { constructor() { } } } catch (e) { }; x:::2 |
| PASS namespace = {}; namespace.A = class { }; namespace.B = class extends namespace.A { } |
| PASS namespace = {}; namespace.A = class A { }; namespace.B = class B extends namespace.A { } |
| PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends namespace.A { constructor() { } } |
| PASS namespace = {}; namespace.A = class A { constructor() { } }; namespace.B = class B extends namespace.A { constructor() { } } |
| PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (namespace.A) { constructor() { } } |
| PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends namespace["A"] { constructor() { } } |
| PASS namespace = {}; namespace.A = class { constructor() { } }; function getClassA() { return namespace.A }; namespace.B = class extends getClassA() { constructor() { } } |
| PASS namespace = {}; namespace.A = class { constructor() { } }; function getClass(prop) { return namespace[prop] }; namespace.B = class extends getClass("A") { constructor() { } } |
| PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (false||null||namespace.A) { constructor() { } } |
| PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends false||null||namespace.A { constructor() { } }:::SyntaxError: Unexpected token '||'. Expected opening '{' at the start of a class body. |
| PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (x++, namespace.A) { constructor() { } }; |
| PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (namespace.A, x++) { constructor() { } };:::TypeError: The superclass is not an object. |
| PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends new namespace.A { constructor() { } }:::TypeError: The value of the superclass's prototype property is not an object. |
| PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends new namespace.A() { constructor() { } }:::TypeError: The value of the superclass's prototype property is not an object. |
| PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; try { namespace.B = class extends (x++, namespace.A) { constructor() { } } } catch (e) { } x:::2 |
| PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; try { namespace.B = class extends (namespace.A, x++) { constructor() { } } } catch (e) { } x:::2 |
| PASS Object.getPrototypeOf((class { constructor () { } }).prototype):::Object.prototype |
| PASS Object.getPrototypeOf((class extends null { constructor () { super(); } }).prototype):::null |
| PASS new (class extends undefined { constructor () { this } }):::TypeError: The superclass is not an object. |
| PASS x = undefined; new (class extends x { constructor () { super(); } }):::TypeError: The superclass is not an object. |
| PASS class x {}; new (class extends null { constructor () { return new x; } }) instanceof x |
| PASS new (class extends null { constructor () { this; } }):::ReferenceError: Cannot access uninitialized variable. |
| PASS new (class extends null { constructor () { super(); } }):::TypeError: function is not a constructor (evaluating 'super()') |
| PASS x = {}; new (class extends null { constructor () { return x } }):::x |
| PASS y = 12; class C extends null { constructor () { return y; } }; new C;:::TypeError: Cannot return a non-object type in the constructor of a derived class. |
| PASS class x {}; new (class extends null { constructor () { return new x; } }) instanceof x |
| PASS x = null; Object.getPrototypeOf((class extends x { }).prototype):::null |
| PASS Object.prototype.isPrototypeOf(class { }) |
| PASS Function.prototype.isPrototypeOf(class { }) |
| PASS successfullyParsed |
| |
| TEST COMPLETE |
| |