Fork me on GitHub
#clojure-spec
<
2019-02-09
>
Alex Miller (Clojure team)00:02:05

Sean is correct. s/gen takes a spec object. A predicate symbol or function is not a spec object. Invoking s/spec with a predicate will expand into a qualified symbolic spec and pass it through spec*, yielding a spec object

Alex Miller (Clojure team)00:02:54

So (s/spec any?) or you can do the work of the spec expander and do (s/spec* `any?)

butterguns02:02:29

Quick question: any way to supply a seed to gen/sample?

butterguns02:02:08

I want to do some performance testing / benchmarking. Hence getting a predictable sample is critical

seancorfield02:02:28

@mattmorten It sounds like you really need to provide your own overridden generators that produce the same sequence over and over again?

butterguns02:02:10

Hmmm. That would involve a lot of duplication. In my test ns, I have 20+ lines of generator code to produce a complex data-structure in my app. I'm very happy with it. I'd rather say "give me seed 1 of this generator" than go back and write duplicate generators for each of my (many, very nested) attributes that produce a constant value

flyboarder05:02:04

Why doesn’t spec/assert let me set my own message, seems like an optional 3rd arg would be really convenient

borkdude07:02:27

@seancorfield @alexmiller alright, thanks. Now that this is clear I’ll change those

borkdude10:02:08

Found a new bug:

speculative.specs=> (s/def ::or-spec (s/with-gen (s/or :vector vector) #(s/gen (s/spec vector?))))
:speculative.specs/or-spec
speculative.specs=> (s/valid? ::or-spec [1 2 3])
false

borkdude10:02:37

without s/with-gen it works, with it doesn’t

borkdude10:02:32

It also works when not using s/or + s/with-gen so it seems s/or specific

borkdude10:02:09

I bumped into another one, but this might be related, so I’ll wait for this one to be resolved

Alex Miller (Clojure team)13:02:18

You have vector in the spec, not vector?

Alex Miller (Clojure team)13:02:38

Not sure that’s the cause but seems like a thing to fix first

borkdude15:02:21

Still doesn’t work with vector?.