it helps if you put the metadata in the right place. also make mediate-on a macro so that I could get at the metadata from the actual test

This commit is contained in:
Aaron Bedra 2010-01-24 11:04:27 -05:00
parent b9fa6742cf
commit 95c0e18728
2 changed files with 12 additions and 10 deletions

View File

@ -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)]

View File

@ -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)