summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Iterator/prototype/map/call-next-on-iterator-while-iterating.js
blob: a5a10120a0d72ff1d9844ddb0e2d5d2329c0e2a3 (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
// |reftest| skip-if(!this.hasOwnProperty('Iterator'))

/*---
esid: pending
description: Call next on an iterator that is being iterated over.
info:
features: [iterator-helpers]
---*/

const iterator = [1, 2, 3].values()
const items = [];

for (const item of iterator.map(x => x ** 2)) {
  const nextItem = iterator.next();
  items.push(item, nextItem.value);
}

assertEq(items[0], 1);
assertEq(items[1], 2);
assertEq(items[2], 9);
assertEq(items[3], undefined);

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