+ assertStrictEquals(toSignedIntegralNumeric(2, 7), -1);
+ });
+
+ it("[[Call]] works with non‐integers", () => {
+ assertStrictEquals(toSignedIntegralNumeric(2, 7.21), -1);
+ assertStrictEquals(toSignedIntegralNumeric(2, Infinity), 0);
+ });
+});
+
+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);
+ });
+});
+
+describe("toIntegralNumberOrInfinity", () => {
+ it("[[Call]] converts nan to zero", () => {
+ assertStrictEquals(toIntegralNumberOrInfinity(NaN), 0);
+ });
+
+ it("[[Call]] converts negative zero to positive zero", () => {
+ assertStrictEquals(toIntegralNumberOrInfinity(-0), 0);
+ });
+
+ it("[[Call]] drops the fractional part of negative numbers", () => {
+ assertStrictEquals(toIntegralNumberOrInfinity(-1.79), -1);
+ });
+
+ it("[[Call]] returns infinity for infinity", () => {
+ assertStrictEquals(toIntegralNumberOrInfinity(Infinity), Infinity);
+ });
+
+ it("[[Call]] returns negative infinity for negative infinity", () => {
+ assertStrictEquals(
+ toIntegralNumberOrInfinity(-Infinity),
+ -Infinity,
+ );
+ });
+
+ it("[[Call]] works with big·ints", () => {
+ assertStrictEquals(toIntegralNumberOrInfinity(2n), 2);