malli icon indicating copy to clipboard operation
malli copied to clipboard

Generator generation diverges

Open nilern opened this issue 4 years ago • 1 comments

While I was trying to describe Malli forms with Malli I noticed that recursive generator generation can diverge:

(mg/generator
  [:schema {:registry {::schema [:or
                                 [:= :int] [:= :string]
                                 [:cat [:= :and] [:* [:schema [:ref ::schema]]]]
                                 [:cat [:= :or] [:* [:schema [:ref ::schema]]]]
                                 [:tuple [:= :vector] [:ref ::schema]]]}}
   ::schema])
; Execution error (OutOfMemoryError) at malli.generator/-create (generator.cljc:219).
; GC overhead limit exceeded

Perhaps malli.generator should use clojure.test.check.generators/recursive-gen instead of the current ad hoc recursion depth limiting? I don't really get the current limits, so can't really say whether they can be made to work for all schemas.

nilern avatar Jan 28 '21 10:01 nilern

There is such a thing? Please.

ikitommi avatar Jan 28 '21 10:01 ikitommi