1// Copyright JS Foundation and other contributors, http://js.foundation 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15var setterCalled = false; 16 17class Base { 18 func () { 19 return 5; 20 } 21 funcArrow () { 22 return () => 5; 23 } 24 ["com" + "puted"] () { 25 return 10; 26 } 27 get getter () { 28 return 6; 29 } 30 set setter (a) { 31 setterCalled = true; 32 } 33 getSuperValueOf() { 34 return super.valueOf; 35 } 36} 37 38class Derived extends Base { 39 func () { 40 return super.func(); 41 } 42 funcArrow () { 43 return () => super.func(); 44 } 45 ["com" + "puted"] () { 46 return super["com" + "puted"](); 47 } 48 get getter () { 49 return super.getter; 50 } 51 set setter (a) { 52 super.setter = a; 53 } 54 deleteSuperReference () { 55 delete super.a; 56 } 57} 58 59var derived = new Derived; 60var base = new Base; 61 62assert (derived.func() === 5); 63assert (derived.funcArrow()() === 5); 64assert (derived.computed() === 10); 65assert (derived.getter === 6); 66derived.setter = 7; 67assert (setterCalled === true); 68assert (base.getSuperValueOf() === Object.prototype.valueOf); 69 70try { 71 derived.deleteSuperReference(); 72 assert (false); 73} catch (e) { 74 assert (e instanceof ReferenceError); 75} 76