Debian Codegraph @

js/src/tests/test262/built-ins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js

raw
1 // |reftest| async
2 // Copyright (C) 2023 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-array.fromasync
7 description: >
8 Non-iterable input with thenables awaits each input once with mapping callback
9 includes: [asyncHelpers.js]
10 flags: [async]
11 features: [Array.fromAsync]
12 ---*/
13
14 asyncTest(async function () {
15 const expectedValue = {};
16 let awaitCounter = 0;
17 const inputThenable = {
18 then (resolve, reject) {
19 awaitCounter++;
20 resolve(expectedValue);
21 },
22 };
23 const input = {
24 length: 1,
25 0: inputThenable,
26 };
27 await Array.fromAsync(input, v => v);
28 assert.sameValue(awaitCounter, 1);
29 });