test262/test/built-ins/Array/fromAsync/asyncitems-arraylike-promise.js
Philip Chimento 63e0986803 Improve printing of property key names in observer helpers
These should be formatted in the same way that they'd be entered in source
code.
2023-04-24 12:14:18 +02:00

32 lines
893 B
JavaScript

// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.fromasync
description: >
Array.fromAsync tries the various properties in order and awaits promises
includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js]
flags: [async]
features: [Array.fromAsync]
---*/
asyncTest(async function () {
const actual = [];
const items = TemporalHelpers.propertyBagObserver(actual, {
length: 2,
0: Promise.resolve(2),
1: Promise.resolve(1),
}, "items");
const result = await Array.fromAsync(items);
assert.compareArray(result, [2, 1]);
assert.compareArray(actual, [
"get items[Symbol.asyncIterator]",
"get items[Symbol.iterator]",
"get items.length",
"get items.length.valueOf",
"call items.length.valueOf",
"get items[0]",
"get items[1]",
]);
});