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 ___ (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]
|
||||
(let [pairs (partition 2 forms)
|
||||
tests (map (fn [[doc# code#]]
|
||||
`(assert ~code# ~doc#))
|
||||
`(fancy-assert ~code# ~doc#))
|
||||
pairs)]
|
||||
`(do ~@tests)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user