aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/gleam/iterator_test.gleam10
-rw-r--r--test/gleam/list_test.gleam10
2 files changed, 20 insertions, 0 deletions
diff --git a/test/gleam/iterator_test.gleam b/test/gleam/iterator_test.gleam
index 81a2908..492bb1e 100644
--- a/test/gleam/iterator_test.gleam
+++ b/test/gleam/iterator_test.gleam
@@ -373,3 +373,13 @@ pub fn group_test() {
tuple(2, [2, 5]),
]))
}
+
+pub fn reduce_test() {
+ iterator.from_list([])
+ |> iterator.reduce(with: fn(x, y) { x + y })
+ |> should.equal(Error(Nil))
+
+ iterator.from_list([1, 2, 3, 4, 5])
+ |> iterator.reduce(with: fn(x, y) { x + y })
+ |> should.equal(Ok(15))
+}
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam
index b7470ac..fc8ea11 100644
--- a/test/gleam/list_test.gleam
+++ b/test/gleam/list_test.gleam
@@ -612,3 +612,13 @@ pub fn sized_chunk_test() {
|> list.sized_chunk(into: 3)
|> should.equal([[1, 2, 3], [4, 5, 6], [7, 8]])
}
+
+pub fn reduce_test() {
+ []
+ |> list.reduce(with: fn(x, y) { x + y })
+ |> should.equal(Error(Nil))
+
+ [1, 2, 3, 4, 5]
+ |> list.reduce(with: fn(x, y) { x + y })
+ |> should.equal(Ok(15))
+}