1Tests for ES6 class syntax "extends" 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 Object.getPrototypeOf(new Base) is Base.prototype 8PASS (new Derived) instanceof Derived is true 9PASS Object.getPrototypeOf(new Derived) is Derived.prototype 10PASS Object.getPrototypeOf(Derived.prototype) is Base.prototype 11PASS (new Derived).baseMethod() is "base" 12PASS (new Derived).overridenMethod() is "derived" 13PASS Derived.staticBaseMethod() is "base" 14PASS Derived.staticOverridenMethod() is "derived" 15PASS x = class extends threw exception SyntaxError: Unexpected end of input. 16PASS x = class extends threw exception SyntaxError: Unexpected end of input. 17PASS x = class extends Base { threw exception SyntaxError: Unexpected end of input. 18PASS x = class extends Base { } did not throw exception. 19PASS x = class extends Base { constructor() { } } did not throw exception. 20PASS x.__proto__ is Base 21PASS Object.getPrototypeOf(x) is Base 22PASS x.prototype.__proto__ is Base.prototype 23PASS Object.getPrototypeOf(x.prototype) is Base.prototype 24PASS x = class extends null { constructor() { } }; x.__proto__ is Function.prototype 25PASS x.__proto__ is Function.prototype 26PASS x = class extends 3 { constructor() { } }; x.__proto__ threw exception TypeError: Class extends value 3 is not a function or null. 27PASS x = class extends "abc" { constructor() { } }; x.__proto__ threw exception TypeError: Class extends value abc is not a function or null. 28PASS baseWithBadPrototype = function () {}; baseWithBadPrototype.prototype = 3; new baseWithBadPrototype did not throw exception. 29PASS x = class extends baseWithBadPrototype { constructor() { } } threw exception TypeError: Class extends value does not have valid prototype property 3. 30PASS baseWithBadPrototype.prototype = "abc" did not throw exception. 31PASS x = class extends baseWithBadPrototype { constructor() { } } threw exception TypeError: Class extends value does not have valid prototype property abc. 32PASS baseWithBadPrototype.prototype = null; x = class extends baseWithBadPrototype { constructor() { } } did not throw exception. 33PASS x = 1; c = class extends ++x { constructor() { } }; threw exception SyntaxError: Unexpected token ++. 34PASS x = 1; c = class extends x++ { constructor() { } }; threw exception SyntaxError: Unexpected token ++. 35PASS x = 1; c = class extends (++x) { constructor() { } }; threw exception TypeError: Class extends value 2 is not a function or null. 36PASS x = 1; c = class extends (x++) { constructor() { } }; threw exception TypeError: Class extends value 1 is not a function or null. 37PASS x = 1; try { c = class extends (++x) { constructor() { } } } catch (e) { }; x is 2 38PASS x = 1; try { c = class extends (x++) { constructor() { } } } catch (e) { }; x is 2 39PASS namespace = {}; namespace.A = class { }; namespace.B = class extends namespace.A { } did not throw exception. 40PASS namespace = {}; namespace.A = class A { }; namespace.B = class B extends namespace.A { } did not throw exception. 41PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends namespace.A { constructor() { } } did not throw exception. 42PASS namespace = {}; namespace.A = class A { constructor() { } }; namespace.B = class B extends namespace.A { constructor() { } } did not throw exception. 43PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (namespace.A) { constructor() { } } did not throw exception. 44PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends namespace["A"] { constructor() { } } did not throw exception. 45PASS namespace = {}; namespace.A = class { constructor() { } }; function getClassA() { return namespace.A }; namespace.B = class extends getClassA() { constructor() { } } did not throw exception. 46PASS namespace = {}; namespace.A = class { constructor() { } }; function getClass(prop) { return namespace[prop] }; namespace.B = class extends getClass("A") { constructor() { } } did not throw exception. 47PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (false||null||namespace.A) { constructor() { } } did not throw exception. 48PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends false||null||namespace.A { constructor() { } } threw exception SyntaxError: Unexpected token ||. 49PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (x++, namespace.A) { constructor() { } }; did not throw exception. 50PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (namespace.A, x++) { constructor() { } }; threw exception TypeError: Class extends value 1 is not a function or null. 51PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends new namespace.A { constructor() { } } threw exception TypeError: Class extends value [object Object] is not a function or null. 52PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends new namespace.A() { constructor() { } } threw exception TypeError: Class extends value [object Object] is not a function or null. 53PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; try { namespace.B = class extends (x++, namespace.A) { constructor() { } } } catch (e) { } x is 2 54PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; try { namespace.B = class extends (namespace.A, x++) { constructor() { } } } catch (e) { } x is 2 55PASS Object.getPrototypeOf((class { constructor () { } }).prototype) is Object.prototype 56PASS Object.getPrototypeOf((class extends null { constructor () { super(); } }).prototype) is null 57PASS new (class extends undefined { constructor () { this } }) threw exception TypeError: Class extends value undefined is not a function or null. 58PASS new (class extends undefined { constructor () { super(); } }) threw exception TypeError: Class extends value undefined is not a function or null. 59PASS x = {}; new (class extends undefined { constructor () { return x; } }) threw exception TypeError: Class extends value undefined is not a function or null. 60PASS y = 12; new (class extends undefined { constructor () { return y; } }) threw exception TypeError: Class extends value undefined is not a function or null. 61PASS class x {}; new (class extends null { constructor () { return new x; } }) instanceof x is true 62PASS new (class extends null { constructor () { this; } }) threw exception ReferenceError: this is not defined. 63PASS new (class extends null { constructor () { super(); } }) threw exception TypeError: super is not a constructor. 64PASS x = {}; new (class extends null { constructor () { return x } }) is x 65PASS y = 12; new (class extends null { constructor () { return y; } }) threw exception TypeError: Derived constructors may only return object or undefined. 66PASS class x {}; new (class extends null { constructor () { return new x; } }) instanceof x is true 67PASS x = null; Object.getPrototypeOf((class extends x { }).prototype) is null 68PASS Object.prototype.isPrototypeOf(class { }) is true 69PASS Function.prototype.isPrototypeOf(class { }) is true 70PASS successfullyParsed is true 71 72TEST COMPLETE 73