Fork me on GitHub
#test-check
<
2020-02-24
>
kenny16:02:58

Is there a way to know if the output from quick-check was the result of a generator throwing an exception versus the function throwing an exception?

gfredericks16:02:30

I don't think generator exceptions get caught

kenny16:02:10

Ah. I'm calling via spec's check which does not throw in that case which explains the weird looking output.

gfredericks16:02:47

Does it catch exceptions?

kenny16:02:06

It appears so. When a gen throws, it attaches the generator exception on the :result key and nothing else.

gfredericks16:02:38

Is it calling the generator manually?

gfredericks16:02:50

Or it just catches everything?

kenny16:02:39

Hmm actually that's not even a generator throwing. It's a gen throwing while being constructed.

kenny16:02:19

Bad test case. Will see what happens when a gen actually throws.

gfredericks16:02:31

I don't like that return value

kenny16:02:58

I'm checking for it like this haha

(and (instance? Throwable (:result ret))
     (nil? (:shrunk ret)))

kenny16:02:19

Same thing when the gen throws

gfredericks16:02:56

Different part of the code returns the same thing?

kenny16:02:12

I don't think there's any way for me to differentiate an exception from a generator throwing while construction and a generator throwing while generating.

gfredericks16:02:40

Except the stack trace 😉

kenny16:02:09

Yeah... Not sure where it's catching the gen throwing case.

kenny16:02:52

It's not in that ns. Must be doing it elsewhere.