unit test cases now pass, added a few to the interner
This commit is contained in:
parent
ad25e208ee
commit
cb504f5404
@ -170,19 +170,6 @@ fn fun_to_str(decl: ast::fn_decl, name: ast::ident,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fun_to_str() {
|
||||
let decl: ast::fn_decl = ast::fn_decl {
|
||||
inputs: ~[],
|
||||
output: @ast::Ty {id: 0,
|
||||
node: ast::ty_nil,
|
||||
span: ast_util::dummy_sp()},
|
||||
//purity: ast::impure_fn,
|
||||
cf: ast::return_val
|
||||
};
|
||||
assert fun_to_str(decl, "abba", ~[]) == "fn abba()";
|
||||
}
|
||||
|
||||
fn block_to_str(blk: ast::blk, intr: @ident_interner) -> ~str {
|
||||
do io::with_str_writer |wr| {
|
||||
let s = rust_printer(wr, intr);
|
||||
@ -207,20 +194,6 @@ fn variant_to_str(var: ast::variant, intr: @ident_interner) -> ~str {
|
||||
to_str(var, print_variant, intr)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_variant_to_str() {
|
||||
let var = ast_util::respan(ast_util::dummy_sp(), {
|
||||
name: "principle_skinner",
|
||||
attrs: ~[],
|
||||
args: ~[],
|
||||
id: 0,
|
||||
disr_expr: None
|
||||
});
|
||||
|
||||
let varstr = variant_to_str(var);
|
||||
assert varstr == "principle_skinner";
|
||||
}
|
||||
|
||||
fn cbox(s: ps, u: uint) {
|
||||
s.boxes.push(pp::consistent);
|
||||
pp::cbox(s.s, u);
|
||||
@ -2273,6 +2246,56 @@ fn proto_to_str(p: ast::Proto) -> ~str {
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use ast;
|
||||
use ast_util;
|
||||
use parse;
|
||||
use super::*;
|
||||
//use util;
|
||||
|
||||
fn string_check<T : Eq> (given : &T, expected: &T) {
|
||||
if !(given == expected) {
|
||||
fail (fmt!("given %?, expected %?",given,expected));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fun_to_str() {
|
||||
let mock_interner = parse::token::mk_fake_ident_interner();
|
||||
let abba_ident = mock_interner.intern(@~"abba");
|
||||
|
||||
let decl: ast::fn_decl = ast::fn_decl {
|
||||
inputs: ~[],
|
||||
output: @ast::Ty {id: 0,
|
||||
node: ast::ty_nil,
|
||||
span: ast_util::dummy_sp()},
|
||||
cf: ast::return_val
|
||||
};
|
||||
assert fun_to_str(decl, abba_ident, ~[],mock_interner)
|
||||
== ~"fn abba()";
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_variant_to_str() {
|
||||
let mock_interner = parse::token::mk_fake_ident_interner();
|
||||
let ident = mock_interner.intern(@~"principal_skinner");
|
||||
|
||||
let var = ast_util::respan(ast_util::dummy_sp(), ast::variant_ {
|
||||
name: ident,
|
||||
attrs: ~[],
|
||||
// making this up as I go.... ?
|
||||
kind: ast::tuple_variant_kind(~[]),
|
||||
id: 0,
|
||||
disr_expr: None,
|
||||
vis: ast::public,
|
||||
});
|
||||
|
||||
let varstr = variant_to_str(var,mock_interner);
|
||||
string_check(&varstr,&~"pub principal_skinner");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
Loading…
x
Reference in New Issue
Block a user