Open znewman01 opened 4 years ago
The root issue is that proptest!
doesn't allow async fn
. Adding async fn
cases to the macro should make this "just work".
I would be interested in adding async support to the proptest macro, would it make sense to just add async versions of each case or have a separate proptest_async macro? I suppose it would be nice to be able to mix and match tests in the same usage.
It would be great to have this!
we'll be looking at async support holisitically in #442
Hi! This is purely an ergonomics thing.
I'm working on some async-heavy code and like to use the
tokio::test
macro:If I try to adapt it to the proptest context:
I get some inscrutable errors:
The following works around fine:
(Using the
proptest!
macro with a closure doesn't, because it doesn't handle async closures.)I think it'd be a little silly to special-case
proptest
for every test runner, but as I understand, the Tokiotest
macro pretty much just does my workaround.I think the
proptest!
macro is very similar. I wonder if we could make one of the following changes:proptest!
would go and expand its code first; the second test macro should pick up the rest. I don't totally get why this doesn't happen currently.#[proptest::test
] macro, which would basically do whatproptest!
does but to one test. The hitch is thattokio::test
wants (1) no arguments, so we'd have to put it after#[proptest::test]
, and (2) no extra#[test]
, which means we'd need#[proptest::test]
to (have an option to) not emit that. We could also maybe address this at the Tokio end.IIRC custom test runner stuff is pretty in-flux right now, so maybe it's premature to do anything. Or I could be missing something obvious.
If you like any of these ideas or something similar, I might be able to take a stab at implementing, though I'm a little shaky on macros.
The above code assumes the following preamble:
P.S. Thanks for your work on proptest; it's really helped me write high-assurance software and made testing fun to boot!