diff --git a/src/path_to_enlightenment.clj b/src/path_to_enlightenment.clj index f0a9d0b..4001658 100644 --- a/src/path_to_enlightenment.clj +++ b/src/path_to_enlightenment.clj @@ -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)))