From 8b79ccb845dc17a15f231222608834a846d9606e Mon Sep 17 00:00:00 2001 From: Mariano Guerra Date: Mon, 11 Feb 2013 11:26:14 +0100 Subject: [PATCH] test defined? --- src/clj/clj_rhino.clj | 2 +- test/clj_rhino/core_test.clj | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/clj/clj_rhino.clj b/src/clj/clj_rhino.clj index e23e076..989bc8d 100644 --- a/src/clj/clj_rhino.clj +++ b/src/clj/clj_rhino.clj @@ -166,7 +166,7 @@ "return true if value is undefined" (= value (. UniqueTag NOT_FOUND))) -(def defined? (comp not undefined?)) +(def defined? (complement undefined?)) (defn set! [scope name value] "bind an object to a name in scope" diff --git a/test/clj_rhino/core_test.clj b/test/clj_rhino/core_test.clj index f7dae11..f2f86c8 100644 --- a/test/clj_rhino/core_test.clj +++ b/test/clj_rhino/core_test.clj @@ -36,6 +36,10 @@ (is (not (js/undefined? 1))) (is (js/undefined? (. UniqueTag NOT_FOUND)))) + (testing "defined? works" + (is (js/defined? 1)) + (is (not (js/defined? (. UniqueTag NOT_FOUND))))) + (testing "get returns undefined if get'ing inexistent var" (let [scope (js/new-scope)] (is (js/undefined? (js/get scope "foo")))))