packages/babel-plugin-proposal-async-generator-functions/test/fixtures/yield-star/ecma262-pr-2819/exec.js
raw| 1 | // https://github.com/tc39/ecma262/pull/2819 |
| 2 | |
| 3 | let done = false; |
| 4 | let inner = { |
| 5 | [Symbol.asyncIterator]: () => ({ |
| 6 | next() { |
| 7 | if (done) { |
| 8 | return Promise.resolve({ done: true }); |
| 9 | } |
| 10 | done = true; |
| 11 | return Promise.resolve({ done: false, value: Promise.resolve(0) }); |
| 12 | }, |
| 13 | }), |
| 14 | }; |
| 15 | |
| 16 | async function* outer() { |
| 17 | yield* inner; |
| 18 | } |
| 19 | |
| 20 | return (async function () { |
| 21 | for await (let x of outer()) { |
| 22 | expect(x).toBeInstanceOf(Promise); |
| 23 | expect(await x).toBe(0); |
| 24 | } |
| 25 | })(); |