superproperty.js (573B)
1 // SuperProperty syntax is allowed in fields. 2 3 class Base { 4 get accessor() { 5 return this.constructor.name; 6 } 7 method() { 8 return this.constructor.name; 9 } 10 } 11 12 class Derived extends Base { 13 constructor() { 14 super(); 15 } 16 get accessor() { 17 throw new Error("don't call this"); 18 } 19 method() { 20 throw new Error("don't call this"); 21 } 22 field1 = super.accessor; 23 field2 = super.method(); 24 } 25 26 assertEq(new Derived().field1, "Derived"); 27 assertEq(new Derived().field2, "Derived"); 28 29 if (typeof reportCompare === "function") { 30 reportCompare(true, true); 31 }