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")))))