Find tests that pass too easily in test run.

This commit is contained in:
Colin Jones 2011-02-08 15:51:05 -06:00
parent ddbb9971fd
commit 6948ed6ec8
2 changed files with 22 additions and 3 deletions

View File

@ -162,8 +162,23 @@
(defn fill-in-answers [text koan sym]
(replace-with text sym (answers-for koan sym)))
(defn ensure-failing-tests []
(let [wtr (java.io.PrintWriter. (java.io.ByteArrayOutputStream.))]
(binding [path-to-enlightenment/handle-problem (constantly nil)
clojure.test/*test-out* wtr]
(dorun
(map
(fn [koan]
(let [form (koan-text koan)
result (load-string form)]
(when (= :pass result)
(println (str "\n" koan ".clj is passing without filling in the blanks")))))
ordered-koans)))))
(defn run []
(try
(ensure-failing-tests)
(dorun
(map
(fn [koan]
@ -173,7 +188,7 @@
(fill-in-answers koan "___"))))
ordered-koans))
(println "\nThe answer key checks out!")
(println "\nAll tests pass when the answers are filled in.")
(catch Exception e
(println "\nAnswer sheet fail: " e)

View File

@ -6,13 +6,17 @@
(def __ :fill-in-the-blank)
(def ___ (fn [& args] __))
(defn ^:dynamic handle-problem []
(System/exit 0))
(defmacro meditations [& forms]
(let [pairs (partition 2 forms)]
`(do
~@(map
(fn [[doc# code#]]
`(when-not (is ~code# ~doc#)
(System/exit 0)))
`(if (is ~code# ~doc#)
:pass
(handle-problem)))
pairs))))
(def ordered-koans