Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/race/resolve-non-obj.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: Resolving with a non-object value
5 es6id: 25.4.4.3
6 info: |
7 [...]
8 6. Let promiseCapability be NewPromiseCapability(C).
9 [...]
10 11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
11 [...]
12
13 25.4.4.3.1 Runtime Semantics: PerformPromiseRace
14 1. Repeat
15 [...]
16 j. Let result be Invoke(nextPromise, "then",
17 «promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
18
19 25.4.1.3.2 Promise Resolve Functions
20 [...]
21 7. If Type(resolution) is not Object, then
22 a. Return FulfillPromise(promise, resolution).
23 flags: [async]
24 ---*/
25
26 var thenable = {
27 then: function(resolve) {
28 resolve(23);
29 }
30 };
31
32 Promise.race([thenable])
33 .then(function(value) {
34 if (value !== 23) {
35 $DONE('The promise should be resolved with the correct value.');
36 return;
37 }
38 $DONE();
39 }, function() {
40 $DONE('The promise should not be rejected.');
41 });