super-in-nested-eval.js (728B)
1 // |jit-test| allow-overrecursed 2 3 // Test super() and super.foo() calls in deeply nested eval. 4 5 class C { 6 constructor(x) { this.x = x; } 7 foo() { this.x++; } 8 } 9 class D extends C { 10 constructor(depth) { 11 var d = depth; 12 var callsuper = 'super(depth); super.foo();'; 13 var s = "var q; if (d-- > 0) { eval(s) } else { eval(callsuper); }"; 14 eval(s); 15 } 16 } 17 18 // These values should work. 19 var depths = [0, 1, 10, 200, 300]; 20 for (var d of depths) { 21 var o = new D(d); 22 assertEq(o.x, d + 1); 23 } 24 25 // When we use a large enough depth that we run out of stack, we throw instead 26 // of crashing 27 var ex; 28 try { 29 new D(2000); 30 } catch(e) { 31 ex = e; 32 } 33 assertEq(ex instanceof InternalError, true);