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] (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]
(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 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)
(print-non-failing-error koan))))
(defn run [] ordered-koans))))
(defn ensure-passing-with-answers []
(try (try
(ensure-failing-tests) (dorun (map
(dorun (fn [koan]
(map (load-string
(fn [koan] (-> (koan-text koan)
(load-string (fill-in-answers koan "__")
(-> (koan-text koan) (fill-in-answers koan "___"))))
(fill-in-answers koan "__") ordered-koans))
(fill-in-answers koan "___"))))
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))