]> Lady’s Gitweb - Pisces/blobdiff - object.test.js
Support unicode sets in Matchers
[Pisces] / object.test.js
index 348d06da83332901c8047288658ab08c607cfa56..aa1796a46311ff701cac01f4b05c3b31b8605ecf 100644 (file)
@@ -1,11 +1,14 @@
-// ♓🌟 Piscēs ∷ object.test.js
-// ====================================================================
-//
-// Copyright © 2022–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: 2022, 2023, 2025 Lady <https://www.ladys.computer/about/#lady>
+// SPDX-License-Identifier: MPL-2.0
+/**
+ * ⁌ ♓🌟 Piscēs ∷ object.js
+ *
+ * Copyright © 2022–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 {
   assert,
@@ -30,9 +33,12 @@ import {
   getMethod,
   getOwnPropertyDescriptor,
   getOwnPropertyDescriptors,
+  getOwnPropertyEntries,
   getOwnPropertyKeys,
   getOwnPropertyStrings,
   getOwnPropertySymbols,
+  getOwnPropertyValue,
+  getOwnPropertyValues,
   getPropertyValue,
   getPrototype,
   hasOwnProperty,
@@ -668,8 +674,8 @@ describe("frozenCopy", () => {
 
   it("[[Call]] does not copy properties on the prototype", () => {
     assert(
-      !("failure" in
-        frozenCopy(Object.create({ failure: undefined }))),
+      !("failure"
+        in frozenCopy(Object.create({ failure: undefined }))),
     );
   });
 
@@ -840,6 +846,58 @@ describe("getOwnPropertyDescriptors", () => {
   });
 });
 
+describe("getOwnPropertyEntries", () => {
+  it("[[Call]] gets own (but not inherited) property entries", () => {
+    assertEquals(
+      getOwnPropertyEntries({ success: true }),
+      [["success", true]],
+    );
+  });
+
+  it("[[Call]] works for values coercible to objects", () => {
+    assertEquals(
+      getOwnPropertyEntries("foo"),
+      [["0", "f"], ["1", "o"], ["2", "o"], ["length", 3]],
+    );
+  });
+
+  it("[[Call]] uses the provided receiver", () => {
+    const target = {};
+    assertEquals(
+      getOwnPropertyEntries({
+        get success() {
+          return this;
+        },
+      }, target),
+      [["success", target]],
+    );
+  });
+
+  it("[[Call]] throws for null and undefined", () => {
+    assertThrows(() => getOwnPropertyEntries(null));
+    assertThrows(() => getOwnPropertyEntries(undefined));
+  });
+
+  it("[[Construct]] throws an error", () => {
+    assertThrows(() => new getOwnPropertyEntries({}));
+  });
+
+  describe(".length", () => {
+    it("[[Get]] returns the correct length", () => {
+      assertStrictEquals(getOwnPropertyEntries.length, 1);
+    });
+  });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        getOwnPropertyEntries.name,
+        "getOwnPropertyEntries",
+      );
+    });
+  });
+});
+
 describe("getOwnPropertyKeys", () => {
   it("[[Call]] gets own (but not inherited) property keys", () => {
     assertEquals(getOwnPropertyKeys({ success: true }), ["success"]);
@@ -950,6 +1008,115 @@ describe("getOwnPropertySymbols", () => {
   });
 });
 
+describe("getOwnPropertyValue", () => {
+  it("[[Call]] gets the own property value", () => {
+    assertStrictEquals(
+      getOwnPropertyValue({ success: true }, "success"),
+      true,
+    );
+  });
+
+  it("[[Call]] returns undefined for non‐own properties", () => {
+    assertStrictEquals(
+      getOwnPropertyValue(Object.create({ success: true }), "success"),
+      undefined,
+    );
+  });
+
+  it("[[Call]] works for values coercible to objects", () => {
+    assertStrictEquals(getOwnPropertyValue("foo", "length"), 3);
+  });
+
+  it("[[Call]] uses the provided receiver", () => {
+    const target = {};
+    assertStrictEquals(
+      getOwnPropertyValue(
+        {
+          get success() {
+            return this;
+          },
+        },
+        "success",
+        target,
+      ),
+      target,
+    );
+  });
+
+  it("[[Call]] throws for null and undefined", () => {
+    assertThrows(() => getOwnPropertyValue(null));
+    assertThrows(() => getOwnPropertyValue(undefined));
+  });
+
+  it("[[Construct]] throws an error", () => {
+    assertThrows(() => new getOwnPropertyValue({}));
+  });
+
+  describe(".length", () => {
+    it("[[Get]] returns the correct length", () => {
+      assertStrictEquals(getOwnPropertyValue.length, 2);
+    });
+  });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        getOwnPropertyValue.name,
+        "getOwnPropertyValue",
+      );
+    });
+  });
+});
+
+describe("getOwnPropertyValues", () => {
+  it("[[Call]] gets own (but not inherited) property values", () => {
+    assertEquals(getOwnPropertyValues({ success: true }), [true]);
+  });
+
+  it("[[Call]] works for values coercible to objects", () => {
+    assertEquals(
+      getOwnPropertyValues("foo"),
+      ["f", "o", "o", 3],
+    );
+  });
+
+  it("[[Call]] uses the provided receiver", () => {
+    const target = {};
+    assertEquals(
+      getOwnPropertyValues({
+        get success() {
+          return this;
+        },
+      }, target),
+      [target],
+    );
+  });
+
+  it("[[Call]] throws for null and undefined", () => {
+    assertThrows(() => getOwnPropertyValues(null));
+    assertThrows(() => getOwnPropertyValues(undefined));
+  });
+
+  it("[[Construct]] throws an error", () => {
+    assertThrows(() => new getOwnPropertyValues({}));
+  });
+
+  describe(".length", () => {
+    it("[[Get]] returns the correct length", () => {
+      assertStrictEquals(getOwnPropertyValues.length, 1);
+    });
+  });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        getOwnPropertyValues.name,
+        "getOwnPropertyValues",
+      );
+    });
+  });
+});
+
 describe("getPropertyValue", () => {
   it("[[Call]] gets property values on the provided object", () => {
     assertStrictEquals(
This page took 0.206049 seconds and 4 git commands to generate.