Fork me on GitHub

Is there a ticket for spec to bring in the rest of the generators in clojure.test.check.generators?

Alex Miller (Clojure team)05:11:58

we did not have a general goal to replicate all aspects of test.check.generators in spec.gen

Alex Miller (Clojure team)05:11:09

so, no as we do not intend to do so

Alex Miller (Clojure team)05:11:26

you can just use them from test.check if you need them?


The problem is that you want the lazy loading spec.gen ns provides.

Alex Miller (Clojure team)17:11:35

is there something specific you're looking for?


No runtime dependency on test.check.

Alex Miller (Clojure team)17:11:16

I mean which generator functions?


The ones that we have copied over are: generator?, let, vector-distinct-by. I believe there may be some others scattered throughout the code though.

Alex Miller (Clojure team)17:11:54

is the dynaload stuff in gen exposed enough to just use?


We had to copy over lazy-combinator macro because dynaload was private.

Alex Miller (Clojure team)17:11:24

lazy-combinator is public though, right?

Alex Miller (Clojure team)17:11:39

ah, so you can't get to the expansion, right

Alex Miller (Clojure team)17:11:00

let's a macro - so I presume that's not something you can dynaload?

Alex Miller (Clojure team)17:11:10

there actually is a ticket about that one in particular


Yes. But let is used a ton so having that in the spec gen ns would be very helpful.

Alex Miller (Clojure team)17:11:47

vector-distinct-by could be done through (s/gen (s/coll-of ::foo :distinct true :into [])) ?

Alex Miller (Clojure team)17:11:34

generator? is prob weird given the thunking done in gen isn't it?


This is what we are using:

(def generator? #'gen/generator?)


where gen is clojure.spec.gen.alpha

Alex Miller (Clojure team)17:11:04

so these each seem like distinct issues

Alex Miller (Clojure team)17:11:43

there's a ticket for let already, generator? could just be made public, and vector-distinct-by could be added to the dynaload list


Yep. @U051KLSJF may be interested in some other missing ones. I'm pretty sure there's a few others I've run into.

Alex Miller (Clojure team)18:11:39

I've made the generator? and vector-distinct-by changes in spec-alpha2


I was missing byte which prompted me to ask, there are also more generators around ints which aren’t exposed


I find that the things in clojure.spec.gen.alpha are sufficient to define generators for specs, and I only need the things in clojure.test.check.generators for generating "interesting" data for tests.

Alex Miller (Clojure team)16:11:36

you can get pretty far by using (s/gen <some-spec>) too

Alex Miller (Clojure team)16:11:58

often I find that's easier that constructing the generator from scratch