Skip to content

Instantly share code, notes, and snippets.

@tirkarthi
Forked from bhb/filter_spec.clj
Created November 1, 2017 07:16
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 tirkarthi/8b5f76dcaf7cd0268b7e12c6433c4fe4 to your computer and use it in GitHub Desktop.
Save tirkarthi/8b5f76dcaf7cd0268b7e12c6433c4fe4 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