test-check

wilkerlucio 2016-06-08T13:51:15.000004Z

hello

wilkerlucio 2016-06-08T13:51:38.000005Z

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

wilkerlucio 2016-06-08T13:51:54.000006Z

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

lucasbradstreet 2016-06-08T14:01:34.000007Z

@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

lucasbradstreet 2016-06-08T14:04:34.000008Z

@wilkerlucio: you may also find https://github.com/czan/stateful-check helpful

wilkerlucio 2016-06-08T14:06:17.000010Z

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?

lucasbradstreet 2016-06-08T14:08:00.000011Z

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

wilkerlucio 2016-06-08T14:52:34.000012Z

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

2016-06-08T18:53:23.000013Z

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

2016-06-08T18:53:42.000014Z

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

2016-06-08T18:53:57.000015Z

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

lucasbradstreet 2016-06-08T18:54:04.000016Z

Oh yeah, I am

2016-06-08T18:54:57.000017Z

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

2016-06-08T18:55:25.000018Z

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

lucasbradstreet 2016-06-08T18:56:14.000019Z

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

2016-06-08T18:57:36.000020Z

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

wilkerlucio 2016-06-08T19:50:02.000021Z

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

2016-06-08T19:50:34.000022Z

I'm happy to advise