Skip to content

Commit

Permalink
add tests for async-test macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev authored and taiki-e committed May 7, 2021
1 parent e40b5f9 commit 08a9aa3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion futures-macro/src/executor.rs
Expand Up @@ -3,10 +3,11 @@ use quote::quote;

pub(crate) fn test(args: TokenStream, item: TokenStream) -> TokenStream {
if !args.is_empty() {
return syn::Error::new_spanned(args, "invalid argument"))
return syn::Error::new_spanned(proc_macro2::TokenStream::from(args), "invalid argument")
.to_compile_error()
.into();
}

let mut input = syn::parse_macro_input!(item as syn::ItemFn);
let attrs = &input.attrs;
let vis = &input.vis;
Expand Down
18 changes: 18 additions & 0 deletions futures/tests/test_macro.rs
@@ -0,0 +1,18 @@
#[cfg(test)]
mod tests {
#[futures_test::test]
async fn it_works() {
let fut = async { true };
assert!(fut.await);

let fut = async { false };
assert!(!fut.await);
}

#[futures_test::test]
#[should_panic]
async fn it_is_being_run() {
let fut = async { false };
assert!(fut.await);
}
}

0 comments on commit 08a9aa3

Please sign in to comment.