test-check

mathpunk 2018-04-21T16:25:39.000119Z

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

mathpunk 2018-04-21T16:26:32.000057Z

When I tested this myself---

mathpunk 2018-04-21T16:29:24.000169Z

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?

2018-04-21T16:29:59.000014Z

how does it fail?

2018-04-21T16:30:08.000011Z

oh sorry

2018-04-21T16:30:13.000013Z

only saw the first five lines of the snippet

2018-04-21T16:31:30.000147Z

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

2018-04-21T16:31:49.000091Z

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

2018-04-21T16:32:06.000032Z

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

2018-04-21T16:32:12.000036Z

try (gen/int)

mathpunk 2018-04-21T16:32:35.000157Z

yep, that did it

mathpunk 2018-04-21T16:33:45.000122Z

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

2018-04-21T16:34:22.000119Z

which doc?

2018-04-21T16:34:44.000144Z

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

2018-04-21T16:34:55.000118Z

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

mathpunk 2018-04-21T16:38:29.000104Z

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

2018-04-21T16:41:39.000086Z

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

2018-04-21T16:41:49.000007Z

one in test.check and one in clojure.spec

2018-04-21T16:42:11.000017Z

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

2018-04-21T16:42:35.000091Z

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

2018-04-21T16:43:15.000071Z

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

2018-04-21T16:43:31.000019Z

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

mathpunk 2018-04-21T16:49:37.000083Z

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?

2018-04-21T16:50:03.000101Z

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

2018-04-21T16:50:20.000104Z

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

mathpunk 2018-04-21T16:50:22.000114Z

ohhhhh huh, ok

mathpunk 2018-04-21T16:50:47.000027Z

because specs have some use in production code

mathpunk 2018-04-21T16:53:07.000076Z

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

2018-04-21T16:54:23.000103Z

it needs a good blog post or something

mathpunk 2018-04-21T17:00:44.000138Z

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

mathpunk 2018-04-21T17:01:04.000109Z

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