mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-15 00:05:02 +00:00
28 lines
658 B
Rust
28 lines
658 B
Rust
extern crate proc_macro;
|
|
|
|
use proc_macro::TokenStream;
|
|
use quote::quote;
|
|
|
|
#[proc_macro_attribute]
|
|
pub fn mono_test(_args: TokenStream, item: TokenStream) -> TokenStream {
|
|
let task_fn = syn::parse_macro_input!(item as syn::ItemFn);
|
|
|
|
let args = task_fn.sig.inputs.clone();
|
|
|
|
let name = task_fn.sig.ident.clone();
|
|
let name_str = name.to_string();
|
|
let body = task_fn.block.clone();
|
|
|
|
let visibility = &task_fn.vis;
|
|
let attributes = task_fn.attrs;
|
|
|
|
let result = quote! {
|
|
#[test]
|
|
#(#attributes)*
|
|
#visibility fn #name(#args) {
|
|
compiles_to_ir(#name_str, #body);
|
|
|
|
}
|
|
};
|
|
result.into()
|
|
}
|