aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-08 18:18:47 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-08 18:23:38 -0500
commitc2db077574be841da586fa62d67619c901dd535d (patch)
treec8eb64846fa7ffb9027fa1ca035dd8ca5712b9d4 /doc
parentbe6d022257d8d7e99bd080823d4d8f0175f320c5 (diff)
downloadzig-c2db077574be841da586fa62d67619c901dd535d.tar.gz
zig-c2db077574be841da586fa62d67619c901dd535d.zip
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
Diffstat (limited to 'doc')
-rw-r--r--doc/docgen.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/doc/docgen.zig b/doc/docgen.zig
index 14e4700553..7aaf5ebdc7 100644
--- a/doc/docgen.zig
+++ b/doc/docgen.zig
@@ -4,7 +4,7 @@ const io = std.io;
const os = std.os;
const warn = std.debug.warn;
const mem = std.mem;
-const assert = std.debug.assert;
+const testing = std.testing;
const max_doc_file_size = 10 * 1024 * 1024;
@@ -620,7 +620,7 @@ const TermState = enum {
test "term color" {
const input_bytes = "A\x1b[32;1mgreen\x1b[0mB";
const result = try termColor(std.debug.global_allocator, input_bytes);
- assert(mem.eql(u8, result, "A<span class=\"t32\">green</span>B"));
+ testing.expectEqualSlices(u8, "A<span class=\"t32\">green</span>B", result));
}
fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 {