diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-04-18 22:26:14 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-04-18 23:29:08 +0100 |
commit | afdabad5cd2df77eb3f309aab9da3d34e36a0b49 (patch) | |
tree | ed6ae77397a00a1715a0df25b1b187f713c20642 /test | |
parent | 6f486a387b623d962868bc514ebe5fcdea84e012 (diff) | |
download | gleam_stdlib-afdabad5cd2df77eb3f309aab9da3d34e36a0b49.tar.gz gleam_stdlib-afdabad5cd2df77eb3f309aab9da3d34e36a0b49.zip |
map:take
Diffstat (limited to 'test')
-rw-r--r-- | test/map_dict_test.gleam | 93 |
1 files changed, 52 insertions, 41 deletions
diff --git a/test/map_dict_test.gleam b/test/map_dict_test.gleam index f72e23a..a0797c2 100644 --- a/test/map_dict_test.gleam +++ b/test/map_dict_test.gleam @@ -6,49 +6,49 @@ pub fn from_list_test() { {4, 0}, {1, 0}, ] - |> map_dict:from_list - |> map_dict:size - |> expect:equal(_, 2) + |> map_dict:from_list + |> map_dict:size + |> expect:equal(_, 2) } pub fn has_key_test() { [] - |> map_dict:from_list - |> map_dict:has_key(_, 1) - |> expect:false + |> map_dict:from_list + |> map_dict:has_key(_, 1) + |> expect:false [ {1, 0}, ] - |> map_dict:from_list - |> map_dict:has_key(_, 1) - |> expect:true + |> map_dict:from_list + |> map_dict:has_key(_, 1) + |> expect:true [ {4, 0}, {1, 0}, ] - |> map_dict:from_list - |> map_dict:has_key(_, 1) - |> expect:true + |> map_dict:from_list + |> map_dict:has_key(_, 1) + |> expect:true [ {4, 0}, {1, 0}, ] - |> map_dict:from_list - |> map_dict:has_key(_, 0) - |> expect:false + |> map_dict:from_list + |> map_dict:has_key(_, 0) + |> expect:false } pub fn new_test() { map_dict:new() - |> map_dict:size - |> expect:equal(_, 0) + |> map_dict:size + |> expect:equal(_, 0) map_dict:new() - |> map_dict:to_list - |> expect:equal(_, []) + |> map_dict:to_list + |> expect:equal(_, []) } pub fn fetch_test() { @@ -59,24 +59,24 @@ pub fn fetch_test() { let m = map_dict:from_list(proplist) m - |> map_dict:fetch(_, 4) - |> expect:equal(_, Ok(0)) + |> map_dict:fetch(_, 4) + |> expect:equal(_, Ok(0)) m - |> map_dict:fetch(_, 1) - |> expect:equal(_, Ok(1)) + |> map_dict:fetch(_, 1) + |> expect:equal(_, Ok(1)) m - |> map_dict:fetch(_, 2) - |> expect:is_error + |> map_dict:fetch(_, 2) + |> expect:is_error } pub fn put_test() { map_dict:new() - |> map_dict:put(_, "a", 0) - |> map_dict:put(_, "b", 1) - |> map_dict:put(_, "c", 2) - |> expect:equal(_, map_dict:from_list([{"a", 0}, {"b", 1}, {"c", 2}])) + |> map_dict:put(_, "a", 0) + |> map_dict:put(_, "b", 1) + |> map_dict:put(_, "c", 2) + |> expect:equal(_, map_dict:from_list([{"a", 0}, {"b", 1}, {"c", 2}])) } pub fn map_values_test() { @@ -85,9 +85,9 @@ pub fn map_values_test() { {2, 1}, {3, 2}, ] - |> map_dict:from_list - |> map_dict:map_values(_, fn(k, v) { k + v }) - |> expect:equal(_, map_dict:from_list([{1, 1}, {2, 3}, {3, 5}])) + |> map_dict:from_list + |> map_dict:map_values(_, fn(k, v) { k + v }) + |> expect:equal(_, map_dict:from_list([{1, 1}, {2, 3}, {3, 5}])) } pub fn keys_test() { @@ -96,9 +96,9 @@ pub fn keys_test() { {"b", 1}, {"c", 2}, ] - |> map_dict:from_list - |> map_dict:keys - |> expect:equal(_, ["a", "b", "c"]) + |> map_dict:from_list + |> map_dict:keys + |> expect:equal(_, ["a", "b", "c"]) } pub fn values_test() { @@ -107,9 +107,9 @@ pub fn values_test() { {"b", 1}, {"c", 2}, ] - |> map_dict:from_list - |> map_dict:values - |> expect:equal(_, [0, 1, 2]) + |> map_dict:from_list + |> map_dict:values + |> expect:equal(_, [0, 1, 2]) } pub fn take_test() { @@ -118,7 +118,18 @@ pub fn take_test() { {"b", 1}, {"c", 2}, ] - |> map_dict:from_list - |> map_dict:take(_, ["a", "b", "d"]) - |> expect:equal(_, map_dict:from_list([{"a", 0}, {"b", 1}])) + |> map_dict:from_list + |> map_dict:take(_, ["a", "b", "d"]) + |> expect:equal(_, map_dict:from_list([{"a", 0}, {"b", 1}])) +} + +pub fn drop_test() { + [ + {"a", 0}, + {"b", 1}, + {"c", 2}, + ] + |> map_dict:from_list + |> map_dict:drop(_, ["a", "b", "d"]) + |> expect:equal(_, map_dict:from_list([{"c", 2}])) } |