Skip to content

Commit 56c4ddf

Browse files
committed
Remove irrelevant tests
1 parent 0701571 commit 56c4ddf

File tree

3 files changed

+3
-169
lines changed

3 files changed

+3
-169
lines changed

src/libsyntax/ext/expand.rs

+1-130
Original file line numberDiff line numberDiff line change
@@ -757,18 +757,11 @@ fn mark_tts(tts: &[TokenTree], m: Mrk) -> Vec<TokenTree> {
757757

758758
#[cfg(test)]
759759
mod tests {
760-
use super::{pattern_bindings, expand_crate};
761-
use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig};
760+
use super::{expand_crate, ExpansionConfig};
762761
use ast;
763-
use ast::Name;
764-
use syntax_pos;
765762
use ext::base::{ExtCtxt, DummyMacroLoader};
766-
use ext::mtwt;
767-
use fold::Folder;
768763
use parse;
769-
use parse::token;
770764
use util::parser_testing::{string_to_parser};
771-
use util::parser_testing::{string_to_pat, string_to_crate, strs_to_idents};
772765
use visit;
773766
use visit::Visitor;
774767

@@ -789,32 +782,6 @@ mod tests {
789782
}
790783
}
791784

792-
// find the variable references in a crate
793-
fn crate_varrefs(the_crate : &ast::Crate) -> Vec<ast::Path> {
794-
let mut path_finder = PathExprFinderContext{path_accumulator:Vec::new()};
795-
visit::walk_crate(&mut path_finder, the_crate);
796-
path_finder.path_accumulator
797-
}
798-
799-
/// A Visitor that extracts the identifiers from a thingy.
800-
// as a side note, I'm starting to want to abstract over these....
801-
struct IdentFinder {
802-
ident_accumulator: Vec<ast::Ident>
803-
}
804-
805-
impl Visitor for IdentFinder {
806-
fn visit_ident(&mut self, _: syntax_pos::Span, id: ast::Ident){
807-
self.ident_accumulator.push(id);
808-
}
809-
}
810-
811-
/// Find the idents in a crate
812-
fn crate_idents(the_crate: &ast::Crate) -> Vec<ast::Ident> {
813-
let mut ident_finder = IdentFinder{ident_accumulator: Vec::new()};
814-
visit::walk_crate(&mut ident_finder, the_crate);
815-
ident_finder.ident_accumulator
816-
}
817-
818785
// these following tests are quite fragile, in that they don't test what
819786
// *kind* of failure occurs.
820787

@@ -876,13 +843,6 @@ mod tests {
876843
expand_crate(ecx, vec![], crate_ast).0
877844
}
878845

879-
// find the pat_ident paths in a crate
880-
fn crate_bindings(the_crate : &ast::Crate) -> Vec<ast::Ident> {
881-
let mut name_finder = PatIdentFinder{ident_accumulator:Vec::new()};
882-
visit::walk_crate(&mut name_finder, the_crate);
883-
name_finder.ident_accumulator
884-
}
885-
886846
#[test] fn macro_tokens_should_match(){
887847
expand_crate_str(
888848
"macro_rules! m((a)=>(13)) ;fn main(){m!(a);}".to_string());
@@ -899,93 +859,4 @@ mod tests {
899859
// create a really evil test case where a $x appears inside a binding of $x
900860
// but *shouldn't* bind because it was inserted by a different macro....
901861
// can't write this test case until we have macro-generating macros.
902-
903-
#[test]
904-
fn fmt_in_macro_used_inside_module_macro() {
905-
let crate_str = "macro_rules! fmt_wrap(($b:expr)=>($b.to_string()));
906-
macro_rules! foo_module (() => (mod generated { fn a() { let xx = 147; fmt_wrap!(xx);}}));
907-
foo_module!();
908-
".to_string();
909-
let cr = expand_crate_str(crate_str);
910-
// find the xx binding
911-
let bindings = crate_bindings(&cr);
912-
let cxbinds: Vec<&ast::Ident> =
913-
bindings.iter().filter(|b| b.name.as_str() == "xx").collect();
914-
let cxbinds: &[&ast::Ident] = &cxbinds[..];
915-
let cxbind = match (cxbinds.len(), cxbinds.get(0)) {
916-
(1, Some(b)) => *b,
917-
_ => panic!("expected just one binding for ext_cx")
918-
};
919-
let resolved_binding = mtwt::resolve(*cxbind);
920-
let varrefs = crate_varrefs(&cr);
921-
922-
// the xx binding should bind all of the xx varrefs:
923-
for (idx,v) in varrefs.iter().filter(|p| {
924-
p.segments.len() == 1
925-
&& p.segments[0].identifier.name.as_str() == "xx"
926-
}).enumerate() {
927-
if mtwt::resolve(v.segments[0].identifier) != resolved_binding {
928-
println!("uh oh, xx binding didn't match xx varref:");
929-
println!("this is xx varref \\# {}", idx);
930-
println!("binding: {}", cxbind);
931-
println!("resolves to: {}", resolved_binding);
932-
println!("varref: {}", v.segments[0].identifier);
933-
println!("resolves to: {}",
934-
mtwt::resolve(v.segments[0].identifier));
935-
mtwt::with_sctable(|x| mtwt::display_sctable(x));
936-
}
937-
assert_eq!(mtwt::resolve(v.segments[0].identifier),
938-
resolved_binding);
939-
};
940-
}
941-
942-
#[test]
943-
fn pat_idents(){
944-
let pat = string_to_pat(
945-
"(a,Foo{x:c @ (b,9),y:Bar(4,d)})".to_string());
946-
let idents = pattern_bindings(&pat);
947-
assert_eq!(idents, strs_to_idents(vec!("a","c","b","d")));
948-
}
949-
950-
// test the list of identifier patterns gathered by the visitor. Note that
951-
// 'None' is listed as an identifier pattern because we don't yet know that
952-
// it's the name of a 0-ary variant, and that 'i' appears twice in succession.
953-
#[test]
954-
fn crate_bindings_test(){
955-
let the_crate = string_to_crate("fn main (a: i32) -> i32 {|b| {
956-
match 34 {None => 3, Some(i) | i => j, Foo{k:z,l:y} => \"banana\"}} }".to_string());
957-
let idents = crate_bindings(&the_crate);
958-
assert_eq!(idents, strs_to_idents(vec!("a","b","None","i","i","z","y")));
959-
}
960-
961-
// test the IdentRenamer directly
962-
#[test]
963-
fn ident_renamer_test () {
964-
let the_crate = string_to_crate("fn f(x: i32){let x = x; x}".to_string());
965-
let f_ident = token::str_to_ident("f");
966-
let x_ident = token::str_to_ident("x");
967-
let int_ident = token::str_to_ident("i32");
968-
let renames = vec!((x_ident,Name(16)));
969-
let mut renamer = IdentRenamer{renames: &renames};
970-
let renamed_crate = renamer.fold_crate(the_crate);
971-
let idents = crate_idents(&renamed_crate);
972-
let resolved : Vec<ast::Name> = idents.iter().map(|id| mtwt::resolve(*id)).collect();
973-
assert_eq!(resolved, [f_ident.name,Name(16),int_ident.name,Name(16),Name(16),Name(16)]);
974-
}
975-
976-
// test the PatIdentRenamer; only PatIdents get renamed
977-
#[test]
978-
fn pat_ident_renamer_test () {
979-
let the_crate = string_to_crate("fn f(x: i32){let x = x; x}".to_string());
980-
let f_ident = token::str_to_ident("f");
981-
let x_ident = token::str_to_ident("x");
982-
let int_ident = token::str_to_ident("i32");
983-
let renames = vec!((x_ident,Name(16)));
984-
let mut renamer = PatIdentRenamer{renames: &renames};
985-
let renamed_crate = renamer.fold_crate(the_crate);
986-
let idents = crate_idents(&renamed_crate);
987-
let resolved : Vec<ast::Name> = idents.iter().map(|id| mtwt::resolve(*id)).collect();
988-
let x_name = x_ident.name;
989-
assert_eq!(resolved, [f_ident.name,Name(16),int_ident.name,Name(16),x_name,x_name]);
990-
}
991862
}

src/libsyntax/ext/mtwt.rs

+2-21
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ fn new_sctable_internal() -> SCTable {
7171
}
7272
}
7373

74-
/// Print out an SCTable for debugging
75-
pub fn display_sctable(table: &SCTable) {
76-
error!("SC table:");
77-
for (idx,val) in table.table.borrow().iter().enumerate() {
78-
error!("{:4} : {:?}",idx,val);
79-
}
80-
}
81-
8274
/// Clear the tables from TLD to reclaim memory.
8375
pub fn clear_tables() {
8476
with_sctable(|table| {
@@ -128,13 +120,8 @@ pub fn source(ident: Ident) -> Option<(Ident /* source ident */, Mrk /* source m
128120

129121
#[cfg(test)]
130122
mod tests {
131-
use ast::{EMPTY_CTXT, Ident, Mrk, Name, SyntaxContext};
132-
use super::{resolve, apply_mark_internal, new_sctable_internal};
133-
use super::{SCTable, Mark};
134-
135-
fn id(n: u32, s: SyntaxContext) -> Ident {
136-
Ident::new(Name(n), s)
137-
}
123+
use ast::{EMPTY_CTXT, Mrk, SyntaxContext};
124+
use super::{apply_mark_internal, new_sctable_internal, Mark, SCTable};
138125

139126
// extend a syntax context with a sequence of marks given
140127
// in a vector. v[0] will be the outermost mark.
@@ -155,12 +142,6 @@ mod tests {
155142
}
156143
}
157144

158-
#[test]
159-
fn mtwt_resolve_test(){
160-
let a = 40;
161-
assert_eq!(resolve(id(a,EMPTY_CTXT)),Name(a));
162-
}
163-
164145
#[test]
165146
fn hashing_tests () {
166147
let mut t = new_sctable_internal();

src/libsyntax/parse/token.rs

-18
Original file line numberDiff line numberDiff line change
@@ -637,21 +637,3 @@ pub fn fresh_name(src: ast::Ident) -> ast::Name {
637637
pub fn fresh_mark() -> ast::Mrk {
638638
gensym("mark").0
639639
}
640-
641-
#[cfg(test)]
642-
mod tests {
643-
use super::*;
644-
use ast;
645-
use ext::mtwt;
646-
647-
fn mark_ident(id : ast::Ident, m : ast::Mrk) -> ast::Ident {
648-
ast::Ident::new(id.name, mtwt::apply_mark(m, id.ctxt))
649-
}
650-
651-
#[test] fn mtwt_token_eq_test() {
652-
assert!(Gt.mtwt_eq(&Gt));
653-
let a = str_to_ident("bac");
654-
let a1 = mark_ident(a,92);
655-
assert!(Ident(a).mtwt_eq(&Ident(a1)));
656-
}
657-
}

0 commit comments

Comments
 (0)