Last active
June 12, 2016 13:58
-
-
Save ryfow/69a64e966d48258dfa9dcb5aa74005eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(require '[clojure.spec :as s]) | |
(defmacro tpe [ & forms ] | |
`(try | |
~@forms | |
(catch Exception e# | |
(println "Form: " (pr-str '~@forms)) | |
(println "Exception Class: " (.getClass e#)) | |
(println "Message: " (.getMessage e#)) | |
(println)))) | |
(defn header [s] | |
(println "=========================================================") | |
(println s) | |
(println "=========================================================")) | |
(s/fdef clojure.core/map | |
:args (s/cat :fn ifn? | |
:seq (s/* sequential?)) | |
:return sequential?) | |
(header "Before instrumenting clojure.core/map") | |
(tpe (into [] (map nil [1 2 3] [1 2 3]))) | |
(tpe (into [] (map 1 [1 2 3] [1 2 3]))) | |
(tpe (into [] (map identity 4))) | |
(header "After instrumenting clojure.core/map") | |
(s/instrument #'clojure.core/map) | |
(tpe (into [] (map nil [1 2 3] [1 2 3]))) | |
(tpe (into [] (map 1 [1 2 3] [1 2 3]))) | |
(tpe (into [] (map identity 4))) | |
(header "Before instrumenting clojure.core/identity") | |
(tpe (into [] (map identity [1 2 3] [1 2 3]))) | |
(s/fdef clojure.core/identity | |
:args (s/cat :one-argument (constantly true))) | |
(s/instrument #'clojure.core/identity) | |
(header "After instrumenting clojure.core/identity") | |
(tpe (into [] (map identity [1 2 3] [4 5 6]))) | |
Author
ryfow
commented
Jun 12, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment