Skip to content

Commit b97318b

Browse files
committed
Simplify the code for generating tests. Issue #428
1 parent ed83f28 commit b97318b

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/comp/front/test.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn nospan[T](&T t) -> ast::spanned[T] {
165165
}
166166

167167
fn mk_tests(&test_ctxt cx) -> @ast::item {
168-
auto ret_ty = mk_test_desc_ivec_ty();
168+
auto ret_ty = mk_test_desc_ivec_ty(cx);
169169

170170
let ast::fn_decl decl = rec(inputs = ~[],
171171
output = ret_ty,
@@ -204,23 +204,16 @@ fn empty_fn_ty() -> ast::ty {
204204
ret nospan(ast::ty_fn(proto, input_ty, ret_ty, cf, constrs));
205205
}
206206

207-
// The ast::ty of std::test::test_desc
208-
fn mk_test_desc_ivec_ty() -> @ast::ty {
209-
// Oh this is brutal to build by hand
210-
let ast::mt name_mt = rec(ty = @nospan(ast::ty_str),
211-
mut = ast::imm);
212-
let ast::mt fn_mt = rec(ty = @empty_fn_ty(),
213-
mut = ast::imm);
214-
215-
let ast::ty_field_ name_ty_field_ = rec(ident = "name",
216-
mt = name_mt);
207+
// The ast::ty of std::test::test_desc[]
208+
fn mk_test_desc_ivec_ty(&test_ctxt cx) -> @ast::ty {
209+
let ast::path test_desc_ty_path = nospan(rec(global = false,
210+
idents = ~["std",
211+
"test",
212+
"test_desc"],
213+
types = ~[]));
217214

218-
let ast::ty_field_ fn_ty_field_ = rec(ident = "fn",
219-
mt = fn_mt);
220-
221-
let ast::ty_field[] test_desc_fields = ~[nospan(name_ty_field_),
222-
nospan(fn_ty_field_)];
223-
let ast::ty test_desc_ty = nospan(ast::ty_rec(test_desc_fields));
215+
let ast::ty test_desc_ty = nospan(ast::ty_path(test_desc_ty_path,
216+
cx.next_node_id()));
224217

225218
let ast::mt ivec_mt = rec(ty = @test_desc_ty,
226219
mut = ast::imm);

0 commit comments

Comments
 (0)