asyncitems-arraylike-length-accessor-throws.js (833B)
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: Rejects on array-like object whose length cannot be gotten 8 info: | 9 3.k.iii. Let _len_ be ? LengthOfArrayLike(_arrayLike_). 10 features: [Array.fromAsync] 11 flags: [async] 12 includes: [asyncHelpers.js] 13 ---*/ 14 15 asyncTest(async function () { 16 await assert.throwsAsync(Test262Error, () => Array.fromAsync({ 17 get length() { 18 throw new Test262Error('accessing length property fails'); 19 } 20 }), "Promise should be rejected if array-like length getter throws"); 21 22 await assert.throwsAsync(TypeError, () => Array.fromAsync({ 23 length: 1n, 24 0: 0 25 }), "Promise should be rejected if array-like length can't be converted to a number"); 26 });