From 8d5c3c092349c473d2b54ea1fe7edf12be025456 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 11 Oct 2026 09:47:01 +0200 Subject: [PATCH] union-parity test: only a quiet-bit-clear NaN is signalling; a finite float32 with bit 22 clear still reads Builds; kills the Stryker survivor at wire.ts:111 (the exponent test replaced by true). Co-Authored-By: Claude Opus 5.5 --- packages/cultcache-ts/test/union-parity.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/cultcache-ts/test/union-parity.test.ts b/packages/cultcache-ts/test/union-parity.test.ts index c0f9524e..5fa663b3 100644 --- a/packages/cultcache-ts/test/union-parity.test.ts +++ b/packages/cultcache-ts/test/union-parity.test.ts @@ -604,6 +604,16 @@ test("a float32 NaN round-trips with its bits, and a signalling one is refused o assert.equal(refused, 3); }); +test("only a NaN with its quiet bit clear is signalling: a finite float32 with a clear bit 22 reads, and a float64 slot reads any float32 NaN", () => { + const f32 = slots<{ v: number }>({ 0: ["v", float32] }); + const f64 = slots<{ v: number }>({ 0: ["v", float64] }); + assert.equal(f32.decode(readWire(fromHex("91ca3f800001"))).v, Math.fround(1.0000001192092896)); + assert.equal(f32.decode(readWire(fromHex("91ca00000001"))).v, Math.fround(1e-45)); + assert.equal(f32.decode(readWire(fromHex("91ca7f800000"))).v, Infinity); + assert.ok(Number.isNaN(f32.decode(readWire(fromHex("91ca7fc00001"))).v)); + assert.ok(Number.isNaN(f64.decode(readWire(fromHex("91ca7f800001"))).v)); +}); + test("numeric leaves write the bytes the C# reference writes, and 64-bit values lose nothing", async () => { const rows = readWire(new Uint8Array(await readFile(join(numericVectors, "writes.msgpack")))) as [string, string, Uint8Array][]; assert.equal(rows.length, 46);