summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/arrays/from-async-oom.js
blob: 8c01b12b437e8fc16dabb67cf3d333f62daca5ac (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
// |jit-test| --enable-array-from-async; skip-if: !Array.fromAsync|| !('oomTest' in this)

// Basic Smoke Test
async function* asyncGen(n) {
    for (let i = 0; i < n; i++) {
        yield i * 2;
    }
}

function test() {
    Array.fromAsync(asyncGen(4)).then((x) => {
        assertEq(Array.isArray(x), true);
        assertEq(x.length, 4);
        assertEq(x[0], 0);
        assertEq(x[1], 2);
        assertEq(x[2], 4);
        assertEq(x[3], 6);
        done = true;
    }
    );

    drainJobQueue();
}

oomTest(test);