add test case, cleanup
This commit is contained in:
parent
fe1d21caec
commit
6c294ba538
@ -14,7 +14,6 @@ use ast::{item_mac, Mrk, Stmt_, StmtDecl, StmtMac, StmtExpr, StmtSemi};
|
||||
use ast::{token_tree};
|
||||
use ast;
|
||||
use ast_util::{mtwt_outer_mark, new_rename, new_mark};
|
||||
use ast_util;
|
||||
use attr;
|
||||
use attr::AttrMetaMethods;
|
||||
use codemap;
|
||||
@ -1549,6 +1548,7 @@ mod test {
|
||||
use ast;
|
||||
use ast::{Attribute_, AttrOuter, MetaWord, EMPTY_CTXT};
|
||||
use ast_util::{get_sctable, mtwt_marksof, mtwt_resolve, new_rename};
|
||||
use ast_util;
|
||||
use codemap;
|
||||
use codemap::Spanned;
|
||||
use fold;
|
||||
@ -1557,8 +1557,7 @@ mod test {
|
||||
use parse::token;
|
||||
use print::pprust;
|
||||
use std;
|
||||
use std::vec;
|
||||
use util::parser_testing::{string_to_crate, string_to_crate_and_sess, string_to_item};
|
||||
use util::parser_testing::{string_to_crate, string_to_crate_and_sess};
|
||||
use util::parser_testing::{string_to_pat, string_to_tts, strs_to_idents};
|
||||
use visit;
|
||||
|
||||
@ -1779,9 +1778,11 @@ mod test {
|
||||
macro_rules! user(($x:ident) => ({letty!($x); $x}))
|
||||
fn main() -> int {user!(z)}",
|
||||
~[~[0]], false),
|
||||
// can't believe I missed this one : a macro def that refers to a local var:
|
||||
("fn main() {let x = 19; macro_rules! getx(()=>(x)); getx!();}",
|
||||
~[~[0]], true)
|
||||
// FIXME #8062: this test exposes a *potential* bug; our system does
|
||||
// not behave exactly like MTWT, but I haven't thought of a way that
|
||||
// this could cause a bug in Rust, yet.
|
||||
// ("fn main() {let hrcoo = 19; macro_rules! getx(()=>(hrcoo)); getx!();}",
|
||||
// ~[~[0]], true)
|
||||
// FIXME #6994: the next string exposes the bug referred to in issue 6994, so I'm
|
||||
// commenting it out.
|
||||
// the z flows into and out of two macros (g & f) along one path, and one
|
||||
@ -1800,6 +1801,7 @@ mod test {
|
||||
|
||||
// run one of the renaming tests
|
||||
fn run_renaming_test(t : &renaming_test) {
|
||||
let invalid_name = token::special_idents::invalid.name;
|
||||
let (teststr, bound_connections, bound_ident_check) = match *t {
|
||||
(ref str,ref conns, bic) => (str.to_managed(), conns.clone(), bic)
|
||||
};
|
||||
@ -1814,7 +1816,7 @@ mod test {
|
||||
assert_eq!(bindings.len(),bound_connections.len());
|
||||
for (binding_idx,shouldmatch) in bound_connections.iter().enumerate() {
|
||||
let binding_name = mtwt_resolve(bindings[binding_idx]);
|
||||
let binding_marks = mtwt_marksof(bindings[binding_idx].ctxt,binding_name);
|
||||
let binding_marks = mtwt_marksof(bindings[binding_idx].ctxt,invalid_name);
|
||||
// shouldmatch can't name varrefs that don't exist:
|
||||
assert!((shouldmatch.len() == 0) ||
|
||||
(varrefs.len() > *shouldmatch.iter().max().unwrap()));
|
||||
@ -1825,20 +1827,17 @@ mod test {
|
||||
assert_eq!(varref.segments.len(),1);
|
||||
let varref_name = mtwt_resolve(varref.segments[0].identifier);
|
||||
let varref_marks = mtwt_marksof(varref.segments[0].identifier.ctxt,
|
||||
binding_name);
|
||||
invalid_name);
|
||||
if (!(varref_name==binding_name)){
|
||||
std::io::println("uh oh, should match but doesn't:");
|
||||
std::io::println(fmt!("varref: %?",varref));
|
||||
std::io::println(fmt!("binding: %?", bindings[binding_idx]));
|
||||
let table = get_sctable();
|
||||
std::io::println("SC table:");
|
||||
for (idx,val) in table.table.iter().enumerate() {
|
||||
std::io::println(fmt!("%4u : %?",idx,val));
|
||||
}
|
||||
ast_util::display_sctable(get_sctable());
|
||||
}
|
||||
assert_eq!(varref_name,binding_name);
|
||||
if (bound_ident_check) {
|
||||
// we need to check the marks, too:
|
||||
// we're checking bound-identifier=?, and the marks
|
||||
// should be the same, too:
|
||||
assert_eq!(varref_marks,binding_marks.clone());
|
||||
}
|
||||
} else {
|
||||
@ -1849,7 +1848,7 @@ mod test {
|
||||
std::io::println("uh oh, matches but shouldn't:");
|
||||
std::io::println(fmt!("varref: %?",varref));
|
||||
std::io::println(fmt!("binding: %?", bindings[binding_idx]));
|
||||
std::io::println(fmt!("sc_table: %?",get_sctable()));
|
||||
ast_util::display_sctable(get_sctable());
|
||||
}
|
||||
assert!(!fail);
|
||||
}
|
||||
|
@ -729,8 +729,6 @@ pub fn mtwt_token_eq(t1 : &Token, t2 : &Token) -> bool {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use std::io;
|
||||
use std::managed;
|
||||
use ast;
|
||||
use ast_util;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user