aboutsummaryrefslogtreecommitdiff
path: root/mingling_cli/src/lints.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_cli/src/lints.rs')
-rw-r--r--mingling_cli/src/lints.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/mingling_cli/src/lints.rs b/mingling_cli/src/lints.rs
index 5bed483..8fab924 100644
--- a/mingling_cli/src/lints.rs
+++ b/mingling_cli/src/lints.rs
@@ -58,4 +58,22 @@ pub fn run_all_lints(file: &syn::File, source: &str) -> Vec<MlintReport> {
// Remove allowed reports (sentinel = Help)
reports.retain(|r| r.level != MlintLevel::Help);
reports
+}
+
+#[macro_export]
+macro_rules! assert_detected {
+ ($linter:expr, $ast_type:ty => $code:tt) => {
+ // Parse the string into a syn::ItemFn
+ let ast: $ast_type = syn::parse_str(&stringify!($code)).unwrap();
+ assert!(!$linter(ast, &stringify!($code).to_string()).is_empty());
+ };
+}
+
+#[macro_export]
+macro_rules! assert_not_detected {
+ ($linter:expr, $ast_type:ty => $code:tt) => {
+ // Parse the string into a syn::ItemFn
+ let ast: $ast_type = syn::parse_str(&stringify!($code)).unwrap();
+ assert!($linter(ast, &stringify!($code).to_string()).is_empty());
+ };
} \ No newline at end of file