diff options
-rw-r--r-- | src/gleam/any.gleam | 4 | ||||
-rw-r--r-- | src/gleam/bool.gleam | 1 | ||||
-rw-r--r-- | src/gleam/list.gleam | 12 | ||||
-rw-r--r-- | src/gleam/map.gleam | 8 | ||||
-rw-r--r-- | src/gleam/order.gleam | 2 | ||||
-rw-r--r-- | test/gleam/any_test.gleam | 18 | ||||
-rw-r--r-- | test/gleam/list_test.gleam | 57 | ||||
-rw-r--r-- | test/gleam/map_test.gleam | 136 | ||||
-rw-r--r-- | test/gleam/order_test.gleam | 98 | ||||
-rw-r--r-- | test/gleam/pair_test.gleam | 46 | ||||
-rw-r--r-- | test/gleam/result_test.gleam | 6 | ||||
-rw-r--r-- | test/gleam/triple_test.gleam | 14 |
12 files changed, 203 insertions, 199 deletions
diff --git a/src/gleam/any.gleam b/src/gleam/any.gleam index 1eec6f1..6384c89 100644 --- a/src/gleam/any.gleam +++ b/src/gleam/any.gleam @@ -1,7 +1,7 @@ import gleam/list as list_mod import gleam/atom import gleam/result -import gleam/pair +import gleam/pair.{Pair} // `Any` data is data that we don"t know the type of yet. // We likely get data like this from interop with Erlang, or from @@ -47,7 +47,7 @@ pub fn list(from any, containing decoder_type) { |> result.then(_, list_mod.traverse(_, decoder_type)) } -pub external fn pair(from: Any) -> Result(pair.Pair(Any, Any), String) +pub external fn pair(from: Any) -> Result(Pair(Any, Any), String) = "gleam_stdlib" "decode_pair" pub external fn field(from: Any, named: a) -> Result(Any, String) diff --git a/src/gleam/bool.gleam b/src/gleam/bool.gleam index e1913c0..0c3b836 100644 --- a/src/gleam/bool.gleam +++ b/src/gleam/bool.gleam @@ -1,5 +1,4 @@ import gleam/order -import gleam/pair pub fn negate(bool) { case bool { diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index cd4b5ea..00d53a2 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -1,6 +1,6 @@ import gleam/int import gleam/order -import gleam/pair +import gleam/pair.{Pair} pub enum LengthMismatch = | LengthMismatch @@ -196,7 +196,7 @@ pub fn zip(xs, ys) { case xs, ys { | [], _ -> [] | _, [] -> [] - | [x | xs], [y | ys] -> [ pair.Pair(x, y) | zip(xs, ys) ] + | [x | xs], [y | ys] -> [ Pair(x, y) | zip(xs, ys) ] } } @@ -289,10 +289,10 @@ pub fn repeat(item a, times times) { fn do_split(list, n, taken) { case n <= 0 { - | True -> pair.Pair(reverse(taken), list) + | True -> Pair(reverse(taken), list) | False -> case list { - | [] -> pair.Pair(reverse(taken), []) + | [] -> Pair(reverse(taken), []) | [x | xs] -> do_split(xs, n - 1, [x | taken]) } } @@ -304,10 +304,10 @@ pub fn split(list list, on target) { fn do_split_while(list, f, acc) { case list { - | [] -> pair.Pair(reverse(acc), []) + | [] -> Pair(reverse(acc), []) | [x | xs] -> case f(x) { - | False -> pair.Pair(reverse(acc), list) + | False -> Pair(reverse(acc), list) | _ -> do_split_while(xs, f, [x | acc]) } } diff --git a/src/gleam/map.gleam b/src/gleam/map.gleam index 6a7ab47..340fb64 100644 --- a/src/gleam/map.gleam +++ b/src/gleam/map.gleam @@ -1,17 +1,17 @@ import gleam/any import gleam/result import gleam/list -import gleam/pair +import gleam/pair.{Pair} pub external type Map(key, value); pub external fn size(Map(k, v)) -> Int = "maps" "size" -pub external fn to_list(Map(key, value)) -> List(pair.Pair(key, value)) +pub external fn to_list(Map(key, value)) -> List(Pair(key, value)) = "maps" "to_list" -pub external fn from_list(List(pair.Pair(key, value))) -> Map(key, value) +pub external fn from_list(List(Pair(key, value))) -> Map(key, value) = "maps" "from_list" external fn is_key(key, Map(key, v)) -> Bool @@ -86,7 +86,7 @@ pub fn update(in map, update key, with fun) { fn do_fold(list, initial, fun) { case list { | [] -> initial - | [pair.Pair(k, v) | tail] -> do_fold(tail, fun(k, v, initial), fun) + | [Pair(k, v) | tail] -> do_fold(tail, fun(k, v, initial), fun) } } diff --git a/src/gleam/order.gleam b/src/gleam/order.gleam index 9aa04fb..bc8ee06 100644 --- a/src/gleam/order.gleam +++ b/src/gleam/order.gleam @@ -1,5 +1,3 @@ -import gleam/pair - pub enum Order = | Lt | Eq diff --git a/test/gleam/any_test.gleam b/test/gleam/any_test.gleam index 376d454..21a10b5 100644 --- a/test/gleam/any_test.gleam +++ b/test/gleam/any_test.gleam @@ -1,10 +1,10 @@ import gleam/any import gleam/atom import gleam/list -import gleam/pair import gleam/expect import gleam/result import gleam/map +import gleam/pair.{Pair} pub fn string_test() { "" @@ -189,32 +189,32 @@ pub fn list_test() { } pub fn pair_test() { - pair.Pair(1, []) + Pair(1, []) |> any.from |> any.pair - |> expect.equal(_, Ok(pair.Pair(any.from(1), any.from([])))) + |> expect.equal(_, Ok(Pair(any.from(1), any.from([])))) - pair.Pair("ok", "ok") + Pair("ok", "ok") |> any.from |> any.pair - |> expect.equal(_, Ok(pair.Pair(any.from("ok"), any.from("ok")))) + |> expect.equal(_, Ok(Pair(any.from("ok"), any.from("ok")))) - pair.Pair(1, 2.0) + Pair(1, 2.0) |> any.from |> any.pair |> result.then(_, fn(x) { x |> pair.first |> any.int - |> result.map(_, fn(f) { pair.Pair(f, pair.second(x)) }) + |> result.map(_, fn(f) { Pair(f, pair.second(x)) }) }) |> result.then(_, fn(x) { x |> pair.second |> any.float - |> result.map(_, fn(f) { pair.Pair(pair.first(x), f) }) + |> result.map(_, fn(f) { Pair(pair.first(x), f) }) }) - |> expect.equal(_, Ok(pair.Pair(1, 2.0))) + |> expect.equal(_, Ok(Pair(1, 2.0))) } pub fn field_test() { diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index d4322fe..1cd0ff0 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -3,13 +3,20 @@ import gleam/list import gleam/int import gleam/float import gleam/string -import gleam/pair +import gleam/pair.{Pair} pub fn length_test() { - list.length([]) |> expect.equal(_, 0) - list.length([1]) |> expect.equal(_, 1) - list.length([1, 1]) |> expect.equal(_, 2) - list.length([1, 1, 1]) |> expect.equal(_, 3) + list.length([]) + |> expect.equal(_, 0) + + list.length([1]) + |> expect.equal(_, 1) + + list.length([1, 1]) + |> expect.equal(_, 2) + + list.length([1, 1, 1]) + |> expect.equal(_, 3) } pub fn reverse_test() { @@ -215,13 +222,13 @@ pub fn zip_test() { |> expect.equal(_, []) list.zip([1, 2, 3], [4, 5, 6]) - |> expect.equal(_, [pair.Pair(1, 4), pair.Pair(2, 5), pair.Pair(3, 6)]) + |> expect.equal(_, [Pair(1, 4), Pair(2, 5), Pair(3, 6)]) list.zip([5, 6], [1, 2, 3]) - |> expect.equal(_, [pair.Pair(5, 1), pair.Pair(6, 2)]) + |> expect.equal(_, [Pair(5, 1), Pair(6, 2)]) list.zip([5, 6, 7], [1, 2]) - |> expect.equal(_, [pair.Pair(5, 1), pair.Pair(6, 2)]) + |> expect.equal(_, [Pair(5, 1), Pair(6, 2)]) } pub fn strict_zip_test() { @@ -233,9 +240,9 @@ pub fn strict_zip_test() { list.strict_zip([1, 2, 3], [4, 5, 6]) |> expect.equal(_, Ok([ - pair.Pair(1, 4), - pair.Pair(2, 5), - pair.Pair(3, 6), + Pair(1, 4), + Pair(2, 5), + Pair(3, 6), ])) list.strict_zip([5, 6], [1, 2, 3]) @@ -300,8 +307,8 @@ pub fn sort_test() { } pub fn index_map_test() { - list.index_map([3, 4, 5], fn(i, x) { pair.Pair(i, x) }) - |> expect.equal(_, [pair.Pair(0, 3), pair.Pair(1, 4), pair.Pair(2, 5)]) + list.index_map([3, 4, 5], fn(i, x) { Pair(i, x) }) + |> expect.equal(_, [Pair(0, 3), Pair(1, 4), Pair(2, 5)]) let f = fn(i, x) { string.append(x, int.to_string(i)) @@ -346,44 +353,44 @@ pub fn repeat_test() { pub fn split_test() { list.split([], 0) - |> expect.equal(_, pair.Pair([], [])) + |> expect.equal(_, Pair([], [])) list.split([0, 1, 2, 3, 4], 0) - |> expect.equal(_, pair.Pair([], [0, 1, 2, 3, 4])) + |> expect.equal(_, Pair([], [0, 1, 2, 3, 4])) list.split([0, 1, 2, 3, 4], -2) - |> expect.equal(_, pair.Pair([], [0, 1, 2, 3, 4])) + |> expect.equal(_, Pair([], [0, 1, 2, 3, 4])) list.split([0, 1, 2, 3, 4], 1) - |> expect.equal(_, pair.Pair([0], [1, 2, 3, 4])) + |> expect.equal(_, Pair([0], [1, 2, 3, 4])) list.split([0, 1, 2, 3, 4], 3) - |> expect.equal(_, pair.Pair([0, 1, 2], [3, 4])) + |> expect.equal(_, Pair([0, 1, 2], [3, 4])) list.split([0, 1, 2, 3, 4], 9) - |> expect.equal(_, pair.Pair([0, 1, 2, 3, 4], [])) + |> expect.equal(_, Pair([0, 1, 2, 3, 4], [])) } pub fn split_while_test() { list.split_while([], fn(x) { x <= 5 }) - |> expect.equal(_, pair.Pair([], [])) + |> expect.equal(_, Pair([], [])) list.split_while([1, 2, 3, 4, 5], fn(x) { x <= 5 }) - |> expect.equal(_, pair.Pair([1, 2, 3, 4, 5], [])) + |> expect.equal(_, Pair([1, 2, 3, 4, 5], [])) list.split_while([1, 2, 3, 4, 5], fn(x) { x == 2 }) - |> expect.equal(_, pair.Pair([], [1, 2, 3, 4, 5])) + |> expect.equal(_, Pair([], [1, 2, 3, 4, 5])) list.split_while([1, 2, 3, 4, 5], fn(x) { x <= 3 }) - |> expect.equal(_, pair.Pair([1, 2, 3], [4, 5])) + |> expect.equal(_, Pair([1, 2, 3], [4, 5])) list.split_while([1, 2, 3, 4, 5], fn(x) { x <= -3 }) - |> expect.equal(_, pair.Pair([], [1, 2, 3, 4, 5])) + |> expect.equal(_, Pair([], [1, 2, 3, 4, 5])) } pub fn key_find_test() { - let proplist = [pair.Pair(0, "1"), pair.Pair(1, "2")] + let proplist = [Pair(0, "1"), Pair(1, "2")] proplist |> list.key_find(_, 0) diff --git a/test/gleam/map_test.gleam b/test/gleam/map_test.gleam index 3d117c3..fee689b 100644 --- a/test/gleam/map_test.gleam +++ b/test/gleam/map_test.gleam @@ -1,12 +1,12 @@ import gleam/string import gleam/expect import gleam/map -import gleam/pair +import gleam/pair.{Pair} pub fn from_list_test() { [ - pair.Pair(4, 0), - pair.Pair(1, 0), + Pair(4, 0), + Pair(1, 0), ] |> map.from_list |> map.size @@ -20,23 +20,23 @@ pub fn has_key_test() { |> expect.false [ - pair.Pair(1, 0), + Pair(1, 0), ] |> map.from_list |> map.has_key(_, 1) |> expect.true [ - pair.Pair(4, 0), - pair.Pair(1, 0), + Pair(4, 0), + Pair(1, 0), ] |> map.from_list |> map.has_key(_, 1) |> expect.true [ - pair.Pair(4, 0), - pair.Pair(1, 0), + Pair(4, 0), + Pair(1, 0), ] |> map.from_list |> map.has_key(_, 0) @@ -55,8 +55,8 @@ pub fn new_test() { pub fn get_test() { let proplist = [ - pair.Pair(4, 0), - pair.Pair(1, 1), + Pair(4, 0), + Pair(1, 1), ] let m = map.from_list(proplist) @@ -79,32 +79,32 @@ pub fn insert_test() { |> map.insert(_, "b", 1) |> map.insert(_, "c", 2) |> expect.equal(_, map.from_list([ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), ])) } pub fn map_values_test() { [ - pair.Pair(1, 0), - pair.Pair(2, 1), - pair.Pair(3, 2), + Pair(1, 0), + Pair(2, 1), + Pair(3, 2), ] |> map.from_list |> map.map_values(_, fn(k, v) { k + v }) |> expect.equal(_, map.from_list([ - pair.Pair(1, 1), - pair.Pair(2, 3), - pair.Pair(3, 5), + Pair(1, 1), + Pair(2, 3), + Pair(3, 5), ])) } pub fn keys_test() { [ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), ] |> map.from_list |> map.keys @@ -113,9 +113,9 @@ pub fn keys_test() { pub fn values_test() { [ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), ] |> map.from_list |> map.values @@ -124,72 +124,72 @@ pub fn values_test() { pub fn take_test() { [ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), ] |> map.from_list |> map.take(_, ["a", "b", "d"]) - |> expect.equal(_, map.from_list([pair.Pair("a", 0), pair.Pair("b", 1)])) + |> expect.equal(_, map.from_list([Pair("a", 0), Pair("b", 1)])) } pub fn drop_test() { [ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), ] |> map.from_list |> map.drop(_, ["a", "b", "d"]) - |> expect.equal(_, map.from_list([pair.Pair("c", 2)])) + |> expect.equal(_, map.from_list([Pair("c", 2)])) } pub fn merge_test() { let a = map.from_list([ - pair.Pair("a", 2), - pair.Pair("c", 4), - pair.Pair("d", 3), + Pair("a", 2), + Pair("c", 4), + Pair("d", 3), ]) let b = map.from_list([ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), ]) map.merge(a, b) |> expect.equal(_, map.from_list([ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), - pair.Pair("d", 3), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), + Pair("d", 3), ])) map.merge(b, a) |> expect.equal(_, map.from_list([ - pair.Pair("a", 2), - pair.Pair("b", 1), - pair.Pair("c", 4), - pair.Pair("d", 3), + Pair("a", 2), + Pair("b", 1), + Pair("c", 4), + Pair("d", 3), ])) } pub fn delete_test() { [ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), ] |> map.from_list |> map.delete(_, "a") |> map.delete(_, "d") - |> expect.equal(_, map.from_list([pair.Pair("b", 1), pair.Pair("c", 2)])) + |> expect.equal(_, map.from_list([Pair("b", 1), Pair("c", 2)])) } pub fn update_test() { let dict = map.from_list([ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), ]) let inc_or_zero = fn(x) { @@ -202,35 +202,35 @@ pub fn update_test() { dict |> map.update(_, "a", inc_or_zero) |> expect.equal(_, map.from_list([ - pair.Pair("a", 1), - pair.Pair("b", 1), - pair.Pair("c", 2), + Pair("a", 1), + Pair("b", 1), + Pair("c", 2), ])) dict |> map.update(_, "b", inc_or_zero) |> expect.equal(_, map.from_list([ - pair.Pair("a", 0), - pair.Pair("b", 2), - pair.Pair("c", 2), + Pair("a", 0), + Pair("b", 2), + Pair("c", 2), ])) dict |> map.update(_, "z", inc_or_zero) |> expect.equal(_, map.from_list([ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), - pair.Pair("z", 0), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), + Pair("z", 0), ])) } pub fn fold_test() { let dict = map.from_list([ - pair.Pair("a", 0), - pair.Pair("b", 1), - pair.Pair("c", 2), - pair.Pair("d", 3), + Pair("a", 0), + Pair("b", 1), + Pair("c", 2), + Pair("d", 3), ]) let add = fn(_, v, acc) { diff --git a/test/gleam/order_test.gleam b/test/gleam/order_test.gleam index 58f1d4e..3d50bf1 100644 --- a/test/gleam/order_test.gleam +++ b/test/gleam/order_test.gleam @@ -1,111 +1,111 @@ import gleam/expect -import gleam/order +import gleam/order.{Lt, Eq, Gt} pub fn reverse_test() { - order.reverse(order.Lt) - |> expect.equal(_, order.Gt) + order.reverse(Lt) + |> expect.equal(_, Gt) order.reverse(order.Eq) |> expect.equal(_, order.Eq) - order.reverse(order.Gt) - |> expect.equal(_, order.Lt) + order.reverse(Gt) + |> expect.equal(_, Lt) } pub fn to_int_test() { - order.to_int(order.Lt) + order.to_int(Lt) |> expect.equal(_, -1) order.to_int(order.Eq) |> expect.equal(_, 0) - order.to_int(order.Gt) + order.to_int(Gt) |> expect.equal(_, 1) } pub fn compare_test() { - order.compare(order.Lt, order.Lt) + order.compare(Lt, Lt) |> expect.equal(_, order.Eq) - order.compare(order.Lt, order.Eq) - |> expect.equal(_, order.Lt) + order.compare(Lt, order.Eq) + |> expect.equal(_, Lt) - order.compare(order.Lt, order.Gt) - |> expect.equal(_, order.Lt) + order.compare(Lt, Gt) + |> expect.equal(_, Lt) - order.compare(order.Eq, order.Lt) - |> expect.equal(_, order.Gt) + order.compare(order.Eq, Lt) + |> expect.equal(_, Gt) order.compare(order.Eq, order.Eq) |> expect.equal(_, order.Eq) - order.compare(order.Eq, order.Gt) - |> expect.equal(_, order.Lt) + order.compare(order.Eq, Gt) + |> expect.equal(_, Lt) - order.compare(order.Gt, order.Lt) - |> expect.equal(_, order.Gt) + order.compare(Gt, Lt) + |> expect.equal(_, Gt) - order.compare(order.Gt, order.Eq) - |> expect.equal(_, order.Gt) + order.compare(Gt, order.Eq) + |> expect.equal(_, Gt) - order.compare(order.Gt, order.Gt) + order.compare(Gt, Gt) |> expect.equal(_, order.Eq) } pub fn max_test() { - order.max(order.Lt, order.Lt) - |> expect.equal(_, order.Lt) + order.max(Lt, Lt) + |> expect.equal(_, Lt) - order.max(order.Lt, order.Eq) + order.max(Lt, order.Eq) |> expect.equal(_, order.Eq) - order.max(order.Lt, order.Gt) - |> expect.equal(_, order.Gt) + order.max(Lt, Gt) + |> expect.equal(_, Gt) - order.max(order.Eq, order.Lt) + order.max(order.Eq, Lt) |> expect.equal(_, order.Eq) order.max(order.Eq, order.Eq) |> expect.equal(_, order.Eq) - order.max(order.Eq, order.Gt) - |> expect.equal(_, order.Gt) + order.max(order.Eq, Gt) + |> expect.equal(_, Gt) - order.max(order.Gt, order.Lt) - |> expect.equal(_, order.Gt) + order.max(Gt, Lt) + |> expect.equal(_, Gt) - order.max(order.Gt, order.Eq) - |> expect.equal(_, order.Gt) + order.max(Gt, order.Eq) + |> expect.equal(_, Gt) - order.max(order.Gt, order.Gt) - |> expect.equal(_, order.Gt) + order.max(Gt, Gt) + |> expect.equal(_, Gt) } pub fn min_test() { - order.min(order.Lt, order.Lt) - |> expect.equal(_, order.Lt) + order.min(Lt, Lt) + |> expect.equal(_, Lt) - order.min(order.Lt, order.Eq) - |> expect.equal(_, order.Lt) + order.min(Lt, order.Eq) + |> expect.equal(_, Lt) - order.min(order.Lt, order.Gt) - |> expect.equal(_, order.Lt) + order.min(Lt, Gt) + |> expect.equal(_, Lt) - order.min(order.Eq, order.Lt) - |> expect.equal(_, order.Lt) + order.min(order.Eq, Lt) + |> expect.equal(_, Lt) order.min(order.Eq, order.Eq) |> expect.equal(_, order.Eq) - order.min(order.Eq, order.Gt) + order.min(order.Eq, Gt) |> expect.equal(_, order.Eq) - order.min(order.Gt, order.Lt) - |> expect.equal(_, order.Lt) + order.min(Gt, Lt) + |> expect.equal(_, Lt) - order.min(order.Gt, order.Eq) + order.min(Gt, order.Eq) |> expect.equal(_, order.Eq) - order.min(order.Gt, order.Gt) - |> expect.equal(_, order.Gt) + order.min(Gt, Gt) + |> expect.equal(_, Gt) } diff --git a/test/gleam/pair_test.gleam b/test/gleam/pair_test.gleam index 5dd2690..4ec4f05 100644 --- a/test/gleam/pair_test.gleam +++ b/test/gleam/pair_test.gleam @@ -1,62 +1,62 @@ import gleam/expect -import gleam/pair +import gleam/pair.{Pair} pub fn first_test() { - pair.Pair(1, 2) + Pair(1, 2) |> pair.first |> expect.equal(_, 1) - pair.Pair("abc", []) + Pair("abc", []) |> pair.first |> expect.equal(_, "abc") } pub fn second_test() { - pair.Pair(1, 2) + Pair(1, 2) |> pair.second |> expect.equal(_, 2) - pair.Pair("abc", []) + Pair("abc", []) |> pair.second |> expect.equal(_,[]) } pub fn swap_test() { - pair.Pair(1, "2") + Pair(1, "2") |> pair.swap - |> expect.equal(_, pair.Pair("2", 1)) + |> expect.equal(_, 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(1, 2), inc) + |> expect.equal(_, Pair(2, 2)) - pair.map_first(pair.Pair(8,2), inc) - |> expect.equal(_, pair.Pair(9, 2)) + pair.map_first(Pair(8,2), inc) + |> expect.equal(_, Pair(9, 2)) - pair.map_first(pair.Pair(0,-2), inc) - |> expect.equal(_, pair.Pair(1, -2)) + pair.map_first(Pair(0,-2), inc) + |> expect.equal(_, Pair(1, -2)) - pair.map_first(pair.Pair(-10, 20), inc) - |> expect.equal(_, pair.Pair(-9, 20)) + pair.map_first(Pair(-10, 20), inc) + |> expect.equal(_, 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(1, 2), dec) + |> expect.equal(_, Pair(1, 1)) - pair.map_second(pair.Pair(8,2), dec) - |> expect.equal(_, pair.Pair(8, 1)) + pair.map_second(Pair(8,2), dec) + |> expect.equal(_, Pair(8, 1)) - pair.map_second(pair.Pair(0,-2), dec) - |> expect.equal(_, pair.Pair(0, -3)) + pair.map_second(Pair(0,-2), dec) + |> expect.equal(_, Pair(0, -3)) - pair.map_second(pair.Pair(-10, 20), dec) - |> expect.equal(_, pair.Pair(-10, 19)) + pair.map_second(Pair(-10, 20), dec) + |> expect.equal(_, Pair(-10, 19)) } diff --git a/test/gleam/result_test.gleam b/test/gleam/result_test.gleam index 644a5fc..d28b622 100644 --- a/test/gleam/result_test.gleam +++ b/test/gleam/result_test.gleam @@ -1,6 +1,6 @@ import gleam/expect import gleam/result -import gleam/pair +import gleam/pair.{Pair} pub fn is_ok_test() { result.is_ok(Ok(1)) @@ -38,8 +38,8 @@ pub fn map_error_test() { |> expect.equal(_, Ok(1)) Error(1) - |> result.map_error(_, fn(x) { pair.Pair("ok", x + 1) }) - |> expect.equal(_, Error(pair.Pair("ok", 2))) + |> result.map_error(_, fn(x) { Pair("ok", x + 1) }) + |> expect.equal(_, Error(Pair("ok", 2))) } pub fn flatten_test() { diff --git a/test/gleam/triple_test.gleam b/test/gleam/triple_test.gleam index 1684cca..53ac7d0 100644 --- a/test/gleam/triple_test.gleam +++ b/test/gleam/triple_test.gleam @@ -1,32 +1,32 @@ import gleam/expect -import gleam/triple +import gleam/triple.{Triple} pub fn first_test() { - triple.Triple(1, 2, 3) + Triple(1, 2, 3) |> triple.first |> expect.equal(_, 1) - triple.Triple([], "abc", 3) + Triple([], "abc", 3) |> triple.first |> expect.equal(_, []) } pub fn second_test() { - triple.Triple(1, 2, 3) + Triple(1, 2, 3) |> triple.second |> expect.equal(_, 2) - triple.Triple([], "abc", 3) + Triple([], "abc", 3) |> triple.second |> expect.equal(_, "abc") } pub fn third_test() { - triple.Triple(1, 2, 3) + Triple(1, 2, 3) |> triple.third |> expect.equal(_, 3) - triple.Triple([], "abc", 3) + Triple([], "abc", 3) |> triple.third |> expect.equal(_, 3) } |