fix cljs compilation broken in 0.19.3
This commit is contained in:
parent
bf6e6c4413
commit
1c209146bf
5 changed files with 77 additions and 57 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -17,5 +17,6 @@ pom.xml.asc
|
|||
.nrepl-port
|
||||
.cpcache/
|
||||
.clj-kondo/*/
|
||||
/cljs-test-runner-out/
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/clojure
|
||||
|
|
|
|||
33
bb.edn
33
bb.edn
|
|
@ -2,29 +2,48 @@
|
|||
:paths ["src" "test"]
|
||||
|
||||
:tasks
|
||||
{:init
|
||||
{:requires ([clojure.string :as str])
|
||||
|
||||
:init
|
||||
(do
|
||||
(defn kaocha [alias args]
|
||||
(apply shell "bin/kaocha" alias args)))
|
||||
(apply shell "bin/kaocha" alias args))
|
||||
|
||||
test-9
|
||||
(defn test-cljs [alias args]
|
||||
(apply clojure (str/join ["-M:test:cljs-test-runner" alias]) args)))
|
||||
|
||||
test-clj-9
|
||||
{:task (kaocha :clj-1-9 *command-line-args*)}
|
||||
|
||||
test-10
|
||||
test-clj-10
|
||||
{:task (kaocha :clj-1-10 *command-line-args*)}
|
||||
|
||||
test-11
|
||||
test-clj-11
|
||||
{:task (kaocha :clj-1-11 *command-line-args*)}
|
||||
|
||||
test-clj
|
||||
{:task (doseq [alias [:clj-1-9 :clj-1-10 :clj-1-11]]
|
||||
(kaocha alias *command-line-args*))}
|
||||
{:depends [test-clj-9 test-clj-10 test-clj-11]}
|
||||
|
||||
test-cljs-9
|
||||
{:task (test-cljs :clj-1-9 *command-line-args*)}
|
||||
|
||||
test-cljs-10
|
||||
{:task (test-cljs :clj-1-10 *command-line-args*)}
|
||||
|
||||
test-cljs-11
|
||||
{:task (test-cljs :clj-1-11 *command-line-args*)}
|
||||
|
||||
test-cljs
|
||||
{:depends [#_test-cljs-9 test-cljs-10 test-cljs-11]}
|
||||
|
||||
test-bb
|
||||
{:requires ([clojure.test :as t]
|
||||
[net.cgrand.xforms-test])
|
||||
:task (t/run-tests 'net.cgrand.xforms-test)}
|
||||
|
||||
test-all
|
||||
{:depends [test-bb test-clj test-cljs]}
|
||||
|
||||
perf-bb
|
||||
{:requires ([net.cgrand.xforms :as x])
|
||||
:task
|
||||
|
|
|
|||
6
deps.edn
6
deps.edn
|
|
@ -25,4 +25,8 @@
|
|||
|
||||
:kaocha
|
||||
{:extra-deps {lambdaisland/kaocha {:mvn/version "1.69.1069"}}
|
||||
:main-opts ["-m" "kaocha.runner"]}}}
|
||||
:main-opts ["-m" "kaocha.runner"]}
|
||||
|
||||
:cljs-test-runner
|
||||
{:extra-deps {olical/cljs-test-runner {:mvn/version "3.8.0"}}
|
||||
:main-opts ["-m" "cljs-test-runner.main"]}}}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,18 @@
|
|||
:clj (:require [net.cgrand.macrovich :as macros]))
|
||||
(:refer-clojure :exclude [some reduce reductions into count for partition
|
||||
str last keys vals min max drop-last take-last
|
||||
sort sort-by time satisfies?])
|
||||
sort sort-by time #?@(:bb [] :clj [satisfies?])])
|
||||
(:require [#?(:clj clojure.core :cljs cljs.core) :as core]
|
||||
[net.cgrand.xforms.rfs :as rf]
|
||||
#?(:clj [clojure.core.protocols]))
|
||||
#?(:cljs (:import [goog.structs Queue])))
|
||||
|
||||
(defn- pair? [x] (and (vector? x) (= 2 (core/count x))))
|
||||
(let [kw-or-& #(or (keyword? %) (= '& %))]
|
||||
(defn destructuring-pair? [x]
|
||||
(and (pair? x)
|
||||
(not (kw-or-& (first x))))))
|
||||
|
||||
(macros/deftime
|
||||
|
||||
(defn- no-user-meta? [x]
|
||||
|
|
@ -28,12 +34,6 @@
|
|||
x#
|
||||
(unreduced-> (-> x# ~expr) ~@exprs)))))
|
||||
|
||||
(defn- pair? [x] (and (vector? x) (= 2 (core/count x))))
|
||||
(let [kw-or-& #(or (keyword? %) (= '& %))]
|
||||
(defn- destructuring-pair? [x]
|
||||
(and (pair? x)
|
||||
(not (kw-or-& (first x))))))
|
||||
|
||||
(defmacro for
|
||||
"Like clojure.core/for with the first expression being replaced by % (or _). Returns a transducer.
|
||||
When the first expression is not % (or _) returns an eduction."
|
||||
|
|
@ -130,12 +130,7 @@
|
|||
|
||||
;; Workaround clojure.core/satisfies? being slow in Clojure
|
||||
;; see https://ask.clojure.org/index.php/3304/make-satisfies-as-fast-as-a-protocol-method-call
|
||||
#?(:cljs
|
||||
(def satisfies? core/satisfies?)
|
||||
|
||||
:bb
|
||||
(def satisfies? core/satisfies?)
|
||||
|
||||
#?(:bb nil
|
||||
:clj
|
||||
(defn fast-satisfies?-fn
|
||||
"Ported from https://github.com/clj-commons/manifold/blob/37658e91f836047a630586a909a2e22debfbbfc6/src/manifold/utils.clj#L77-L89"
|
||||
|
|
@ -155,7 +150,7 @@
|
|||
|
||||
#?(:cljs
|
||||
(defn kvreducible? [coll]
|
||||
(satisfies? core/IKVReduce coll))
|
||||
(satisfies? IKVReduce coll))
|
||||
|
||||
:clj
|
||||
(let [satisfies-ikvreduce? #?(:bb #(satisfies? clojure.core.protocols/IKVReduce %)
|
||||
|
|
|
|||
|
|
@ -97,41 +97,42 @@
|
|||
|
||||
#?(:bb nil ;; babashka doesn't currently support calling iterator on range type
|
||||
:clj
|
||||
(deftest iterator
|
||||
(is (true? (.hasNext (x/iterator x/count (.iterator ^java.lang.Iterable (range 5))))))
|
||||
(is (is (= [5] (iterator-seq (x/iterator x/count (.iterator ^java.lang.Iterable (range 5)))))))
|
||||
(is (= [[0 1] [1 2] [2 3] [3 4] [4]] (iterator-seq (x/iterator (x/partition 2 1 nil) (.iterator ^java.lang.Iterable (range 5)))))))
|
||||
|
||||
(deftest window-by-time
|
||||
(is (= (into
|
||||
[]
|
||||
(x/window-by-time :ts 4
|
||||
(fn
|
||||
([] clojure.lang.PersistentQueue/EMPTY)
|
||||
([q] (vec q))
|
||||
([q x] (conj q x)))
|
||||
(fn [q _] (pop q)))
|
||||
(map (fn [x] {:ts x}) (concat (range 0 2 0.5) (range 3 5 0.25))))
|
||||
[[{:ts 0}] ; t = 0
|
||||
[{:ts 0}] ; t = 0.25
|
||||
[{:ts 0} {:ts 0.5}] ; t = 0.5
|
||||
[{:ts 0} {:ts 0.5}] ; t = 0.75
|
||||
[{:ts 0.5} {:ts 1.0}] ; t = 1.0
|
||||
[{:ts 0.5} {:ts 1.0}] ; t = 1.25
|
||||
[{:ts 1.0} {:ts 1.5}] ; t = 1.5
|
||||
[{:ts 1.0} {:ts 1.5}] ; t = 1.75
|
||||
[{:ts 1.5}] ; t = 2.0
|
||||
[{:ts 1.5}] ; t = 2.25
|
||||
[] ; t = 2.5
|
||||
[] ; t = 2.75
|
||||
[{:ts 3}] ; t = 3.0
|
||||
[{:ts 3} {:ts 3.25}] ; t = 3.25
|
||||
[{:ts 3} {:ts 3.25} {:ts 3.5}] ; t = 3.5
|
||||
[{:ts 3} {:ts 3.25} {:ts 3.5} {:ts 3.75}] ; t = 3.75
|
||||
[{:ts 3.25} {:ts 3.5} {:ts 3.75} {:ts 4.0}] ; t = 4.0
|
||||
[{:ts 3.5} {:ts 3.75} {:ts 4.0} {:ts 4.25}] ; t = 4.25
|
||||
[{:ts 3.75} {:ts 4.0} {:ts 4.25} {:ts 4.5}] ; t = 4.5
|
||||
[{:ts 4.0} {:ts 4.25} {:ts 4.5} {:ts 4.75}]])))) ; t = 4.75
|
||||
(do
|
||||
(deftest iterator
|
||||
(is (true? (.hasNext (x/iterator x/count (.iterator ^java.lang.Iterable (range 5))))))
|
||||
(is (is (= [5] (iterator-seq (x/iterator x/count (.iterator ^java.lang.Iterable (range 5)))))))
|
||||
(is (= [[0 1] [1 2] [2 3] [3 4] [4]] (iterator-seq (x/iterator (x/partition 2 1 nil) (.iterator ^java.lang.Iterable (range 5)))))))
|
||||
|
||||
(deftest window-by-time
|
||||
(is (= (into
|
||||
[]
|
||||
(x/window-by-time :ts 4
|
||||
(fn
|
||||
([] clojure.lang.PersistentQueue/EMPTY)
|
||||
([q] (vec q))
|
||||
([q x] (conj q x)))
|
||||
(fn [q _] (pop q)))
|
||||
(map (fn [x] {:ts x}) (concat (range 0 2 0.5) (range 3 5 0.25))))
|
||||
[[{:ts 0}] ; t = 0
|
||||
[{:ts 0}] ; t = 0.25
|
||||
[{:ts 0} {:ts 0.5}] ; t = 0.5
|
||||
[{:ts 0} {:ts 0.5}] ; t = 0.75
|
||||
[{:ts 0.5} {:ts 1.0}] ; t = 1.0
|
||||
[{:ts 0.5} {:ts 1.0}] ; t = 1.25
|
||||
[{:ts 1.0} {:ts 1.5}] ; t = 1.5
|
||||
[{:ts 1.0} {:ts 1.5}] ; t = 1.75
|
||||
[{:ts 1.5}] ; t = 2.0
|
||||
[{:ts 1.5}] ; t = 2.25
|
||||
[] ; t = 2.5
|
||||
[] ; t = 2.75
|
||||
[{:ts 3}] ; t = 3.0
|
||||
[{:ts 3} {:ts 3.25}] ; t = 3.25
|
||||
[{:ts 3} {:ts 3.25} {:ts 3.5}] ; t = 3.5
|
||||
[{:ts 3} {:ts 3.25} {:ts 3.5} {:ts 3.75}] ; t = 3.75
|
||||
[{:ts 3.25} {:ts 3.5} {:ts 3.75} {:ts 4.0}] ; t = 4.0
|
||||
[{:ts 3.5} {:ts 3.75} {:ts 4.0} {:ts 4.25}] ; t = 4.25
|
||||
[{:ts 3.75} {:ts 4.0} {:ts 4.25} {:ts 4.5}] ; t = 4.5
|
||||
[{:ts 4.0} {:ts 4.25} {:ts 4.5} {:ts 4.75}]]))))) ; t = 4.75
|
||||
|
||||
(deftest do-not-kvreduce-vectors
|
||||
(is (= {0 nil 1 nil} (x/into {} (x/for [[k v] %] [k v]) [[0] [1]])))
|
||||
|
|
|
|||
Loading…
Reference in a new issue