Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/all/S25.4.4.1_A7.1_T1.js

raw
1 // Copyright 2014 Cubane Canada, Inc. All rights reserved.
2 // See LICENSE for details.
3
4 /*---
5 info: |
6 Promise.all with 1-element array
7 should accept an array with settled promise
8 es6id: S25.4.4.1_A6.1_T2
9 author: Sam Mikes
10 description: Promise.all([p1]) is resolved with a promise for a one-element array
11 flags: [async]
12 ---*/
13
14 var p1 = Promise.resolve(3);
15
16 var pAll = Promise.all([p1]);
17
18 pAll.then(function(result) {
19 if (!(pAll instanceof Promise)) {
20 $ERROR("Expected Promise.all() to be promise, actually " + pAll);
21 }
22 if (!(result instanceof Array)) {
23 $ERROR("Expected Promise.all() to be promise for an Array, actually " + result);
24 }
25 if (result.length !== 1) {
26 $ERROR("Expected Promise.all([p1]) to be a promise for one-element Array, actually " + result);
27 }
28 if (result[0] !== 3) {
29 $ERROR("Expected result[0] to be 3, actually " + result[0]);
30 }
31 }).then($DONE, $DONE);