Ported tests
This commit is contained in:
parent
cffd76298b
commit
21a506c364
1 changed files with 33 additions and 32 deletions
|
|
@ -1,5 +1,5 @@
|
|||
(ns net.cgrand.xforms-test
|
||||
(:require [clojure.test :refer :all]
|
||||
(:require [clojure.test :refer [is deftest testing]]
|
||||
[net.cgrand.xforms :as x]))
|
||||
|
||||
(defn trial
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
n is the number of calls to rf before it returns a reduced.
|
||||
accs is a collection of successive return values for rf."
|
||||
([xform n coll]
|
||||
(trial xform n (repeatedly #(Object.)) coll))
|
||||
(trial xform n (repeatedly #(#?(:clj Object. :clj js/Object.))) coll))
|
||||
([xform n accs coll]
|
||||
(let [vaccs (volatile! accs)
|
||||
vstate (volatile! {:n n :acc (first @vaccs) :state :init})
|
||||
|
|
@ -82,6 +82,7 @@
|
|||
(is (= (into [] (comp (take 3) (x/reductions +)) (range)) [0 0 1 3]))
|
||||
(is (= (into [] (x/reductions (constantly (reduced 42)) 0) (range)) [0 42])))
|
||||
|
||||
#?(:clj
|
||||
(deftest window-by-time
|
||||
(is (= (into
|
||||
[]
|
||||
|
|
@ -111,7 +112,7 @@
|
|||
[{: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
|
||||
[{: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