diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js new file mode 100644 index 0000000000..19fea4fdfa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js @@ -0,0 +1,31 @@ +// |reftest| async +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.fromasync +description: > + Async-iterable awaits each input once with mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + async function* generateInput () { + yield* [ 0, 1, 2 ]; + } + const input = generateInput(); + let awaitCounter = 0; + await Array.fromAsync(input, v => { + return { + // This “then” method should occur three times: + // one for each value from the input. + then (resolve, reject) { + awaitCounter ++; + resolve(v); + }, + }; + }); + assert.sameValue(awaitCounter, 3); +}); |