This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-16
Channels
- # announcements (1)
- # babashka (23)
- # beginners (157)
- # boot (3)
- # calva (2)
- # chlorine-clover (12)
- # cider (14)
- # clara (5)
- # clj-kondo (6)
- # cljs-dev (61)
- # cljsrn (30)
- # clojure (65)
- # clojure-argentina (8)
- # clojure-berlin (2)
- # clojure-europe (13)
- # clojure-france (9)
- # clojure-germany (2)
- # clojure-italy (4)
- # clojure-nl (6)
- # clojure-portugal (2)
- # clojure-romania (2)
- # clojure-uk (76)
- # clojurescript (56)
- # conjure (52)
- # core-async (37)
- # datomic (209)
- # duct (17)
- # emacs (17)
- # exercism (1)
- # fulcro (26)
- # graalvm (5)
- # instaparse (2)
- # jackdaw (9)
- # jobs-discuss (27)
- # joker (2)
- # juxt (23)
- # leiningen (4)
- # malli (11)
- # midje (3)
- # pedestal (2)
- # quil (2)
- # re-frame (78)
- # reagent (8)
- # reitit (18)
- # remote-jobs (1)
- # ring (2)
- # ring-swagger (1)
- # shadow-cljs (29)
- # sql (11)
- # test-check (12)
- # tools-deps (5)
- # xtdb (16)
- # yada (4)
hello! does anyone know if it is possible to use test.check’s let
generator to create a spec using spec’s with-gen
? basically i am spec’ing a function and one for one of the args i use let
to create the generator. the problem is that it doesn’t work if i try (spec/with-gen a-spec #(tcg/let…))
or (spec/with-gen a-spec (tcg/let…))
. it seems that something is missing to bridge from test.check to spec.
@matheus.emm that first one should work; what happens when you try it?
this is the error that i see:
Error printing return value (ClassCastException) at advent.code.2019.day4/fn$fn (day4.clj:48).
class clojure.test.check.generators.Generator cannot be cast to class clojure.lang.IFn (clojure.test.check.generators.Generator is in unnamed module of loader clojure.lang.DynamicClassLoader @717f07d1; clojure.lang.IFn is in unnamed module of loader 'app')
and this is the function spec:
(spec/fdef repeated-consecutive-digits?
:args (spec/cat
:ds
(spec/with-gen
(spec/coll-of nat-int? :kind vector? :min-count 1)
(fn []
(check.gen/let [n (check.gen/elements #{2 3 4 5 6})
x (check.gen/nat)
d (check.gen/vector-distinct
(check.gen/such-that #(not= % x)
(check.gen/nat))
(- 6 n))
i (check.gen/elements (range (- 6 n)))]
(concat (subvec d 0 i)
(repeat n x)
(subvec d (+ i n))))))))
nothing there looks weird to me
maybe the problem is just (
try removing the parens
hum… let me see.
that is it. 🙂
thanks! and it was an idiot mistake because i used check.gen/nat
correctly to build another generator. 😓