aboutsummaryrefslogtreecommitdiff
path: root/modules/with-ns/src
diff options
context:
space:
mode:
Diffstat (limited to 'modules/with-ns/src')
-rw-r--r--modules/with-ns/src/test/clojure/clojure/contrib/test_with_ns.clj18
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/with-ns/src/test/clojure/clojure/contrib/test_with_ns.clj b/modules/with-ns/src/test/clojure/clojure/contrib/test_with_ns.clj
new file mode 100644
index 00000000..8d3ca3c1
--- /dev/null
+++ b/modules/with-ns/src/test/clojure/clojure/contrib/test_with_ns.clj
@@ -0,0 +1,18 @@
+(ns clojure.contrib.test-with-ns
+ (:use clojure.test
+ clojure.contrib.with-ns))
+
+(deftest test-namespace-gets-removed
+ (let [all-ns-names (fn [] (map #(.name %) (all-ns)))]
+ (testing "unexceptional return"
+ (let [ns-name (with-temp-ns (ns-name *ns*))]
+ (is (not (some #{ns-name} (all-ns-names))))))
+ (testing "when an exception is thrown"
+ (let [ns-name-str
+ (try
+ (with-temp-ns
+ (throw (RuntimeException. (str (ns-name *ns*)))))
+ (catch clojure.lang.Compiler$CompilerException e
+ (-> e .getCause .getMessage)))]
+ (is (re-find #"^sym.*$" ns-name-str))
+ (is (not (some #{(symbol ns-name-str)} (all-ns-names))))))))