test-check

wilkerlucio 2018-02-08T02:57:12.000265Z

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

wilkerlucio 2018-02-08T02:57:43.000195Z

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

wilkerlucio 2018-02-08T02:58:23.000171Z

I was trying something like this:

wilkerlucio 2018-02-08T02:58:24.000299Z

(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 #{[]}))))

wilkerlucio 2018-02-08T02:58:46.000032Z

but this doesn't work, because the binding is running on the generator definition, and not when the actual gen is running

wilkerlucio 2018-02-08T02:59:04.000121Z

I was trying to find a way to wrap some generator with this logic, but can't figure how to hook it up

wilkerlucio 2018-02-08T02:59:33.000020Z

how can I make this? because otherwise my generator fail about 80% of the time because of stack overflow =/

2018-02-08T14:30:58.000394Z

by "test.check recursion limit" you're referring to the mechanism in clojure.spec that's used when generating generators?

2018-02-08T14:31:53.000036Z

have you tried expressing the generator for the whole thing using gen/recursive-gen?