From 7c931956f38759625c00e30a92265de20ba0fb3d Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Thu, 29 Oct 2026 00:27:45 +0000 Subject: [PATCH] Test: Number, BigInt, String and Boolean called without new convert Needs the compiler change that makes these calls convert to the primitive (TypeScriptCompiler bigint-cluster). Co-Authored-By: Claude Opus 5.5 --- tests/bigint_conversions.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/bigint_conversions.ts diff --git a/tests/bigint_conversions.ts b/tests/bigint_conversions.ts new file mode 100644 index 0000000..a653b44 --- /dev/null +++ b/tests/bigint_conversions.ts @@ -0,0 +1,18 @@ +// `Number(x)`, `BigInt(x)`, `String(x)` and `Boolean(x)` called without `new` convert to the primitive, as in +// JavaScript: each made the class's object, and `BigInt(42) + 1n` or `Number(x) + 0.5` was an invalid cast. +function main() { + const b = BigInt(42); + assert(b + 1n == 43n, "BigInt of a number"); + + const x = 5; + assert(Number(x) + 0.5 == 5.5, "Number of a number"); + assert(Number(10n) + 0.5 == 10.5, "Number of a bigint"); + assert(Number("2.5") * 2 == 5, "Number of a string"); + + assert(String(12) + "!" == "12!", "String of a number"); + assert(!Boolean(0) && Boolean(3), "Boolean of a number"); + + assert(10n.toString() == "10", "a bigint's toString"); + + console.log("ALL DONE"); +}