@@ -1452,10 +1452,6 @@ mod test {
1452
1452
pprust::print_mod(s, &crate.module, crate.attrs);
1453
1453
}
1454
1454
1455
- // " fn a( ) -> int { let b = 13 ; let c = b; b+c } " --> b & c should get new names, in the expr too.
1456
- // " macro_rules! f ( ( $x: ident) => ( $x + b) ) fn a( ) -> int { let b = 13 ; f!( b) } " --> one should
1457
- // be renamed, one should not.
1458
-
1459
1455
fn expand_and_resolve_and_pretty_print (crate_str : @str) -> ~str {
1460
1456
let resolver = new_ident_resolver();
1461
1457
let resolver_fold = fun_to_ident_folder(resolver);
@@ -1469,10 +1465,20 @@ mod test {
1469
1465
1470
1466
#[ test]
1471
1467
fn automatic_renaming ( ) {
1468
+ // "fn a() -> int { let b = 13; let c = b; b+c }"
1469
+ // --> b & c should get new names, in the expr too.
1470
+ // "macro_rules! f (($x:ident) => ($x + b)) fn a() -> int { let b = 13; f!(b)}"
1471
+ // --> one should be renamed, one should not.
1472
+
1472
1473
let teststrs =
1473
- ~[ @"fn a ( ) -> int { let b = 13 ; let c = b; b+c } ",
1474
- @" macro_rules! f ( ( $x: ident) => ( $x + b) ) fn a ( ) -> int { let b = 13 ; f ! ( b) } "];
1474
+ ~[ // b & c should get new names throughout, in the expr too:
1475
+ @"fn a ( ) -> int { let b = 13 ; let c = b; b+c } ",
1476
+ // the use of b before the + should be renamed, the other one not:
1477
+ @" macro_rules! f ( ( $x: ident) => ( $x + b) ) fn a ( ) -> int { let b = 13 ; f ! ( b) } ",
1478
+ // the b before the plus should not be renamed (requires marks)
1479
+ @" macro_rules! f ( ( $x: ident) => ( { let b=9 ; ( $x + b) } ) ) fn a ( ) -> int { f ! ( b) } "];
1475
1480
for s in teststrs.iter() {
1481
+ // we need regexps to test these!
1476
1482
std::io::println(expand_and_resolve_and_pretty_print(*s));
1477
1483
}
1478
1484
}
0 commit comments