Skip to content
Snippets Groups Projects
Unverified Commit 1e08d80e authored by Simon Belak's avatar Simon Belak Committed by GitHub
Browse files

Make cumulative aggregations work with nils (#12632)

parent 58ed2d6f
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@
row
:else
(recur more last-row (update (vec row) index (partial + (nth last-row index))))))
(recur more last-row (update (vec row) index (partial (fnil + 0 0) (nth last-row index))))))
(defn- cumulative-ags-xform [replaced-indecies rf]
{:pre [(fn? rf)]}
......
......@@ -14,7 +14,12 @@
(is (thrown?
IndexOutOfBoundsException
(#'cumulative-aggregations/add-values-from-last-row #{4} [1 2 3] [1 2 3]))
"should throw an Exception if index is out of bounds"))
"should throw an Exception if index is out of bounds")
(testing "Do we handle nils correctly"
(is (= [1] (#'cumulative-aggregations/add-values-from-last-row #{0} [nil] [1])))
(is (= [0] (#'cumulative-aggregations/add-values-from-last-row #{0} [nil] [nil])))
(is (= [1] (#'cumulative-aggregations/add-values-from-last-row #{0} [1] [nil])))))
(deftest diff-indicies-test
(testing "collections are the same"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment