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:
parent
b9fa6742cf
commit
95c0e18728
@ -1,10 +1,10 @@
|
|||||||
(defn test-truth
|
(defn #^{:zen "We shall contemplate truth by testing reality, via asserts."}
|
||||||
#^{:zen "We shall contemplate truth by testing reality, via asserts."}
|
test-truth
|
||||||
[]
|
[]
|
||||||
(assert false)) ;; This should be true
|
(assert false)) ;; This should be true
|
||||||
|
|
||||||
(defn test-assert-equality
|
(defn #^{:zen "To understand reality, we must compare our expectations against reality."}
|
||||||
#^{:zen "To understand reality, we must compare our expectations against reality."}
|
test-assert-equality
|
||||||
[]
|
[]
|
||||||
(let [expected-value 0
|
(let [expected-value 0
|
||||||
actual-value (+ 1 1)]
|
actual-value (+ 1 1)]
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
(load "about-asserts")
|
(load "about-asserts")
|
||||||
|
|
||||||
(defn meditate-on
|
(defmacro meditate-on
|
||||||
"Runs tests but exits if an assertion fails"
|
"Runs tests but exits if an assertion fails"
|
||||||
[test]
|
[test-function]
|
||||||
(try
|
`(try
|
||||||
(test)
|
(~test-function)
|
||||||
(catch Throwable t
|
(catch Throwable t#
|
||||||
(println (str "Metadata zen\n" "test name failed"))
|
(println (str (:zen (meta #'~test-function)) "\n"
|
||||||
|
(:name (meta #'~test-function))
|
||||||
|
" returned " t#))
|
||||||
(System/exit 1))))
|
(System/exit 1))))
|
||||||
|
|
||||||
(meditate-on test-truth)
|
(meditate-on test-truth)
|
||||||
|
Loading…
Reference in New Issue
Block a user