-
-
Save jeaye/eaa8da70171a538e23b3c5dbfd9797fd to your computer and use it in GitHub Desktop.
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
(defn arities | |
([a] | |
(inc a)) | |
([a b] | |
(+ a b)) | |
([a b c] | |
0)) | |
(s/fdef arities | |
:args (s/or :arity-1 (s/cat :a number?) | |
:arity-2 (s/cat :a number? :b number?) | |
:arity-3 (s/cat :a string? :b boolean? :c map?)) | |
:ret number?) | |
(st/instrument) | |
(deftest arities' | |
(testing "Arity-1 Positive" | |
(is (arities 1))) | |
(testing "Arity-1 Negative" | |
(is (thrown? #?(:clj RuntimeException :cljs :default) | |
(arities "bad"))))) ; Doesn't throw with ClojureScript, but does with Clojure |
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
(defn arities | |
[a] | |
(inc a)) | |
(s/fdef arities ; Same spec, but defn doesn't have multiple arities | |
:args (s/or :arity-1 (s/cat :a number?) | |
:arity-2 (s/cat :a number? :b number?) | |
:arity-3 (s/cat :a string? :b boolean? :c map?)) | |
:ret number?) | |
(st/instrument) | |
(deftest arities' | |
(testing "Arity-1 Positive" | |
(is (arities 1))) | |
(testing "Arity-1 Negative" | |
(is (thrown? #?(:clj RuntimeException :cljs :default) | |
(arities "bad"))))) ; Throws for Clojure and ClojureScript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is what I get:
And