@@ -122,24 +122,35 @@ pub fn make_runner() -> proptest::test_runner::TestRunner {
122122 proptest:: test_runner:: TestRunner :: new ( proptest:: test_runner:: Config :: with_cases ( 4 ) )
123123}
124124
125+ #[ track_caller]
126+ fn unwrap_test_error < T , U : std:: fmt:: Debug > (
127+ x : Result < T , proptest:: test_runner:: TestError < U > > ,
128+ ) -> T {
129+ // Using the `Display` instance of the error is much more readable.
130+ match x {
131+ Ok ( v) => v,
132+ Err ( e) => panic ! ( "{e}" ) ,
133+ }
134+ }
135+
125136/// Test a function that takes a single value.
126137pub fn test_1 < A : core:: fmt:: Debug + DefaultStrategy > (
127138 f : & dyn Fn ( A ) -> proptest:: test_runner:: TestCaseResult ,
128139) {
129140 let mut runner = make_runner ( ) ;
130- runner. run ( & A :: default_strategy ( ) , f) . unwrap ( ) ;
141+ unwrap_test_error ( runner. run ( & A :: default_strategy ( ) , f) )
131142}
132143
133144/// Test a function that takes two values.
134145pub fn test_2 < A : core:: fmt:: Debug + DefaultStrategy , B : core:: fmt:: Debug + DefaultStrategy > (
135146 f : & dyn Fn ( A , B ) -> proptest:: test_runner:: TestCaseResult ,
136147) {
137148 let mut runner = make_runner ( ) ;
138- runner
139- . run ( & ( A :: default_strategy ( ) , B :: default_strategy ( ) ) , |( a, b) | {
149+ unwrap_test_error (
150+ runner . run ( & ( A :: default_strategy ( ) , B :: default_strategy ( ) ) , |( a, b) | {
140151 f ( a, b)
141- } )
142- . unwrap ( ) ;
152+ } ) ,
153+ )
143154}
144155
145156/// Test a function that takes two values.
@@ -151,16 +162,14 @@ pub fn test_3<
151162 f : & dyn Fn ( A , B , C ) -> proptest:: test_runner:: TestCaseResult ,
152163) {
153164 let mut runner = make_runner ( ) ;
154- runner
155- . run (
156- & (
157- A :: default_strategy ( ) ,
158- B :: default_strategy ( ) ,
159- C :: default_strategy ( ) ,
160- ) ,
161- |( a, b, c) | f ( a, b, c) ,
162- )
163- . unwrap ( ) ;
165+ unwrap_test_error ( runner. run (
166+ & (
167+ A :: default_strategy ( ) ,
168+ B :: default_strategy ( ) ,
169+ C :: default_strategy ( ) ,
170+ ) ,
171+ |( a, b, c) | f ( a, b, c) ,
172+ ) ) ;
164173}
165174
166175/// Test a unary vector function against a unary scalar function, applied elementwise.
0 commit comments