superProp.js (1326B)
1 var g_get_this = "get_this"; 2 var g_prop_this = "prop_this"; 3 4 class Base 5 { 6 get get_prop() { return 7; } 7 get get_this() { return this; } 8 prop_call() { return 11; } 9 prop_this() { return this.x; } 10 } 11 Base.prototype.prop_proto = 5; 12 Base.prototype.x = (-1); 13 Base.prototype[0] = 100; 14 Base.prototype[1] = 101; 15 Base.prototype[2] = 102; 16 17 class Derived extends Base 18 { 19 get get_prop() { throw "Bad"; } 20 get get_this() { throw "Bad"; } 21 prop_call() { throw "Bad"; } 22 prop_this() { throw "Bad"; } 23 24 do_test_getprop() 25 { 26 this.x = 13; 27 28 assertEq(super.prop_proto, 5); 29 30 assertEq(super.get_prop, 7); 31 assertEq(super.get_this, this); 32 33 assertEq(super.prop_call(), 11); 34 assertEq(super.prop_this(), 13); 35 } 36 37 do_test_getelem() 38 { 39 this.x = 13; 40 41 assertEq(super[g_get_this], this); 42 43 assertEq(super[g_prop_this](), 13); 44 assertEq(super[0], 100); 45 assertEq(super[1], 101); 46 assertEq(super[2], 102); 47 } 48 } 49 Derived.prototype.prop_proto = (-1); 50 Derived.prototype.x = (-2); 51 Derived.prototype[0] = (-3); 52 Derived.prototype[1] = (-4); 53 Derived.prototype[2] = (-5); 54 55 for (var i = 0; i < 20; ++i) { 56 let t = new Derived(); 57 58 for (var j = 0; j < 20; ++j) { 59 t.do_test_getprop(); 60 t.do_test_getelem(); 61 } 62 }