test defined?

This commit is contained in:
Mariano Guerra 2013-02-11 11:26:14 +01:00
parent 0dc976913c
commit 8b79ccb845
2 changed files with 5 additions and 1 deletions

View file

@ -166,7 +166,7 @@
"return true if value is undefined" "return true if value is undefined"
(= value (. UniqueTag NOT_FOUND))) (= value (. UniqueTag NOT_FOUND)))
(def defined? (comp not undefined?)) (def defined? (complement undefined?))
(defn set! [scope name value] (defn set! [scope name value]
"bind an object to a name in scope" "bind an object to a name in scope"

View file

@ -36,6 +36,10 @@
(is (not (js/undefined? 1))) (is (not (js/undefined? 1)))
(is (js/undefined? (. UniqueTag NOT_FOUND)))) (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" (testing "get returns undefined if get'ing inexistent var"
(let [scope (js/new-scope)] (let [scope (js/new-scope)]
(is (js/undefined? (js/get scope "foo"))))) (is (js/undefined? (js/get scope "foo")))))