Fork me on GitHub
#clojure-spec
<
2017-10-28
>
mike70657419:10:46

Is it intentional that the functions in clojure.spec.gen that alias functions in clojure.test.check.generators aren't considered generators?

mike70657419:10:53

Or am I doing something wrong?

mike70657419:10:32

(clojure.test.check.generators/generator? clojure.spec.gen.alpha/int) seems to be returning false

mike70657419:10:10

In my case, I'm trying to write a spec for an 5-10 character alphabetic string with a custom generator that uses clojure.spec.gen.alpha/char-alpha

mike70657419:10:00

Sampling is failing with an AssertionError with a message of Assert failed: First arg to vector must be a generator (generator? generator)

mike70657419:10:23

It works fine when I use clojure.test.check.generators/char-alpha - just seems counterintuitive that the aliased function doesn't work

hiredman19:10:58

the spec aliases are actually single argument functions that return generators

mike70657419:10:26

that makes more sense

hiredman19:10:40

this is to support lazy loading of clojure.test.check

mike70657419:10:57

so i shouldn't be using them?

hiredman19:10:31

you can use them, you just have to be aware of that fact when mixing with plain test.check generators

hiredman19:10:21

and if I recall correctly, most places in clojure.spec where you can supply a custom generator, you supply a no arg function that returns a test.check generator

mike70657419:10:35

i just put parens around it - (gen/vector gen/char-alpha 5 10) to (gen/vector (gen/char-alpha) 5 10) - and it worked

hiredman19:10:59

that's lisp for you

mike70657419:10:11

cool, thanks