Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active June 6, 2017 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfikes/3ac5ca668b299e104490059ad0ccfcca to your computer and use it in GitHub Desktop.
Save mfikes/3ac5ca668b299e104490059ad0ccfcca to your computer and use it in GitHub Desktop.
instrument exercising
user=> (require '[clojure.spec.alpha :as s] '[clojure.spec.test.alpha :as st])
nil
user=> (s/def ::number-sink (s/fspec :args (s/cat :n integer?)))
:user/number-sink
user=> (defn foo [n number-sink])
#'user/foo
user=> (s/fdef foo :args (s/cat :n integer? :number-sink ::number-sink))
user/foo
user=> (st/instrument)
[user/foo]
user=> (foo 1 2)

ExceptionInfo Call to #'user/foo did not conform to spec:
In: [1] val: 2 fails spec: :user/number-sink at: [:args :number-sink] predicate: ifn?
:clojure.spec.alpha/spec  #object[clojure.spec.alpha$regex_spec_impl$reify__1200 0x73603d25 "clojure.spec.alpha$regex_spec_impl$reify__1200@73603d25"]
:clojure.spec.alpha/value  (1 2)
:clojure.spec.alpha/args  (1 2)
:clojure.spec.alpha/failure  :instrument
:clojure.spec.test.alpha/caller  {:file "form-init7277332518996825304.clj", :line 1, :var-scope user/eval1425}
  clojure.core/ex-info (core.clj:4725)
user=> (foo 1 (fn [n] (prn n)))
-1
0
-2
-1
2
2
1
11
0
50
-14
2
-1
2
-135
-8
26
-2852
-8
-858
108
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment