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
When I tested this myself---
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)
yep, that did it
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
ohhhhh huh, ok
because specs have some use in production code
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
I may be able to contribute to the beginners' end of the topic. The comments I'm writing to myself may become a post on a repl-to-gen-tests workflow with cognitect/transcriptor
and test.chuck
Not gonna touch when a gen is a gen and when a gen is a thunk