Skip to content

Commit e4f4bf6

Browse files
committed
Add coll? function and tests
1 parent c9baf42 commit e4f4bf6

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
@@ -867,6 +867,7 @@ If further arguments are passed, invokes the method named by symbol, passing the
867867
(defn set? [v] (instance? PersistentHashSet v))
868868
(defn map? [v] (satisfies? IMap v))
869869
(defn fn? [v] (satisfies? IFn v))
870+
(defn coll? [v] (satisfies? IPersistentCollection v))
870871

871872
(defn indexed? [v] (satisfies? IIndexed v))
872873
(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)