Allow `fspy` to capture freq for exception-throwing bodies

This commit is contained in:
Peter Taoussanis 2013-07-23 14:28:28 +07:00
parent 37f4d35b07
commit 545c278394
1 changed files with 6 additions and 5 deletions

View File

@ -51,10 +51,11 @@
`(if-not *fdata* `(if-not *fdata*
(do ~@body) (do ~@body)
(let [name# ~name (let [name# ~name
result# (do ~@body)] result# (try (do ~@body) (catch Throwable t# {::throwable t#}))
(swap! *fdata* #(assoc-in % [name# result#] throwable# (and (map? result#) (::throwable result#))]
(inc (get-in % [name# result#] 0)))) (swap! *fdata* #(assoc-in % [name# (or throwable# result#)]
result#)))) (inc (get-in % [name# (or throwable# result#)] 0))))
(if throwable# (throw throwable#) result#)))))
(defmacro f [name & body] `(fspy name ~@body)) ; Alias (defmacro f [name & body] `(fspy name ~@body)) ; Alias