@@ -197,7 +197,8 @@ pub struct Bencher {
197197#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
198198pub enum ShouldPanic {
199199 No ,
200- Yes ( Option < & ' static str > )
200+ Yes ,
201+ YesWithMessage ( & ' static str )
201202}
202203
203204// The definition of a single test. A test runner will run a list of
@@ -262,8 +263,8 @@ pub fn test_main(args: &[String], tests: Vec<TestDescAndFn> ) {
262263// a Vec<TestDescAndFn> is used in order to effect ownership-transfer
263264// semantics into parallel test runners, which in turn requires a Vec<>
264265// rather than a &[].
265- pub fn test_main_static ( args : env :: Args , tests : & [ TestDescAndFn ] ) {
266- let args = args. collect :: < Vec < _ > > ( ) ;
266+ pub fn test_main_static ( tests : & [ TestDescAndFn ] ) {
267+ let args = env :: args ( ) . collect :: < Vec < _ > > ( ) ;
267268 let owned_tests = tests. iter ( ) . map ( |t| {
268269 match t. testfn {
269270 StaticTestFn ( f) => TestDescAndFn { testfn : StaticTestFn ( f) , desc : t. desc . clone ( ) } ,
@@ -1027,8 +1028,8 @@ pub fn run_test(opts: &TestOpts,
10271028fn calc_result ( desc : & TestDesc , task_result : Result < ( ) , Box < Any +Send > > ) -> TestResult {
10281029 match ( & desc. should_panic , task_result) {
10291030 ( & ShouldPanic :: No , Ok ( ( ) ) ) |
1030- ( & ShouldPanic :: Yes ( None ) , Err ( _) ) => TrOk ,
1031- ( & ShouldPanic :: Yes ( Some ( msg) ) , Err ( ref err) )
1031+ ( & ShouldPanic :: Yes , Err ( _) ) => TrOk ,
1032+ ( & ShouldPanic :: YesWithMessage ( msg) , Err ( ref err) )
10321033 if err. downcast_ref :: < String > ( )
10331034 . map ( |e| & * * e)
10341035 . or_else ( || err. downcast_ref :: < & ' static str > ( ) . map ( |e| * e) )
@@ -1276,7 +1277,7 @@ mod tests {
12761277 desc : TestDesc {
12771278 name : StaticTestName ( "whatever" ) ,
12781279 ignore : false ,
1279- should_panic : ShouldPanic :: Yes ( None )
1280+ should_panic : ShouldPanic :: Yes ,
12801281 } ,
12811282 testfn : DynTestFn ( Box :: new ( move || f ( ) ) ) ,
12821283 } ;
@@ -1293,7 +1294,7 @@ mod tests {
12931294 desc : TestDesc {
12941295 name : StaticTestName ( "whatever" ) ,
12951296 ignore : false ,
1296- should_panic : ShouldPanic :: Yes ( Some ( "error message" ) )
1297+ should_panic : ShouldPanic :: YesWithMessage ( "error message" ) ,
12971298 } ,
12981299 testfn : DynTestFn ( Box :: new ( move || f ( ) ) ) ,
12991300 } ;
@@ -1310,7 +1311,7 @@ mod tests {
13101311 desc : TestDesc {
13111312 name : StaticTestName ( "whatever" ) ,
13121313 ignore : false ,
1313- should_panic : ShouldPanic :: Yes ( Some ( "foobar" ) )
1314+ should_panic : ShouldPanic :: YesWithMessage ( "foobar" ) ,
13141315 } ,
13151316 testfn : DynTestFn ( Box :: new ( move || f ( ) ) ) ,
13161317 } ;
@@ -1327,7 +1328,7 @@ mod tests {
13271328 desc : TestDesc {
13281329 name : StaticTestName ( "whatever" ) ,
13291330 ignore : false ,
1330- should_panic : ShouldPanic :: Yes ( None )
1331+ should_panic : ShouldPanic :: Yes ,
13311332 } ,
13321333 testfn : DynTestFn ( Box :: new ( move || f ( ) ) ) ,
13331334 } ;
0 commit comments