super-property-optional-call.js (679B)
1 // Copyright 2019 Google, LLC. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: prod-OptionalExpression 5 description: > 6 optional call invoked on super method should be equivalent to call 7 info: | 8 OptionalExpression 9 MemberExpression OptionalChain 10 SuperProperty OptionalChain 11 features: [optional-chaining] 12 ---*/ 13 14 let called = false; 15 let context; 16 class Base { 17 method() { 18 called = true; 19 context = this; 20 } 21 } 22 class Foo extends Base { 23 method() { 24 super.method?.(); 25 } 26 } 27 const foo = new Foo(); 28 foo.method(); 29 assert(foo === context); 30 assert.sameValue(called, true); 31 32 reportCompare(0, 0);