Fork me on GitHub
#test-check
<
2018-04-21
>
mathpunk16:04:39

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

mathpunk16:04:32

When I tested this myself---

mathpunk16:04:24

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?

gfredericks16:04:59

how does it fail?

gfredericks16:04:13

only saw the first five lines of the snippet

gfredericks16:04:30

I'm guessing gen/ refers to clojure.spec.gen.alpha or something of that sort

gfredericks16:04:49

and that this is the inevitable confusion that stems from the fact that spec generally deals with 0-arg functions that return generators

gfredericks16:04:06

while http://test.ch[eu]ck deals with vanilla generators

gfredericks16:04:12

try (gen/int)

mathpunk16:04:35

yep, that did it

mathpunk16:04:45

i can attempt to fix that doc if you like, though I haven't forked-and-pulled much open source

gfredericks16:04:44

the checking docs are referring to the clojure.test.check.generators namespace

gfredericks16:04:55

if you used that namespace instead, gen/int would work and (gen/int) wouldn't

mathpunk16:04:29

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

gfredericks16:04:39

the problem is that there are two different namespaces that you'll see aliased as gen/

gfredericks16:04:49

one in test.check and one in clojure.spec

gfredericks16:04:11

the namespace in clojure.spec mostly exists to alias the namespace in test.check

gfredericks16:04:35

with the added confusion that it has functions that return generators instead of generators

gfredericks16:04:15

I would alias the clojure.spec namespace as sgen just to keep things straight

gfredericks16:04:31

so gen/int is the same as (sgen/int)

mathpunk16:04:37

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?

gfredericks16:04:03

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

gfredericks16:04:20

that's also the reason for the functions-that-return-generators thing

mathpunk16:04:22

ohhhhh huh, ok

mathpunk16:04:47

because specs have some use in production code

mathpunk16:04:07

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

gfredericks16:04:23

it needs a good blog post or something

mathpunk17:04:44

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

mathpunk17:04:04

Not gonna touch when a gen is a gen and when a gen is a thunk