Skip to content

Commit f1096c3

Browse files
author
Keegan McAllister
committed
Clean up syntax expansion tests
1 parent 0adf3a9 commit f1096c3

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ impl<'a, 'v> Visitor<'v> for MacroExterminator<'a> {
11201120
#[cfg(test)]
11211121
mod test {
11221122
use super::{pattern_bindings, expand_crate, contains_macro_escape};
1123-
use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer};
1123+
use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig};
11241124
use ast;
11251125
use ast::{Attribute_, AttrOuter, MetaWord, Name};
11261126
use attr;
@@ -1185,6 +1185,13 @@ mod test {
11851185
// these following tests are quite fragile, in that they don't test what
11861186
// *kind* of failure occurs.
11871187

1188+
fn test_ecfg() -> ExpansionConfig {
1189+
ExpansionConfig {
1190+
deriving_hash_type_parameter: false,
1191+
crate_name: "test".to_string(),
1192+
}
1193+
}
1194+
11881195
// make sure that macros can't escape fns
11891196
#[should_fail]
11901197
#[test] fn macros_cant_escape_fns_test () {
@@ -1196,11 +1203,7 @@ mod test {
11961203
src,
11971204
Vec::new(), &sess);
11981205
// should fail:
1199-
let cfg = ::syntax::ext::expand::ExpansionConfig {
1200-
deriving_hash_type_parameter: false,
1201-
crate_name: "test".to_string(),
1202-
};
1203-
expand_crate(&sess,cfg,vec!(),vec!(),crate_ast);
1206+
expand_crate(&sess,test_ecfg(),vec!(),vec!(),crate_ast);
12041207
}
12051208

12061209
// make sure that macros can't escape modules
@@ -1213,11 +1216,7 @@ mod test {
12131216
"<test>".to_string(),
12141217
src,
12151218
Vec::new(), &sess);
1216-
let cfg = ::syntax::ext::expand::ExpansionConfig {
1217-
deriving_hash_type_parameter: false,
1218-
crate_name: "test".to_string(),
1219-
};
1220-
expand_crate(&sess,cfg,vec!(),vec!(),crate_ast);
1219+
expand_crate(&sess,test_ecfg(),vec!(),vec!(),crate_ast);
12211220
}
12221221

12231222
// macro_escape modules should allow macros to escape
@@ -1229,11 +1228,7 @@ mod test {
12291228
"<test>".to_string(),
12301229
src,
12311230
Vec::new(), &sess);
1232-
let cfg = ::syntax::ext::expand::ExpansionConfig {
1233-
deriving_hash_type_parameter: false,
1234-
crate_name: "test".to_string(),
1235-
};
1236-
expand_crate(&sess, cfg, vec!(), vec!(), crate_ast);
1231+
expand_crate(&sess, test_ecfg(), vec!(), vec!(), crate_ast);
12371232
}
12381233

12391234
#[test] fn test_contains_flatten (){
@@ -1266,11 +1261,7 @@ mod test {
12661261
let ps = parse::new_parse_sess();
12671262
let crate_ast = string_to_parser(&ps, crate_str).parse_crate_mod();
12681263
// the cfg argument actually does matter, here...
1269-
let cfg = ::syntax::ext::expand::ExpansionConfig {
1270-
deriving_hash_type_parameter: false,
1271-
crate_name: "test".to_string(),
1272-
};
1273-
expand_crate(&ps,cfg,vec!(),vec!(),crate_ast)
1264+
expand_crate(&ps,test_ecfg(),vec!(),vec!(),crate_ast)
12741265
}
12751266

12761267
// find the pat_ident paths in a crate

0 commit comments

Comments
 (0)