summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/AsyncIterator/prototype/flatMap/inner-generator.js
blob: 08c0dfbba7940ad3e3c49ac11d02f9ff24dfcc15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator'))

//
//
/*---
esid: pending
description: %AsyncIterator.prototype%.flatMap innerIterator can be a generator.
info: >
  Iterator Helpers proposal 2.1.6.7
features: [iterator-helpers]
---*/

async function* gen() {
  yield 1;
  yield 2;
}

(async () => {
  const iter = gen().flatMap(async function*(x) {
    yield x;
    yield* [x + 1, x + 2];
  });

  for (const expected of [1, 2, 3, 2, 3, 4]) {
    const result = await iter.next();
    assertEq(result.value, expected);
    assertEq(result.done, false);
  }

  const result = await iter.next();
  assertEq(result.value, undefined);
  assertEq(result.done, true);
})();

if (typeof reportCompare == 'function')
  reportCompare(0, 0);