new mono testing mechanism

This commit is contained in:
Folkert 2021-05-30 18:09:41 +02:00
parent 22a4df0e5e
commit 54057c90b8
8 changed files with 284 additions and 55 deletions

View file

@ -1,45 +1,25 @@
#![warn(clippy::dbg_macro)]
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)]
// we actually want to compare against the literal float bits
#![allow(clippy::clippy::float_cmp)]
extern crate proc_macro;
use proc_macro::{Span, TokenStream};
use quote::{format_ident, quote};
use syn::spanned::Spanned;
// pub mod gen_compare;
// pub mod gen_dict;
// pub mod gen_hash;
// pub mod gen_list;
// pub mod gen_num;
// pub mod gen_primitives;
// pub mod gen_records;
// pub mod gen_result;
// pub mod gen_set;
// pub mod gen_str;
// pub mod gen_tags;
// mod helpers;
use proc_macro::TokenStream;
use quote::quote;
#[proc_macro_attribute]
pub fn mono_test(args: TokenStream, item: TokenStream) -> TokenStream {
let macro_args = syn::parse_macro_input!(args as syn::AttributeArgs);
pub fn mono_test(_args: TokenStream, item: TokenStream) -> TokenStream {
let task_fn = syn::parse_macro_input!(item as syn::ItemFn);
let mut arg_names: syn::punctuated::Punctuated<syn::Ident, syn::Token![,]> =
syn::punctuated::Punctuated::new();
let mut args = task_fn.sig.inputs.clone();
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 result = quote! {
#visibility fn #name(#args) {
println!( #body);
#[test]
#visibility fn #name(#args) -> () {
compiles_to_ir(#name_str, #body);
}
};
result.into()