X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/e7f1624844b6bb27626d982ac046fddf68845136..d8b8bf6b37eb780a98bca3be06d2d98df4c83691:/iterable.test.js diff --git a/iterable.test.js b/iterable.test.js index 0f7c9fc..3651c6c 100644 --- a/iterable.test.js +++ b/iterable.test.js @@ -1,11 +1,14 @@ -// ♓🌟 Piscēs ∷ iterable.test.js -// ==================================================================== -// -// Copyright © 2023 Lady [@ Lady’s Computer]. -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at . +// SPDX-FileCopyrightText: 2023, 2025 Lady +// SPDX-License-Identifier: MPL-2.0 +/** + * ⁌ ♓🧩 Piscēs ∷ iterable.test.js + * + * Copyright © 2023, 2025 Lady [@ Ladys Computer]. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at . + */ import { assertEquals, @@ -126,6 +129,26 @@ describe("arrayIteratorFunction", () => { }); }); + it("[[Construct]] throws an error", () => { + const iterator = arrayIteratorFunction(); + assertThrows(() => new iterator([])); + }); + + describe(".length", () => { + it("[[Get]] returns the correct length", () => { + assertStrictEquals(arrayIteratorFunction().length, 1); + }); + }); + + describe(".name", () => { + it("[[Get]] returns the correct name", () => { + assertStrictEquals( + arrayIteratorFunction().name, + "values", + ); + }); + }); + describe("::next", () => { it("[[Call]] throws if there are values and the mapper is not a generator function", () => { const iterator = arrayIteratorFunction(function () {}); @@ -253,6 +276,26 @@ describe("generatorIteratorFunction", () => { }); }); + it("[[Construct]] throws an error", () => { + const iterator = generatorIteratorFunction(); + assertThrows(() => new iterator(function* () {})); + }); + + describe(".length", () => { + it("[[Get]] returns the correct length", () => { + assertStrictEquals(generatorIteratorFunction().length, 1); + }); + }); + + describe(".name", () => { + it("[[Get]] returns the correct name", () => { + assertStrictEquals( + generatorIteratorFunction().name, + "yields", + ); + }); + }); + describe("::next", () => { it("[[Call]] throws if there are values and the mapper is not a generator function", () => { const generator = function* () { @@ -378,6 +421,26 @@ describe("mapIteratorFunction", () => { }); }); + it("[[Construct]] throws an error", () => { + const iterator = mapIteratorFunction(); + assertThrows(() => new iterator(new Map())); + }); + + describe(".length", () => { + it("[[Get]] returns the correct length", () => { + assertStrictEquals(mapIteratorFunction().length, 1); + }); + }); + + describe(".name", () => { + it("[[Get]] returns the correct name", () => { + assertStrictEquals( + mapIteratorFunction().name, + "entries", + ); + }); + }); + describe("::next", () => { it("[[Call]] throws if there are values and the mapper is not a generator function", () => { const iterator = mapIteratorFunction(function () {}); @@ -493,6 +556,26 @@ describe("setIteratorFunction", () => { }); }); + it("[[Construct]] throws an error", () => { + const iterator = setIteratorFunction(); + assertThrows(() => new iterator(new Set())); + }); + + describe(".length", () => { + it("[[Get]] returns the correct length", () => { + assertStrictEquals(setIteratorFunction().length, 1); + }); + }); + + describe(".name", () => { + it("[[Get]] returns the correct name", () => { + assertStrictEquals( + setIteratorFunction().name, + "values", + ); + }); + }); + describe("::next", () => { it("[[Call]] throws if there are values and the mapper is not a generator function", () => { const iterator = setIteratorFunction(function () {}); @@ -613,6 +696,26 @@ describe("stringIteratorFunction", () => { }); }); + it("[[Construct]] throws an error", () => { + const iterator = stringIteratorFunction(); + assertThrows(() => new iterator("")); + }); + + describe(".length", () => { + it("[[Get]] returns the correct length", () => { + assertStrictEquals(stringIteratorFunction().length, 1); + }); + }); + + describe(".name", () => { + it("[[Get]] returns the correct name", () => { + assertStrictEquals( + stringIteratorFunction().name, + "characters", + ); + }); + }); + describe("::next", () => { it("[[Call]] throws if there are values and the mapper is not a generator function", () => { const iterator = stringIteratorFunction(function () {});