@@ -199,8 +199,8 @@ use quote::quote;
199
199
200
200
use crate :: parse:: {
201
201
fixture:: FixtureInfo ,
202
- parametrize :: { ParametrizeData , ParametrizeInfo , TestCase } ,
203
- rstest:: { RsTestAttributes , RsTestInfo } ,
202
+ testcase :: TestCase ,
203
+ rstest:: { RsTestAttributes , RsTestInfo , RsTestData } ,
204
204
} ;
205
205
use crate :: refident:: MaybeIdent ;
206
206
use crate :: resolver:: { arg_2_fixture, Resolver } ;
@@ -625,8 +625,8 @@ fn duplicate_arguments_errors<'a, I: MaybeIdent + Spanned + 'a>(args: impl Itera
625
625
)
626
626
}
627
627
628
- fn invalid_case_errors ( params : & ParametrizeData ) -> Errors {
629
- let n_args = params. args ( ) . count ( ) ;
628
+ fn invalid_case_errors ( params : & RsTestData ) -> Errors {
629
+ let n_args = params. case_args ( ) . count ( ) ;
630
630
Box :: new (
631
631
params. cases ( )
632
632
. filter ( move |case| case. args . len ( ) != n_args)
@@ -636,10 +636,10 @@ fn invalid_case_errors(params: &ParametrizeData) -> Errors {
636
636
)
637
637
}
638
638
639
- fn errors_in_parametrize ( test : & ItemFn , info : & ParametrizeInfo ) -> TokenStream {
640
- missed_arguments_errors ( test, info. data . args ( ) )
639
+ fn errors_in_parametrize ( test : & ItemFn , info : & RsTestInfo ) -> TokenStream {
640
+ missed_arguments_errors ( test, info. data . case_args ( ) )
641
641
. chain ( missed_arguments_errors ( test, info. data . fixtures ( ) ) )
642
- . chain ( duplicate_arguments_errors ( info. data . data . iter ( ) ) )
642
+ . chain ( duplicate_arguments_errors ( info. data . items . iter ( ) ) )
643
643
. chain ( invalid_case_errors ( & info. data ) )
644
644
. map ( |e| e. to_compile_error ( ) )
645
645
. collect ( )
@@ -717,8 +717,8 @@ fn format_case_name(case: &TestCase, index: usize, display_len: usize) -> String
717
717
format ! ( "case_{:0len$}{d}" , index, len = display_len, d = description)
718
718
}
719
719
720
- fn render_parametrize_cases ( test : ItemFn , params : ParametrizeInfo ) -> TokenStream {
721
- let ParametrizeInfo { data, attributes } = params;
720
+ fn render_parametrize_cases ( test : ItemFn , params : RsTestInfo ) -> TokenStream {
721
+ let RsTestInfo { data, attributes } = params;
722
722
let display_len = data. cases ( ) . count ( ) . display_len ( ) ;
723
723
724
724
let cases = data. cases ( )
@@ -729,7 +729,7 @@ fn render_parametrize_cases(test: ItemFn, params: ParametrizeInfo) -> TokenStrea
729
729
move |( n, case) |
730
730
{
731
731
let resolver_fixtures = resolver:: fixture_resolver ( data. fixtures ( ) ) ;
732
- let resolver_case = data. args ( )
732
+ let resolver_case = data. case_args ( )
733
733
. map ( |a| a. to_string ( ) )
734
734
. zip ( case. args . iter ( ) )
735
735
. collect :: < HashMap < _ , _ > > ( ) ;
@@ -858,7 +858,7 @@ fn render_matrix_cases(test: ItemFn, params: parse::matrix::MatrixInfo) -> Token
858
858
pub fn rstest_parametrize ( args : proc_macro:: TokenStream , input : proc_macro:: TokenStream )
859
859
-> proc_macro:: TokenStream
860
860
{
861
- let params = parse_macro_input ! ( args as ParametrizeInfo ) ;
861
+ let params = parse_macro_input ! ( args as RsTestInfo ) ;
862
862
let test = parse_macro_input ! ( input as ItemFn ) ;
863
863
864
864
let errors = errors_in_parametrize ( & test, & params) ;
@@ -1127,24 +1127,25 @@ mod render {
1127
1127
mod parametrize_cases {
1128
1128
use std:: iter:: FromIterator ;
1129
1129
1130
- use crate :: parse:: parametrize:: { ParametrizeData , ParametrizeInfo , ParametrizeItem , TestCase } ;
1130
+ use crate :: parse:: rstest:: { RsTestInfo , RsTestData , RsTestItem } ;
1131
+ use crate :: parse:: testcase:: TestCase ;
1131
1132
1132
1133
use super :: { * , assert_eq} ;
1133
1134
1134
- impl < ' a > From < & ' a ItemFn > for ParametrizeData {
1135
+ impl < ' a > From < & ' a ItemFn > for RsTestData {
1135
1136
fn from ( item_fn : & ' a ItemFn ) -> Self {
1136
- ParametrizeData {
1137
- data : fn_args_idents ( item_fn)
1137
+ RsTestData {
1138
+ items : fn_args_idents ( item_fn)
1138
1139
. cloned ( )
1139
- . map ( ParametrizeItem :: CaseArgName )
1140
+ . map ( RsTestItem :: CaseArgName )
1140
1141
. collect ( ) ,
1141
1142
}
1142
1143
}
1143
1144
}
1144
1145
1145
- impl < ' a > From < & ' a ItemFn > for ParametrizeInfo {
1146
+ impl < ' a > From < & ' a ItemFn > for RsTestInfo {
1146
1147
fn from ( item_fn : & ' a ItemFn ) -> Self {
1147
- ParametrizeInfo {
1148
+ RsTestInfo {
1148
1149
data : item_fn. into ( ) ,
1149
1150
attributes : Default :: default ( ) ,
1150
1151
}
@@ -1212,13 +1213,13 @@ mod render {
1212
1213
assert_eq ! ( expected, output. module. attrs) ;
1213
1214
}
1214
1215
1215
- impl ParametrizeInfo {
1216
+ impl RsTestInfo {
1216
1217
fn push_case ( & mut self , case : TestCase ) {
1217
- self . data . data . push ( ParametrizeItem :: TestCase ( case) ) ;
1218
+ self . data . items . push ( RsTestItem :: TestCase ( case) ) ;
1218
1219
}
1219
1220
1220
1221
fn extend ( & mut self , cases : impl Iterator < Item =TestCase > ) {
1221
- self . data . data . extend ( cases. map ( ParametrizeItem :: TestCase ) ) ;
1222
+ self . data . items . extend ( cases. map ( RsTestItem :: TestCase ) ) ;
1222
1223
}
1223
1224
}
1224
1225
@@ -1239,20 +1240,20 @@ mod render {
1239
1240
}
1240
1241
}
1241
1242
1242
- fn one_simple_case ( ) -> ( ItemFn , ParametrizeInfo ) {
1243
+ fn one_simple_case ( ) -> ( ItemFn , RsTestInfo ) {
1243
1244
let item_fn = parse_str :: < ItemFn > (
1244
1245
r#"fn test(mut fix: String) { println!("user code") }"#
1245
1246
) . unwrap ( ) ;
1246
- let mut info: ParametrizeInfo = ( & item_fn) . into ( ) ;
1247
+ let mut info: RsTestInfo = ( & item_fn) . into ( ) ;
1247
1248
info. push_case ( TestCase :: from ( r#"String::from("3")"# ) ) ;
1248
1249
( item_fn, info)
1249
1250
}
1250
1251
1251
- fn some_simple_cases ( cases : i32 ) -> ( ItemFn , ParametrizeInfo ) {
1252
+ fn some_simple_cases ( cases : i32 ) -> ( ItemFn , RsTestInfo ) {
1252
1253
let item_fn = parse_str :: < ItemFn > (
1253
1254
r#"fn test(mut fix: String) { println!("user code") }"#
1254
1255
) . unwrap ( ) ;
1255
- let mut info: ParametrizeInfo = ( & item_fn) . into ( ) ;
1256
+ let mut info: RsTestInfo = ( & item_fn) . into ( ) ;
1256
1257
info. extend ( ( 0 ..cases) . map ( |_| TestCase :: from ( r#"String::from("3")"# ) ) ) ;
1257
1258
( item_fn, info)
1258
1259
}
@@ -1317,7 +1318,7 @@ mod render {
1317
1318
let ( item_fn, mut info) = one_simple_case ( ) ;
1318
1319
let description = "show_this_description" ;
1319
1320
1320
- if let & mut ParametrizeItem :: TestCase ( ref mut case) = & mut info. data . data [ 1 ] {
1321
+ if let & mut RsTestItem :: TestCase ( ref mut case) = & mut info. data . items [ 1 ] {
1321
1322
case. description = Some ( parse_str :: < Ident > ( description) . unwrap ( ) ) ;
1322
1323
} else {
1323
1324
panic ! ( "Test case should be the second one" ) ;
@@ -1336,7 +1337,7 @@ mod render {
1336
1337
1337
1338
use crate :: parse:: matrix:: { MatrixData , MatrixInfo , ValueList } ;
1338
1339
1339
- /// Should test matrix tests render without take in account MatrixInfo to ParametrizeInfo
1340
+ /// Should test matrix tests render without take in account MatrixInfo to RsTestInfo
1340
1341
/// transformation
1341
1342
1342
1343
use super :: { * , assert_eq} ;
0 commit comments