summaryrefslogtreecommitdiff
path: root/test/built-ins/Promise/all/S25.4.4.1_A8.1_T1.js
blob: 7a6d917d0e5dee40040e8cb6b74e94abe9cdfe62 (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
30
31
32
33
34
// Copyright 2014 Cubane Canada, Inc.  All rights reserved.
// See LICENSE for details.

/*---
es6id: S25.4.4.1_A8.1_T1
author: Sam Mikes
description: Promise.all([p1, p2]) resolution functions are called in predictable sequence
includes: [promiseHelper.js]
flags: [async]
---*/

var sequence = [];

var p1 = new Promise(function (resolve) { resolve(1); } );
var p2 = new Promise(function (resolve) { resolve(2); } );

sequence.push(1);

p1.then(function () {
    sequence.push(3);
    checkSequence(sequence, "Expected to be called first.");
}).catch($DONE);

Promise.all([p1, p2]).then(function () {
    sequence.push(5);
    checkSequence(sequence, "Expected to be called third.");
}).then($DONE, $DONE);

p2.then(function () {
    sequence.push(4);
    checkSequence(sequence, "Expected to be called second.");
}).catch($DONE);

sequence.push(2);