Fork me on GitHub
#clojure-spec
<
2016-07-18
>
kendall.buchanan16:07:24

Any hints on limiting :num-tests in stest/check? (stest/check b/match-klasses {:clojure.spec.test/opts {:num-tests 10}}) isn’t working. It’s gotta be something simple I’m missing.

kendall.buchanan16:07:35

Whoops, found it!:

kendall.buchanan16:07:45

(stest/check b/match-klasses {:clojure.spec.test.check/opts {:num-tests 10}})

Chris O’Donnell19:07:54

I'm struggling to create a spec for dates with a custom conformer, unformer, and generator. I'd love input on how to make this work or if I'm just trying to fit a square peg into a round hole. See the snippet for my attempts.

wilkerlucio20:07:43

@kendall.buchanan quick tip: you can probably replace :clojure.spec.test.check/opts with ::stest/opts

kendall.buchanan20:07:32

Ah, will ::stest/opts create an alias?

wilkerlucio20:07:17

when you import a namespace into a short name (like stest for clojure.spec.test.check) you can use double colon notation :: and the namespace will be expanded

Chris O’Donnell20:07:41

@kendall.buchanan @wilkerlucio I think in this case stest resolves to clojure.spec.test, not clojure.spec.test.check, so you can't use it here.

wilkerlucio20:07:27

that was the part I wasn't sure, to where the alias was pointing, eheh

kendall.buchanan20:07:51

In any case, I made myself a helper function and referenced that instead.

wilkerlucio20:07:08

I'm looking forward for the feature that will enable us to alias namespaces without having to require it (specially good for referencing namespaces that not exists, for namespacing only), alex said it's on the table

Chris O’Donnell20:07:44

that would be handy

seancorfield20:07:09

@wilkerlucio: Did you see the workaround Alex posted? Using in-ns to create the namespace in memory without needing a file for it.

wilkerlucio20:07:31

@seancorfield: I didn't, seems cool, do you know if that works with cljs?

seancorfield20:07:31

Sorry, no idea.

wilkerlucio20:07:00

@seancorfield: do you have the snippet for that? I tried to search here, but no lucky

seancorfield21:07:49

Oh, you just use (in-ns 'qualified.keyword.namespace) (in-ns 'original.namespace) to create qualified.keyword.namespace in memory and then switch back to whatever ns you were in.

seancorfield21:07:58

Then you can do (alias 'q 'qualified.keyword.namespace) — because that ns exists now — and then ::q/k expands to :qualified.keyword.namespace/k as "expected".

Chris O’Donnell23:07:24

If anyone is curious, I solved my problem above with a dirty hack that relies heavily on implementation. (See snippet.)

Chris O’Donnell23:07:10

If with-gen* passed unc along to spec-impl, I could do it with just spec.