Skip to content

Commit c5d33bf

Browse files
committed
---
yaml --- r: 3767 b: refs/heads/master c: 5543404 h: refs/heads/master i: 3765: 35e778f 3763: 7061664 3759: 6ba8d8b v: v3
1 parent 7132578 commit c5d33bf

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 9af59f9d81b8d8c91e2c470e82813d75a6bcdc9e
2+
refs/heads/master: 5543404abe2ecfe280ffd4393d4e4c9ad3d489b8

trunk/src/comp/front/test.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
// Code that generates a test runner to run all the tests in a crate
22

33
import std::option;
4+
import std::ivec;
45
import syntax::ast;
56
import syntax::fold;
67

78
export modify_for_testing;
89

910
type node_id_gen = @fn() -> ast::node_id;
1011

11-
type test_ctxt = rec(node_id_gen next_node_id);
12+
type test_ctxt = rec(node_id_gen next_node_id,
13+
mutable ast::ident[] path);
1214

1315
// Traverse the crate, collecting all the test functions, eliding any
1416
// existing main functions, and synthesizing a main test harness
@@ -26,9 +28,11 @@ fn modify_for_testing(@ast::crate crate) -> @ast::crate {
2628
ret this_node_id;
2729
} (next_node_id);
2830

29-
auto cx = rec(next_node_id = next_node_id_fn);
31+
auto cx = rec(next_node_id = next_node_id_fn,
32+
mutable path = ~[]);
3033

31-
auto precursor = rec(fold_crate = bind fold_crate(cx, _, _)
34+
auto precursor = rec(fold_crate = bind fold_crate(cx, _, _),
35+
fold_item = bind fold_item(cx, _, _)
3236
with *fold::default_ast_fold());
3337

3438
auto fold = fold::make_fold(precursor);
@@ -94,6 +98,16 @@ fn mk_main(&test_ctxt cx) -> @ast::item {
9498
ret @item;
9599
}
96100

101+
fn fold_item(&test_ctxt cx, &@ast::item i,
102+
fold::ast_fold fld) -> @ast::item {
103+
104+
cx.path += ~[i.ident];
105+
log #fmt("current path: %s", ast::path_name_i(cx.path));
106+
auto res = fold::noop_fold_item(i, fld);
107+
ivec::pop(cx.path);
108+
ret res;
109+
}
110+
97111
// Local Variables:
98112
// mode: rust
99113
// fill-column: 78;

trunk/src/comp/syntax/ast.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ type path_ = rec(ident[] idents, (@ty)[] types);
2020

2121
type path = spanned[path_];
2222

23-
fn path_name(&path p) -> str { ret str::connect_ivec(p.node.idents, "::"); }
23+
fn path_name(&path p) -> str { path_name_i(p.node.idents) }
24+
25+
fn path_name_i(&ident[] idents) -> str { str::connect_ivec(idents, "::") }
2426

2527
type crate_num = int;
2628
type node_id = int;

trunk/src/comp/syntax/fold.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default_ast_fold;
1212
export make_fold;
1313
export dummy_out;
1414
export noop_fold_crate;
15+
export noop_fold_item;
1516

1617
type ast_fold = @mutable a_f;
1718

0 commit comments

Comments
 (0)