diff --git a/koans/about-asserts.clj b/koans/about-asserts.clj index b62ef60..b6272cf 100644 --- a/koans/about-asserts.clj +++ b/koans/about-asserts.clj @@ -1,10 +1,10 @@ -(defn test-truth - #^{:zen "We shall contemplate truth by testing reality, via asserts."} +(defn #^{:zen "We shall contemplate truth by testing reality, via asserts."} + test-truth [] (assert false)) ;; This should be true -(defn test-assert-equality - #^{:zen "To understand reality, we must compare our expectations against reality."} +(defn #^{:zen "To understand reality, we must compare our expectations against reality."} + test-assert-equality [] (let [expected-value 0 actual-value (+ 1 1)] diff --git a/koans/path_to_enlightenment.clj b/koans/path_to_enlightenment.clj index dfa7046..3f221c1 100644 --- a/koans/path_to_enlightenment.clj +++ b/koans/path_to_enlightenment.clj @@ -1,12 +1,14 @@ (load "about-asserts") -(defn meditate-on +(defmacro meditate-on "Runs tests but exits if an assertion fails" - [test] - (try - (test) - (catch Throwable t - (println (str "Metadata zen\n" "test name failed")) + [test-function] + `(try + (~test-function) + (catch Throwable t# + (println (str (:zen (meta #'~test-function)) "\n" + (:name (meta #'~test-function)) + " returned " t#)) (System/exit 1)))) (meditate-on test-truth)