rlm@10: (ns clojure.contrib.test-with-ns rlm@10: (:use clojure.test rlm@10: clojure.contrib.with-ns)) rlm@10: rlm@10: (deftest test-namespace-gets-removed rlm@10: (let [all-ns-names (fn [] (map #(.name %) (all-ns)))] rlm@10: (testing "unexceptional return" rlm@10: (let [ns-name (with-temp-ns (ns-name *ns*))] rlm@10: (is (not (some #{ns-name} (all-ns-names)))))) rlm@10: (testing "when an exception is thrown" rlm@10: (let [ns-name-str rlm@10: (try rlm@10: (with-temp-ns rlm@10: (throw (RuntimeException. (str (ns-name *ns*))))) rlm@10: (catch clojure.lang.Compiler$CompilerException e rlm@10: (-> e .getCause .getMessage)))] rlm@10: (is (re-find #"^sym.*$" ns-name-str)) rlm@10: (is (not (some #{(symbol ns-name-str)} (all-ns-names))))))))