aboutsummaryrefslogtreecommitdiff
path: root/test/js/async_try_catch_call.t.js
blob: 6e8ef1043aadc0af5442b6e8400472df16110f6e (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
/*---
includes: [compareArray.js]
flags: [async]
---*/

let stages = [];
const fn = async () => { throw new Error('Oops') };

async function af() {
    try {
        await fn();

        $DONOTEVALUATE();
    }
    catch (v) {
        stages.push(`catch:${v}`);
    }
    finally {
        stages.push('finally');
    }

    return "end";
};

af().then(v => {
    stages.push(v);
    assert.compareArray(stages, ['catch:Error: Oops', 'finally', 'end']);
})
.then($DONE, $DONE)