Fork me on GitHub
#test-check
<
2017-01-10
>
gfredericks13:01:17

@nberger do you know whether your refactoring of the quick-check function would make it easier to support asynchronous tests?

gfredericks13:01:22

apologies if I've asked that before

nberger15:01:25

@gfredericks: I'm not sure what's the issue with asynchronous tests, do you have more context? An example or something to read?

nberger15:01:28

I do think it should help with running tests in parallel, maybe with a bit more refactoring

gfredericks16:01:55

@nberger basic use case is wanting to test browser stuff in cljs; if you need to pause the thread to let the browser render things, you can't have a test that just returns pass/fail

gfredericks16:01:48

you could e.g. return a future or a channel; but that means the quickcheck loop cannot just examine the result, it has to also pause somehow or another until the result is available; traditionally that would mean it would have to shove the rest of the computation into a callback

gfredericks16:01:41

this is why core.async is so complex, to allow you to pretend your code is synchronous, and the go macro twists it all into a knot so you don't have to

gfredericks16:01:22

but unless you're already programming with this kind of thing in mind it's usually a big pain to rework the program

gfredericks16:01:31

so test.check just doesn't support that kind of test at the moment

nberger16:01:34

@gfredericks: got it. Thought it was something like that but wanted to confirm. Have you seen the async macro in cljs.test? It's definitely not perfect (doesn't play well with with-redefs for example) but it's a start

gfredericks16:01:30

I'm asking about your changes because if you tried to take the current code and refactor it to be async, the loops would have to be transformed into something more abstract; I wasn't sure if your restructuring had already accomplished that

nberger17:01:46

I see. I didn't take it that far

nberger17:01:34

I'm also not 100% sure in that the loop would have to be transformed. Using an approach similar to the cljs.test async macro or how some core.async tests are written, which is basically using a "latch" (with countdown or not), the loop can be used as is, even without the refactoring. I'll try to come up with an example next week

gfredericks18:01:19

that would surprise me

nberger19:01:27

Yeah, thinking more about it, a different abstraction would be needed. I'll hopefully have some time to play with it next week