Separate expected-failing and -passing concerns.

This commit is contained in:
Colin Jones 2011-02-08 16:07:36 -06:00
parent 21c911f0a4
commit c604126a4e

View File

@ -162,32 +162,32 @@
(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
(defn print-non-failing-error [koan]
(println (str "\n" koan ".clj is passing without filling in the blanks")))
(defn ensure-failing-without-answers []
(binding [path-to-enlightenment/handle-problem
(constantly :correctly-failing-test)
clojure.test/*test-out*
(java.io.PrintWriter. (java.io.ByteArrayOutputStream.))]
(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")))))
(print-non-failing-error koan))))
ordered-koans)))))
ordered-koans))))
(defn run []
(defn ensure-passing-with-answers []
(try
(ensure-failing-tests)
(dorun
(map
(dorun (map
(fn [koan]
(load-string
(-> (koan-text koan)
(fill-in-answers koan "__")
(fill-in-answers koan "___"))))
ordered-koans))
(println "\nAll tests pass when the answers are filled in.")
(catch Exception e
@ -195,3 +195,8 @@
(.printStackTrace e)
(println "Answer sheet fail"))))
(defn run []
(ensure-failing-without-answers)
(ensure-passing-with-answers))