Debian Codegraph @

js/src/tests/test262/built-ins/Promise/all/resolve-non-thenable.js

raw
1 // |reftest| async
2 // Copyright (C) 2016 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: Resolving with a non-thenable object value
6 es6id: 25.4.4.1
7 info: |
8 [...]
9 6. Let promiseCapability be NewPromiseCapability(C).
10 [...]
11 11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
12 [...]
13
14 25.4.4.1.1 Runtime Semantics: PerformPromiseAll
15 [...]
16 6. Repeat
17 [...]
18 d. If next is false,
19 [...]
20 iii. If remainingElementsCount.[[value]] is 0,
21 1. Let valuesArray be CreateArrayFromList(values).
22 2. Let resolveResult be Call(resultCapability.[[Resolve]],
23 undefined, «valuesArray»).
24 3. ReturnIfAbrupt(resolveResult)
25 iv. Return resultCapability.[[Promise]].
26
27 25.4.1.3.2 Promise Resolve Functions
28 [...]
29 8. Let then be Get(resolution, "then").
30 9. If then is an abrupt completion, then
31 [...]
32 10. Let thenAction be then.[[value]].
33 11. If IsCallable(thenAction) is false, then
34 a. Return FulfillPromise(promise, resolution).
35 flags: [async]
36 ---*/
37
38 var v1 = {};
39 var v2 = {};
40 var v3 = {};
41
42 Promise.all([v1, v2, v3])
43 .then(function(values) {
44 if (!values) {
45 $DONE('The promise should be resolved with a value.');
46 return;
47 }
48 if (values.constructor !== Array) {
49 $DONE('The promise should be resolved with an Array instance.');
50 return;
51 }
52
53 if (values.length !== 3) {
54 $DONE('The promise should be resolved with an array of proper length.');
55 return;
56 }
57
58 if (values[0] !== v1) {
59 $DONE('The promise should be resolved with the correct element values (#1)');
60 return;
61 }
62
63 if (values[1] !== v2) {
64 $DONE('The promise should be resolved with the correct element values (#2)');
65 return;
66 }
67
68 if (values[2] !== v3) {
69 $DONE('The promise should be resolved with the correct element values (#3)');
70 return;
71 }
72
73 $DONE();
74 }, function() {
75 $DONE('The promise should not be rejected.');
76 });