Skip to content

Commit

Permalink
Fix recursive macro invocation (#66)
Browse files Browse the repository at this point in the history
Close #64.

Signed-off-by: slinkydeveloper <[email protected]>
  • Loading branch information
slinkydeveloper authored Oct 3, 2022
1 parent 6645f17 commit b57c593
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ macro_rules! fail_point {
}};
($name:expr, $cond:expr, $e:expr) => {{
if $cond {
fail_point!($name, $e);
$crate::fail_point!($name, $e);
}
}};
}
Expand Down
20 changes: 20 additions & 0 deletions tests/no_use_import.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2022 TiKV Project Authors. Licensed under Apache-2.0.

use std::*;

#[test]
#[cfg_attr(not(feature = "failpoints"), ignore)]
fn test_return() {
let f = || {
fail::fail_point!("return", |s: Option<String>| s
.map_or(2, |s| s.parse().unwrap()));
0
};
assert_eq!(f(), 0);

fail::cfg("return", "return(1000)").unwrap();
assert_eq!(f(), 1000);

fail::cfg("return", "return").unwrap();
assert_eq!(f(), 2);
}

0 comments on commit b57c593

Please sign in to comment.