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

let stages = [];

function pr(x) { return new Promise(resolve => {resolve(x)}); }

pr(10)
.then(async (v) => {
    stages.push("then before");
    let y = await pr(22);
    stages.push(`then ${v} ${y}`);
    return v + y;
})
.then(v => stages.push(`then2 ${v}`))
.catch(e => $DONOTEVALUATE())
.then(v => assert.compareArray(stages, ['then before', 'then 10 22', 'then2 32']))
.then($DONE, $DONE);