@@ -197,7 +197,8 @@ pub struct Bencher {
197
197
#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
198
198
pub enum ShouldPanic {
199
199
No ,
200
- Yes ( Option < & ' static str > )
200
+ Yes ,
201
+ YesWithMessage ( & ' static str )
201
202
}
202
203
203
204
// 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> ) {
262
263
// a Vec<TestDescAndFn> is used in order to effect ownership-transfer
263
264
// semantics into parallel test runners, which in turn requires a Vec<>
264
265
// 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 < _ > > ( ) ;
267
268
let owned_tests = tests. iter ( ) . map ( |t| {
268
269
match t. testfn {
269
270
StaticTestFn ( f) => TestDescAndFn { testfn : StaticTestFn ( f) , desc : t. desc . clone ( ) } ,
@@ -1027,8 +1028,8 @@ pub fn run_test(opts: &TestOpts,
1027
1028
fn calc_result ( desc : & TestDesc , task_result : Result < ( ) , Box < Any +Send > > ) -> TestResult {
1028
1029
match ( & desc. should_panic , task_result) {
1029
1030
( & 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) )
1032
1033
if err. downcast_ref :: < String > ( )
1033
1034
. map ( |e| & * * e)
1034
1035
. or_else ( || err. downcast_ref :: < & ' static str > ( ) . map ( |e| * e) )
@@ -1276,7 +1277,7 @@ mod tests {
1276
1277
desc : TestDesc {
1277
1278
name : StaticTestName ( "whatever" ) ,
1278
1279
ignore : false ,
1279
- should_panic : ShouldPanic :: Yes ( None )
1280
+ should_panic : ShouldPanic :: Yes ,
1280
1281
} ,
1281
1282
testfn : DynTestFn ( Box :: new ( move || f ( ) ) ) ,
1282
1283
} ;
@@ -1293,7 +1294,7 @@ mod tests {
1293
1294
desc : TestDesc {
1294
1295
name : StaticTestName ( "whatever" ) ,
1295
1296
ignore : false ,
1296
- should_panic : ShouldPanic :: Yes ( Some ( "error message" ) )
1297
+ should_panic : ShouldPanic :: YesWithMessage ( "error message" ) ,
1297
1298
} ,
1298
1299
testfn : DynTestFn ( Box :: new ( move || f ( ) ) ) ,
1299
1300
} ;
@@ -1310,7 +1311,7 @@ mod tests {
1310
1311
desc : TestDesc {
1311
1312
name : StaticTestName ( "whatever" ) ,
1312
1313
ignore : false ,
1313
- should_panic : ShouldPanic :: Yes ( Some ( "foobar" ) )
1314
+ should_panic : ShouldPanic :: YesWithMessage ( "foobar" ) ,
1314
1315
} ,
1315
1316
testfn : DynTestFn ( Box :: new ( move || f ( ) ) ) ,
1316
1317
} ;
@@ -1327,7 +1328,7 @@ mod tests {
1327
1328
desc : TestDesc {
1328
1329
name : StaticTestName ( "whatever" ) ,
1329
1330
ignore : false ,
1330
- should_panic : ShouldPanic :: Yes ( None )
1331
+ should_panic : ShouldPanic :: Yes ,
1331
1332
} ,
1332
1333
testfn : DynTestFn ( Box :: new ( move || f ( ) ) ) ,
1333
1334
} ;
0 commit comments