summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/cacheir/bound-construct-hook.js
blob: 6d31db4192beb01f1021991e1d94923cce056e1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function test() {
    // Some bound callables that we're unlikely to optimize better in CacheIR.
    var boundCtor = (new Proxy(Array, {})).bind(null, 1, 2, 3);
    var boundNonCtor = (new Proxy(x => x + 1, {})).bind(null, 1, 2, 3);

    for (var i = 0; i < 60; i++) {
        var fun = i < 40 ? boundCtor : boundNonCtor;
        var ex = null;
        try {
            var res = new fun(100, 101);
            assertEq(JSON.stringify(res), "[1,2,3,100,101]");
        } catch (e) {
            ex = e;
        }
        assertEq(ex === null, i < 40);
    }
}
test();