From c2db077574be841da586fa62d67619c901dd535d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 8 Feb 2019 18:18:47 -0500 Subject: std.debug.assert: remove special case for test builds Previously, std.debug.assert would `@panic` in test builds, if the assertion failed. Now, it's always `unreachable`. This makes release mode test builds more accurately test the actual code that will be run. However this requires tests to call `std.testing.expect` rather than `std.debug.assert` to make sure output is correct. Here is the explanation of when to use either one, copied from the assert doc comments: Inside a test block, it is best to use the `std.testing` module rather than assert, because assert may not detect a test failure in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert is the correct function to use. closes #1304 --- std/math/sinh.zig | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'std/math/sinh.zig') diff --git a/std/math/sinh.zig b/std/math/sinh.zig index 733b89754a..95924ba55a 100644 --- a/std/math/sinh.zig +++ b/std/math/sinh.zig @@ -7,7 +7,7 @@ const builtin = @import("builtin"); const std = @import("../index.zig"); const math = std.math; -const assert = std.debug.assert; +const expect = std.testing.expect; const expo2 = @import("expo2.zig").expo2; const maxInt = std.math.maxInt; @@ -87,40 +87,40 @@ fn sinh64(x: f64) f64 { } test "math.sinh" { - assert(sinh(f32(1.5)) == sinh32(1.5)); - assert(sinh(f64(1.5)) == sinh64(1.5)); + expect(sinh(f32(1.5)) == sinh32(1.5)); + expect(sinh(f64(1.5)) == sinh64(1.5)); } test "math.sinh32" { const epsilon = 0.000001; - assert(math.approxEq(f32, sinh32(0.0), 0.0, epsilon)); - assert(math.approxEq(f32, sinh32(0.2), 0.201336, epsilon)); - assert(math.approxEq(f32, sinh32(0.8923), 1.015512, epsilon)); - assert(math.approxEq(f32, sinh32(1.5), 2.129279, epsilon)); + expect(math.approxEq(f32, sinh32(0.0), 0.0, epsilon)); + expect(math.approxEq(f32, sinh32(0.2), 0.201336, epsilon)); + expect(math.approxEq(f32, sinh32(0.8923), 1.015512, epsilon)); + expect(math.approxEq(f32, sinh32(1.5), 2.129279, epsilon)); } test "math.sinh64" { const epsilon = 0.000001; - assert(math.approxEq(f64, sinh64(0.0), 0.0, epsilon)); - assert(math.approxEq(f64, sinh64(0.2), 0.201336, epsilon)); - assert(math.approxEq(f64, sinh64(0.8923), 1.015512, epsilon)); - assert(math.approxEq(f64, sinh64(1.5), 2.129279, epsilon)); + expect(math.approxEq(f64, sinh64(0.0), 0.0, epsilon)); + expect(math.approxEq(f64, sinh64(0.2), 0.201336, epsilon)); + expect(math.approxEq(f64, sinh64(0.8923), 1.015512, epsilon)); + expect(math.approxEq(f64, sinh64(1.5), 2.129279, epsilon)); } test "math.sinh32.special" { - assert(sinh32(0.0) == 0.0); - assert(sinh32(-0.0) == -0.0); - assert(math.isPositiveInf(sinh32(math.inf(f32)))); - assert(math.isNegativeInf(sinh32(-math.inf(f32)))); - assert(math.isNan(sinh32(math.nan(f32)))); + expect(sinh32(0.0) == 0.0); + expect(sinh32(-0.0) == -0.0); + expect(math.isPositiveInf(sinh32(math.inf(f32)))); + expect(math.isNegativeInf(sinh32(-math.inf(f32)))); + expect(math.isNan(sinh32(math.nan(f32)))); } test "math.sinh64.special" { - assert(sinh64(0.0) == 0.0); - assert(sinh64(-0.0) == -0.0); - assert(math.isPositiveInf(sinh64(math.inf(f64)))); - assert(math.isNegativeInf(sinh64(-math.inf(f64)))); - assert(math.isNan(sinh64(math.nan(f64)))); + expect(sinh64(0.0) == 0.0); + expect(sinh64(-0.0) == -0.0); + expect(math.isPositiveInf(sinh64(math.inf(f64)))); + expect(math.isNegativeInf(sinh64(-math.inf(f64)))); + expect(math.isNan(sinh64(math.nan(f64)))); } -- cgit v1.2.3