This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-17
Channels
- # bangalore-clj (1)
- # beginners (23)
- # boot (141)
- # cider (68)
- # cljs-dev (29)
- # cljsjs (1)
- # cljsrn (11)
- # clojure (150)
- # clojure-austin (3)
- # clojure-berlin (1)
- # clojure-france (2)
- # clojure-greece (13)
- # clojure-italy (5)
- # clojure-russia (49)
- # clojure-spec (15)
- # clojure-uk (45)
- # clojurescript (152)
- # code-art (1)
- # core-async (75)
- # cursive (12)
- # datascript (2)
- # datomic (90)
- # dirac (5)
- # emacs (10)
- # garden (1)
- # hoplon (52)
- # instaparse (4)
- # juxt (2)
- # lein-figwheel (2)
- # lumo (47)
- # mount (94)
- # off-topic (20)
- # om (21)
- # onyx (14)
- # parinfer (19)
- # pedestal (3)
- # protorepl (13)
- # re-frame (5)
- # reagent (20)
- # slack-help (10)
- # spacemacs (8)
- # specter (57)
- # unrepl (11)
- # untangled (3)
- # vim (1)
- # yada (1)
I’d like to simplify this API, but I’m not sure how to create both a “variable” and a function-reference from the same parameter https://gist.github.com/hkjels/1656508f7666ce6fa39699522743505f
if you start from the symbol, it’s easy enough to get the meta from there
(meta (resolve s))
ah, true, didn’t notice that
Just starting with custom generators, and I have only looked at the underlying code in clojure.test.check.generators a bit, and didn’t notice if there was a more straight-forward way to use custom generators without input arguments. clojure.test.check.generator’s own uuid
is an interesting example, but it relies on an internally passed random number (while ignoring size) and defines itself with namespace internal functions.
(s/def ::saddle (s/with-gen
(s/and string? (partial re-matches saddle.regex))
#(gen/fmap (fn [_] (zero-arity-gen)) (gen/return nil))))
@waffletower this is generally discouraged since it sidesteps most of the test.check orchestration -- it should be possible for you to write any generator you need using the built in combinators
Is your specific problem about generating a string that matches a regex?
the generator doesn’t need shrinking as with gen/uuid
, and it currently uses RNG internally. I could use RNG from the generator namespace instead — which seems to suggest I could continue using gen/fmap
you can opt-out of shrinking by wrapping with gen/no-shrink
using the randomness from test.check means that at least your generator (and any composition including it) is deterministic
@waffletower if you'd like to share the details of the generator you already have I could suggest how to rewrite it