Fork me on GitHub
#test-check
<
2016-06-08
>
wilkerlucio13:06:38

is it possible to run async code into a (props/for-all)?

wilkerlucio13:06:54

I would like to test some cljs code that requires to be async, any ideas on how to do that?

lucasbradstreet14:06:34

@wilkerlucio: I’ve used property testing with core.async before. The only real way I could figure out to do it to make sure that there’s some kind of terminator on the channel (this could be that the channel was closed), and that you’ve hit it. You could also add a big enough sleep to make sure that everything should have finished, but that’s super hacky and will limit how many examples you can run in a given time

wilkerlucio14:06:17

hi Lucas, sorry, I didn't understand the idea you told me to use core.async, can you show me a code example of it please?

lucasbradstreet14:06:00

Sorry, I don’t really have an example handy. It really depends on what you’re trying to do

wilkerlucio14:06:34

thats fine, on my case I don't really need the for-all, I'm doing ok just sampling and testing from it, thanks for the assistance

gfredericks18:06:23

lucasbradstreet: "big enough sleep" ⇐ are you talking about clj-jvm instead of cljs?

gfredericks18:06:42

wilkerlucio: I was just wondering about async tests myself like two days ago; I think you'd need a separate test runner

gfredericks18:06:57

i.e., would have to modify clojure.test.check/quick-check

gfredericks18:06:57

wilkerlucio: you'd have to rewrite quick-check to listen for results on a core.async channel I think

gfredericks18:06:25

it'd probably be one of those "quick-check returns a channel that will eventually receive the result" sort of situations

lucasbradstreet18:06:14

Yeah, that’s basically along the lines of what I was trying to get across

gfredericks18:06:36

and then would need to rewrite prop/for-all to supply a channel for the body to write to somehow, or something

wilkerlucio19:06:02

yeah, seems a lot of fun doing it, just need some time to learn how test.check works, hehe

gfredericks19:06:34

I'm happy to advise