Given that we now have to use clojure.spec.test to get :ret / :fn tested, we lose the “nice” exceptions explaining the conformance failure:
Alpha 5:
;;=> ExceptionInfo Call to #'spec-example.core/ranged-rand did not conform to spec:
;;=> At: [:fn] val: {:args {:start 8, :end 10}, :ret 7} fails predicate: (>= (:ret %) (-> % :args :start))
;;=> :clojure.spec/args (8 10)
;;=> clojure.core/ex-info (core.clj:4617)
Alpha 6:
boot.user=> (t/check-var #'ranged-rand)
{:result {:clojure.spec/problems {[] {:pred (>= (:ret %) (-> % :args :start)), :val {:args {:start -1, :end 2}, :ret -2}, :via [], :in []}}, :failed-on :fn}, :seed 1466016600676, :failing-size 4, :num-tests 5, :fail [(-1 2)], :shrunk {:total-nodes-visited 5, :depth 1, :result {:clojure.spec/problems {[] {:pred (>= (:ret %) (-> % :args :start)), :val {:args {:start -1, :end 1}, :ret -2}, :via [], :in []}}, :failed-on :fn}, :smallest [(-1 1)]}}
Are there plans to provide an “explain” equivalent for this?
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I fear you’re missing my point.
You can get close to the previous nice value with:
(#’s/explain-out (:result (t/check-var #’ranged-rand)))
But that leverages a private function / implementation detail and doesn’t handle :failed-on very nicely:
boot.user=> (#'s/explain-out (:result (t/check-var #'ranged-rand)))
val: {:args {:start -3, :end 1}, :ret -5} fails predicate: (>= (:ret %) (-> % :args :start))
:failed-on :fn
When you run-all-tests you get the non-pretty-printed version as a hard-to-read blob of text on stdout and a bare pass/fail map result. Having that text formatted via something like explain-out would be a big help for usability when testing. Having that function exposed publicly would be a nice convenience for other tooling to build on top of clojure.spec.test.
We can pass :reporter-fn to check-var / check-fn, but we run-all-tests just passes println in and calls (prn ret) on the result of check-var so we have no control over that output.
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
--
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.