asyncitems-object-not-arraylike.js (729B)
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 Treats an asyncItems object that isn't an array-like as a 0-length array-like 9 info: | 10 3.k.iii. Let _len_ be ? LengthOfArrayLike(_arrayLike_). 11 features: [Array.fromAsync] 12 flags: [async] 13 includes: [asyncHelpers.js, compareArray.js] 14 ---*/ 15 16 asyncTest(async function () { 17 const notArrayLike = Object.create(null); 18 notArrayLike[0] = 0; 19 notArrayLike[1] = 1; 20 notArrayLike[2] = 2; 21 22 const array = await Array.fromAsync(notArrayLike); 23 assert.compareArray(array, [], "non-array-like object is treated as 0-length array-like"); 24 });