Permalink
Browse files

* src/cljs/cljs/core.cljs: fix type to return nil for types w/o const…

…ructors
  • Loading branch information...
1 parent f7a0039 commit 9319579acfc4fc9dbcf6e79f611afad707f97579 David Nolen committed Apr 11, 2012
Showing with 5 additions and 1 deletion.
  1. +3 −1 src/cljs/cljs/core.cljs
  2. +2 −0 test/cljs/cljs/core_test.cljs
View
@@ -245,7 +245,9 @@
(identical? x nil))
(defn type [x]
- (js* "(~{x}).constructor"))
+ (if (or (nil? x) (undefined? x))
+ nil
+ (js* "(~{x}).constructor")))
;;;;;;;;;;;;;;;;;;; protocols on primitives ;;;;;;;;
(declare hash-map list equiv-sequential)
@@ -609,6 +609,8 @@
;; js->clj
(assert (= {"a" 1, "b" 2} (js->clj (js* "{\"a\":1,\"b\":2}"))))
+ (assert (= {"a" nil} (js->clj (js* "{\"a\":null}"))))
+ (assert (= {"a" true, "b" false} (js->clj (js* "{\"a\":true,\"b\":false}"))))
(assert (= {:a 1, :b 2} (js->clj (js* "{\"a\":1,\"b\":2}") :keywordize-keys true)))
(assert (= [[{:a 1, :b 2} {:a 1, :b 2}]]
(js->clj (js* "[[{\"a\":1,\"b\":2}, {\"a\":1,\"b\":2}]]") :keywordize-keys true)))

0 comments on commit 9319579

Please sign in to comment.