diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-05 16:35:33 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-05 16:35:33 +0800 |
commit | 6ed28585d2e9bcab82a05cb6d8c877e1b75548b1 (patch) | |
tree | 4b3d29cd63846ff672a7f6ce87d3d4b6b1d32f94 /src/expand/test.cpp | |
parent | d773edd75db789de4ccad0fed7c62faf13c50603 (diff) | |
download | mrust-6ed28585d2e9bcab82a05cb6d8c877e1b75548b1.tar.gz |
Expand - add #[test] handler that removes all tests
Diffstat (limited to 'src/expand/test.cpp')
-rw-r--r-- | src/expand/test.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/expand/test.cpp b/src/expand/test.cpp new file mode 100644 index 00000000..ba18fd24 --- /dev/null +++ b/src/expand/test.cpp @@ -0,0 +1,27 @@ +/* + * MRustC - Rust Compiler + * - By John Hodge (Mutabah/thePowersGang) + * + * expand/test.cpp + * - #[test] handling + */ +#include <synext_decorator.hpp> +#include <ast/ast.hpp> + +class CTestHandler: + public ExpandDecorator +{ + AttrStage stage() const override { return AttrStage::Pre; } + + void handle(const Span& sp, const AST::MetaItem& mi, ::AST::Crate& crate, const AST::Path& path, AST::Module& mod, AST::Item&i) const override { + if( ! i.is_Function() ) { + ERROR(sp, E0000, "#[test] can only be put on functions - found on " << i.tag_str()); + } + + // TODO: Proper #[test] support, for now just remove them + i = AST::Item::make_None({}); + } +}; + +STATIC_DECORATOR("test", CTestHandler); + |