Find tests that pass too easily in test run.
This commit is contained in:
parent
ddbb9971fd
commit
6948ed6ec8
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user