non-iterable-with-thenable-async-mapped-awaits-once.js (742B)
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 without mapping callback 9 includes: [asyncHelpers.js] 10 flags: [async] 11 features: [Array.fromAsync] 12 ---*/ 13 14 asyncTest(async function () { 15 const expectedValue = {}; 16 const expected = [ expectedValue ]; 17 let awaitCounter = 0; 18 const inputThenable = { 19 then (resolve, reject) { 20 awaitCounter++; 21 resolve(expectedValue); 22 }, 23 }; 24 const input = { 25 length: 1, 26 0: inputThenable, 27 }; 28 await Array.fromAsync(input, async v => v); 29 assert.sameValue(awaitCounter, 1); 30 });