Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/reject-via-fn-deferred.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: Rejecting through deferred invocation of the provided resolving function
5 es6id: 25.4.3.1
6 info: |
7 [...]
8 9. Let completion be Call(executor, undefined,
9 «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
10 10. If completion is an abrupt completion, then
11 [...]
12 11. Return promise.
13
14 25.4.1.3.1 Promise Reject Functions
15 [...]
16 6. Return RejectPromise(promise, reason).
17 flags: [async]
18 ---*/
19
20 var thenable = new Promise(function() {});
21 var returnValue = null;
22 var reject;
23 var p = new Promise(function(_, _reject) {
24 reject = _reject;
25 });
26
27 p.then(function() {
28 $DONE('The promise should not be fulfilled.');
29 }, function(x) {
30 if (x !== thenable) {
31 $DONE('The promise should be rejected with the resolution value.');
32 return;
33 }
34
35 $DONE();
36 });
37
38 returnValue = reject(thenable);
39
40 assert.sameValue(returnValue, undefined, '"reject" function return value');