metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.47k stars 209 forks source link

Minor generator optimizations, add generator code generator #794

Closed frenchy64 closed 1 year ago

frenchy64 commented 1 year ago

Perhaps these little optimizations might be significant in large cases. generator-ast made at least their ugliness painfully obvious, as you can see in the updated tests (this is more obvious in test/malli/generator_test.cljc after whitespace changes are hidden).

  1. Use gen/return for singleton gen/elements calls.
  2. Use constrained gen/vector instead of (gen/not-empty (gen/vector ..)).

Add dev helper generator-code to help generate the large recursive-gen test cases.

ikitommi commented 1 year ago

Thanks! I think gen-one-of and gen-elements would be good optimizations in test.check itself. Maybe try a PR there?