Catch exceptions that happen before the assertion can be made
This commit is contained in:
parent
02b00bafd7
commit
8e33a43ee8
@ -6,10 +6,19 @@
|
|||||||
(def __ :fill-in-the-blank)
|
(def __ :fill-in-the-blank)
|
||||||
(def ___ (fn [& args] __))
|
(def ___ (fn [& args] __))
|
||||||
|
|
||||||
|
(defmacro fancy-assert
|
||||||
|
([x] (fancy-assert x ""))
|
||||||
|
([x message]
|
||||||
|
`(try
|
||||||
|
(assert ~x ~message)
|
||||||
|
(catch Exception e#
|
||||||
|
(throw (Exception. (str '~message "\n" '~x )
|
||||||
|
e#))))))
|
||||||
|
|
||||||
(defmacro meditations [& forms]
|
(defmacro meditations [& forms]
|
||||||
(let [pairs (partition 2 forms)
|
(let [pairs (partition 2 forms)
|
||||||
tests (map (fn [[doc# code#]]
|
tests (map (fn [[doc# code#]]
|
||||||
`(assert ~code# ~doc#))
|
`(fancy-assert ~code# ~doc#))
|
||||||
pairs)]
|
pairs)]
|
||||||
`(do ~@tests)))
|
`(do ~@tests)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user