authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-27 17:58:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-27 17:58:26-07:00
logdc62dde9826a94c161e20bf56e23940dc3f2f0dc
tree0d988423f5b22de5e7c98425d633eb385483b538
parent758ec9bdd4585b28f50cb7beb01b1cfc4e3cf1a9

behavior test: use expectApproxEqAbs instead of expectEqual

This is to account for the small differences in math functions of different libcs. For example, if the compiler links against glibc, but the target is musl libc, then these values might be slightly different. Arguably, this is a bug in the compiler because comptime should emulate the target, including rounding errors in libc math functions. However that behavior is not what this particular test is intended to cover.

1 files changed, 8 insertions(+), 1 deletions(-)

test/behavior/bugs/920.zig+8-1
......@@ -63,6 +63,13 @@ test "bug 920 fixed" {
6363 };
6464
6565 for (NormalDist1.f) |_, i| {
66 try std.testing.expectEqual(NormalDist1.f[i], NormalDist.f[i]);
66 // Here we use `expectApproxEqAbs` instead of `expectEqual` to account for the small
67 // differences in math functions of different libcs. For example, if the compiler
68 // links against glibc, but the target is musl libc, then these values might be
69 // slightly different.
70 // Arguably, this is a bug in the compiler because comptime should emulate the target,
71 // including rounding errors in libc math functions. However that behavior is not
72 // what this particular test is intended to cover.
73 try std.testing.expectApproxEqAbs(NormalDist1.f[i], NormalDist.f[i], @sqrt(std.math.floatEps(f64)));
6774 }
6875}