Fork me on GitHub
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?)


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


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


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


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


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


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


Found a new bug:

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


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


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


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


Still doesn’t work with vector?.