Add compatibility with babashka

This commit is contained in:
Michiel Borkent 2021-11-24 12:06:29 +01:00
parent 62375212a8
commit 283cb13e58
2 changed files with 5 additions and 3 deletions

View file

@ -99,7 +99,8 @@
(not (arities 2)) (conj (let [[[acc karg varg] & body] (arities 3)]
`([~acc [~karg ~varg]] ~@body))))]
`(reify
~@(macros/case :clj '[clojure.lang.Fn])
#?@(:bb [] ;; babashka currently only supports reify with one Java interface at a time
:default [~@(macros/case :clj '[clojure.lang.Fn])])
KvRfable
(some-kvrf [this#] this#)
~(macros/case :cljs `core/IFn :clj 'clojure.lang.IFn)

View file

@ -94,7 +94,8 @@
(is (= {0 :ok 2 :ok 4 :ok 6 :ok 8 :ok} (x/without (zipmap (range 10) (repeat :ok)) (filter odd?) (range 20))))
(is (= #{0 2 4 6 8 } (x/without (set (range 10)) (filter odd?) (range 20)))))
#?(:clj
#?(:bb nil ;; babashka doesn't currently support calling iterator on range type
:clj
(deftest iterator
(is (true? (.hasNext (x/iterator x/count (.iterator (range 5))))))
(is (is (= [5] (iterator-seq (x/iterator x/count (.iterator (range 5)))))))
@ -139,4 +140,4 @@
(is (= (range 100) (x/into [] (x/sort) (shuffle (range 100)))))
(is (= (reverse (range 100)) (x/into [] (x/sort >) (shuffle (range 100)))))
(is (= (sort-by str (range 100)) (x/into [] (x/sort-by str) (shuffle (range 100)))))
(is (= (sort-by str (comp - compare) (range 100)) (x/into [] (x/sort-by str (comp - compare)) (shuffle (range 100))))))
(is (= (sort-by str (comp - compare) (range 100)) (x/into [] (x/sort-by str (comp - compare)) (shuffle (range 100))))))