Skip to content

Commit 166bca7

Browse files
Merge pull request #404 from alejandrodob/coll-support
Add coll? function
2 parents 730cd71 + e4f4bf6 commit 166bca7

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

pixie/stdlib.pxi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ If further arguments are passed, invokes the method named by symbol, passing the
839839
(defn set? [v] (instance? PersistentHashSet v))
840840
(defn map? [v] (satisfies? IMap v))
841841
(defn fn? [v] (satisfies? IFn v))
842+
(defn coll? [v] (satisfies? IPersistentCollection v))
842843

843844
(defn indexed? [v] (satisfies? IIndexed v))
844845
(defn counted? [v] (satisfies? ICounted v))

tests/pixie/tests/test-stdlib.pxi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,16 @@
304304
(t/assert= (fn? "foo") false)
305305
(t/assert= (fn? (let [x 8] (fn [y] (+ x y)))) true))
306306

307+
(t/deftest test-coll?
308+
(t/assert= (coll? '()) true)
309+
(t/assert= (coll? []) true)
310+
(t/assert= (coll? {:foo "bar"}) true)
311+
(t/assert= (coll? #{:foo :bar}) true)
312+
(t/assert= (coll? #(%)) false)
313+
(t/assert= (coll? :foo) false)
314+
(t/assert= (coll? "foo") false)
315+
(t/assert= (coll? 1) false))
316+
307317
(t/deftest test-macro?
308318
(t/assert= (macro? and) true)
309319
(t/assert= (macro? or) true)

0 commit comments

Comments
 (0)