diff --git a/build.xml b/build.xml deleted file mode 100644 index e34ac4f..0000000 --- a/build.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - functional-koans - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/koans/about-asserts.clj b/koans/about-asserts.clj new file mode 100644 index 0000000..b62ef60 --- /dev/null +++ b/koans/about-asserts.clj @@ -0,0 +1,11 @@ +(defn test-truth + #^{:zen "We shall contemplate truth by testing reality, via asserts."} + [] + (assert false)) ;; This should be true + +(defn test-assert-equality + #^{:zen "To understand reality, we must compare our expectations against reality."} + [] + (let [expected-value 0 + actual-value (+ 1 1)] + (assert (= expected-value actual-value)))) diff --git a/koans/about_asserts_test.clj b/koans/about_asserts_test.clj deleted file mode 100644 index 78b2705..0000000 --- a/koans/about_asserts_test.clj +++ /dev/null @@ -1,12 +0,0 @@ -(ns about-asserts-test - (:use clojure.test)) - -(deftest test-truth - (testing "We shall contemplate truth by testing reality, via asserts." - (assert false))) ;; This should be true - -(deftest test-assert-equality - (testing "To understand reality, we must compare our expectations against reality." - (let [expected-value 0 - actual-value (+ 1 1)] - (is (= expected-value actual-value))))) \ No newline at end of file diff --git a/koans/path_to_enlightenment.clj b/koans/path_to_enlightenment.clj index 70789e4..dfa7046 100644 --- a/koans/path_to_enlightenment.clj +++ b/koans/path_to_enlightenment.clj @@ -1,20 +1,14 @@ -(use 'clojure.contrib.find-namespaces - 'clojure.test) +(load "about-asserts") -(def exit-code (atom 0)) +(defn meditate-on + "Runs tests but exits if an assertion fails" + [test] + (try + (test) + (catch Throwable t + (println (str "Metadata zen\n" "test name failed")) + (System/exit 1)))) -(defn find-tests [] - (filter - #(re-find #"-test" (str %)) (find-namespaces-in-dir (java.io.File. ".")))) - -(defn require-tests [] - - (doseq [test (find-tests)] - (require test))) - -(require-tests) -(let [results (apply merge-with + (map test-ns (find-tests)))] - (if (or (> (results :fail) 0) - (> (results :error) 0)) - (System/exit -1) - (System/exit 0))) \ No newline at end of file +(meditate-on test-truth) +(meditate-on test-assert-equality) +(println "You have achieved clojure zen. Go out into the universe and spread your newfound knowledge.") diff --git a/path_to_enlightenment b/path_to_enlightenment new file mode 100755 index 0000000..e7c5a1a --- /dev/null +++ b/path_to_enlightenment @@ -0,0 +1,9 @@ +#!/bin/sh + +CLASSPATH=koans + +for f in lib/*.jar; do + CLASSPATH=$CLASSPATH:$f +done + +java -cp $CLASSPATH clojure.main -i koans/path_to_enlightenment.clj