Permalink
Browse files

added test for namespace isolation

  • Loading branch information...
ngrunwald committed Nov 20, 2012
1 parent 4424bfe commit 29de7927395c4df73b73c0b6ed70ebdca53605df
Showing with 23 additions and 6 deletions.
  1. +23 −6 test/gavagai/core_test.clj
View
@@ -6,10 +6,6 @@
["java.util.Date" :add {:string str}]
["java.awt.Color" :only [:green #"r.d" :blue] :add {:string str} :lazy? false])
-(g/register-converters {:exclude [:class]}
- ["java.awt.Button" :translate-arrays? true :lazy? false]
- ["java.awt.Button$AccessibleAWTButton" :exclude [#"loc.le"] :lazy? false])
-
(deftest basic-tests
(testing "basic translations tests"
(let [dt (java.util.Date.)]
@@ -24,12 +20,33 @@
(g/with-translator-ns gavagai.core-test
(let [tc (g/translate c)]
(is (instance? clojure.lang.PersistentArrayMap tc))
- (is (= #{:green :red :blue :string} (into #{} (keys tc))))))))
+ (is (= #{:green :red :blue :string} (into #{} (keys tc)))))))))
+
+(g/register-converters {:exclude [:class]}
+ ["java.awt.Button" :translate-arrays? true :lazy? false]
+ ["java.awt.Button$AccessibleAWTButton" :exclude [#"loc.le"] :lazy? false])
+
+(deftest greedy-tests
(testing "testing recursivity, max-depth and array translations"
(let [b (java.awt.Button. "test")]
(g/with-translator-ns gavagai.core-test
(let [tb (g/translate b {:max-depth 3})]
(is (nil? (:locale tb)))
(is (instance? java.awt.Button$AccessibleAWTButton
(get-in tb [:accessible-context :accessible-action :accessible-action])))
- (is (vector? (:action-listeners tb))))))))
+ (is (vector? (:action-listeners tb))))))))
+
+(in-ns 'gavagai.other-core-test)
+
+(gavagai.core/register-converters {:exclude [:class] :lazy? false}
+ ["java.util.Date" :only [:time]])
+
+(in-ns 'gavagai.core-test)
+
+(deftest other-ns-tests
+ (testing "namespace isolation"
+ (let [dt (java.util.Date.)]
+ (gavagai.core/with-translator-ns gavagai.other-core-test
+ (let [tdt (gavagai.core/translate dt)]
+ (is (integer? (:time tdt)))
+ (is (= 1 (count tdt))))))))

0 comments on commit 29de792

Please sign in to comment.