aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2019-09-15 21:05:05 +0100
committerLouis Pilfold <louis@lpil.uk>2019-09-15 21:06:35 +0100
commit0579308bf0559635e3742e7fa634648182d916c5 (patch)
tree3ef129b822133bd2d78ca19a123298e2e0fe3f04 /test
parent3f316053c680448c4b81a2c04071f7cf81497c2b (diff)
downloadgleam_stdlib-0579308bf0559635e3742e7fa634648182d916c5.tar.gz
gleam_stdlib-0579308bf0559635e3742e7fa634648182d916c5.zip
Remove maps from stdlib
Diffstat (limited to 'test')
-rw-r--r--test/gleam/any_test.gleam11
-rw-r--r--test/gleam/map_test.gleam (renamed from test/gleam/map_dict_test.gleam)118
2 files changed, 67 insertions, 62 deletions
diff --git a/test/gleam/any_test.gleam b/test/gleam/any_test.gleam
index ef441d7..13af0cb 100644
--- a/test/gleam/any_test.gleam
+++ b/test/gleam/any_test.gleam
@@ -4,6 +4,7 @@ import gleam/list
import gleam/tuple
import gleam/expect
import gleam/result
+import gleam/map
pub fn string_test() {
""
@@ -250,18 +251,22 @@ pub fn struct2_test() {
pub fn field_test() {
let Ok(ok_atom) = atom.from_string("ok")
+ let Ok(earlier_atom) = atom.from_string("earlier")
- {ok = 1}
+ map.new()
+ |> map.put(_, ok_atom, 1)
|> any.from
|> any.field(_, ok_atom)
|> expect.equal(_, Ok(any.from(1)))
- {earlier = 2, ok = 3}
+ map.new()
+ |> map.put(_, ok_atom, 3)
+ |> map.put(_, earlier_atom, 1)
|> any.from
|> any.field(_, ok_atom)
|> expect.equal(_, Ok(any.from(3)))
- {}
+ map.new()
|> any.from
|> any.field(_, ok_atom)
|> expect.is_error
diff --git a/test/gleam/map_dict_test.gleam b/test/gleam/map_test.gleam
index a258067..529afe2 100644
--- a/test/gleam/map_dict_test.gleam
+++ b/test/gleam/map_test.gleam
@@ -1,54 +1,54 @@
import gleam/string
import gleam/expect
-import gleam/map_dict
+import gleam/map
pub fn from_list_test() {
[
struct(4, 0),
struct(1, 0),
]
- |> map_dict.from_list
- |> map_dict.size
+ |> map.from_list
+ |> map.size
|> expect.equal(_, 2)
}
pub fn has_key_test() {
[]
- |> map_dict.from_list
- |> map_dict.has_key(_, 1)
+ |> map.from_list
+ |> map.has_key(_, 1)
|> expect.false
[
struct(1, 0),
]
- |> map_dict.from_list
- |> map_dict.has_key(_, 1)
+ |> map.from_list
+ |> map.has_key(_, 1)
|> expect.true
[
struct(4, 0),
struct(1, 0),
]
- |> map_dict.from_list
- |> map_dict.has_key(_, 1)
+ |> map.from_list
+ |> map.has_key(_, 1)
|> expect.true
[
struct(4, 0),
struct(1, 0),
]
- |> map_dict.from_list
- |> map_dict.has_key(_, 0)
+ |> map.from_list
+ |> map.has_key(_, 0)
|> expect.false
}
pub fn new_test() {
- map_dict.new()
- |> map_dict.size
+ map.new()
+ |> map.size
|> expect.equal(_, 0)
- map_dict.new()
- |> map_dict.to_list
+ map.new()
+ |> map.to_list
|> expect.equal(_, [])
}
@@ -57,27 +57,27 @@ pub fn fetch_test() {
struct(4, 0),
struct(1, 1),
]
- let m = map_dict.from_list(proplist)
+ let m = map.from_list(proplist)
m
- |> map_dict.fetch(_, 4)
+ |> map.fetch(_, 4)
|> expect.equal(_, Ok(0))
m
- |> map_dict.fetch(_, 1)
+ |> map.fetch(_, 1)
|> expect.equal(_, Ok(1))
m
- |> map_dict.fetch(_, 2)
+ |> map.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([
+ map.new()
+ |> map.put(_, "a", 0)
+ |> map.put(_, "b", 1)
+ |> map.put(_, "c", 2)
+ |> expect.equal(_, map.from_list([
struct("a", 0),
struct("b", 1),
struct("c", 2),
@@ -90,9 +90,9 @@ pub fn map_values_test() {
struct(2, 1),
struct(3, 2),
]
- |> map_dict.from_list
- |> map_dict.map_values(_, fn(k, v) { k + v })
- |> expect.equal(_, map_dict.from_list([
+ |> map.from_list
+ |> map.map_values(_, fn(k, v) { k + v })
+ |> expect.equal(_, map.from_list([
struct(1, 1),
struct(2, 3),
struct(3, 5),
@@ -105,8 +105,8 @@ pub fn keys_test() {
struct("b", 1),
struct("c", 2),
]
- |> map_dict.from_list
- |> map_dict.keys
+ |> map.from_list
+ |> map.keys
|> expect.equal(_, ["a", "b", "c"])
}
@@ -116,8 +116,8 @@ pub fn values_test() {
struct("b", 1),
struct("c", 2),
]
- |> map_dict.from_list
- |> map_dict.values
+ |> map.from_list
+ |> map.values
|> expect.equal(_, [0, 1, 2])
}
@@ -127,9 +127,9 @@ pub fn take_test() {
struct("b", 1),
struct("c", 2),
]
- |> map_dict.from_list
- |> map_dict.take(_, ["a", "b", "d"])
- |> expect.equal(_, map_dict.from_list([struct("a", 0), struct("b", 1)]))
+ |> map.from_list
+ |> map.take(_, ["a", "b", "d"])
+ |> expect.equal(_, map.from_list([struct("a", 0), struct("b", 1)]))
}
pub fn drop_test() {
@@ -138,33 +138,33 @@ pub fn drop_test() {
struct("b", 1),
struct("c", 2),
]
- |> map_dict.from_list
- |> map_dict.drop(_, ["a", "b", "d"])
- |> expect.equal(_, map_dict.from_list([struct("c", 2)]))
+ |> map.from_list
+ |> map.drop(_, ["a", "b", "d"])
+ |> expect.equal(_, map.from_list([struct("c", 2)]))
}
pub fn merge_test() {
- let a = map_dict.from_list([
+ let a = map.from_list([
struct("a", 2),
struct("c", 4),
struct("d", 3),
])
- let b = map_dict.from_list([
+ let b = map.from_list([
struct("a", 0),
struct("b", 1),
struct("c", 2),
])
- map_dict.merge(a, b)
- |> expect.equal(_, map_dict.from_list([
+ map.merge(a, b)
+ |> expect.equal(_, map.from_list([
struct("a", 0),
struct("b", 1),
struct("c", 2),
struct("d", 3),
]))
- map_dict.merge(b, a)
- |> expect.equal(_, map_dict.from_list([
+ map.merge(b, a)
+ |> expect.equal(_, map.from_list([
struct("a", 2),
struct("b", 1),
struct("c", 4),
@@ -178,14 +178,14 @@ pub fn delete_test() {
struct("b", 1),
struct("c", 2),
]
- |> map_dict.from_list
- |> map_dict.delete(_, "a")
- |> map_dict.delete(_, "d")
- |> expect.equal(_, map_dict.from_list([struct("b", 1), struct("c", 2)]))
+ |> map.from_list
+ |> map.delete(_, "a")
+ |> map.delete(_, "d")
+ |> expect.equal(_, map.from_list([struct("b", 1), struct("c", 2)]))
}
pub fn update_test() {
- let dict = map_dict.from_list([
+ let dict = map.from_list([
struct("a", 0),
struct("b", 1),
struct("c", 2),
@@ -199,24 +199,24 @@ pub fn update_test() {
}
dict
- |> map_dict.update(_, "a", inc_or_zero)
- |> expect.equal(_, map_dict.from_list([
+ |> map.update(_, "a", inc_or_zero)
+ |> expect.equal(_, map.from_list([
struct("a", 1),
struct("b", 1),
struct("c", 2),
]))
dict
- |> map_dict.update(_, "b", inc_or_zero)
- |> expect.equal(_, map_dict.from_list([
+ |> map.update(_, "b", inc_or_zero)
+ |> expect.equal(_, map.from_list([
struct("a", 0),
struct("b", 2),
struct("c", 2),
]))
dict
- |> map_dict.update(_, "z", inc_or_zero)
- |> expect.equal(_, map_dict.from_list([
+ |> map.update(_, "z", inc_or_zero)
+ |> expect.equal(_, map.from_list([
struct("a", 0),
struct("b", 1),
struct("c", 2),
@@ -225,7 +225,7 @@ pub fn update_test() {
}
pub fn fold_test() {
- let dict = map_dict.from_list([
+ let dict = map.from_list([
struct("a", 0),
struct("b", 1),
struct("c", 2),
@@ -237,7 +237,7 @@ pub fn fold_test() {
}
dict
- |> map_dict.fold(_, 0, add)
+ |> map.fold(_, 0, add)
|> expect.equal(_, 6)
let concat = fn(k, _, acc) {
@@ -245,10 +245,10 @@ pub fn fold_test() {
}
dict
- |> map_dict.fold(_, "", concat)
+ |> map.fold(_, "", concat)
|> expect.equal(_, "abcd")
- map_dict.from_list([])
- |> map_dict.fold(_, 0, add)
+ map.from_list([])
+ |> map.fold(_, 0, add)
|> expect.equal(_, 0)
}