Fork me on GitHub
#clojure-spec
<
2016-10-19
>
Niclas09:10:20

How does one set the default number of tests to run with cljs.spec.test/check?

bhagany12:10:01

@looveh based on my reading of the source (specifically, https://github.com/clojure/clojure/blob/master/src/clj/clojure/spec/test.clj#L304), I don’t believe the default number is configurable.

bhagany12:10:00

hopefully I didn’t misunderstand you there - if you’re looking for how to specify the number of tests to run when you invoke check, you’d pass an options map that looks like {:clojure.spec.test.check/opts {:num-tests 500}}

decoursin12:10:40

@alexmiller Thanks Alex! I'll try next opportunity

Niclas12:10:40

Thanks @bhagany! Yes, that was my understanding too from the docs, but the call doesn’t seem to take the option into account when I test it locally:

(cljs.spec.test/check
  `my-func
  {:clojure.spec.test.check/opts {:num-tests 200}}) =>

[{:spec #object[cljs.spec.t_cljs$spec16362],
  :clojure.test.check/ret {:result true,
                           :num-tests 1000,
                           :seed 1476881391908},
  :sym my-ns/my-func}]

minimal12:10:24

(st/check `my-func {:clojure.test.check/opts {:num-tests 15}})

Niclas12:10:19

@minimal Yes! That did it

bhagany14:10:18

Ah yes, it is different in clojurescript. I believe it's a difference in test.check iirc

minimal14:10:15

Yeah took me while to work it out in cljs

jrheard15:10:32

@dnolen - this is what patch 1 on that issue fixes

jrheard15:10:45

deleting patch 2, pretend you never saw it

Alex Miller (Clojure team)15:10:31

would be nice to get that fixed

dnolen16:10:40

@jrheard applied to master

jrheard16:10:48

😮 😮 😮

jrheard16:10:53

thanks! 🙂 my first cljs commit!

Tim20:10:57

anyone using clojure-future-spec ?

liamd21:10:08

to use a spec in another namespace do you have to require anything?

borkdude21:10:39

yes, we are using it too at work

jrheard21:10:56

@liamd - my understanding of the world is that you need to either require the namespace that the spec was defined in, or require another namespace that requires that namespace

jrheard21:10:47

like, the (s/def ::foo) line is a side effect, and so in order for you to use ::foo somewhere else, you need to ensure that that side effect was run

jrheard21:10:56

this could be a poor mental model to use, but it’s the one i’m currently using 🙂