diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js new file mode 100644 index 0000000000..81932ec791 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js @@ -0,0 +1,26 @@ +// |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: Rejects on array-like object whose length cannot be gotten +info: | + 3.k.iii. Let _len_ be ? LengthOfArrayLike(_arrayLike_). +features: [Array.fromAsync] +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(Test262Error, () => Array.fromAsync({ + get length() { + throw new Test262Error('accessing length property fails'); + } + }), "Promise should be rejected if array-like length getter throws"); + + await assert.throwsAsync(TypeError, () => Array.fromAsync({ + length: 1n, + 0: 0 + }), "Promise should be rejected if array-like length can't be converted to a number"); +}); |