rustc: Fix fun_to_str

This commit is contained in:
Brian Anderson 2012-01-19 18:09:06 -08:00
parent 052340980b
commit 991db34b5b

View File

@ -98,10 +98,24 @@ fn fun_to_str(decl: ast::fn_decl, name: ast::ident,
let buffer = io::mk_mem_buffer();
let s = rust_printer(io::mem_buffer_writer(buffer));
print_fn(s, decl, name, params);
end(s); // Close the head box
end(s); // Close the outer box
eof(s.s);
io::mem_buffer_str(buffer)
}
#[test]
fn test_fun_to_str() {
let decl: ast::fn_decl = {
inputs: [],
output: @ast_util::respan(ast_util::dummy_sp(), ast::ty_nil),
purity: ast::impure_fn,
cf: ast::return_val,
constraints: []
};
assert fun_to_str(decl, "a", []) == "fn a()";
}
fn block_to_str(blk: ast::blk) -> str {
let buffer = io::mk_mem_buffer();
let s = rust_printer(io::mem_buffer_writer(buffer));