Fork me on GitHub

Are logs of this channel available somewhere?


Is there a way to limit the size of the a map generated from (gen/generate (s/gen map?))?


generate can take another argument size e.g. (gen/generate (s/gen map?) 10)


I think the general range of sizes is 0-200 maybe?


looks like it uses 30 by default

Alex Miller (Clojure team)21:01:50

no, but you can use something like (s/map-of any? any? :gen-max 5)


is there a better way of making a transducer spec than ifn?? e.g. this works, but it shouldn’t:

(s/conform (:ret (s/get-spec `map)) [1 2 3])
[:transducer [1 2 3]]

Alex Miller (Clojure team)21:01:35

I’ve looked at it, and generally I’d say no

Alex Miller (Clojure team)21:01:06

this is well outside the sweet spot for spec


I'm seeing strange behavior when running clojure.spec.test.alpha/check on an fdef'ed function. I have a prn as the first line in my function that prints out the size of the args. When the generative tests first start running, I get print statements out rapidly. After running for a few seconds, the print statements slow down to once every second. After 10-20s more, they speed up again. This goes on for about 10 mins until check returns. At first I thought it was due to test.check generating large maps so I changed the :args in my fdef to use (s/map-of any? any? :gen-max 5). Then I thought it was a JVM memory issue but (.maxMemory (Runtime/getRuntime)) says the JVM has over 7gb available. I haven't seen this behavior with spec check before. Any ideas on what could cause this?

Alex Miller (Clojure team)21:01:55

sounds awfully like GC churn to me

Alex Miller (Clojure team)21:01:37

do you have an fspec anywhere?


Not in this function.

Alex Miller (Clojure team)22:01:30

you can add -verbose:gc to watch the gc

Alex Miller (Clojure team)22:01:15

you could isolate just the gen on the args if you suspect that it’s it

Alex Miller (Clojure team)22:01:03

something like

(gen/sample (s/gen (:args (s/get-spec `foo))) 1000)


Generating the args like you have there takes about 30s. I'll add the gc flag to see if it sheds any light.


Added the gc flag. I get a message that looks like this [GC (Allocation Failure) 2477246K->1068161K(3133952K), 0.1575999 secs] printed out every second or so.


This is what the output with the -verbose:gc flag looks like The numbers are the count on the two args this function takes.


Updated to test.check 0.10.0-alpha3 and the problem goes away.


I have a map like:

{::kind :bool
 ::default true}
that, given a different ::kind, might need a different predicate for ::default. E.g.:
{::kind :string
 ::default "foo"}
What's the best way to model this in spec? I thought multi-specs would work, but I'm still struggling with the fact that the name of the spec I pass into s/keys needs to match the key, which makes overloading ::default difficult


@lilactown I've done this with s/or specs


I can give you an example in our work slack