compat: float reads return the canonical NaN for NaN payloads (checked through the bits: no aliased LuaJIT object values); host: raise LuaJIT trace / mcode limits (opt-out FORMATS_NO_JIT_TUNE)

This commit is contained in:
4DBug committed 2026-10-31 09:07:07 -05:00
1 parent 8e49c997ce
commit 15b742cada
2 files changed
+28

No files matched your search

+21
View File
@@ -272,4 +272,25 @@ do
t:eq(0x7FFFFFFF + 1, 2147483648, "no integer overflow")
end
do -- float reads: NaNs with a payload come back as the canonical NaN (LuaJIT: never an aliased object value)
local b = buffer.create(16)
buffer.writeu32(b, 0, 0x7fc12345)
buffer.writeu32(b, 4, 0x7f800000)
buffer.writeu32(b, 8, 0xdeadbeef)
buffer.writeu32(b, 12, 0xfff12345)
local a, i, c = buffer.readf32(b, 0), buffer.readf32(b, 4), buffer.readf64(b, 8)
t:eq(type(a), "number", "f32 NaN payload is a number")
t:ok(a ~= a, "f32 NaN payload reads as NaN")
t:eq(i, math.huge, "f32 +inf")
t:eq(type(c), "number", "f64 NaN payload is a number")
t:ok(c ~= c, "f64 NaN payload reads as NaN")
buffer.writeu32(b, 8, 0)
buffer.writeu32(b, 12, 0xfff00000)
t:eq(buffer.readf64(b, 8), -math.huge, "f64 -inf")
buffer.writef32(b, 0, 1.5)
buffer.writef64(b, 8, -2.25)
t:eq(buffer.readf32(b, 0), 1.5, "f32 normal")
t:eq(buffer.readf64(b, 8), -2.25, "f64 normal")
end
t:done()