diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-10 15:49:31 +0200 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-10 15:49:31 +0200 |
| commit | b27809517b26089ad3359c1212caf9c3ffbf247d (patch) | |
| tree | 0bb51c2fcd28fd5e2af434bea5e5784d495d386b /src/test/values.zig | |
| parent | 320c5aafff0499512475686feb374bdfde2a4123 (diff) | |
NaN-packing changes for interpreter.
Diffstat (limited to 'src/test/values.zig')
| -rw-r--r-- | src/test/values.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/values.zig b/src/test/values.zig index 968a5bc..a276b2e 100644 --- a/src/test/values.zig +++ b/src/test/values.zig @@ -42,6 +42,29 @@ test "fixnum" { try testing.expectEqual(int1 + int2, result); } +test "snan" { + // Can speculative execution screw up sNaN handling? + const v1 = value.fixnum.pack(1234); + const v2 = value.fixnum.pack(1234); + + // Even executing this unconditionally doesn't seem to cause issues on my + // machine, so it's not clear how to best test this. + //const f = v1.double + v2.double; + //std.debug.print("oh no! {}\n", .{f}); + + if (v1.isDouble() and v2.isDouble()) { + @branchHint(.likely); + // This actually doesn't even cause any issues if you execute it + // unconditionally. It just prints the NaN value. + const fl = v1.double + v2.double; + std.debug.print("oh no! {}\n", .{fl}); + } else { + @branchHint(.cold); + const v3 = value.fixnum.add(v1, v2); + try testing.expectEqual(value.fixnum.unpack(v3), 2468); + } +} + test "ptr" { const ptr = value.ptr; |
