mirror of
https://github.com/janet-lang/janet
synced 2026-11-28 18:03:09 +00:00
Add tests for filter (#1812)
Co-authored-by: sogaiu <983021772@users.noreply.github.com> Co-authored-by: Calvin Rose <calsrose@gmail.com>
This commit is contained in:
1 file changed
+6
@@ -1074,6 +1074,12 @@
|
||||
(assert (= (find even? @{:x 11 :y 28 :z 33}) 28))
|
||||
(assert (= (find keyword? (coro (yield 'jump) (yield :wave))) :wave))
|
||||
|
||||
# filter
|
||||
(assert (deep= (filter |(< $ (chr "m")) "azbycw") @[97 98 99]))
|
||||
(assert (deep= (filter pos? @[-1 0 1]) @[1]))
|
||||
(assert (deep= (sort (filter int? {:a 1 :b 2.3 :c 3})) @[1 3]))
|
||||
(assert (deep= (filter even? (coro (yield 1) (yield 2) (yield 8))) @[2 8]))
|
||||
|
||||
# interpose
|
||||
(assert (deep= (interpose ":" "hello")
|
||||
@[104 ":" 101 ":" 108 ":" 108 ":" 111]))
|
||||
|
||||
Reference in new issue
Block a user