From 16d761ac9593fec586663cb399f967ccea630b91 Mon Sep 17 00:00:00 2001 From: McModknower Date: Tue, 3 Feb 2026 22:02:16 +0100 Subject: [PATCH] fix: missing arguments when shrinking does not find a smaller input --- src/tester.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/tester.rs b/src/tester.rs index f09326c..6500cbe 100644 --- a/src/tester.rs +++ b/src/tester.rs @@ -393,11 +393,18 @@ impl r, Fail => { - shrink_failure(g, self_, a).unwrap_or(r) + shrink_failure(g, self_, a.clone()).unwrap_or_else( + || { + //if no shrinked value failed, we need to add the arguments here. + let ($(ref $name,)*) : ($($name,)*) = a; + r.arguments = Some(debug_reprs(&[$($name),*])); + r + } + ) } } } @@ -466,4 +473,16 @@ mod test { } crate::quickcheck(foo_can_shrink as fn(i8) -> bool); } + + #[test] + fn arguments_when_shrinking_does_not_find_a_smaller_input() { + fn thetest(x: bool) -> bool { + x + } + let failing_case = QuickCheck::new() + .quicktest(thetest as fn(x: bool) -> bool) + .unwrap_err(); + let expected_argument = format!("{:?}", false); + assert_eq!(failing_case.arguments, Some(vec![expected_argument])); + } }