// file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
import {
+ assert,
assertStrictEquals,
assertThrows,
describe,
} from "./dev-deps.js";
import {
abs,
- atan2,
+ arccos,
+ arccosh,
+ arcsin,
+ arcsinh,
+ arctan,
+ arctan2,
+ arctanh,
+ cbrt,
+ ceil,
clz32,
+ cos,
+ cosh,
+ exp,
+ expm1,
+ floor,
+ hypot,
+ isFiniteNumber,
+ isIntegralNumber,
+ isNan,
+ isSafeIntegralNumber,
+ ln,
+ LN10,
+ ln1p,
+ LN2,
+ log10,
+ LOG10ℇ,
+ log2,
+ LOG2ℇ,
max,
+ MAXIMUM_NUMBER,
+ MAXIMUM_SAFE_INTEGRAL_NUMBER,
min,
+ MINIMUM_NUMBER,
+ MINIMUM_SAFE_INTEGRAL_NUMBER,
+ NAN,
+ NEGATIVE_INFINITY,
NEGATIVE_ZERO,
+ POSITIVE_INFINITY,
POSITIVE_ZERO,
+ rand,
+ RECIPROCAL_SQRT2,
+ round,
sgn,
+ sin,
+ sinh,
+ sqrt,
+ SQRT2,
+ tan,
+ tanh,
toBigInt,
toExponentialNotation,
toFixedDecimalNotation,
toNumeric,
toSignedIntegralNumeric,
toUnsignedIntegralNumeric,
+ trunc,
+ Ε,
+ Π,
+ ℇ,
} from "./numeric.js";
+describe("LN10", () => {
+ it("[[Get]] is ln(10)", () => {
+ assertStrictEquals(LN10, Math.LN10);
+ });
+});
+
+describe("LN2", () => {
+ it("[[Get]] is ln(2)", () => {
+ assertStrictEquals(LN2, Math.LN2);
+ });
+});
+
+describe("LOG10ℇ", () => {
+ it("[[Get]] is log10(ℇ)", () => {
+ assertStrictEquals(LOG10ℇ, Math.LOG10E);
+ });
+});
+
+describe("LOG2ℇ", () => {
+ it("[[Get]] is log2(ℇ)", () => {
+ assertStrictEquals(LOG2ℇ, Math.LOG2E);
+ });
+});
+
+describe("MAXIMUM_NUMBER", () => {
+ it("[[Get]] is the maximum number", () => {
+ assertStrictEquals(MAXIMUM_NUMBER, Number.MAX_VALUE);
+ });
+});
+
+describe("MAXIMUM_SAFE_INTEGRAL_NUMBER", () => {
+ it("[[Get]] is the maximum safe integral number", () => {
+ assertStrictEquals(
+ MAXIMUM_SAFE_INTEGRAL_NUMBER,
+ Number.MAX_SAFE_INTEGER,
+ );
+ });
+});
+
+describe("MINIMUM_NUMBER", () => {
+ it("[[Get]] is the minimum number", () => {
+ assertStrictEquals(MINIMUM_NUMBER, Number.MIN_VALUE);
+ });
+});
+
+describe("MINIMUM_SAFE_INTEGRAL_NUMBER", () => {
+ it("[[Get]] is the minimum safe integral number", () => {
+ assertStrictEquals(
+ MINIMUM_SAFE_INTEGRAL_NUMBER,
+ Number.MIN_SAFE_INTEGER,
+ );
+ });
+});
+
+describe("NAN", () => {
+ it("[[Get]] is nan", () => {
+ assertStrictEquals(NAN, NaN);
+ });
+});
+
+describe("NEGATIVE_INFINITY", () => {
+ it("[[Get]] is negative infinity", () => {
+ assertStrictEquals(NEGATIVE_INFINITY, -Infinity);
+ });
+});
+
describe("NEGATIVE_ZERO", () => {
it("[[Get]] is negative zero", () => {
assertStrictEquals(NEGATIVE_ZERO, -0);
});
});
+describe("POSITIVE_INFINITY", () => {
+ it("[[Get]] is negative infinity", () => {
+ assertStrictEquals(POSITIVE_INFINITY, Infinity);
+ });
+});
+
describe("POSITIVE_ZERO", () => {
it("[[Get]] is positive zero", () => {
assertStrictEquals(POSITIVE_ZERO, 0);
});
});
+describe("RECIPROCAL_SQRT2", () => {
+ it("[[Get]] is sqrt(½)", () => {
+ assertStrictEquals(RECIPROCAL_SQRT2, Math.SQRT1_2);
+ });
+});
+
+describe("SQRT2", () => {
+ it("[[Get]] is sqrt(2)", () => {
+ assertStrictEquals(SQRT2, Math.SQRT2);
+ });
+});
+
+describe("Ε", () => {
+ it("[[Get]] is ε", () => {
+ assertStrictEquals(Ε, Number.EPSILON);
+ });
+});
+
+describe("Π", () => {
+ it("[[Get]] is π", () => {
+ assertStrictEquals(Π, Math.PI);
+ });
+});
+
+describe("ℇ", () => {
+ it("[[Get]] is ℇ", () => {
+ assertStrictEquals(ℇ, Math.E);
+ });
+});
+
describe("abs", () => {
it("[[Call]] returns the absolute value", () => {
assertStrictEquals(abs(-1), 1);
const bn = BigInt(Number.MAX_SAFE_INTEGER) + 2n;
assertStrictEquals(abs(-bn), bn);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new abs(0));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(abs.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(abs.name, "abs");
+ });
+ });
+});
+
+describe("arccos", () => {
+ it("[[Call]] returns the arccos", () => {
+ assertStrictEquals(arccos(1), 0);
+ assertStrictEquals(arccos(0), Math.PI / 2);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => arccos(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new arccos(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(arccos.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(arccos.name, "arccos");
+ });
+ });
});
-describe("atan2", () => {
- it("[[Call]] returns the atan2", () => {
- assertStrictEquals(atan2(6, 9), Math.atan2(6, 9));
+describe("arccosh", () => {
+ it("[[Call]] returns the arccosh", () => {
+ assertStrictEquals(arccosh(1), 0);
+ assertStrictEquals(arccosh(0), NaN);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => arccosh(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new arccosh(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(arccosh.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(arccosh.name, "arccosh");
+ });
+ });
+});
+
+describe("arcsin", () => {
+ it("[[Call]] returns the arcsin", () => {
+ assertStrictEquals(arcsin(1), Math.PI / 2);
+ assertStrictEquals(arcsin(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => arcsin(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new arcsin(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(arcsin.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(arcsin.name, "arcsin");
+ });
+ });
+});
+
+describe("arcsinh", () => {
+ it("[[Call]] returns the arcsinh", () => {
+ assertStrictEquals(arcsinh(1), Math.asinh(1));
+ assertStrictEquals(arcsinh(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => arcsinh(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new arcsinh(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(arcsinh.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(arcsinh.name, "arcsinh");
+ });
+ });
+});
+
+describe("arctan", () => {
+ it("[[Call]] returns the arctan", () => {
+ assertStrictEquals(arctan(1), Math.PI / 4);
+ assertStrictEquals(arctan(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => arctan(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new arctan(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(arctan.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(arctan.name, "arctan");
+ });
+ });
+});
+
+describe("arctan2", () => {
+ it("[[Call]] returns the arctan2", () => {
+ assertStrictEquals(arctan2(6, 9), Math.atan2(6, 9));
});
it("[[Call]] works with big·ints", () => {
- assertStrictEquals(atan2(6n, 9n), Math.atan2(6, 9));
+ assertStrictEquals(arctan2(6n, 9n), Math.atan2(6, 9));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new arctan2(1, 0));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(arctan2.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(arctan2.name, "arctan2");
+ });
+ });
+});
+
+describe("arctanh", () => {
+ it("[[Call]] returns the arctanh", () => {
+ assertStrictEquals(arctanh(1), Infinity);
+ assertStrictEquals(arctanh(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => arctanh(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new arctanh(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(arctanh.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(arctanh.name, "arctanh");
+ });
+ });
+});
+
+describe("cbrt", () => {
+ it("[[Call]] returns the cbrt", () => {
+ assertStrictEquals(cbrt(1), 1);
+ assertStrictEquals(cbrt(2), Math.cbrt(2));
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => cbrt(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new cbrt(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(cbrt.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(cbrt.name, "cbrt");
+ });
+ });
+});
+
+describe("ceil", () => {
+ it("[[Call]] returns the ceil", () => {
+ assertStrictEquals(ceil(1), 1);
+ assertStrictEquals(ceil(1.1), 2);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => ceil(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new ceil(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(ceil.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(ceil.name, "ceil");
+ });
});
});
it("[[Call]] works with big·ints", () => {
assertStrictEquals(clz32(1n << 28n), 3);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new clz32(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(clz32.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(clz32.name, "clz32");
+ });
+ });
+});
+
+describe("cos", () => {
+ it("[[Call]] returns the cos", () => {
+ assertStrictEquals(cos(1), Math.cos(1));
+ assertStrictEquals(cos(0), 1);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => cos(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new cos(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(cos.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(cos.name, "cos");
+ });
+ });
+});
+
+describe("cosh", () => {
+ it("[[Call]] returns the cosh", () => {
+ assertStrictEquals(cosh(1), Math.cosh(1));
+ assertStrictEquals(cosh(0), 1);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => cosh(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new cosh(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(cosh.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(cosh.name, "cosh");
+ });
+ });
+});
+
+describe("exp", () => {
+ it("[[Call]] returns the exp", () => {
+ assertStrictEquals(exp(1), Math.E);
+ assertStrictEquals(exp(0), 1);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => exp(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new exp(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(exp.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(exp.name, "exp");
+ });
+ });
+});
+
+describe("expm1", () => {
+ it("[[Call]] returns the expm1", () => {
+ assertStrictEquals(expm1(1), Math.E - 1);
+ assertStrictEquals(expm1(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => expm1(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new expm1(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(expm1.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(expm1.name, "expm1");
+ });
+ });
+});
+
+describe("floor", () => {
+ it("[[Call]] returns the floor", () => {
+ assertStrictEquals(floor(1), 1);
+ assertStrictEquals(floor(0.1), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => floor(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new floor(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(floor.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(floor.name, "floor");
+ });
+ });
+});
+
+describe("hypot", () => {
+ it("[[Call]] returns the floor", () => {
+ assertStrictEquals(hypot(1, 0), 1);
+ assertStrictEquals(hypot(3, 4), 5);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => hypot(1n, 0n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new hypot(1, 0));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(hypot.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(hypot.name, "hypot");
+ });
+ });
+});
+
+describe("isFiniteNumber", () => {
+ it("[[Call]] returns true for finite numbers", () => {
+ assertStrictEquals(isFiniteNumber(1), true);
+ assertStrictEquals(isFiniteNumber(Number.MAX_VALUE), true);
+ assertStrictEquals(isFiniteNumber(Number.EPSILON), true);
+ });
+
+ it("[[Call]] returns false for nonfinite numbers", () => {
+ assertStrictEquals(isFiniteNumber(NaN), false);
+ assertStrictEquals(isFiniteNumber(Infinity), false);
+ });
+
+ it("[[Call]] returns false for nonnumbers", () => {
+ assertStrictEquals(isFiniteNumber(1n), false);
+ assertStrictEquals(isFiniteNumber("1"), false);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new isFiniteNumber(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(isFiniteNumber.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(isFiniteNumber.name, "isFiniteNumber");
+ });
+ });
+});
+
+describe("isIntegralNumber", () => {
+ it("[[Call]] returns true for integral numbers", () => {
+ assertStrictEquals(isIntegralNumber(1), true);
+ assertStrictEquals(isIntegralNumber(Number.MAX_VALUE), true);
+ });
+
+ it("[[Call]] returns false for nonfinite numbers", () => {
+ assertStrictEquals(isIntegralNumber(NaN), false);
+ assertStrictEquals(isIntegralNumber(Infinity), false);
+ });
+
+ it("[[Call]] returns false for nonintegral numbers", () => {
+ assertStrictEquals(isIntegralNumber(.1), false);
+ assertStrictEquals(isIntegralNumber(Number.EPSILON), false);
+ });
+
+ it("[[Call]] returns false for nonnumbers", () => {
+ assertStrictEquals(isIntegralNumber(1n), false);
+ assertStrictEquals(isIntegralNumber("1"), false);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new isIntegralNumber(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(isIntegralNumber.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(isIntegralNumber.name, "isIntegralNumber");
+ });
+ });
+});
+
+describe("isNan", () => {
+ it("[[Call]] returns true for nan", () => {
+ assertStrictEquals(isNan(NaN), true);
+ });
+
+ it("[[Call]] returns false for infinite numbers", () => {
+ assertStrictEquals(isNan(-Infinity), false);
+ assertStrictEquals(isNan(Infinity), false);
+ });
+
+ it("[[Call]] returns false for finite numbers", () => {
+ assertStrictEquals(isNan(1), false);
+ assertStrictEquals(isNan(Number.MAX_VALUE), false);
+ assertStrictEquals(isNan(.1), false);
+ assertStrictEquals(isNan(Number.EPSILON), false);
+ });
+
+ it("[[Call]] returns false for nonnumbers", () => {
+ assertStrictEquals(isNan(1n), false);
+ assertStrictEquals(isNan("NaN"), false);
+ assertStrictEquals(isNan({}), false);
+ assertStrictEquals(isNan(new Date(NaN)), false);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new isNan(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(isNan.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(isNan.name, "isNan");
+ });
+ });
+});
+
+describe("isSafeIntegralNumber", () => {
+ it("[[Call]] returns true for safe integral numbers", () => {
+ assertStrictEquals(isSafeIntegralNumber(1), true);
+ assertStrictEquals(
+ isSafeIntegralNumber(Number.MAX_SAFE_INTEGER),
+ true,
+ );
+ });
+
+ it("[[Call]] returns false for nonfinite numbers", () => {
+ assertStrictEquals(isSafeIntegralNumber(NaN), false);
+ assertStrictEquals(isSafeIntegralNumber(Infinity), false);
+ });
+
+ it("[[Call]] returns false for nonintegral numbers", () => {
+ assertStrictEquals(isSafeIntegralNumber(.1), false);
+ assertStrictEquals(isSafeIntegralNumber(Number.EPSILON), false);
+ });
+ it("[[Call]] returns true for unsafe integral numbers", () => {
+ assertStrictEquals(isSafeIntegralNumber(Number.MAX_VALUE), false);
+ });
+
+ it("[[Call]] returns false for nonnumbers", () => {
+ assertStrictEquals(isSafeIntegralNumber(1n), false);
+ assertStrictEquals(isSafeIntegralNumber("1"), false);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new isSafeIntegralNumber(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(isSafeIntegralNumber.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ isSafeIntegralNumber.name,
+ "isSafeIntegralNumber",
+ );
+ });
+ });
+});
+
+describe("ln", () => {
+ it("[[Call]] returns the ln", () => {
+ assertStrictEquals(ln(1), 0);
+ assertStrictEquals(ln(Math.E), 1);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => ln(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new ln(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(ln.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(ln.name, "ln");
+ });
+ });
+});
+
+describe("ln1p", () => {
+ it("[[Call]] returns the ln1p", () => {
+ assertStrictEquals(ln1p(1), Math.log1p(1));
+ assertStrictEquals(ln1p(Math.E - 1), 1);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => ln1p(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new ln1p(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(ln1p.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(ln1p.name, "ln1p");
+ });
+ });
+});
+
+describe("log10", () => {
+ it("[[Call]] returns the log10", () => {
+ assertStrictEquals(log10(1), 0);
+ assertStrictEquals(log10(10), 1);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => log10(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new log10(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(log10.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(log10.name, "log10");
+ });
+ });
+});
+
+describe("log2", () => {
+ it("[[Call]] returns the log2", () => {
+ assertStrictEquals(log2(1), 0);
+ assertStrictEquals(log2(2), 1);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => log2(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new log2(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(log2.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(log2.name, "log2");
+ });
+ });
});
describe("max", () => {
it("[[Call]] throws if both big·int and number arguments are provided", () => {
assertThrows(() => max(-Infinity, 0n));
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new max(1, 0));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(max.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(max.name, "max");
+ });
+ });
});
describe("min", () => {
it("[[Call]] throws if both big·int and number arguments are provided", () => {
assertThrows(() => min(Infinity, 0n));
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new min(1, 0));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(min.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(min.name, "min");
+ });
+ });
+});
+
+describe("rand", () => {
+ it("[[Call]] returns a random number between 0 and 1", () => {
+ // Not possible to fully test, obviously.
+ const r = rand();
+ assert(typeof r === "number");
+ assert(r >= 0 && r < 1);
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new rand());
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(rand.length, 0);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(rand.name, "rand");
+ });
+ });
+});
+
+describe("round", () => {
+ it("[[Call]] returns the round", () => {
+ assertStrictEquals(round(1), 1);
+ assertStrictEquals(round(0.5), 1);
+ assertStrictEquals(round(-0.5), -0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => round(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new round(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(round.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(round.name, "round");
+ });
+ });
});
describe("sgn", () => {
assertStrictEquals(sgn(92n), 1n);
assertStrictEquals(sgn(-92n), -1n);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new sgn(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(sgn.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(sgn.name, "sgn");
+ });
+ });
+});
+
+describe("sin", () => {
+ it("[[Call]] returns the sin", () => {
+ assertStrictEquals(sin(1), Math.sin(1));
+ assertStrictEquals(sin(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => sin(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new sin(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(sin.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(sin.name, "sin");
+ });
+ });
+});
+
+describe("sinh", () => {
+ it("[[Call]] returns the sinh", () => {
+ assertStrictEquals(sinh(1), Math.sinh(1));
+ assertStrictEquals(sinh(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => sinh(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new sinh(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(sinh.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(sinh.name, "sinh");
+ });
+ });
+});
+
+describe("sqrt", () => {
+ it("[[Call]] returns the sqrt", () => {
+ assertStrictEquals(sqrt(1), 1);
+ assertStrictEquals(sqrt(2), Math.SQRT2);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => sqrt(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new sqrt(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(sqrt.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(sqrt.name, "sqrt");
+ });
+ });
+});
+
+describe("tan", () => {
+ it("[[Call]] returns the tan", () => {
+ assertStrictEquals(tan(1), Math.tan(1));
+ assertStrictEquals(tan(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => tan(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new tan(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(tan.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(tan.name, "tan");
+ });
+ });
+});
+
+describe("tanh", () => {
+ it("[[Call]] returns the tanh", () => {
+ assertStrictEquals(tanh(1), Math.tanh(1));
+ assertStrictEquals(tanh(0), 0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => tanh(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new tanh(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(tanh.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(tanh.name, "tanh");
+ });
+ });
});
describe("toBigInt", () => {
it("[[Call]] converts to a big·int", () => {
assertStrictEquals(toBigInt(2), 2n);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toBigInt(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toBigInt.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(toBigInt.name, "toBigInt");
+ });
+ });
});
describe("toExponentialNotation", () => {
assertStrictEquals(toExponentialNotation(6850n, 1), "6.9e+3");
assertStrictEquals(toExponentialNotation(4199n, 2), "4.20e+3");
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toExponentialNotation(1, 1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toExponentialNotation.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ toExponentialNotation.name,
+ "toExponentialNotation",
+ );
+ });
+ });
});
describe("toFixedDecimalNotation", () => {
"9007199254740993.00",
);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toFixedDecimalNotation(1, 1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toFixedDecimalNotation.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ toFixedDecimalNotation.name,
+ "toFixedDecimalNotation",
+ );
+ });
+ });
});
describe("toFloat32", () => {
Math.fround(562949953421313),
);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toFloat32(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toFloat32.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(toFloat32.name, "toFloat32");
+ });
+ });
});
describe("toSignedIntegralNumeric", () => {
assertStrictEquals(toSignedIntegralNumeric(2, 7.21), -1);
assertStrictEquals(toSignedIntegralNumeric(2, Infinity), 0);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toSignedIntegralNumeric(1, 1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toSignedIntegralNumeric.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ toSignedIntegralNumeric.name,
+ "toSignedIntegralNumeric",
+ );
+ });
+ });
});
describe("toIntegralNumber", () => {
it("[[Call]] works with big·ints", () => {
assertStrictEquals(toIntegralNumber(2n), 2);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toIntegralNumber(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toIntegralNumber.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(toIntegralNumber.name, "toIntegralNumber");
+ });
+ });
});
describe("toIntegralNumberOrInfinity", () => {
it("[[Call]] works with big·ints", () => {
assertStrictEquals(toIntegralNumberOrInfinity(2n), 2);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toIntegralNumberOrInfinity(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toIntegralNumberOrInfinity.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ toIntegralNumberOrInfinity.name,
+ "toIntegralNumberOrInfinity",
+ );
+ });
+ });
});
describe("toNumber", () => {
231n,
);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toNumeric(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toNumeric.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(toNumeric.name, "toNumeric");
+ });
+ });
});
describe("toUnsignedIntegralNumeric", () => {
assertStrictEquals(toUnsignedIntegralNumeric(2, 7.21), 3);
assertStrictEquals(toUnsignedIntegralNumeric(2, Infinity), 0);
});
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new toUnsignedIntegralNumeric(1, 1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(toUnsignedIntegralNumeric.length, 2);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(
+ toUnsignedIntegralNumeric.name,
+ "toUnsignedIntegralNumeric",
+ );
+ });
+ });
+});
+
+describe("trunc", () => {
+ it("[[Call]] returns the trunc", () => {
+ assertStrictEquals(trunc(1), 1);
+ assertStrictEquals(trunc(0.5), 0);
+ assertStrictEquals(trunc(-0.5), -0);
+ });
+
+ it("[[Call]] throws with big·ints", () => {
+ assertThrows(() => trunc(1n));
+ });
+
+ it("[[Construct]] throws an error", () => {
+ assertThrows(() => new trunc(1));
+ });
+
+ describe(".length", () => {
+ it("[[Get]] returns the correct length", () => {
+ assertStrictEquals(trunc.length, 1);
+ });
+ });
+
+ describe(".name", () => {
+ it("[[Get]] returns the correct name", () => {
+ assertStrictEquals(trunc.name, "trunc");
+ });
+ });
});