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]
|
(defn fill-in-answers [text koan sym]
|
||||||
(replace-with text sym (answers-for 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 []
|
(defn run []
|
||||||
(try
|
(try
|
||||||
|
(ensure-failing-tests)
|
||||||
(dorun
|
(dorun
|
||||||
(map
|
(map
|
||||||
(fn [koan]
|
(fn [koan]
|
||||||
@ -173,7 +188,7 @@
|
|||||||
(fill-in-answers koan "___"))))
|
(fill-in-answers koan "___"))))
|
||||||
ordered-koans))
|
ordered-koans))
|
||||||
|
|
||||||
(println "\nThe answer key checks out!")
|
(println "\nAll tests pass when the answers are filled in.")
|
||||||
|
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(println "\nAnswer sheet fail: " e)
|
(println "\nAnswer sheet fail: " e)
|
||||||
|
@ -6,13 +6,17 @@
|
|||||||
(def __ :fill-in-the-blank)
|
(def __ :fill-in-the-blank)
|
||||||
(def ___ (fn [& args] __))
|
(def ___ (fn [& args] __))
|
||||||
|
|
||||||
|
(defn ^:dynamic handle-problem []
|
||||||
|
(System/exit 0))
|
||||||
|
|
||||||
(defmacro meditations [& forms]
|
(defmacro meditations [& forms]
|
||||||
(let [pairs (partition 2 forms)]
|
(let [pairs (partition 2 forms)]
|
||||||
`(do
|
`(do
|
||||||
~@(map
|
~@(map
|
||||||
(fn [[doc# code#]]
|
(fn [[doc# code#]]
|
||||||
`(when-not (is ~code# ~doc#)
|
`(if (is ~code# ~doc#)
|
||||||
(System/exit 0)))
|
:pass
|
||||||
|
(handle-problem)))
|
||||||
pairs))))
|
pairs))))
|
||||||
|
|
||||||
(def ordered-koans
|
(def ordered-koans
|
||||||
|
Loading…
Reference in New Issue
Block a user