Fork me on GitHub

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.


Whoops, found it!:


(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.


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


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


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.


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


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


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


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


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


Sorry, no idea.


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


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.


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.