Skip to content

Instantly share code, notes, and snippets.

@bhb
Created November 9, 2017 15:22
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 bhb/f538f2b1a47eb7a1514da0fe62d46265 to your computer and use it in GitHub Desktop.
Save bhb/f538f2b1a47eb7a1514da0fe62d46265 to your computer and use it in GitHub Desktop.
Testing instrumentation with expound
user=> (require '[expound.alpha :as expound])
nil
user=> (require '[clojure.spec.test.alpha :as st])
nil
user=> (require '[clojure.spec.alpha :as s])
nil
user=> (s/fdef foo :args (s/cat :int int?))
user/foo
user=> (defn foo [x] x)
#'user/foo
user=> (st/instrument)
[expound.printer/indent expound.paths/prefix-path? expound.alpha/specs expound.paths/kvps-path? user/foo expound.alpha/value-in-context expound.printer/pprint-str expound.paths/kps-path? expound.problems/summary-form expound.printer/no-trailing-whitespace]
user=> (set! s/*explain-out* expound/printer)
#function[expound.alpha/printer]
user=> (foo "")
ExceptionInfo Call to #'user/foo did not conform to spec:
form-init4994507209937619287.clj:1
-- Spec failed --------------------
Function arguments
("")
^^
should satisfy
int?
-------------------------
Detected 1 error
clojure.core/ex-info (core.clj:4744)
user=>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment