#[allow(unused_imports)]
use crate::*;
#[macro_export]
macro_rules! FIXME{
({$($code:tt)*} $($fmt:literal $(, $($args:tt),*)? $(,)?)?) => {{
$crate::TRACE_NOBUG!(($($fmt)*) $(,$($args),*)?);
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::ASSERT!({$($code)*}, ("FIXME: " $(, $fmt)?) $($(, $($args),*)?)?);
$crate::NOTICE_ONCE!(("FIXME: " $(, $fmt)?) $($(, $($args),*)?)?);
} else {
compile_error!(concat!("FIXME: " $(, $fmt)?) $($(, $($args),*)?)?);
}
}
}};
($fmt:literal $(, $($args:tt),*)? $(,)?) => {{
$crate::TRACE_NOBUG!($fmt $(,$($args),*)?);
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::DIE!(("FIXME: ", $fmt) $(, $($args),*)?);
} else {
compile_error!(concat!("FIXME: ", $fmt) $(, $($args),*)?);
}
}
}};
}
#[test]
#[cfg(debug_assertions)]
#[should_panic = "FIXME:"]
fn test_fixme() {
FIXME!("this is a bug");
}
#[test]
#[cfg(debug_assertions)]
#[should_panic = "FIXME:"]
fn test_fixme2() {
fn fm() -> i32 {
FIXME!("this is a bug")
}
fm();
}
#[test]
#[cfg(debug_assertions)]
fn test_fixme_codeblock() {
FIXME!({ true });
FIXME!({true} "this is ok");
}
#[test]
#[cfg(debug_assertions)]
#[should_panic = "FIXME:"]
fn test_fixme_codeblock_fail() {
FIXME!({false} "this is a bug again");
}
#[macro_export]
macro_rules! FIXED{
({$($code:tt)*} $($fmt:literal $(, $($args:tt),*)? $(,)?)?) => {{
$crate::TRACE_NOBUG!($($fmt $(,$($args),*)?)?);
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::ASSERT!({$($code)*}, ("REGRESSION: " $(, $fmt)?) $($(, $($args),*)?)?)
} else if #[cfg(not(feature = "completed_in_release"))] {
compile_error!("FIXED: forbidden in release")
}
}
}};
($fmt:literal $(, $($args:tt),*)? $(,)?) => {
$crate::CFG_IF! {
if #[cfg(not(any(debug_assertions, feature = "completed_in_release")))] {
compile_error!("FIXED: forbidden in release")
}
}
};
}
#[test]
fn test_fixed() {
FIXED!({true} "no bug");
}
#[test]
#[cfg(debug_assertions)]
#[should_panic = "REGRESSION:"]
fn test_fixed_fail() {
FIXED!({false} "this is a bug again");
}
#[macro_export]
macro_rules! TODO {
($text:literal) => {{
$crate::TRACE_NOBUG!($text);
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::DIE!("TODO: {}", $text)
} else {
compile_error!(concat!("TODO: ",$text))
}
}
}};
() => {{
$crate::TRACE_NOBUG!();
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::DIE!("TODO")
} else {
compile_error!("TODO")
}
}
}};
}
#[test]
#[cfg(debug_assertions)]
#[should_panic = "TODO:"]
fn test_todo() {
TODO!("message");
}
#[test]
#[cfg(debug_assertions)]
#[should_panic = "TODO"]
fn test_todo_nomsg() {
TODO!();
}
#[macro_export]
macro_rules! WIP {
({$($code:tt)*} $text:literal) => {{
$crate::TRACE_NOBUG!($text);
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
if !{$($code)*} {
$crate::NOTICE!(
("WIP: {}: {{{}}}"),
$text,
stringify!($($code)*)
)
} else {
$crate::NOTICE!(
("WIP DONE: {}: {{{}}}"),
$text,
stringify!($($code)*)
)
}
} else {
compile_error!(concat!("WIP:", $text))
}
}
}};
({$($code:tt)*}) => {{
$crate::TRACE_NOBUG!();
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
if !{$($code)*} {
$crate::NOTICE!(
("WIP: {{{}}}"),
stringify!($($code)*)
)
} else {
$crate::NOTICE!(
("WIP DONE: {{{}}}"),
stringify!($($code)*)
)
}
} else {
compile_error!(concat!("WIP"))
}
}
}};
($text:literal) => {{
$crate::TRACE_NOBUG!($text);
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::NOTICE_ONCE!("WIP: {}", $text)
} else {
compile_error!(concat!("WIP: ", $text))
}
}
}};
() => {{
$crate::TRACE_NOBUG!();
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::NOTICE!("WIP")
} else {
compile_error!("WIP")
}
}
}};
}
#[cfg(debug_assertions)]
#[test]
fn test_wip_only_text() {
WIP!("only text");
WIP!(); }
#[cfg(debug_assertions)]
#[test]
fn test_wip_with_code() {
WIP!({false} "some idea");
WIP!({ false });
WIP!({true} "some idea");
WIP!({ true });
}
#[macro_export]
macro_rules! DONE {
({$($code:tt)*} $text:literal) => {
$crate::TRACE_NOBUG!($text);
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::ASSERT!({$($code)*}, "DONE REGRESSION: {}", $text)
} else if #[cfg(not(feature = "completed_in_release"))] {
compile_error!("DONE: forbidden in release")
}
}
};
({$($code:tt)*}) => {
$crate::TRACE_NOBUG!();
$crate::CFG_IF! {
if #[cfg(debug_assertions)] {
$crate::ASSERT!({$($code)*}, "DONE REGRESSION")
} else if #[cfg(not(feature = "completed_in_release"))] {
compile_error!("DONE: forbidden in release")
}
}
};
($text:literal) => {
$crate::CFG_IF! {
if #[cfg(not(any(debug_assertions, feature = "completed_in_release")))] {
compile_error!("DONE: forbidden in release")
}
}
};
}
#[test]
fn test_done_with_code() {
DONE!({true} "this works");
DONE!({ true });
}
#[test]
#[allow(clippy::missing_const_for_fn)]
fn test_done_textonly() {
DONE!("this works");
}
#[test]
#[cfg(debug_assertions)]
#[should_panic = "DONE REGRESSION:"]
fn test_done_with_code_fail() {
DONE!({false} "this doesn't");
}
#[test]
#[cfg(debug_assertions)]
#[should_panic = "DONE REGRESSION"]
fn test_done_code_only_fail() {
DONE!({ false });
}
#[macro_export]
macro_rules! IDEA {
($text:literal) => {{
$crate::TRACE_NOBUG!($text);
#[cfg(debug_assertions)]
$crate::NOTICE_ONCE!(("IDEA: ", $text));
}};
}
#[test]
fn test_idea() {
IDEA!("message");
}
#[macro_export]
macro_rules! PLANNED {
($text:literal) => {{
$crate::TRACE_NOBUG!($text);
#[cfg(debug_assertions)]
$crate::NOTICE_ONCE!(("PLANNED: ", $text));
}};
}