summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/AsyncIterator/prototype/find/coerce-result-to-boolean.js
blob: eb89eca84006753164afab6da689b69d098e8d30 (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
// |reftest| skip-if(!this.hasOwnProperty('AsyncIterator')) 

async function* gen(value) {
  yield value;
}
const fn = x => x;
function check(value, expected) {
  gen(value).find(fn).then(result => assertEq(result, expected));
}

check(true, true);
check(1, 1);
check('test', 'test');

check(false, undefined);
check(0, undefined);
check('', undefined);
check(null, undefined);
check(undefined, undefined);
check(NaN, undefined);
check(-0, undefined);
check(0n, undefined);
check(Promise.resolve(false), undefined);

let array = [];
check(array, array);

let object = {};
check(object, object);

const htmlDDA = createIsHTMLDDA();
check(htmlDDA, undefined);

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