This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-21
Channels
- # beginners (25)
- # cljsrn (3)
- # clojars (4)
- # clojure (37)
- # clojure-news (1)
- # clojure-poland (2)
- # clojure-uk (6)
- # clojurescript (9)
- # datomic (2)
- # duct (7)
- # fulcro (2)
- # hoplon (3)
- # jobs (1)
- # keechma (1)
- # luminus (1)
- # off-topic (27)
- # om (3)
- # om-next (2)
- # overtone (4)
- # pedestal (2)
- # re-frame (11)
- # reagent (4)
- # reitit (6)
- # rum (2)
- # shadow-cljs (212)
- # slack-help (3)
- # spacemacs (1)
- # sql (1)
- # test-check (32)
- # tools-deps (1)
I found something unclear in the documentation for test.chuck
. I guess it could be a bug but I think it's more likely I'm holding generators wrong. In particular, I'm trying out the checking
macro
So the surprising bit is, why does it work fine if I get my generator with (s/gen int?)
and fail if I get (what I think is) the same generator via gen/int
?
how does it fail?
oh sorry
only saw the first five lines of the snippet
I'm guessing gen/
refers to clojure.spec.gen.alpha
or something of that sort
and that this is the inevitable confusion that stems from the fact that spec generally deals with 0-arg functions that return generators
while http://test.ch[eu]ck deals with vanilla generators
try (gen/int)
i can attempt to fix that doc if you like, though I haven't forked-and-pulled much open source
which doc?
the checking
docs are referring to the clojure.test.check.generators
namespace
if you used that namespace instead, gen/int
would work and (gen/int)
wouldn't
I'm looking here: https://github.com/gfredericks/test.chuck/blob/master/src/com/gfredericks/test/chuck/clojure_test.cljc#L108
Mind you I've been working on untangling the differences among: - clojure.test - test.check - test.chuck - test.check.clojure-test - clojure.spec.alpha.test ...so maybe I'm confusing the hammers I should be using
the problem is that there are two different namespaces that you'll see aliased as gen/
one in test.check and one in clojure.spec
the namespace in clojure.spec mostly exists to alias the namespace in test.check
with the added confusion that it has functions that return generators instead of generators
I would alias the clojure.spec namespace as sgen
just to keep things straight
so gen/int
is the same as (sgen/int)
I see. Do they have different purposes? Or is clojure.spec an alpha because it's absorbing test.check but hasn't fully digested it yet?
the purpose of the spec namespace is to lazily load test.check only when necessary, so you don't need to have it as a production dependency
that's also the reason for the functions-that-return-generators thing
Thanks--- there's a lot of polysemy going on in the terms test
spec
gen
and check
as I try and develop a sensible workflow for spec-driving
it needs a good blog post or something