Skip to content

Commit 6c294ba

Browse files
committed
add test case, cleanup
1 parent fe1d21c commit 6c294ba

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use ast::{item_mac, Mrk, Stmt_, StmtDecl, StmtMac, StmtExpr, StmtSemi};
1414
use ast::{token_tree};
1515
use ast;
1616
use ast_util::{mtwt_outer_mark, new_rename, new_mark};
17-
use ast_util;
1817
use attr;
1918
use attr::AttrMetaMethods;
2019
use codemap;
@@ -1549,6 +1548,7 @@ mod test {
15491548
use ast;
15501549
use ast::{Attribute_, AttrOuter, MetaWord, EMPTY_CTXT};
15511550
use ast_util::{get_sctable, mtwt_marksof, mtwt_resolve, new_rename};
1551+
use ast_util;
15521552
use codemap;
15531553
use codemap::Spanned;
15541554
use fold;
@@ -1557,8 +1557,7 @@ mod test {
15571557
use parse::token;
15581558
use print::pprust;
15591559
use std;
1560-
use std::vec;
1561-
use util::parser_testing::{string_to_crate, string_to_crate_and_sess, string_to_item};
1560+
use util::parser_testing::{string_to_crate, string_to_crate_and_sess};
15621561
use util::parser_testing::{string_to_pat, string_to_tts, strs_to_idents};
15631562
use visit;
15641563

@@ -1779,9 +1778,11 @@ mod test {
17791778
macro_rules! user(($x:ident) => ({letty!($x); $x}))
17801779
fn main() -> int {user!(z)}",
17811780
~[~[0]], false),
1782-
// can't believe I missed this one : a macro def that refers to a local var:
1783-
("fn main() {let x = 19; macro_rules! getx(()=>(x)); getx!();}",
1784-
~[~[0]], true)
1781+
// FIXME #8062: this test exposes a *potential* bug; our system does
1782+
// not behave exactly like MTWT, but I haven't thought of a way that
1783+
// this could cause a bug in Rust, yet.
1784+
// ("fn main() {let hrcoo = 19; macro_rules! getx(()=>(hrcoo)); getx!();}",
1785+
// ~[~[0]], true)
17851786
// FIXME #6994: the next string exposes the bug referred to in issue 6994, so I'm
17861787
// commenting it out.
17871788
// the z flows into and out of two macros (g & f) along one path, and one
@@ -1800,6 +1801,7 @@ mod test {
18001801

18011802
// run one of the renaming tests
18021803
fn run_renaming_test(t : &renaming_test) {
1804+
let invalid_name = token::special_idents::invalid.name;
18031805
let (teststr, bound_connections, bound_ident_check) = match *t {
18041806
(ref str,ref conns, bic) => (str.to_managed(), conns.clone(), bic)
18051807
};
@@ -1814,7 +1816,7 @@ mod test {
18141816
assert_eq!(bindings.len(),bound_connections.len());
18151817
for (binding_idx,shouldmatch) in bound_connections.iter().enumerate() {
18161818
let binding_name = mtwt_resolve(bindings[binding_idx]);
1817-
let binding_marks = mtwt_marksof(bindings[binding_idx].ctxt,binding_name);
1819+
let binding_marks = mtwt_marksof(bindings[binding_idx].ctxt,invalid_name);
18181820
// shouldmatch can't name varrefs that don't exist:
18191821
assert!((shouldmatch.len() == 0) ||
18201822
(varrefs.len() > *shouldmatch.iter().max().unwrap()));
@@ -1825,20 +1827,17 @@ mod test {
18251827
assert_eq!(varref.segments.len(),1);
18261828
let varref_name = mtwt_resolve(varref.segments[0].identifier);
18271829
let varref_marks = mtwt_marksof(varref.segments[0].identifier.ctxt,
1828-
binding_name);
1830+
invalid_name);
18291831
if (!(varref_name==binding_name)){
18301832
std::io::println("uh oh, should match but doesn't:");
18311833
std::io::println(fmt!("varref: %?",varref));
18321834
std::io::println(fmt!("binding: %?", bindings[binding_idx]));
1833-
let table = get_sctable();
1834-
std::io::println("SC table:");
1835-
for (idx,val) in table.table.iter().enumerate() {
1836-
std::io::println(fmt!("%4u : %?",idx,val));
1837-
}
1835+
ast_util::display_sctable(get_sctable());
18381836
}
18391837
assert_eq!(varref_name,binding_name);
18401838
if (bound_ident_check) {
1841-
// we need to check the marks, too:
1839+
// we're checking bound-identifier=?, and the marks
1840+
// should be the same, too:
18421841
assert_eq!(varref_marks,binding_marks.clone());
18431842
}
18441843
} else {
@@ -1849,7 +1848,7 @@ mod test {
18491848
std::io::println("uh oh, matches but shouldn't:");
18501849
std::io::println(fmt!("varref: %?",varref));
18511850
std::io::println(fmt!("binding: %?", bindings[binding_idx]));
1852-
std::io::println(fmt!("sc_table: %?",get_sctable()));
1851+
ast_util::display_sctable(get_sctable());
18531852
}
18541853
assert!(!fail);
18551854
}

src/libsyntax/parse/token.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,6 @@ pub fn mtwt_token_eq(t1 : &Token, t2 : &Token) -> bool {
729729
#[cfg(test)]
730730
mod test {
731731
use super::*;
732-
use std::io;
733-
use std::managed;
734732
use ast;
735733
use ast_util;
736734

0 commit comments

Comments
 (0)