X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/f3e417be2077db5839dcada4aa1395ae2e9337ba..fb3e0d562e2dbe9e3ea911a80bfdabc8851f92b2:/numeric.test.js?ds=sidebyside diff --git a/numeric.test.js b/numeric.test.js index 6c58d04..dfb8063 100644 --- a/numeric.test.js +++ b/numeric.test.js @@ -25,6 +25,7 @@ import { toBigInt, toFloat32, toIntegerOrInfinity, + toIntegralNumber, toIntN, toNumber, toNumeric, @@ -189,7 +190,37 @@ describe("toIntegerOrInfinity", () => { }); it("[[Call]] returns negative infinity for negative infinity", () => { - assertStrictEquals(toIntegerOrInfinity(Infinity), Infinity); + assertStrictEquals(toIntegerOrInfinity(-Infinity), -Infinity); + }); + + it("[[Call]] works with bigĀ·ints", () => { + assertStrictEquals(toIntegerOrInfinity(2n), 2); + }); +}); + +describe("toIntegralNumber", () => { + it("[[Call]] converts nan to zero", () => { + assertStrictEquals(toIntegralNumber(NaN), 0); + }); + + it("[[Call]] converts negative zero to positive zero", () => { + assertStrictEquals(toIntegralNumber(-0), 0); + }); + + it("[[Call]] drops the fractional part of negative numbers", () => { + assertStrictEquals(toIntegralNumber(-1.79), -1); + }); + + it("[[Call]] returns zero for infinity", () => { + assertStrictEquals(toIntegralNumber(Infinity), 0); + }); + + it("[[Call]] returns zero for negative infinity", () => { + assertStrictEquals(toIntegralNumber(-Infinity), 0); + }); + + it("[[Call]] works with bigĀ·ints", () => { + assertStrictEquals(toIntegralNumber(2n), 2); }); });