Debian Codegraph @

js/src/tests/test262/language/statements/async-generator/yield-star-promise-not-unwrapped.js

raw
1 // |reftest| async
2 // Copyright (C) 2022 Kevin Gibbons. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-generator-function-definitions-runtime-semantics-evaluation
7 description: >
8 `yield*` in an async generator does not await promises returned by a manually implemented async iterator.
9 flags: [async]
10 features: [async-iteration]
11 ---*/
12
13 var innerPromise = Promise.resolve("unwrapped value");
14
15 var asyncIter = {
16 [Symbol.asyncIterator]() {
17 return this;
18 },
19 next() {
20 return {
21 done: false,
22 value: innerPromise,
23 };
24 },
25 get return() {
26 throw new Test262Error(".return should not be accessed");
27 },
28 get throw() {
29 throw new Test262Error(".throw should not be accessed");
30 },
31 };
32
33 async function* f() {
34 yield* asyncIter;
35 }
36
37 f()
38 .next()
39 .then(v => {
40 assert.sameValue(v.value, innerPromise, "yield* should not unwrap promises from manually-implemented async iterators");
41 })
42 .then($DONE, $DONE)