Fork me on GitHub
#clojure-spec
<
2019-11-14
>
danielcompton04:11:22

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?

kenny16:11:21

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?

kenny17:11:12

No runtime dependency on test.check.

Alex Miller (Clojure team)17:11:16

I mean which generator functions?

kenny17:11:50

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?

kenny17:11:07

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

kenny17:11:41

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?

kenny17:11:19

This is what we are using:

(def generator? #'gen/generator?)

kenny17:11:29

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

kenny17:11:07

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

danielcompton20:11:08

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

ataggart15:11:47

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