Debian Codegraph @

js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-promise.js

raw
1 // |reftest| async
2 // Copyright (C) 2022 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 Array.fromAsync tries the various properties in order and awaits promises
9 includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js]
10 flags: [async]
11 features: [Array.fromAsync]
12 ---*/
13
14 asyncTest(async function () {
15 const actual = [];
16 const items = TemporalHelpers.propertyBagObserver(actual, {
17 length: 2,
18 0: Promise.resolve(2),
19 1: Promise.resolve(1),
20 }, "items");
21 const result = await Array.fromAsync(items);
22 assert.compareArray(result, [2, 1]);
23 assert.compareArray(actual, [
24 "get items[Symbol.asyncIterator]",
25 "get items[Symbol.iterator]",
26 "get items.length",
27 "get items.length.valueOf",
28 "call items.length.valueOf",
29 "get items[0]",
30 "get items[1]",
31 ]);
32 });