mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
rtl: add custom assert
This commit is contained in:
@@ -84,6 +84,19 @@ pub fn assert_interface(T: type, I: type) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn assert(condition: bool, comptime msg: []const u8, args: anytype) void {
|
||||||
|
if (!condition) {
|
||||||
|
@branchHint(.unlikely);
|
||||||
|
|
||||||
|
switch (@import("builtin").mode) {
|
||||||
|
.ReleaseFast, .ReleaseSmall => unreachable,
|
||||||
|
.Debug, .ReleaseSafe => {
|
||||||
|
std.debug.panicExtra(@returnAddress(), "Assertion failed: " ++ msg, args);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
std.testing.refAllDecls(@This());
|
std.testing.refAllDecls(@This());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user