test262/test/built-ins/Array/fromAsync/asyncitems-iterator-not-callable.js
Ms2ger 9704d7f22f
Add tests for the asyncItems argument to Array.fromAsync. (#3754)
Co-authored-by: Philip Chimento <pchimento@igalia.com>
2023-03-10 11:46:59 +01:00

20 lines
543 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 rejects if the @@iterator property is not callable
includes: [asyncHelpers.js]
flags: [async]
features: [Array.fromAsync]
---*/
asyncTest(async function () {
for (const v of [true, "", Symbol(), 1, 1n, {}]) {
await assert.throwsAsync(TypeError,
() => Array.fromAsync({ [Symbol.iterator]: v }),
`@@iterator = ${typeof v}`);
}
});