Created
July 10, 2017 06:32
-
-
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
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
(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