From: Lady Date: Mon, 4 Sep 2023 19:37:32 +0000 (-0400) Subject: Test value.js non·constructor constructability X-Git-Url: https://git.ladys.computer/Pisces/commitdiff_plain/e144b3079639f839551c0f243764fb39ab81604f Test value.js non·constructor constructability --- diff --git a/value.test.js b/value.test.js index cfaded4..1be5950 100644 --- a/value.test.js +++ b/value.test.js @@ -202,6 +202,10 @@ describe("ordinaryToPrimitive", () => { assertThrows(() => ordinaryToPrimitive(obj)); }); + it("[[Construct]] throws an error", () => { + assertThrows(() => new ordinaryToPrimitive("")); + }); + describe(".name", () => { it("[[Get]] returns the correct name", () => { assertStrictEquals( @@ -250,6 +254,10 @@ describe("sameValue", () => { assertStrictEquals(sameValue(false, new Boolean(false)), false); }); + it("[[Construct]] throws an error", () => { + assertThrows(() => new sameValue(true, true)); + }); + describe(".name", () => { it("[[Get]] returns the correct name", () => { assertStrictEquals(sameValue.name, "sameValue"); @@ -298,6 +306,10 @@ describe("sameValueZero", () => { ); }); + it("[[Construct]] throws an error", () => { + assertThrows(() => new sameValueZero(true, true)); + }); + describe(".name", () => { it("[[Get]] returns the correct name", () => { assertStrictEquals(sameValueZero.name, "sameValueZero"); @@ -376,7 +388,7 @@ describe("toPrimitive", () => { }, }, ); - assertStrictEquals(toPrimitive(value, "default"), "success"); + assertStrictEquals(toPrimitive(value), "success"); }); it("[[Call]] throws for an invalid hint", () => { @@ -401,6 +413,10 @@ describe("toPrimitive", () => { assertThrows(() => toPrimitive(true, "badhint")); }); + it("[[Construct]] throws an error", () => { + assertThrows(() => new toPrimitive(true)); + }); + describe(".name", () => { it("[[Get]] returns the correct name", () => { assertStrictEquals(toPrimitive.name, "toPrimitive"); @@ -429,6 +445,10 @@ describe("type", () => { assertStrictEquals(type(class {}), "object"); }); + it("[[Construct]] throws an error", () => { + assertThrows(() => new type({})); + }); + describe(".name", () => { it("[[Get]] returns the correct name", () => { assertStrictEquals(type.name, "type");