Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/race/invoke-resolve-error-reject.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 /*---
5 description: Promise rejection in response to error from `Promise.resolve`
6 esid: sec-promise.race
7 es6id: 25.4.4.3
8 info: |
9 [...]
10 11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
11 12. If result is an abrupt completion, then
12 a. If iteratorRecord.[[done]] is false, let result be
13 IteratorClose(iterator,result).
14 b. IfAbruptRejectPromise(result, promiseCapability).
15
16
17 25.4.4.3.1 Runtime Semantics: PerformPromiseRace
18
19 1. Repeat
20 [...]
21 h. Let nextPromise be Invoke(C, "resolve", «nextValue»).
22 i. ReturnIfAbrupt(nextPromise).
23 flags: [async]
24 ---*/
25
26 var err = new Test262Error();
27 var CustomPromise = function(executor) {
28 return new Promise(executor);
29 };
30
31 CustomPromise.resolve = function() {
32 throw err;
33 };
34
35 Promise.race.call(CustomPromise, [1])
36 .then(function() {
37 $ERROR('The promise should be rejected.');
38 }, function(reason) {
39 assert.sameValue(reason, err);
40 $DONE();
41 });