summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/AsyncIterator/prototype/take/take-more-than-available.js
blob: 65355704ae720f82c453aeacb0abeacc66b7a065 (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
// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator'))

//
//
/*---
esid: pending
description: %AsyncIterator.prototype%.take returns if the iterator is done.
info: >
  Iterator Helpers proposal 2.1.6.4
  2. Repeat,
    ...
    c. Let next be ? Await(? IteratorNext(iterated, lastValue)).
    d. If ? IteratorComplete(next) is false, return undefined.
features: [iterator-helpers]
---*/

async function* gen(values) {
  yield* values;
}

(async () => {
  const iter = gen([1, 2]).take(10);
  for (const expected of [1, 2]) {
    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);