Created
May 30, 2018 18:02
-
-
Save bhb/e8328ce1c15c3fc6f5f4ea71cabfa076 to your computer and use it in GitHub Desktop.
instrumentation with clojure.spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ ~ clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.3\"}}}" -m rebel-readline.main | |
[Rebel readline] Type :repl/help for online help info | |
user=> (require '[clojure.spec.alpha :as s]) | |
nil | |
user=> (s/fdef foo :args (s/cat :x int? :y string?)) | |
user/foo | |
user=> (defn foo [x y] (prn {:x x :y y}) {y x}) | |
#'user/foo | |
user=> (require '[clojure.spec.test.alpha :as st]) | |
nil | |
user=> (st/instrument) | |
[user/foo] | |
user=> (foo 1 "") | |
{:x 1, :y ""} | |
{"" 1} | |
user=> (foo "a" "b") | |
ExceptionInfo Call to #'user/foo did not conform to spec: | |
In: [0] val: "a" fails at: [:args :x] predicate: int? | |
clojure.core/ex-info (core.clj:4739) | |
user=> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment