Skip to content

Instantly share code, notes, and snippets.

@bhb
Last active November 1, 2017 07:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bhb/0f2210914095b45afb7d0061322bc6a3 to your computer and use it in GitHub Desktop.
Save bhb/0f2210914095b45afb7d0061322bc6a3 to your computer and use it in GitHub Desktop.
Adding your own spec for filter
(require '[clojure.spec.test.alpha :as st])
(require '[clojure.spec.alpha :as s])
(require '[expound.alpha :as expound])
(set! s/*explain-out* expound/printer)
(st/instrument)
(filter 123 "12333333333333") ; java.lang.Long cannot be cast to clojure.lang.IFn
(s/fdef clojure.core/filter
:args (s/cat :pred ifn? :coll (s/? coll?)))
(st/instrument)
(filter 123 "12333333333333")
;; ExceptionInfo Call to #'clojure.core/filter did not conform to spec:
;; form-init3643830678794618507.clj:1
;; -- Spec failed --------------------
;; Function arguments
;; (123 ...)
;; ^^^
;; should satisfy
;; ifn?
;; -------------------------
;; Detected 1 error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment