Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/all/invoke-then-error-reject.js

raw
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: >
6 Error thrown when invoking the instance's `then` method (rejecting Promise)
7 esid: sec-performpromiseall
8 es6id: 25.4.4.1
9 info: |
10 11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
11 12. If result is an abrupt completion,
12 a. If iteratorRecord.[[done]] is false, let result be
13 IteratorClose(iterator, result).
14 b. IfAbruptRejectPromise(result, promiseCapability).
15
16 [...]
17
18 25.4.4.1.1 Runtime Semantics: PerformPromiseAll
19
20 [...]
21 6. Repeat
22 [...]
23 r. Let result be Invoke(nextPromise, "then", «resolveElement,
24 resultCapability.[[Reject]]»).
25 s. ReturnIfAbrupt(result).
26 flags: [async]
27 ---*/
28
29 var promise = new Promise(function() {});
30 var error = new Test262Error();
31
32 promise.then = function() {
33 throw error;
34 };
35
36 Promise.all([promise]).then(function() {
37 $ERROR('The promise should be rejected');
38 }, function(reason) {
39 assert.sameValue(reason, error);
40 }).then($DONE, $DONE);