diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-27 17:58:26 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-04-27 17:58:26 -0700 |
| commit | dc62dde9826a94c161e20bf56e23940dc3f2f0dc (patch) | |
| tree | 0d988423f5b22de5e7c98425d633eb385483b538 /test | |
| parent | 758ec9bdd4585b28f50cb7beb01b1cfc4e3cf1a9 (diff) | |
| download | zig-dc62dde9826a94c161e20bf56e23940dc3f2f0dc.tar.gz zig-dc62dde9826a94c161e20bf56e23940dc3f2f0dc.zip | |
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.
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/bugs/920.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test/behavior/bugs/920.zig b/test/behavior/bugs/920.zig index 5a7cadc595..19fce71549 100644 --- a/test/behavior/bugs/920.zig +++ b/test/behavior/bugs/920.zig @@ -63,6 +63,13 @@ test "bug 920 fixed" { }; for (NormalDist1.f) |_, i| { - try std.testing.expectEqual(NormalDist1.f[i], NormalDist.f[i]); + // Here we use `expectApproxEqAbs` instead of `expectEqual` 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. + try std.testing.expectApproxEqAbs(NormalDist1.f[i], NormalDist.f[i], @sqrt(std.math.floatEps(f64))); } } |
