From 75a5d752341cef2e35ec82752ab9b34539dba2a4 Mon Sep 17 00:00:00 2001 From: Ahmad Sattar Date: Wed, 17 Jun 2020 22:12:52 +0200 Subject: Option map function --- test/gleam/option_test.gleam | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/gleam/option_test.gleam b/test/gleam/option_test.gleam index e41c221..edbb569 100644 --- a/test/gleam/option_test.gleam +++ b/test/gleam/option_test.gleam @@ -40,3 +40,17 @@ pub fn unwrap_option_test() { option.unwrap(None, 0) |> should.equal(0) } + +pub fn map_option_test() { + Some(1) + |> option.map(fn(x) { x + 1 }) + |> should.equal(Some(2)) + + Some(1) + |> option.map(fn(x) { "2" }) + |> should.equal(Some("2")) + + None + |> option.map(fn(x) { x + 1 }) + |> should.equal(None) +} -- cgit v1.2.3