hello, I'm trying to limit the recursion of a generator, the problem is that the recursion is not "direct", it generates something, that generates something else, and ends up in circle, but this kind of recursion seems to not be detected by test.check recursion limit
I was thinking about using some dynamic var to track how many times my generator was called, and stop if goes after a number in a call stack
I was trying something like this:
(s/def ::query-root
(s/coll-of ::query-expr-root :kind vector?
:gen #(if (> *max-depth* 0)
(binding [*max-depth* (dec *max-depth*)]
(s/gen (s/coll-of ::query-expr-root :kind vector? :max-count 5)))
(s/gen #{[]}))))
but this doesn't work, because the binding is running on the generator definition, and not when the actual gen is running
I was trying to find a way to wrap some generator with this logic, but can't figure how to hook it up
how can I make this? because otherwise my generator fail about 80% of the time because of stack overflow =/
by "test.check recursion limit" you're referring to the mechanism in clojure.spec that's used when generating generators?
have you tried expressing the generator for the whole thing using gen/recursive-gen
?