diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-02-26 16:30:15 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-02-26 16:30:15 -0500 |
| commit | 8dd0b4e1f12bc9f70ff6c312b35563595fdb4476 (patch) | |
| tree | 05022203182824c64c65cb5d64bbde5b04eb7743 | |
| parent | 0ac1934ad64716adeb98620003a0b905fb5cfda6 (diff) | |
| download | zig-8dd0b4e1f12bc9f70ff6c312b35563595fdb4476.tar.gz zig-8dd0b4e1f12bc9f70ff6c312b35563595fdb4476.zip | |
add passing test for floating point edge case
| -rw-r--r-- | test/cases/math.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/cases/math.zig b/test/cases/math.zig index 55f6680493..fc1555ef14 100644 --- a/test/cases/math.zig +++ b/test/cases/math.zig @@ -201,3 +201,18 @@ fn smallIntAddition() { assert(result == 0); } + +fn testFloatEquality() { + @setFnTest(this); + + const x: f64 = 0.012; + const y: f64 = x + 1.0; + + testFloatEqualityImpl(x, y); + comptime testFloatEqualityImpl(x, y); +} + +fn testFloatEqualityImpl(x: f64, y: f64) { + const y2 = x + 1.0; + assert(y == y2); +} |
