tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/reject-via-fn-immed.js
raw symbols SCIP| 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 immediate 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 p = new Promise(function(_, reject) { |
| 23 | returnValue = reject(thenable); |
| 24 | }); |
| 25 | |
| 26 | assert.sameValue(returnValue, undefined, '"reject" function return value'); |
| 27 | |
| 28 | p.then(function() { |
| 29 | $DONE('The promise should not be fulfilled.'); |
| 30 | }, function(x) { |
| 31 | if (x !== thenable) { |
| 32 | $DONE('The promise should be rejected with the resolution value.'); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | $DONE(); |
| 37 | }); |