Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/race/invoke-resolve-get-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 retrieving the constructor's `resolve` method (promise rejection)
7 esid: sec-promise.race
8 es6id: 25.4.4.3
9 info: |
10 11. Let result be PerformPromiseRace(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.3.1 Runtime Semantics: PerformPromiseRace
19
20 1. Repeat
21 [...]
22 h. Let nextPromise be Invoke(C, "resolve", «nextValue»).
23 i. ReturnIfAbrupt(nextPromise).
24 flags: [async]
25 ---*/
26
27 var error = new Test262Error();
28 Object.defineProperty(Promise, 'resolve', {
29 get: function() {
30 throw error;
31 }
32 });
33
34 Promise.race([new Promise(function() {})]).then(function() {
35 $ERROR('The promise should be rejected');
36 }, function(reason) {
37 assert.sameValue(reason, error);
38 }).then($DONE, $DONE);