Mercurial > lasercutter
view src/clojure/test_clojure.clj @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
line wrap: on
line source
1 ; Copyright (c) Rich Hickey. All rights reserved.2 ; The use and distribution terms for this software are covered by the3 ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)4 ; which can be found in the file epl-v10.html at the root of this distribution.5 ; By using this software in any fashion, you are agreeing to be bound by6 ; the terms of this license.7 ; You must not remove this notice, or any other, from this software.8 ;10 ;; clojure.test-clojure11 ;;12 ;; Tests for the facilities provided by Clojure13 ;;14 ;; scgilardi (gmail)15 ;; Created 22 October 200817 (ns clojure.test-clojure18 (:require [clojure.test :as t])19 (:gen-class))21 (def test-names22 [:reader23 :printer24 :compilation25 :evaluation26 :special27 :macros28 :metadata29 :ns-libs30 :logic31 :predicates32 :control33 :data-structures34 :numbers35 :sequences36 :for37 :multimethods38 :other-functions39 :vars40 :refs41 :agents42 :atoms43 :parallel44 :java-interop45 :test46 :test-fixtures47 ;; libraries48 :clojure-set49 :clojure-xml50 :clojure-zip51 :protocols52 :genclass53 :main54 :vectors55 :annotations56 :pprint57 :serialization58 :rt59 :repl60 :java.io61 :string62 :java.javadoc63 :java.shell64 :transients65 :def66 ])68 (def test-namespaces69 (map #(symbol (str "clojure.test-clojure." (name %)))70 test-names))72 (defn run73 "Runs all defined tests"74 []75 (println "Loading tests...")76 (apply require :reload-all test-namespaces)77 (apply t/run-tests test-namespaces))79 (defn run-ant80 "Runs all defined tests, prints report to *err*, throw if failures. This works well for running in an ant java task."81 []82 (let [rpt t/report]83 (binding [;; binding to *err* because, in ant, when the test target84 ;; runs after compile-clojure, *out* doesn't print anything85 *out* *err*86 t/*test-out* *err*87 t/report (fn report [m]88 (if (= :summary (:type m))89 (do (rpt m)90 (if (or (pos? (:fail m)) (pos? (:error m)))91 (throw (new Exception (str (:fail m) " failures, " (:error m) " errors.")))))92 (rpt m)))]93 (run))))95 (defn -main96 "Run all defined tests from the command line"97 [& args]98 (run)99 (System/exit 0))