]> Lady’s Gitweb - Pisces/commitdiff
Ensure each function in value.js has correct name
authorLady <redacted>
Sat, 22 Jul 2023 06:39:26 +0000 (23:39 -0700)
committerLady <redacted>
Sat, 22 Jul 2023 06:53:09 +0000 (23:53 -0700)
This requires making `sameValue` a wrapper of `Object.is` instead of
literally the same function.

value.js
value.test.js

index 3f0c6fa1b9483d2e45358f9907bbfd66452e1d13..bda9180e4347e6cd74f0b36676fa82da208a2384 100644 (file)
--- a/value.js
+++ b/value.js
@@ -141,14 +141,14 @@ export const {
   };
 })();
 
-/**
- * Returns whether the provided values are the same value.
- *
- * ※ This differs from `===` in the cases of nan and zero.
- */
-export const sameValue = Object.is;
-
 export const {
+  /**
+   * Returns whether the provided values are the same value.
+   *
+   * ※ This differs from `===` in the cases of nan and zero.
+   */
+  sameValue,
+
   /**
    * Returns whether the provided values are either the same value or
    * both zero (either positive or negative).
@@ -158,7 +158,9 @@ export const {
   sameValueZero,
 } = (() => {
   const { isNaN: isNan } = Number;
+  const { is } = Object;
   return {
+    sameValue: (a, b) => is(a, b),
     sameValueZero: ($1, $2) => {
       const type1 = type($1);
       const type2 = type($2);
index 747b18e39087d18010414158a3b661a6443802da..cfaded4e39569af25966ef94501a349027b6442d 100644 (file)
@@ -201,6 +201,15 @@ describe("ordinaryToPrimitive", () => {
     };
     assertThrows(() => ordinaryToPrimitive(obj));
   });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(
+        ordinaryToPrimitive.name,
+        "ordinaryToPrimitive",
+      );
+    });
+  });
 });
 
 describe("sameValue", () => {
@@ -240,6 +249,12 @@ describe("sameValue", () => {
   it("[[Call]] returns false for a primitive and its wrapped object", () => {
     assertStrictEquals(sameValue(false, new Boolean(false)), false);
   });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(sameValue.name, "sameValue");
+    });
+  });
 });
 
 describe("sameValueZero", () => {
@@ -282,6 +297,12 @@ describe("sameValueZero", () => {
       false,
     );
   });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(sameValueZero.name, "sameValueZero");
+    });
+  });
 });
 
 describe("toPrimitive", () => {
@@ -379,6 +400,12 @@ describe("toPrimitive", () => {
     assertThrows(() => toPrimitive(value2, "badhint"));
     assertThrows(() => toPrimitive(true, "badhint"));
   });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(toPrimitive.name, "toPrimitive");
+    });
+  });
 });
 
 describe("type", () => {
@@ -401,4 +428,10 @@ describe("type", () => {
   it('[[Call]] returns "object" for constructable objects', () => {
     assertStrictEquals(type(class {}), "object");
   });
+
+  describe(".name", () => {
+    it("[[Get]] returns the correct name", () => {
+      assertStrictEquals(type.name, "type");
+    });
+  });
 });
This page took 0.02717 seconds and 4 git commands to generate.