Move #[test_case] to a syntax extension

This commit is contained in:
John Renner
2018-09-02 09:03:24 -07:00
parent e5ed105716
commit 0593dc7e3c
15 changed files with 108 additions and 82 deletions

View File

@@ -135,8 +135,14 @@ pub fn expand_test_or_bench(
};
let mut test_const = cx.item(sp, item.ident.gensym(),
// #[test_case]
vec![cx.attribute(attr_sp, cx.meta_word(attr_sp, Symbol::intern("test_case")))],
vec![
// #[cfg(test)]
cx.attribute(attr_sp, cx.meta_list(attr_sp, Symbol::intern("cfg"), vec![
cx.meta_list_item_word(attr_sp, Symbol::intern("test"))
])),
// #[rustc_test_marker]
cx.attribute(attr_sp, cx.meta_word(attr_sp, Symbol::intern("rustc_test_marker")))
],
// const $ident: test::TestDescAndFn =
ast::ItemKind::Const(cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),
// test::TestDescAndFn {