aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBrett Snyder <bsnyder@digitalocean.com>2019-10-02 10:49:43 -0500
committerLouis Pilfold <louis@lpil.uk>2019-10-03 11:38:43 +0100
commitcf7831f278423bab72f5d9433771e5a16ce44cac (patch)
tree1dbbb96cd4f040c85a343dc7244365dcf87f1c30 /test
parent7677e9e96d38dffcf230891b7c74991aa7f16df5 (diff)
downloadgleam_stdlib-cf7831f278423bab72f5d9433771e5a16ce44cac.tar.gz
gleam_stdlib-cf7831f278423bab72f5d9433771e5a16ce44cac.zip
add pair:map_first and pair:map_second
Diffstat (limited to 'test')
-rw-r--r--test/gleam/pair_test.gleam34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/gleam/pair_test.gleam b/test/gleam/pair_test.gleam
index 54a12af..5dd2690 100644
--- a/test/gleam/pair_test.gleam
+++ b/test/gleam/pair_test.gleam
@@ -26,3 +26,37 @@ pub fn swap_test() {
|> pair.swap
|> expect.equal(_, pair.Pair("2", 1))
}
+
+pub fn map_first_test() {
+ let inc = fn(a) {
+ a + 1
+ }
+ pair.map_first(pair.Pair(1, 2), inc)
+ |> expect.equal(_, pair.Pair(2, 2))
+
+ pair.map_first(pair.Pair(8,2), inc)
+ |> expect.equal(_, pair.Pair(9, 2))
+
+ pair.map_first(pair.Pair(0,-2), inc)
+ |> expect.equal(_, pair.Pair(1, -2))
+
+ pair.map_first(pair.Pair(-10, 20), inc)
+ |> expect.equal(_, pair.Pair(-9, 20))
+}
+
+pub fn map_second_test() {
+ let dec = fn(a) {
+ a - 1
+ }
+ pair.map_second(pair.Pair(1, 2), dec)
+ |> expect.equal(_, pair.Pair(1, 1))
+
+ pair.map_second(pair.Pair(8,2), dec)
+ |> expect.equal(_, pair.Pair(8, 1))
+
+ pair.map_second(pair.Pair(0,-2), dec)
+ |> expect.equal(_, pair.Pair(0, -3))
+
+ pair.map_second(pair.Pair(-10, 20), dec)
+ |> expect.equal(_, pair.Pair(-10, 19))
+}