diff options
author | Giacomo Cavalieri <giacomo.cavalieri@icloud.com> | 2023-06-24 11:03:42 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2023-06-24 12:04:38 +0100 |
commit | 7999445174abbc3a40913734b2f7131180667e35 (patch) | |
tree | f32951aec97f305efcc9d026b483ed3e31b2fcb7 /test | |
parent | 2f5aef226f77db0c924f14d499fa73d2cf0dd872 (diff) | |
download | gleam_stdlib-7999445174abbc3a40913734b2f7131180667e35.tar.gz gleam_stdlib-7999445174abbc3a40913734b2f7131180667e35.zip |
Add `list.map2`
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/list_test.gleam | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index e32c1a9..b44c53c 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -168,6 +168,27 @@ pub fn map_test() { |> list.map(fn(x) { x }) } +pub fn map2_test() { + list.map2([1, 2, 3], [], int.add) + |> should.equal([]) + + list.map2([], [1, 2, 3], int.add) + |> should.equal([]) + + list.map2([], [], int.add) + |> should.equal([]) + + list.map2([1, 2, 3], [4, 5], int.add) + |> should.equal([5, 7]) + + list.map2([1, 2, 3], [4, 5, 6], int.add) + |> should.equal([5, 7, 9]) + + // TCO test + let list = list.repeat(0, recursion_test_cycles) + list.map2(list, list, int.add) +} + pub fn map_fold_test() { [1, 2, 3, 4] |> list.map_fold(from: 0, with: fn(acc, i) { #(acc + i, i * 2) }) |