limbo/core/assert.rs
Pekka Enberg 645c0bd796 core: Add Antithesis-aware turso_assert
This adds a `turso_assert` macro that is Antithesis aware when
`antithesis` feature flag is enabled. I did not yet convert any
call-sites to use it.

Co-authored-by: Nikita Sivukhin <sivukhin@turso.tech>
2025-06-29 11:46:18 +03:00

25 lines
834 B
Rust

/// turso_assert! is a direct replacement for assert! builtin macros which under the hood
/// uses Antithesis SDK to guide Antithesis simulator if --features antithesis is enabled
#[cfg(not(feature = "antithesis"))]
#[macro_export]
macro_rules! turso_assert {
($cond:expr, $msg:literal, $($optional:tt)+) => {
assert!($cond, $msg, $($optional)+);
};
($cond:expr, $msg:literal) => {
assert!($cond, $msg);
};
}
#[cfg(feature = "antithesis")]
#[macro_export]
macro_rules! turso_assert {
($cond:expr, $msg:literal, $($optional:tt)+) => {
antithesis_sdk::assert_always_or_unreachable!($cond, $msg);
assert!($cond, $msg, $($optional)+);
};
($cond:expr, $msg:literal) => {
antithesis_sdk::assert_always_or_unreachable!($cond, $msg);
assert!($cond, $msg);
};
}