Skip to content

Commit ff9995e

Browse files
committed
added test cases for closure arg hygiene
1 parent 63fb7c6 commit ff9995e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/libsyntax/ext/expand.rs

+22
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,28 @@ mod test {
13871387
0)
13881388
}
13891389

1390+
// closure arg hygiene
1391+
// expands to fn f(){(|x_1 : int| {(x_2 + x_1)})(3);}
1392+
#[test] fn closure_arg_hygiene(){
1393+
run_renaming_test(
1394+
&("macro_rules! inject_x (()=>(x))
1395+
fn f(){(|x : int| {(inject_x!() + x)})(3);}",
1396+
vec!(vec!(1)),
1397+
true),
1398+
0)
1399+
}
1400+
1401+
// closure arg hygiene (ExprProc)
1402+
// expands to fn f(){(proc(x_1 : int) {(x_2 + x_1)})(3);}
1403+
#[test] fn closure_arg_hygiene_2(){
1404+
run_renaming_test(
1405+
&("macro_rules! inject_x (()=>(x))
1406+
fn f(){ (proc(x : int){(inject_x!() + x)})(3); }",
1407+
vec!(vec!(1)),
1408+
true),
1409+
0)
1410+
}
1411+
13901412
// run one of the renaming tests
13911413
fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
13921414
let invalid_name = token::special_idents::invalid.name;

0 commit comments

Comments
 (0)