This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-06
Channels
- # architecture (25)
- # bangalore-clj (1)
- # beginners (21)
- # boot (45)
- # cljs-dev (38)
- # clojure (272)
- # clojure-austin (7)
- # clojure-finland (7)
- # clojure-france (3)
- # clojure-italy (7)
- # clojure-japan (1)
- # clojure-russia (13)
- # clojure-spec (36)
- # clojure-uk (31)
- # clojurescript (96)
- # core-async (15)
- # cursive (16)
- # datascript (3)
- # datomic (97)
- # emacs (107)
- # hoplon (16)
- # jobs (9)
- # keechma (1)
- # luminus (1)
- # off-topic (19)
- # om (39)
- # onyx (15)
- # pedestal (3)
- # planck (22)
- # protorepl (4)
- # re-frame (20)
- # reagent (3)
- # ring-swagger (25)
- # specter (26)
- # test-check (19)
- # testing (1)
- # untangled (381)
Is there any way to generate a value (or a sequence of values) from a generator using a custom seed? It looks to me like the only place you can set the seed (that's a public interface) is in quick-check
itself.
It looks like gen/vector
with a min/max length ignores size
. That is, I expected (gen/generate (gen/vector gen/string 0 10) 0)
to generate an empty vector, but it doesn't (any more often than it would with no size
given).
@peeja ignores size when picking the vector size, probably; it doesn't ignore size entirely since it'll use it when generating elements from the passed-in generator
I think you could call it a half-bug
I'd be happy to have a ticket about it if it's a problem for you
trying to think of a workaround
@peeja w.r.t. custom seeds, you'd have to resort to not-quite-public-API calls such as (rose/root (gen/call-gen g (random/make-random seed) size))
I would consider making something like that first-class if there was a compelling general need for it
In my case, I'm trying to determine whether a keyword's spec specifies a sequence or not by generating the simplest (cheapest) value I can and asking if it's sequential?
. clojure.spec/every
's generator uses a max/min even if you don't give it one, which means I'm always generating elements. Generating an empty vector/list would be better, but it's not a dealbreaker, considering the size still keeps the complexity of what it generates pretty low.
every
can't generate an empty collection? that sounds like a spec bug
Oh I see. Spec does some manual sizing that I'm not sure is justified in every case, and this might be an example of that
the question of a better distribution for gen/vector
is interesting, since users could say something like (gen/vector g 0 40000)
and it'd seem weird to only give them relatively small vectors
I'm reworking the distribution of gen/large-integer
and I think something based on that could work