]> Lady’s Gitweb - Pisces/blobdiff - iterable.test.js
Minor refactors to numeric.js
[Pisces] / iterable.test.js
index 2e62d5c01146ac9e5e10f2dd1b1b700174501833..3651c6cb6917e254a940f4d09118aaedd38a0dfe 100644 (file)
@@ -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 <https://mozilla.org/MPL/2.0/>.
+// SPDX-FileCopyrightText: 2023, 2025 Lady <https://www.ladys.computer/about/#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 <https://mozilla.org/MPL/2.0/>.
+ */
 
 import {
   assertEquals,
@@ -34,6 +37,25 @@ describe("arrayIteratorFunction", () => {
     );
   });
 
+  it("[[Construct]] throws an error", () => {
+    assertThrows(() => new arrayIteratorFunction());
+  });
+
+  describe(".length", () => {
+    it("[[Get]] returns the correct length", () => {
+      assertStrictEquals(arrayIteratorFunction.length, 1);
+    });
+  });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        arrayIteratorFunction.name,
+        "arrayIteratorFunction",
+      );
+    });
+  });
+
   describe("()", () => {
     it("[[Call]] returns a value which inherits from %IteratorPrototype%", () => {
       const iteratorProto = Object.getPrototypeOf(
@@ -107,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 () {});
@@ -130,6 +172,25 @@ describe("generatorIteratorFunction", () => {
     );
   });
 
+  it("[[Construct]] throws an error", () => {
+    assertThrows(() => new generatorIteratorFunction());
+  });
+
+  describe(".length", () => {
+    it("[[Get]] returns the correct length", () => {
+      assertStrictEquals(generatorIteratorFunction.length, 1);
+    });
+  });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        generatorIteratorFunction.name,
+        "generatorIteratorFunction",
+      );
+    });
+  });
+
   describe("()", () => {
     it("[[Call]] returns a value which inherits from %IteratorPrototype%", () => {
       const iteratorProto = Object.getPrototypeOf(
@@ -215,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* () {
@@ -248,6 +329,25 @@ describe("mapIteratorFunction", () => {
     );
   });
 
+  it("[[Construct]] throws an error", () => {
+    assertThrows(() => new mapIteratorFunction());
+  });
+
+  describe(".length", () => {
+    it("[[Get]] returns the correct length", () => {
+      assertStrictEquals(mapIteratorFunction.length, 1);
+    });
+  });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        mapIteratorFunction.name,
+        "mapIteratorFunction",
+      );
+    });
+  });
+
   describe("()", () => {
     it("[[Call]] returns a value which inherits from %IteratorPrototype%", () => {
       const iteratorProto = Object.getPrototypeOf(
@@ -321,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 () {});
@@ -344,6 +464,25 @@ describe("setIteratorFunction", () => {
     );
   });
 
+  it("[[Construct]] throws an error", () => {
+    assertThrows(() => new setIteratorFunction());
+  });
+
+  describe(".length", () => {
+    it("[[Get]] returns the correct length", () => {
+      assertStrictEquals(setIteratorFunction.length, 1);
+    });
+  });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        setIteratorFunction.name,
+        "setIteratorFunction",
+      );
+    });
+  });
+
   describe("()", () => {
     it("[[Call]] returns a value which inherits from %IteratorPrototype%", () => {
       const iteratorProto = Object.getPrototypeOf(
@@ -417,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 () {});
@@ -440,6 +599,25 @@ describe("stringIteratorFunction", () => {
     );
   });
 
+  it("[[Construct]] throws an error", () => {
+    assertThrows(() => new stringIteratorFunction());
+  });
+
+  describe(".length", () => {
+    it("[[Get]] returns the correct length", () => {
+      assertStrictEquals(stringIteratorFunction.length, 1);
+    });
+  });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        stringIteratorFunction.name,
+        "stringIteratorFunction",
+      );
+    });
+  });
+
   describe("()", () => {
     it("[[Call]] returns a value which inherits from %IteratorPrototype%", () => {
       const iteratorProto = Object.getPrototypeOf(
@@ -518,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 () {});
This page took 0.24856 seconds and 4 git commands to generate.