Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron1024 committed May 18, 2024
1 parent 51d4daa commit c3c07ce
Show file tree
Hide file tree
Showing 9 changed files with 3,853 additions and 4 deletions.
32 changes: 29 additions & 3 deletions proptest-macro/src/property_test/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::{parse_str, spanned::Spanned, Attribute, Ident, ItemFn, PatType};

use super::{utils::strip_args, options::Options};
use super::{options::Options, utils::strip_args};

mod test_body;

Expand All @@ -27,7 +27,6 @@ pub(super) fn generate(item_fn: ItemFn, options: Options) -> TokenStream {
#arb_tokens
};


let new_body = test_body::body(
*argless_fn.block,
&args,
Expand All @@ -38,7 +37,6 @@ pub(super) fn generate(item_fn: ItemFn, options: Options) -> TokenStream {
);

*argless_fn.block = new_body;

argless_fn.attrs.push(test_attr());

argless_fn.to_token_stream()
Expand Down Expand Up @@ -203,3 +201,31 @@ mod tests {
assert_eq!(arb.to_string(), expected.to_string());
}
}

#[cfg(test)]
mod snapshot_tests {
use super::*;

macro_rules! snapshot_test {
($name:ident) => {
#[test]
fn $name() {
const TEXT: &str = include_str!(concat!(
"test_data/",
stringify!($name),
".rs"
));

let tokens = generate(
parse_str(TEXT).unwrap(),
$crate::property_test::options::Options::default(),
);
insta::assert_debug_snapshot!(tokens);
}
};
}

snapshot_test!(simple);
snapshot_test!(many_params);
snapshot_test!(arg_pattern);
}
Loading

0 comments on commit c3c07ce

Please sign in to comment.