Debian Codegraph @

js/src/tests/test262/built-ins/Promise/race/resolve-non-callable.js

raw
1 // |reftest| async
2 // Copyright (C) 2020 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-promise.race
7 description: >
8 Promise.resolve is retrieved before GetIterator call (non-callable).
9 info: |
10 Promise.race ( iterable )
11
12 [...]
13 3. Let promiseResolve be GetPromiseResolve(C).
14 4. IfAbruptRejectPromise(promiseResolve, promiseCapability).
15
16 GetPromiseResolve ( promiseConstructor )
17
18 [...]
19 2. Let promiseResolve be ? Get(promiseConstructor, "resolve").
20 3. If IsCallable(promiseResolve) is false, throw a TypeError exception.
21 flags: [async]
22 features: [Symbol.iterator]
23 ---*/
24
25 const iter = { 
26 get [Symbol.iterator]() {
27 throw new Test262Error("unreachable");
28 },
29 };
30
31 Promise.resolve = "certainly not callable";
32
33 Promise.race(iter).then(() => {
34 throw new Test262Error("The promise should be rejected, but it was resolved");
35 }, (reason) => {
36 assert(reason instanceof TypeError);
37 }).then($DONE, $DONE);