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

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

const log = [];
const fn = (value) => {
  log.push(value.toString());
  return value % 2 == 0;
};

gen().find(fn).then(result => {
  assertEq(result, 2);
  assertEq(log.join(','), '1,2');
});

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