summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/AsyncIterator/prototype/toArray/toArray.js
blob: 0a91e4d95ddf46cd903762a6bc575fa91ae39b06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator')) 

async function* gen() {
  yield 1;
  yield 2;
  yield 3;
}
assertEq(Array.isArray(gen()), false);

gen().toArray().then(array => {
  assertEq(Array.isArray(array), true);
  assertEq(array.length, 3);

  const expected = [1, 2, 3];
  for (const item of array) {
    const expect = expected.shift();
    assertEq(item, expect);
  }
});

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