Skip to content

Commit

Permalink
CLJS-1246: Add cljs.core/record? predicate.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonbloom authored and swannodette committed May 4, 2015
1 parent 703561b commit cda08f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,11 @@ reduces them without incurring seq initialization"
false
(satisfies? IMap x)))

(defn ^boolean record?
"Return true if x satisfies IRecord"
[x]
(satisfies? IRecord x))

(defn ^boolean vector?
"Return true if x satisfies IVector"
[x] (satisfies? IVector x))
Expand Down
2 changes: 2 additions & 0 deletions test/cljs/cljs/core_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,8 @@
letters (C. "a" "b" "c")
more-letters (assoc letters :d "d" :e "e" :f "f")]
(testing "Testing records"
(is (record? fred))
(is (not (record? {})))
(is (= (:firstname fred) "Fred"))
(is (= fred fred-too))
(is (false? (= fred nil)))
Expand Down

0 comments on commit cda08f0

Please sign in to comment.