Skip to content

Commit 6c318f5

Browse files
bruceadamsstuarthalloway
authored andcommitted
Test exception propagation out of r/fold CLJ-1058
Signed-off-by: Stuart Halloway <[email protected]>
1 parent 91dd867 commit 6c318f5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/clojure/test_clojure/reducers.clj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@
6161
(deftest test-nil
6262
(is (= {:k :v} (reduce-kv assoc {:k :v} nil)))
6363
(is (= 0 (r/fold + nil))))
64+
65+
(deftest test-fold-runtime-exception
66+
(is (thrown? IndexOutOfBoundsException
67+
(let [test-map-count 1234
68+
k-fail (rand-int test-map-count)]
69+
(r/fold (fn ([])
70+
([ret [k v]])
71+
([ret k v] (when (= k k-fail)
72+
(throw (IndexOutOfBoundsException.)))))
73+
(zipmap (range test-map-count) (repeat :dummy)))))))

0 commit comments

Comments
 (0)