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 */ 15 16 var A = Array; 17 var order = 0; 18 19 function f () { 20 order++; 21 22 return function () { 23 return A; 24 } 25 } 26 27 var B = class extends f ()() { 28 constructor () { 29 assert (++order === 2); 30 eval ("eval ('super (1, 2, 3, 4)')"); 31 try { 32 super (1, 2, 3, 4, 5) 33 assert (false); 34 } catch (e) { 35 assert (e instanceof ReferenceError) 36 } 37 38 assert (this.g ()()()() === 10); 39 assert (eval ("eval ('this.g ()')()")()() === 10); 40 assert (eval ("eval ('this.g ()')")()()() === 10); 41 assert (eval ("eval ('this.g ()()()')")() === 10); 42 assert (eval ("eval ('this.g')")()()()() === 10); 43 this.push (5); 44 assert (this.length === 5) 45 eval ('this.push (6)'); 46 assert (this.length === 6); 47 eval ("eval ('this.push (7)')"); 48 this.j = 6; 49 return; 50 } 51 } 52 53 var C = class extends B { 54 g () { 55 return function () { 56 return () => { 57 return 10; 58 } 59 } 60 } 61 } 62 63 var D = class D extends C { 64 constructor () { 65 super (); 66 this.k = 5; 67 return 68 } 69 70 g () { 71 return eval ('super["g"]'); 72 } 73 } 74 75 assert (order === 1); 76 77 var d = new D; 78 assert (d.length === 7); 79 assert (d.k === 5); 80 assert (d.j === 6); 81 assert (d instanceof D); 82 assert (d instanceof C); 83 assert (d instanceof B); 84 assert (d instanceof f ()()); 85 assert (JSON.stringify (d) === "[1,2,3,4,5,6,7]"); 86