Skip to content

Commit

Permalink
* src/cljs/cljs/core.cljs: fix type to return nil for types w/o const…
Browse files Browse the repository at this point in the history
…ructors
  • Loading branch information
David Nolen authored and David Nolen committed Apr 11, 2012
1 parent f7a0039 commit 9319579
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cljs/cljs/core.cljs
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions test/cljs/cljs/core_test.cljs
Expand Up @@ -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)))
Expand Down

0 comments on commit 9319579

Please sign in to comment.