diff options
Diffstat (limited to 'macros/src/mock.rs')
-rw-r--r-- | macros/src/mock.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/macros/src/mock.rs b/macros/src/mock.rs index 9aa03f4..4d040a9 100644 --- a/macros/src/mock.rs +++ b/macros/src/mock.rs @@ -226,6 +226,22 @@ fn create_mock_function( }) .collect::<Vec<_>>(); + let typed_args = item_method + .sig + .inputs + .iter() + .filter_map(|fn_arg| match fn_arg { + FnArg::Typed(arg) => { + let Pat::Ident(pat_ident) = arg.pat.as_ref() else { + return None; + }; + + Some(pat_ident.ident.clone()) + } + FnArg::Receiver(_) => None, + }) + .collect::<Vec<_>>(); + let expectations_field = format_ident!("{func_ident}_expectations"); ImplItemMethod { @@ -257,6 +273,8 @@ fn create_mock_function( )) .with_generic_params::<#(#type_param_idents,)*>(); + expectation.check_predicates(#(&#typed_args),*); + (expectation.get_returning())(#(#args),*) } }) |