From 1745ac9c61010b416673070d466b5007ed48540b Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 15 Mar 2012 15:44:19 +0100 Subject: [PATCH] Remove tests from astencode.rs They mysteriously fail on Windows, and Niko assures me this code is about be replaced anyway. --- src/rustc/metadata/astencode.rs | 116 -------------------------------- 1 file changed, 116 deletions(-) diff --git a/src/rustc/metadata/astencode.rs b/src/rustc/metadata/astencode.rs index ee0afc22fb4..5cd46fd6790 100644 --- a/src/rustc/metadata/astencode.rs +++ b/src/rustc/metadata/astencode.rs @@ -901,119 +901,3 @@ fn decode_side_tables(xcx: extended_decode_ctxt, #debug[">< Side table doc loaded"]; } } - -// ______________________________________________________________________ -// Testing of astencode_gen - -#[cfg(test)] -fn encode_item_ast(ebml_w: ebml::writer, item: @ast::item) { - ebml_w.wr_tag(c::tag_tree as uint) {|| - astencode_gen::serialize_syntax_ast_item(ebml_w, *item); - } -} - -#[cfg(test)] -fn decode_item_ast(par_doc: ebml::doc) -> @ast::item { - let chi_doc = par_doc[c::tag_tree]; - let d = ebml::ebml_deserializer(chi_doc); - @astencode_gen::deserialize_syntax_ast_item(d) -} - -#[cfg(test)] -fn new_parse_sess() -> parser::parse_sess { - let cm = codemap::new_codemap(); - let handler = diagnostic::mk_handler(option::none); - let sess = @{ - cm: cm, - mutable next_id: 1, - span_diagnostic: diagnostic::mk_span_handler(handler, cm), - mutable chpos: 0u, - mutable byte_pos: 0u - }; - ret sess; -} - -#[cfg(test)] -iface fake_ext_ctxt { - fn session() -> fake_session; -} - -#[cfg(test)] -type fake_options = {cfg: ast::crate_cfg}; - -#[cfg(test)] -type fake_session = {opts: @fake_options, - parse_sess: parser::parse_sess}; - -#[cfg(test)] -impl of fake_ext_ctxt for fake_session { - fn session() -> fake_session {self} -} - -#[cfg(test)] -fn mk_ctxt() -> fake_ext_ctxt { - let opts : fake_options = {cfg: []}; - {opts: @opts, parse_sess: new_parse_sess()} as fake_ext_ctxt -} - -#[cfg(test)] -fn roundtrip(in_item: @ast::item) { - #debug["in_item = %s", pprust::item_to_str(in_item)]; - let mbuf = io::mem_buffer(); - let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf)); - encode_item_ast(ebml_w, in_item); - let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf)); - let out_item = decode_item_ast(ebml_doc); - #debug["out_item = %s", pprust::item_to_str(out_item)]; - assert in_item == out_item; -} - -#[test] -fn test_basic() { - let ext_cx = mk_ctxt(); - roundtrip(#ast(item){ - fn foo() {} - }); -} - -#[test] -fn test_smalltalk() { - let ext_cx = mk_ctxt(); - roundtrip(#ast(item){ - fn foo() -> int { 3 + 4 } // first smalltalk program ever executed. - }); -} - -#[test] -fn test_more() { - let ext_cx = mk_ctxt(); - roundtrip(#ast(item){ - fn foo(x: uint, y: uint) -> uint { - let z = x + y; - ret z; - } - }); -} - -#[test] -fn test_simplification() { - let ext_cx = mk_ctxt(); - let item_in = ast::ii_item(#ast(item) { - fn new_int_alist() -> alist { - fn eq_int(&&a: int, &&b: int) -> bool { a == b } - ret {eq_fn: eq_int, mut data: []}; - } - }); - let item_out = simplify_ast(item_in); - let item_exp = ast::ii_item(#ast(item) { - fn new_int_alist() -> alist { - ret {eq_fn: eq_int, mut data: []}; - } - }); - alt (item_out, item_exp) { - (ast::ii_item(item_out), ast::ii_item(item_exp)) { - assert pprust::item_to_str(item_out) == pprust::item_to_str(item_exp); - } - _ { fail; } - } -}