Separate expected-failing and -passing concerns.
This commit is contained in:
parent
21c911f0a4
commit
c604126a4e
@ -162,32 +162,32 @@
|
|||||||
(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 []
|
(defn print-non-failing-error [koan]
|
||||||
(let [wtr (java.io.PrintWriter. (java.io.ByteArrayOutputStream.))]
|
(println (str "\n" koan ".clj is passing without filling in the blanks")))
|
||||||
(binding [path-to-enlightenment/handle-problem (constantly nil)
|
|
||||||
clojure.test/*test-out* wtr]
|
(defn ensure-failing-without-answers []
|
||||||
(dorun
|
(binding [path-to-enlightenment/handle-problem
|
||||||
(map
|
(constantly :correctly-failing-test)
|
||||||
|
clojure.test/*test-out*
|
||||||
|
(java.io.PrintWriter. (java.io.ByteArrayOutputStream.))]
|
||||||
|
(dorun (map
|
||||||
(fn [koan]
|
(fn [koan]
|
||||||
(let [form (koan-text koan)
|
(let [form (koan-text koan)
|
||||||
result (load-string form)]
|
result (load-string form)]
|
||||||
(when (= :pass result)
|
(when (= :pass result)
|
||||||
(println (str "\n" koan ".clj is passing without filling in the blanks")))))
|
(print-non-failing-error koan))))
|
||||||
|
|
||||||
ordered-koans)))))
|
ordered-koans))))
|
||||||
|
|
||||||
(defn run []
|
(defn ensure-passing-with-answers []
|
||||||
(try
|
(try
|
||||||
(ensure-failing-tests)
|
(dorun (map
|
||||||
(dorun
|
|
||||||
(map
|
|
||||||
(fn [koan]
|
(fn [koan]
|
||||||
(load-string
|
(load-string
|
||||||
(-> (koan-text koan)
|
(-> (koan-text koan)
|
||||||
(fill-in-answers koan "__")
|
(fill-in-answers koan "__")
|
||||||
(fill-in-answers koan "___"))))
|
(fill-in-answers koan "___"))))
|
||||||
ordered-koans))
|
ordered-koans))
|
||||||
|
|
||||||
(println "\nAll tests pass when the answers are filled in.")
|
(println "\nAll tests pass when the answers are filled in.")
|
||||||
|
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
@ -195,3 +195,8 @@
|
|||||||
(.printStackTrace e)
|
(.printStackTrace e)
|
||||||
(println "Answer sheet fail"))))
|
(println "Answer sheet fail"))))
|
||||||
|
|
||||||
|
(defn run []
|
||||||
|
(ensure-failing-without-answers)
|
||||||
|
(ensure-passing-with-answers))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user