summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/class/super-in-nested-eval.js
blob: 8786de4ba780889f71bcfab07d10f67beedfe24c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// |jit-test| allow-overrecursed

// Test super() and super.foo() calls in deeply nested eval.

class C {
    constructor(x) { this.x = x; }
    foo() { this.x++; }
}
class D extends C {
    constructor(depth) {
        var d = depth;
        var callsuper = 'super(depth); super.foo();';
        var s = "var q; if (d-- > 0) { eval(s) } else { eval(callsuper); }";
        eval(s);
    }
}

const MAX_DEPTH = 250;

// These values should work.
var depths = [0, 1, 10, 200, MAX_DEPTH];
for (var d of depths) {
    var o = new D(d);
    assertEq(o.x, d + 1);
}

// This should fail.
var ex;
try {
    new D(MAX_DEPTH + 1);
} catch(e) {
    ex = e;
}
assertEq(ex instanceof InternalError, true);