From: Lady Date: Fri, 17 Nov 2023 01:45:04 +0000 (-0500) Subject: Test constructability, name, length in numeric.js X-Git-Url: https://git.ladys.computer/Pisces/commitdiff_plain/4895d39790c88da109d29959ca026c666669e6f3?ds=inline Test constructability, name, length in numeric.js --- diff --git a/numeric.js b/numeric.js index 5a3d6ea..f5bc738 100644 --- a/numeric.js +++ b/numeric.js @@ -7,7 +7,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at . -import { call } from "./function.js"; +import { call, createArrowFunction } from "./function.js"; import { stringCatenate, stringPadEnd, @@ -60,230 +60,6 @@ export const { */ SQRT2, - /** - * Returns the arccos of the provided value. - * - * ※ This is an alias for `Math.acos`. - * - * ☡ This function does not allow big·int arguments. - */ - acos: arccos, - - /** - * Returns the arccosh of the provided value. - * - * ※ This is an alias for `Math.acosh`. - * - * ☡ This function does not allow big·int arguments. - */ - acosh: arccosh, - - /** - * Returns the arcsin of the provided value. - * - * ※ This is an alias for `Math.asin`. - * - * ☡ This function does not allow big·int arguments. - */ - asin: arcsin, - - /** - * Returns the arcsinh of the provided value. - * - * ※ This is an alias for `Math.asinh`. - * - * ☡ This function does not allow big·int arguments. - */ - asinh: arcsinh, - - /** - * Returns the arctan of the provided value. - * - * ※ This is an alias for `Math.atan`. - * - * ☡ This function does not allow big·int arguments. - */ - atan: arctan, - - /** - * Returns the arctanh of the provided value. - * - * ※ This is an alias for `Math.atanh`. - * - * ☡ This function does not allow big·int arguments. - */ - atanh: arctanh, - - /** - * Returns the cube root of the provided value. - * - * ※ This is an alias for `Math.cbrt`. - * - * ☡ This function does not allow big·int arguments. - */ - cbrt, - - /** - * Returns the ceiling of the provided value. - * - * ※ This is an alias for `Math.ceil`. - * - * ☡ This function does not allow big·int arguments. - */ - ceil, - - /** - * Returns the cos of the provided value. - * - * ※ This is an alias for `Math.cos`. - * - * ☡ This function does not allow big·int arguments. - */ - cos, - - /** - * Returns the cosh of the provided value. - * - * ※ This is an alias for `Math.cosh`. - * - * ☡ This function does not allow big·int arguments. - */ - cosh, - - /** - * Returns the Euler number raised to the provided value. - * - * ※ This is an alias for `Math.exp`. - * - * ☡ This function does not allow big·int arguments. - */ - exp, - - /** - * Returns the Euler number raised to the provided value, minus one. - * - * ※ This is an alias for `Math.expm1`. - * - * ☡ This function does not allow big·int arguments. - */ - expm1, - - /** - * Returns the floor of the provided value. - * - * ※ This is an alias for `Math.floor`. - * - * ☡ This function does not allow big·int arguments. - */ - floor, - - /** - * Returns the square root of the sum of the squares of the provided - * arguments. - * - * ※ This is an alias for `Math.hypot`. - * - * ☡ This function does not allow big·int arguments. - */ - hypot, - - /** - * Returns the ln of the provided value. - * - * ※ This is an alias for `Math.log`. - * - * ☡ This function does not allow big·int arguments. - */ - log: ln, - - /** - * Returns the log10 of the provided value. - * - * ※ This is an alias for `Math.log10`. - * - * ☡ This function does not allow big·int arguments. - */ - log10, - - /** - * Returns the ln of one plus the provided value. - * - * ※ This is an alias for `Math.log1p`. - * - * ☡ This function does not allow big·int arguments. - */ - log1p: ln1p, - - /** - * Returns the log2 of the provided value. - * - * ※ This is an alias for `Math.log2`. - * - * ☡ This function does not allow big·int arguments. - */ - log2, - - /** - * Returns a pseudo·random value in the range [0, 1). - * - * ※ This is an alias for `Math.random`. - */ - random: rand, - - /** - * Returns the round of the provided value. - * - * ※ This is an alias for `Math.round`. - * - * ☡ This function does not allow big·int arguments. - */ - round, - - /** - * Returns the sinh of the provided value. - * - * ※ This is an alias for `Math.sinh`. - * - * ☡ This function does not allow big·int arguments. - */ - sinh, - - /** - * Returns the square root of the provided value. - * - * ※ This is an alias for `Math.sqrt`. - * - * ☡ This function does not allow big·int arguments. - */ - sqrt, - - /** - * Returns the tan of the provided value. - * - * ※ This is an alias for `Math.tan`. - * - * ☡ This function does not allow big·int arguments. - */ - tan, - - /** - * Returns the tanh of the provided value. - * - * ※ This is an alias for `Math.tanh`. - * - * ☡ This function does not allow big·int arguments. - */ - tanh, - - /** - * Returns the trunc of the provided value. - * - * ※ This is an alias for `Math.trunc`. - * - * ☡ This function does not allow big·int arguments. - */ - trunc, - /** * The mathematical constant π. * @@ -355,42 +131,14 @@ export const { * ※ This is an alias for `Number.EPSILON`. */ EPSILON: Ε, - - /** - * Returns whether the provided value is a finite number. - * - * ※ This is an alias for `Number.isFinite`. - */ - isFinite: isFiniteNumber, - - /** - * Returns whether the provided value is an integral number. - * - * ※ This is an alias for `Number.isInteger`. - */ - isInteger: isIntegralNumber, - - /** - * Returns whether the provided value is nan. - * - * ※ This is an alias for `Number.isNaN`. - */ - isNaN: isNan, - - /** - * Returns whether the provided value is a safe integral number. - * - * ※ This is an alias for `Number.isSafeInteger`. - */ - isSafeInteger: isSafeIntegralNumber, } = Number; -/** Positive zero. */ -export const POSITIVE_ZERO = 0; - /** Negative zero. */ export const NEGATIVE_ZERO = -0; +/** Positive zero. */ +export const POSITIVE_ZERO = 0; + /** * Returns the magnitude (absolute value) of the provided value. * @@ -411,6 +159,66 @@ export const abs = ($) => { : n; }; +/** + * Returns the arccos of the provided value. + * + * ※ This function is effectively an alias for `Math.acos`. + * + * ☡ This function does not allow big·int arguments. + */ +export const arccos = createArrowFunction( + Math.acos, + { name: "arccos" }, +); + +/** + * Returns the arccosh of the provided value. + * + * ※ This function is effectively an alias for `Math.acosh`. + * + * ☡ This function does not allow big·int arguments. + */ +export const arccosh = createArrowFunction( + Math.acosh, + { name: "arccosh" }, +); + +/** + * Returns the arcsin of the provided value. + * + * ※ This function is effectively an alias for `Math.asin`. + * + * ☡ This function does not allow big·int arguments. + */ +export const arcsin = createArrowFunction( + Math.asin, + { name: "arcsin" }, +); + +/** + * Returns the arcsinh of the provided value. + * + * ※ This function is effectively an alias for `Math.asinh`. + * + * ☡ This function does not allow big·int arguments. + */ +export const arcsinh = createArrowFunction( + Math.asinh, + { name: "arcsinh" }, +); + +/** + * Returns the arctan of the provided value. + * + * ※ This function is effectively an alias for `Math.atan`. + * + * ☡ This function does not allow big·int arguments. + */ +export const arctan = createArrowFunction( + Math.atan, + { name: "arctan" }, +); + export const { /** * Returns the arctangent of the dividend of the provided values. @@ -418,7 +226,7 @@ export const { * ※ Unlike `Math.atan2`, this function can take big·int arguments. * However, the result will always be a number. */ - atan2, + arctan2, /** * Returns the number of leading zeroes in the 32‐bit representation @@ -440,7 +248,7 @@ export const { } = (() => { const { atan2, fround, clz32 } = Math; return { - atan2: (y, x) => atan2(toNumber(y), toNumber(x)), + arctan2: (y, x) => atan2(toNumber(y), toNumber(x)), clz32: ($) => { const n = toNumeric($); return clz32( @@ -453,6 +261,167 @@ export const { }; })(); +/** + * Returns the arctanh of the provided value. + * + * ※ This function is effectively an alias for `Math.atanh`. + * + * ☡ This function does not allow big·int arguments. + */ +export const arctanh = createArrowFunction( + Math.atanh, + { name: "arctanh" }, +); + +/** + * Returns the cube root of the provided value. + * + * ※ This function is effectively an alias for `Math.cbrt`. + * + * ☡ This function does not allow big·int arguments. + */ +export const cbrt = createArrowFunction(Math.cbrt); + +/** + * Returns the ceiling of the provided value. + * + * ※ This function is effectively an alias for `Math.ceil`. + * + * ☡ This function does not allow big·int arguments. + */ +export const ceil = createArrowFunction(Math.ceil); + +/** + * Returns the cos of the provided value. + * + * ※ This function is effectively an alias for `Math.cos`. + * + * ☡ This function does not allow big·int arguments. + */ +export const cos = createArrowFunction(Math.cos); + +/** + * Returns the cosh of the provided value. + * + * ※ This function is effectively an alias for `Math.cosh`. + * + * ☡ This function does not allow big·int arguments. + */ +export const cosh = createArrowFunction(Math.cosh); + +/** + * Returns the Euler number raised to the provided value. + * + * ※ This function is effectively an alias for `Math.exp`. + * + * ☡ This function does not allow big·int arguments. + */ +export const exp = createArrowFunction(Math.exp); + +/** + * Returns the Euler number raised to the provided value, minus one. + * + * ※ This function is effectively an alias for `Math.expm1`. + * + * ☡ This function does not allow big·int arguments. + */ +export const expm1 = createArrowFunction(Math.expm1); + +/** + * Returns the floor of the provided value. + * + * ※ This function is effectively an alias for `Math.floor`. + * + * ☡ This function does not allow big·int arguments. + */ +export const floor = createArrowFunction(Math.floor); + +/** + * Returns the square root of the sum of the squares of the provided + * arguments. + * + * ※ This function is effectively an alias for `Math.hypot`. + * + * ☡ This function does not allow big·int arguments. + */ +export const hypot = createArrowFunction(Math.hypot); + +/** + * Returns whether the provided value is a finite number. + * + * ※ This function is effectively an alias for `Number.isFinite`. + */ +export const isFiniteNumber = createArrowFunction( + Number.isFinite, + { name: "isFiniteNumber" }, +); + +/** + * Returns whether the provided value is an integral number. + * + * ※ This function is effectively an alias for `Number.isInteger`. + */ +export const isIntegralNumber = createArrowFunction( + Number.isInteger, + { name: "isIntegralNumber" }, +); + +/** + * Returns whether the provided value is nan. + * + * ※ This function is effectively an alias for `Number.isNaN`. + */ +export const isNan = createArrowFunction( + Number.isNaN, + { name: "isNan" }, +); + +/** + * Returns whether the provided value is a safe integral number. + * + * ※ This function is effectively an alias for `Number.isSafeInteger`. + */ +export const isSafeIntegralNumber = createArrowFunction( + Number.isSafeInteger, + { name: "isSafeIntegralNumber" }, +); + +/** + * Returns the ln of the provided value. + * + * ※ This function is effectively an alias for `Math.log`. + * + * ☡ This function does not allow big·int arguments. + */ +export const ln = createArrowFunction(Math.log, { name: "ln" }); + +/** + * Returns the ln of one plus the provided value. + * + * ※ This function is effectively an alias for `Math.log1p`. + * + * ☡ This function does not allow big·int arguments. + */ +export const ln1p = createArrowFunction(Math.log1p, { name: "ln1p" }); + +/** + * Returns the log10 of the provided value. + * + * ※ This function is effectively an alias for `Math.log10`. + * + * ☡ This function does not allow big·int arguments. + */ +export const log10 = createArrowFunction(Math.log10); + +/** + * Returns the log2 of the provided value. + * + * ※ This function is effectively an alias for `Math.log2`. + * + * ☡ This function does not allow big·int arguments. + */ +export const log2 = createArrowFunction(Math.log2); + /** * Returns the highest value of the provided arguments, or negative * infinity if no argument is provided. @@ -464,7 +433,7 @@ export const { * ☡ If no argument is supplied, the result will be a number, not a * big·int. */ -export const max = (...$s) => { +export const max = Object.defineProperties((...$s) => { let highest = undefined; for (let i = 0; i < $s.length; ++i) { // Iterate over all the numbers. @@ -500,7 +469,7 @@ export const max = (...$s) => { } } return highest ?? NEGATIVE_INFINITY; -}; +}, { name: { value: "max" }, length: { value: 2 } }); /** * Returns the lowest value of the provided arguments, or positive @@ -513,7 +482,7 @@ export const max = (...$s) => { * ☡ If no argument is supplied, the result will be a number, not a * big·int. */ -export const min = (...$s) => { +export const min = Object.defineProperties((...$s) => { let lowest = undefined; for (let i = 0; i < $s.length; ++i) { // Iterate over all the numbers. @@ -550,7 +519,26 @@ export const min = (...$s) => { } } return lowest ?? POSITIVE_INFINITY; -}; +}, { name: { value: "min" }, length: { value: 2 } }); + +/** + * Returns a pseudo·random value in the range [0, 1). + * + * ※ This function is effectively an alias for `Math.random`. + */ +export const rand = createArrowFunction( + Math.random, + { name: "rand" }, +); + +/** + * Returns the round of the provided value. + * + * ※ This function is effectively an alias for `Math.round`. + * + * ☡ This function does not allow big·int arguments. + */ +export const round = createArrowFunction(Math.round); /** * Returns a unit value with the same sign as the provided value, or @@ -582,6 +570,51 @@ export const sgn = ($) => { : 1; }; +/** + * Returns the sin of the provided value. + * + * ※ This function is effectively an alias for `Math.sin`. + * + * ☡ This function does not allow big·int arguments. + */ +export const sin = createArrowFunction(Math.sin); + +/** + * Returns the sinh of the provided value. + * + * ※ This function is effectively an alias for `Math.sinh`. + * + * ☡ This function does not allow big·int arguments. + */ +export const sinh = createArrowFunction(Math.sinh); + +/** + * Returns the square root of the provided value. + * + * ※ This function is effectively an alias for `Math.sqrt`. + * + * ☡ This function does not allow big·int arguments. + */ +export const sqrt = createArrowFunction(Math.sqrt); + +/** + * Returns the tan of the provided value. + * + * ※ This function is effectively an alias for `Math.tan`. + * + * ☡ This function does not allow big·int arguments. + */ +export const tan = createArrowFunction(Math.tan); + +/** + * Returns the tanh of the provided value. + * + * ※ This function is effectively an alias for `Math.tanh`. + * + * ☡ This function does not allow big·int arguments. + */ +export const tanh = createArrowFunction(Math.tanh); + /** * Returns the result of converting the provided value to a big·int. * @@ -805,3 +838,12 @@ export const { }, }; })(); + +/** + * Returns the trunc of the provided value. + * + * ※ This function is effectively an alias for `Math.trunc`. + * + * ☡ This function does not allow big·int arguments. + */ +export const trunc = createArrowFunction(Math.trunc); diff --git a/numeric.test.js b/numeric.test.js index 4d3d2cb..9d0dbd1 100644 --- a/numeric.test.js +++ b/numeric.test.js @@ -8,6 +8,7 @@ // file, You can obtain one at . import { + assert, assertStrictEquals, assertThrows, describe, @@ -15,13 +16,55 @@ import { } 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, @@ -32,20 +75,126 @@ import { 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); @@ -55,15 +204,263 @@ describe("abs", () => { 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"); + }); }); }); @@ -75,6 +472,452 @@ describe("clz32", () => { 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", () => { @@ -97,6 +940,22 @@ 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", () => { @@ -119,6 +978,75 @@ 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", () => { @@ -135,12 +1063,179 @@ 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", () => { @@ -171,6 +1266,25 @@ 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", () => { @@ -188,6 +1302,25 @@ 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", () => { @@ -204,6 +1337,22 @@ 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", () => { @@ -219,6 +1368,25 @@ 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", () => { @@ -245,6 +1413,22 @@ 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", () => { @@ -274,6 +1458,25 @@ 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", () => { @@ -304,6 +1507,22 @@ describe("toNumeric", () => { 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", () => { @@ -319,4 +1538,51 @@ 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"); + }); + }); });