Skip to content

Commit c3c07ce

Browse files
committed
PR feedback
1 parent 51d4daa commit c3c07ce

9 files changed

+3853
-4
lines changed

proptest-macro/src/property_test/codegen/mod.rs

+29-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use proc_macro2::TokenStream;
22
use quote::{quote, ToTokens};
33
use syn::{parse_str, spanned::Spanned, Attribute, Ident, ItemFn, PatType};
44

5-
use super::{utils::strip_args, options::Options};
5+
use super::{options::Options, utils::strip_args};
66

77
mod test_body;
88

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

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

4039
*argless_fn.block = new_body;
41-
4240
argless_fn.attrs.push(test_attr());
4341

4442
argless_fn.to_token_stream()
@@ -203,3 +201,31 @@ mod tests {
203201
assert_eq!(arb.to_string(), expected.to_string());
204202
}
205203
}
204+
205+
#[cfg(test)]
206+
mod snapshot_tests {
207+
use super::*;
208+
209+
macro_rules! snapshot_test {
210+
($name:ident) => {
211+
#[test]
212+
fn $name() {
213+
const TEXT: &str = include_str!(concat!(
214+
"test_data/",
215+
stringify!($name),
216+
".rs"
217+
));
218+
219+
let tokens = generate(
220+
parse_str(TEXT).unwrap(),
221+
$crate::property_test::options::Options::default(),
222+
);
223+
insta::assert_debug_snapshot!(tokens);
224+
}
225+
};
226+
}
227+
228+
snapshot_test!(simple);
229+
snapshot_test!(many_params);
230+
snapshot_test!(arg_pattern);
231+
}

0 commit comments

Comments
 (0)