aboutsummaryrefslogtreecommitdiff
path: root/test/js/async_throw_catch.t.js
blob: cafcab4c99e89a3abffdd41d16e36b8d612c7052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*---
includes: []
flags: [async]
---*/

function pr(x) {
    return new Promise(resolve => {resolve(x)}).then(v => {throw v}).catch(v => v);
}

async function add(x) {
    const a = await pr(x);
    const b = await pr(x + 10);

    return a + b;
}

add(50).then(v => {
    assert.sameValue(v, 110);
})
.then($DONE, $DONE);