Skip to content

Commit ef36808

Browse files
committed
Clean up syntax expansion tests
1 parent 4163a72 commit ef36808

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
@@ -1112,7 +1112,7 @@ impl<'a, 'v> Visitor<'v> for MacroExterminator<'a> {
11121112
#[cfg(test)]
11131113
mod test {
11141114
use super::{pattern_bindings, expand_crate, contains_macro_escape};
1115-
use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer};
1115+
use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig};
11161116
use ast;
11171117
use ast::{Attribute_, AttrOuter, MetaWord, Name};
11181118
use attr;
@@ -1177,6 +1177,13 @@ mod test {
11771177
// these following tests are quite fragile, in that they don't test what
11781178
// *kind* of failure occurs.
11791179

1180+
fn test_ecfg() -> ExpansionConfig {
1181+
ExpansionConfig {
1182+
deriving_hash_type_parameter: false,
1183+
crate_name: "test".to_string(),
1184+
}
1185+
}
1186+
11801187
// make sure that macros can't escape fns
11811188
#[should_fail]
11821189
#[test] fn macros_cant_escape_fns_test () {
@@ -1188,11 +1195,7 @@ mod test {
11881195
src,
11891196
Vec::new(), &sess);
11901197
// should fail:
1191-
let cfg = ::syntax::ext::expand::ExpansionConfig {
1192-
deriving_hash_type_parameter: false,
1193-
crate_name: "test".to_string(),
1194-
};
1195-
expand_crate(&sess,cfg,vec!(),vec!(),crate_ast);
1198+
expand_crate(&sess,test_ecfg(),vec!(),vec!(),crate_ast);
11961199
}
11971200

11981201
// make sure that macros can't escape modules
@@ -1205,11 +1208,7 @@ mod test {
12051208
"<test>".to_string(),
12061209
src,
12071210
Vec::new(), &sess);
1208-
let cfg = ::syntax::ext::expand::ExpansionConfig {
1209-
deriving_hash_type_parameter: false,
1210-
crate_name: "test".to_string(),
1211-
};
1212-
expand_crate(&sess,cfg,vec!(),vec!(),crate_ast);
1211+
expand_crate(&sess,test_ecfg(),vec!(),vec!(),crate_ast);
12131212
}
12141213

12151214
// macro_escape modules should allow macros to escape
@@ -1221,11 +1220,7 @@ mod test {
12211220
"<test>".to_string(),
12221221
src,
12231222
Vec::new(), &sess);
1224-
let cfg = ::syntax::ext::expand::ExpansionConfig {
1225-
deriving_hash_type_parameter: false,
1226-
crate_name: "test".to_string(),
1227-
};
1228-
expand_crate(&sess, cfg, vec!(), vec!(), crate_ast);
1223+
expand_crate(&sess, test_ecfg(), vec!(), vec!(), crate_ast);
12291224
}
12301225

12311226
#[test] fn test_contains_flatten (){
@@ -1258,11 +1253,7 @@ mod test {
12581253
let ps = parse::new_parse_sess();
12591254
let crate_ast = string_to_parser(&ps, crate_str).parse_crate_mod();
12601255
// the cfg argument actually does matter, here...
1261-
let cfg = ::syntax::ext::expand::ExpansionConfig {
1262-
deriving_hash_type_parameter: false,
1263-
crate_name: "test".to_string(),
1264-
};
1265-
expand_crate(&ps,cfg,vec!(),vec!(),crate_ast)
1256+
expand_crate(&ps,test_ecfg(),vec!(),vec!(),crate_ast)
12661257
}
12671258

12681259
// find the pat_ident paths in a crate

0 commit comments

Comments
 (0)