speculative

https://github.com/borkdude/speculative
borkdude 2018-10-27T08:48:24.107700Z

@mfikes Shortest path to reproduction:

$ plk -A:test:repl
cljs.user=> (stest/instrument [`=])
[cljs.core/=]
cljs.user=> (= [1 1] ::s/invalid)
Call to #'cljs.core/= did not conform to spec:
In: [1] val: :cljs.spec.alpha/invalid fails at: [:args] predicate: any?
:cljs.spec.alpha/spec  #object[cljs.spec.alpha.t_cljs$spec$alpha5193]
:cljs.spec.alpha/value  ([1 1] :cljs.spec.alpha/invalid)
:cljs.spec.alpha/args  ([1 1] :cljs.spec.alpha/invalid)
:cljs.spec.alpha/failure  :instrument

	cljs.core/ExceptionInfo (cljs/core.cljs:11129:11)
	cljs.spec.test.alpha/c (cljs/spec/test/alpha.cljs:117:57)
	cljs.spec.test.alpha/d (cljs/spec/test/alpha.cljs:114:29)
	cljs.core/d (cljs/core.cljs:2008:6)
	cljs.core/a (cljs/core.cljs:2045:15)

borkdude 2018-10-27T09:01:20.109700Z

Now I can repoduce this on clj + cljs:

(defn foo [& args])
(s/fdef foo :args (s/* any?))
(stest/instrument [`foo])
(foo 1 2 3) ;; fine
(foo 1 2 ::s/invalid) ;; error

borkdude 2018-10-27T09:06:31.110Z

working on a fix

borkdude 2018-10-27T12:38:55.110500Z

Iā€™m a bit stuck on with-unstrumentation in cljs. it does work properly in clj: https://github.com/slipset/speculative/blob/master/test/speculative/core_test.cljc#L30

borkdude 2018-10-27T12:39:45.111100Z

with-instrumentation and with-unstrumentation should now restore their previous instrumented state

borkdude 2018-10-27T12:40:15.111700Z

reason for this extra unstrumentation macro: having = instrumented while check-ing it, causes a spec error in cljs

borkdude 2018-10-27T12:52:23.112300Z

fixed

borkdude 2018-10-27T12:54:14.112500Z

sorry for the noise šŸ™‚

borkdude 2018-10-27T13:13:34.113200Z

would it be ok to move some of test-utils to a speculative.spec.test namespace, so I could use it in other projects as well? it relies on some of the spec.test.alpha internals, but our library is called speculative for a reason right? šŸ˜‰

slipset 2018-10-27T13:16:13.113600Z

Go ahead!

borkdude 2018-10-27T13:26:47.113800Z

done

borkdude 2018-10-27T15:33:01.114900Z

I also added a :repl alias for easy debugging

borkdude 2018-10-27T15:48:19.115400Z

E.g.:

$ plk -A:test:repl
cljs.user=> (with-instrumentation `= (=))
                                     ^
WARNING: Wrong number of args (0) passed to cljs.core/= at line 1
Call to #'cljs.core/= did not conform to spec: