Fork me on GitHub
#test-check
<
2018-02-09
>
wilkerlucio00:02:56

@gfredericks sorry the delay, I'm not sure I can use recursive-gen on this case

wilkerlucio00:02:00

but I was able to make it work

wilkerlucio00:02:19

this how it ended up:

wilkerlucio00:02:22

(s/def ::query
  (s/coll-of ::query-expr :kind vector?
    :gen #(let [g (s/gen (s/coll-of ::query-expr :kind vector? :max-count 5))]
            (gen/->Generator
              (fn [rdn size]
                (if (> *query-gen-max-depth* 0)
                  (binding [*query-gen-max-depth* (dec *query-gen-max-depth*)]
                    (gen/call-gen g rdn size))
                  (gen/call-gen (gen/return []) rdn size)))))))

wilkerlucio00:02:51

this limits the depth of the generator by using a dynamic var, was the best solution I could find

gfredericks00:02:09

yeah, I think it's technically possible with recursive-gen but maybe not easy would definitely be better for spec to handle it without error