diff src/clojure/contrib/test_contrib/test_with_ns.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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/clojure/contrib/test_contrib/test_with_ns.clj	Sat Aug 21 06:25:44 2010 -0400
     1.3 @@ -0,0 +1,18 @@
     1.4 +(ns clojure.contrib.test-with-ns
     1.5 +  (:use clojure.test
     1.6 +	clojure.contrib.with-ns))
     1.7 +
     1.8 +(deftest test-namespace-gets-removed
     1.9 +  (let [all-ns-names (fn [] (map #(.name %) (all-ns)))]
    1.10 +    (testing "unexceptional return"
    1.11 +      (let [ns-name (with-temp-ns (ns-name *ns*))]
    1.12 +        (is (not (some #{ns-name} (all-ns-names))))))
    1.13 +    (testing "when an exception is thrown"
    1.14 +      (let [ns-name-str
    1.15 +            (try
    1.16 +             (with-temp-ns
    1.17 +               (throw (RuntimeException. (str (ns-name *ns*)))))
    1.18 +             (catch clojure.lang.Compiler$CompilerException e
    1.19 +               (-> e .getCause .getMessage)))]
    1.20 +        (is (re-find #"^sym.*$" ns-name-str))
    1.21 +        (is (not (some #{(symbol ns-name-str)} (all-ns-names))))))))