about summary refs log tree commit diff
path: root/src/rustc/front/test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/rustc/front/test.rs')
-rw-r--r--src/rustc/front/test.rs59
1 files changed, 35 insertions, 24 deletions
diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs
index 90de6a4335f..33908f004f5 100644
--- a/src/rustc/front/test.rs
+++ b/src/rustc/front/test.rs
@@ -62,17 +62,17 @@ fn strip_test_functions(crate: @ast::crate) -> @ast::crate {
     }
 }
 
-fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
+fn fold_mod(cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
 
     // Remove any defined main function from the AST so it doesn't clash with
     // the one we're going to add.
 
     // FIXME (#2403): This is sloppy. Instead we should have some mechanism to
     // indicate to the translation pass which function we want to be main.
-    fn nomain(&&item: @ast::item) -> option<@ast::item> {
+    fn nomain(cx: test_ctxt, item: @ast::item) -> option<@ast::item> {
         match item.node {
           ast::item_fn(_, _, _) => {
-            if *item.ident == ~"main" {
+            if item.ident == cx.sess.ident_of(~"main") {
                 option::none
             } else { option::some(item) }
           }
@@ -81,7 +81,8 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
     }
 
     let mod_nomain =
-        {view_items: m.view_items, items: vec::filter_map(m.items, nomain)};
+        {view_items: m.view_items, items: vec::filter_map(m.items,
+                                                          |i| nomain(cx, i))};
     return fold::noop_fold_mod(mod_nomain, fld);
 }
 
@@ -99,7 +100,8 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) ->
    option<@ast::item> {
 
     vec::push(cx.path, i.ident);
-    debug!{"current path: %s", ast_util::path_name_i(cx.path)};
+    debug!{"current path: %s",
+           ast_util::path_name_i(cx.path, cx.sess.parse_sess.interner)};
 
     if is_test_fn(i) {
         match i.node {
@@ -192,16 +194,17 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
     let item_ = ast::item_mod(testmod);
     // This attribute tells resolve to let us call unexported functions
     let resolve_unexported_attr =
-        attr::mk_attr(attr::mk_word_item(@~"!resolve_unexported"));
+        attr::mk_attr(attr::mk_word_item(~"!resolve_unexported"));
     let item: ast::item =
-        {ident: @~"__test",
+        {ident: cx.sess.ident_of(~"__test"),
          attrs: ~[resolve_unexported_attr],
          id: cx.sess.next_node_id(),
          node: item_,
          vis: ast::public,
          span: dummy_sp()};
 
-    debug!{"Synthetic test module:\n%s\n", pprust::item_to_str(@item)};
+    debug!{"Synthetic test module:\n%s\n",
+           pprust::item_to_str(@item, cx.sess.intr())};
 
     return @item;
 }
@@ -232,7 +235,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
 
     let item_ = ast::item_fn(decl, ~[], body);
     let item: ast::item =
-        {ident: @~"tests",
+        {ident: cx.sess.ident_of(~"tests"),
          attrs: ~[],
          id: cx.sess.next_node_id(),
          node: item_,
@@ -247,18 +250,19 @@ fn mk_path(cx: test_ctxt, path: ~[ast::ident]) -> ~[ast::ident] {
     let is_std = {
         let items = attr::find_linkage_metas(cx.crate.node.attrs);
         match attr::last_meta_item_value_str_by_name(items, ~"name") {
-          some(@~"std") => true,
+          some(~"std") => true,
           _ => false
         }
     };
     if is_std { path }
-    else { vec::append(~[@~"std"], path) }
+    else { vec::append(~[cx.sess.ident_of(~"std")], path) }
 }
 
 // The ast::ty of ~[std::test::test_desc]
 fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
     let test_desc_ty_path =
-        path_node(mk_path(cx, ~[@~"test", @~"test_desc"]));
+        path_node(mk_path(cx, ~[cx.sess.ident_of(~"test"),
+                                cx.sess.ident_of(~"test_desc")]));
 
     let test_desc_ty: ast::ty =
         {id: cx.sess.next_node_id(),
@@ -296,10 +300,12 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
     let span = test.span;
     let path = test.path;
 
-    debug!{"encoding %s", ast_util::path_name_i(path)};
+    debug!{"encoding %s", ast_util::path_name_i(path,
+                                                cx.sess.parse_sess.interner)};
 
     let name_lit: ast::lit =
-        nospan(ast::lit_str(@ast_util::path_name_i(path)));
+        nospan(ast::lit_str(@ast_util::path_name_i(path, cx.sess.parse_sess
+                                                   .interner)));
     let name_expr_inner: @ast::expr =
         @{id: cx.sess.next_node_id(),
           callee_id: cx.sess.next_node_id(),
@@ -313,7 +319,8 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
 
 
     let name_field: ast::field =
-        nospan({mutbl: ast::m_imm, ident: @~"name", expr: @name_expr});
+        nospan({mutbl: ast::m_imm, ident: cx.sess.ident_of(~"name"),
+                expr: @name_expr});
 
     let fn_path = path_node(path);
 
@@ -326,7 +333,8 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
     let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span);
 
     let fn_field: ast::field =
-        nospan({mutbl: ast::m_imm, ident: @~"fn", expr: fn_wrapper_expr});
+        nospan({mutbl: ast::m_imm, ident: cx.sess.ident_of(~"fn"),
+                expr: fn_wrapper_expr});
 
     let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));
 
@@ -337,7 +345,8 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
          span: span};
 
     let ignore_field: ast::field =
-        nospan({mutbl: ast::m_imm, ident: @~"ignore", expr: @ignore_expr});
+        nospan({mutbl: ast::m_imm, ident: cx.sess.ident_of(~"ignore"),
+                expr: @ignore_expr});
 
     let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail));
 
@@ -349,7 +358,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
 
     let fail_field: ast::field =
         nospan({mutbl: ast::m_imm,
-                ident: @~"should_fail",
+                ident: cx.sess.ident_of(~"should_fail"),
                 expr: @fail_expr});
 
     let desc_rec_: ast::expr_ =
@@ -404,7 +413,7 @@ fn mk_test_wrapper(cx: test_ctxt,
 }
 
 fn mk_main(cx: test_ctxt) -> @ast::item {
-    let str_pt = path_node(~[@~"str"]);
+    let str_pt = path_node(~[cx.sess.ident_of(~"str")]);
     let str_ty_inner = @{id: cx.sess.next_node_id(),
                          node: ast::ty_path(str_pt, cx.sess.next_node_id()),
                          span: dummy_sp()};
@@ -423,7 +432,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
     let args_arg: ast::arg =
         {mode: ast::expl(ast::by_val),
          ty: @args_ty,
-         ident: @~"args",
+         ident: cx.sess.ident_of(~"args"),
          id: cx.sess.next_node_id()};
 
     let ret_ty = {id: cx.sess.next_node_id(),
@@ -445,7 +454,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
 
     let item_ = ast::item_fn(decl, ~[], body);
     let item: ast::item =
-        {ident: @~"main",
+        {ident: cx.sess.ident_of(~"main"),
          attrs: ~[],
          id: cx.sess.next_node_id(),
          node: item_,
@@ -457,7 +466,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
 fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
 
     // Get the args passed to main so we can pass the to test_main
-    let args_path = path_node(~[@~"args"]);
+    let args_path = path_node(~[cx.sess.ident_of(~"args")]);
 
     let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
 
@@ -466,7 +475,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
          node: args_path_expr_, span: dummy_sp()};
 
     // Call __test::test to generate the vector of test_descs
-    let test_path = path_node(~[@~"tests"]);
+    let test_path = path_node(~[cx.sess.ident_of(~"tests")]);
 
     let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
 
@@ -481,7 +490,9 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
          node: test_call_expr_, span: dummy_sp()};
 
     // Call std::test::test_main
-    let test_main_path = path_node(mk_path(cx, ~[@~"test", @~"test_main"]));
+    let test_main_path = path_node(
+        mk_path(cx, ~[cx.sess.ident_of(~"test"),
+                      cx.sess.ident_of(~"test_main")]));
 
     let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);