Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anticrisis/19b7126b1dec366678bcefb0d92f2aef to your computer and use it in GitHub Desktop.
Save anticrisis/19b7126b1dec366678bcefb0d92f2aef to your computer and use it in GitHub Desktop.
Inconsistent behavior with a simple spec that uses a regex op in an instrumented function
(s/def ::test (s/cat :k keyword? :rest (s/* pos-int?)))
(s/conform ::test [:foo 1 2 3 4])
;; => {:k :foo, :rest [1 2 3 4]}
(s/conform (s/spec ::test) [:foo 1 2 3 4])
;; => {:k :foo, :rest [1 2 3 4]}
(s/conform (s/cat :t ::test) [:foo 1 2 3 4])
;; => {:t {:k :foo, :rest [1 2 3 4]}}
(s/conform (s/cat :t (s/spec ::test)) [:foo 1 2 3 4])
;; => :clojure.spec.alpha/invalid
(defn test-fn [test] nil)
(s/fdef test-fn :args (s/cat :t ::test) :ret nil?)
(stest/instrument `test-fn)
(test-fn [:foo 1 2 3 4])
;; => exception
(s/fdef test-fn :args (s/cat :t (s/spec ::test)) :ret nil?)
(stest/instrument `test-fn)
(test-fn [:foo 1 2 3 4])
;; => nil
;; Note that in order to get test-fn to pass instrumentation,
;; its :args must use the same form which conform considers invalid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment