Remove clojure.test dependencies

This commit is contained in:
Colin Jones 2011-06-10 22:22:04 -05:00
parent 5a5f519fb8
commit e6174d80dc
3 changed files with 27 additions and 20 deletions

View File

@ -1,8 +1,7 @@
(ns path-to-answer-sheet (ns path-to-answer-sheet
(:use [runner.koans :only [ordered-koans]] (:use [runner.koans :only [ordered-koans]]
[path-to-enlightenment :only [meditations __ ___]] [path-to-enlightenment :only [meditations __ ___]]
[clojure.string :only [join split trim]] [clojure.string :only [join split trim]]))
[clojure.test :only [*test-out*]]))
(def answers (def answers
{"equalities" {"__" [true {"equalities" {"__" [true
@ -216,17 +215,23 @@
(println (str "\n" koan ".clj is passing without filling in the blanks"))) (println (str "\n" koan ".clj is passing without filling in the blanks")))
(defn ensure-failing-without-answers [] (defn ensure-failing-without-answers []
(binding [clojure.test/*test-out* (if (every?
(java.io.PrintWriter. (java.io.ByteArrayOutputStream.))] (fn [koan]
(if (every? (let [form (koan-text koan)
(fn [koan] fake-err (java.io.PrintStream. (java.io.ByteArrayOutputStream.))
(let [form (koan-text koan) real-err System/err
result (load-string form)] result (try
(if result (System/setErr fake-err)
(print-non-failing-error koan) (load-string form)
:pass))) true
ordered-koans) (catch AssertionError e false)
(println "\nTests all fail before the answers are filled in.")))) (catch Exception e false)
(finally (System/setErr real-err)))]
(if result
(print-non-failing-error koan)
:pass)))
ordered-koans)
(println "\nTests all fail before the answers are filled in.")))
(defn ensure-passing-with-answers [] (defn ensure-passing-with-answers []
(try (try

View File

@ -1,18 +1,15 @@
(ns path-to-enlightenment (ns path-to-enlightenment
(:use [runner.freshness :only [setup-freshener]]) (:use [runner.freshness :only [setup-freshener]])
(:require [clojure.set] (:require [clojure.set]
[clojure.string] [clojure.string]))
[clojure.test]))
(def __ :fill-in-the-blank) (def __ :fill-in-the-blank)
(def ___ (fn [& args] __)) (def ___ (fn [& args] __))
(defmacro meditations [& forms] (defmacro meditations [& forms]
(let [pairs (conj (partition 2 forms) (let [pairs (partition 2 forms)
["Bootstrap for file/line reporting"
'(clojure.test/is (= 0 0))])
tests (map (fn [[doc# code#]] tests (map (fn [[doc# code#]]
`(clojure.test/is ~code# ~doc#)) `(assert ~code# ~doc#))
pairs)] pairs)]
`(and ~@tests))) `(and ~@tests)))

View File

@ -42,7 +42,12 @@
(load-file file-path) (load-file file-path)
(catch Exception e (catch Exception e
(println) (println)
(println e) (println "Problem in " file-path)
(println "---------------------")
(println "Assertion failed!")
(println (.replaceFirst (.getMessage (.getCause e))
"^Assert failed: "
""))
false))) false)))
(defn namaste [] (defn namaste []