diff options
author | Louis Pilfold <louis@lpil.uk> | 2019-08-18 22:23:14 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2019-08-26 11:57:25 +0100 |
commit | 3f316053c680448c4b81a2c04071f7cf81497c2b (patch) | |
tree | bcdc358b5df4c12bef7670fe5f5e3af1ea78b4c8 | |
parent | f90bd89adba09502b5a7ff188a910750257ef1b0 (diff) | |
download | gleam_stdlib-3f316053c680448c4b81a2c04071f7cf81497c2b.tar.gz gleam_stdlib-3f316053c680448c4b81a2c04071f7cf81497c2b.zip |
Update stdlib to new syntax
-rw-r--r-- | src/gleam/any.gleam | 4 | ||||
-rw-r--r-- | src/gleam/bool.gleam | 8 | ||||
-rw-r--r-- | src/gleam/float.gleam | 10 | ||||
-rw-r--r-- | src/gleam/int.gleam | 6 | ||||
-rw-r--r-- | src/gleam/list.gleam | 10 | ||||
-rw-r--r-- | src/gleam/map_dict.gleam | 2 | ||||
-rw-r--r-- | src/gleam/string.gleam | 20 | ||||
-rw-r--r-- | src/gleam/tuple.gleam | 2 | ||||
-rw-r--r-- | test/gleam/any_test.gleam | 302 | ||||
-rw-r--r-- | test/gleam/atom_test.gleam | 39 | ||||
-rw-r--r-- | test/gleam/bool_test.gleam | 64 | ||||
-rw-r--r-- | test/gleam/float_test.gleam | 128 | ||||
-rw-r--r-- | test/gleam/int_test.gleam | 68 | ||||
-rw-r--r-- | test/gleam/iodata_test.gleam | 102 | ||||
-rw-r--r-- | test/gleam/list_test.gleam | 346 | ||||
-rw-r--r-- | test/gleam/map_dict_test.gleam | 148 | ||||
-rw-r--r-- | test/gleam/order_test.gleam | 132 | ||||
-rw-r--r-- | test/gleam/result_test.gleam | 76 | ||||
-rw-r--r-- | test/gleam/string_test.gleam | 40 | ||||
-rw-r--r-- | test/gleam/tuple_test.gleam | 32 |
20 files changed, 770 insertions, 769 deletions
diff --git a/src/gleam/any.gleam b/src/gleam/any.gleam index ae26bc5..5f0d5e3 100644 --- a/src/gleam/any.gleam +++ b/src/gleam/any.gleam @@ -28,7 +28,7 @@ pub external fn int(Any) -> Result(Int, String) pub external fn float(Any) -> Result(Float, String) = "gleam__stdlib" "decode_float" -pub external fn atom(Any) -> Result(atom:Atom, String) +pub external fn atom(Any) -> Result(atom.Atom, String) = "gleam__stdlib" "decode_atom" pub external fn bool(Any) -> Result(Bool, String) @@ -43,7 +43,7 @@ external fn list_any(Any) -> Result(List(Any), String) = pub fn list(any, decode) { any |> list_any - |> result:then(_, list_mod:traverse(_, decode)) + |> result.then(_, list_mod.traverse(_, decode)) } pub external fn struct2(Any) -> Result(struct(Any, Any), String) diff --git a/src/gleam/bool.gleam b/src/gleam/bool.gleam index f003691..438c232 100644 --- a/src/gleam/bool.gleam +++ b/src/gleam/bool.gleam @@ -9,10 +9,10 @@ pub fn negate(bool) { pub fn compare(a, b) { case struct(a, b) { - | struct(True, True) -> order:Eq - | struct(True, False) -> order:Gt - | struct(False, False) -> order:Eq - | struct(False, True) -> order:Lt + | struct(True, True) -> order.Eq + | struct(True, False) -> order.Gt + | struct(False, False) -> order.Eq + | struct(False, True) -> order.Lt } } diff --git a/src/gleam/float.gleam b/src/gleam/float.gleam index 65be088..4b6d589 100644 --- a/src/gleam/float.gleam +++ b/src/gleam/float.gleam @@ -9,17 +9,17 @@ pub external fn parse(String) -> Result(Float, NotAFloat) = pub fn to_string(f) { f - |> iodata:from_float - |> iodata:to_string + |> iodata.from_float + |> iodata.to_string } pub fn compare(a, b) { case a == b { - | True -> order:Eq + | True -> order.Eq | False -> case a <. b { - | True -> order:Lt - | False -> order:Gt + | True -> order.Lt + | False -> order.Gt } } } diff --git a/src/gleam/int.gleam b/src/gleam/int.gleam index c4fbf6f..2fed6bd 100644 --- a/src/gleam/int.gleam +++ b/src/gleam/int.gleam @@ -11,11 +11,11 @@ pub external fn to_base_string(Int, Int) -> String = "erlang" "integer_to_binary pub fn compare(a, b) { case a == b { - | True -> order:Eq + | True -> order.Eq | False -> case a < b { - | True -> order:Lt - | False -> order:Gt + | True -> order.Lt + | False -> order.Gt } } } diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index f0adb44..7b13760 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -238,7 +238,7 @@ fn merge_sort(a, b, compare) { | struct(_, []) -> a | struct([ax | ar], [bx | br]) -> case compare(ax, bx) { - | order:Lt -> [ax | merge_sort(ar, b, compare)] + | order.Lt -> [ax | merge_sort(ar, b, compare)] | _ -> [bx | merge_sort(a, br, compare)] } } @@ -264,10 +264,10 @@ pub fn sort(list, compare) { } pub fn range(start, stop) { - case int:compare(start, stop) { - | order:Eq -> [] - | order:Gt -> [start | range(start - 1, stop)] - | order:Lt -> [start | range(start + 1, stop)] + case int.compare(start, stop) { + | order.Eq -> [] + | order.Gt -> [start | range(start - 1, stop)] + | order.Lt -> [start | range(start + 1, stop)] } } diff --git a/src/gleam/map_dict.gleam b/src/gleam/map_dict.gleam index e77e861..5e24816 100644 --- a/src/gleam/map_dict.gleam +++ b/src/gleam/map_dict.gleam @@ -73,7 +73,7 @@ pub fn delete(map, key) { } pub fn drop(map, keys) { - list:fold(keys, map, fn(key, acc) { + list.fold(keys, map, fn(key, acc) { delete(acc, key) }) } diff --git a/src/gleam/string.gleam b/src/gleam/string.gleam index cc759a6..10de2b7 100644 --- a/src/gleam/string.gleam +++ b/src/gleam/string.gleam @@ -12,25 +12,25 @@ pub external fn uppercase(String) -> String = "string" "uppercase" pub fn reverse(string) { string - |> iodata:new - |> iodata:reverse - |> iodata:to_string + |> iodata.new + |> iodata.reverse + |> iodata.to_string } pub fn split(string, on) { string - |> iodata:new - |> iodata:split(_, on) - |> list:map(_, iodata:to_string) + |> iodata.new + |> iodata.split(_, on) + |> list.map(_, iodata.to_string) } pub fn replace(string, pattern, with) { string - |> iodata:new - |> iodata:replace(_, pattern, with) - |> iodata:to_string + |> iodata.new + |> iodata.replace(_, pattern, with) + |> iodata.to_string } pub fn append(s1, s2) { - iodata:new(s1) |> iodata:append(_, s2) |> iodata:to_string(_) + iodata.new(s1) |> iodata.append(_, s2) |> iodata.to_string(_) } diff --git a/src/gleam/tuple.gleam b/src/gleam/tuple.gleam index 5260682..03ee14d 100644 --- a/src/gleam/tuple.gleam +++ b/src/gleam/tuple.gleam @@ -20,7 +20,7 @@ pub fn swap(tup) { } pub fn fetch(haystack, needle) { - list:find(haystack, fn(tuple) { + list.find(haystack, fn(tuple) { case first(tuple) == needle { | True -> tuple |> second |> Ok | False -> Error([]) diff --git a/test/gleam/any_test.gleam b/test/gleam/any_test.gleam index 5dda768..ef441d7 100644 --- a/test/gleam/any_test.gleam +++ b/test/gleam/any_test.gleam @@ -7,272 +7,272 @@ import gleam/result pub fn string_test() { "" - |> any:from - |> any:string - |> expect:equal(_, Ok("")) + |> any.from + |> any.string + |> expect.equal(_, Ok("")) "Hello" - |> any:from - |> any:string - |> expect:equal(_, Ok("Hello")) + |> any.from + |> any.string + |> expect.equal(_, Ok("Hello")) 1 - |> any:from - |> any:string - |> expect:equal(_, Error("Expected a String, got `1`")) + |> any.from + |> any.string + |> expect.equal(_, Error("Expected a String, got `1`")) [] - |> any:from - |> any:string - |> expect:equal(_, Error("Expected a String, got `[]`")) + |> any.from + |> any.string + |> expect.equal(_, Error("Expected a String, got `[]`")) } pub fn int_test() { 1 - |> any:from - |> any:int - |> expect:equal(_, Ok(1)) + |> any.from + |> any.int + |> expect.equal(_, Ok(1)) 2 - |> any:from - |> any:int - |> expect:equal(_, Ok(2)) + |> any.from + |> any.int + |> expect.equal(_, Ok(2)) 1.0 - |> any:from - |> any:int - |> expect:equal(_, Error("Expected an Int, got `1.0`")) + |> any.from + |> any.int + |> expect.equal(_, Error("Expected an Int, got `1.0`")) [] - |> any:from - |> any:int - |> expect:equal(_, Error("Expected an Int, got `[]`")) + |> any.from + |> any.int + |> expect.equal(_, Error("Expected an Int, got `[]`")) } pub fn float_test() { 1.0 - |> any:from - |> any:float - |> expect:equal(_, Ok(1.0)) + |> any.from + |> any.float + |> expect.equal(_, Ok(1.0)) 2.2 - |> any:from - |> any:float - |> expect:equal(_, Ok(2.2)) + |> any.from + |> any.float + |> expect.equal(_, Ok(2.2)) 1 - |> any:from - |> any:float - |> expect:equal(_, Error("Expected a Float, got `1`")) + |> any.from + |> any.float + |> expect.equal(_, Error("Expected a Float, got `1`")) [] - |> any:from - |> any:float - |> expect:equal(_, Error("Expected a Float, got `[]`")) + |> any.from + |> any.float + |> expect.equal(_, Error("Expected a Float, got `[]`")) } // pub fn atom_test() { // make an atom here -// |> any:from +// |> any.from // |> atom -// |> expect:equal(_, Ok("")) +// |> expect.equal(_, Ok("")) // make an atom here -// |> any:from +// |> any.from // |> atom -// |> expect:equal(_, Ok("ok")) +// |> expect.equal(_, Ok("ok")) // 1 -// |> any:from +// |> any.from // |> atom -// |> expect:is_error +// |> expect.is_error // [] -// |> any:from +// |> any.from // |> atom -// |> expect:is_error +// |> expect.is_error // } pub fn thunk_test() { fn() { 1 } - |> any:from - |> any:thunk - |> expect:is_ok + |> any.from + |> any.thunk + |> expect.is_ok fn() { 1 } - |> any:from - |> any:thunk - |> result:map(_, fn(f) { f() }) - |> expect:equal(_, Ok(any:from(1))) + |> any.from + |> any.thunk + |> result.map(_, fn(f) { f() }) + |> expect.equal(_, Ok(any.from(1))) fn(x) { x } - |> any:from - |> any:thunk - |> expect:is_error + |> any.from + |> any.thunk + |> expect.is_error 1 - |> any:from - |> any:thunk - |> expect:is_error + |> any.from + |> any.thunk + |> expect.is_error [] - |> any:from - |> any:thunk - |> expect:is_error + |> any.from + |> any.thunk + |> expect.is_error } pub fn bool_test() { True - |> any:from - |> any:bool - |> expect:equal(_, Ok(True)) + |> any.from + |> any.bool + |> expect.equal(_, Ok(True)) False - |> any:from - |> any:bool - |> expect:equal(_, Ok(False)) + |> any.from + |> any.bool + |> expect.equal(_, Ok(False)) 1 - |> any:from - |> any:bool - |> expect:equal(_, Error("Expected a Bool, got `1`")) + |> any.from + |> any.bool + |> expect.equal(_, Error("Expected a Bool, got `1`")) [] - |> any:from - |> any:bool - |> expect:equal(_, Error("Expected a Bool, got `[]`")) + |> any.from + |> any.bool + |> expect.equal(_, Error("Expected a Bool, got `[]`")) } pub fn atom_test() { "" - |> atom:create_from_string - |> any:from - |> any:atom - |> expect:equal(_, Ok(atom:create_from_string(""))) + |> atom.create_from_string + |> any.from + |> any.atom + |> expect.equal(_, Ok(atom.create_from_string(""))) "ok" - |> atom:create_from_string - |> any:from - |> any:atom - |> expect:equal(_, Ok(atom:create_from_string("ok"))) + |> atom.create_from_string + |> any.from + |> any.atom + |> expect.equal(_, Ok(atom.create_from_string("ok"))) 1 - |> any:from - |> any:atom - |> expect:is_error + |> any.from + |> any.atom + |> expect.is_error [] - |> any:from - |> any:atom - |> expect:is_error + |> any.from + |> any.atom + |> expect.is_error } pub fn list_test() { [] - |> any:from - |> any:list(_, any:string) - |> expect:equal(_, Ok([])) + |> any.from + |> any.list(_, any.string) + |> expect.equal(_, Ok([])) [] - |> any:from - |> any:list(_, any:int) - |> expect:equal(_, Ok([])) + |> any.from + |> any.list(_, any.int) + |> expect.equal(_, Ok([])) [1, 2, 3] - |> any:from - |> any:list(_, any:int) - |> expect:equal(_, Ok([1, 2, 3])) + |> any.from + |> any.list(_, any.int) + |> expect.equal(_, Ok([1, 2, 3])) [[1], [2], [3]] - |> any:from - |> any:list(_, any:list(_, any:int)) - |> expect:equal(_, Ok([[1], [2], [3]])) + |> any.from + |> any.list(_, any.list(_, any.int)) + |> expect.equal(_, Ok([[1], [2], [3]])) 1 - |> any:from - |> any:list(_, any:string) - |> expect:is_error + |> any.from + |> any.list(_, any.string) + |> expect.is_error 1.0 - |> any:from - |> any:list(_, any:int) - |> expect:is_error + |> any.from + |> any.list(_, any.int) + |> expect.is_error [""] - |> any:from - |> any:list(_, any:int) - |> expect:is_error - - [any:from(1), any:from("not an int")] - |> any:from - |> any:list(_, any:int) - |> expect:is_error + |> any.from + |> any.list(_, any.int) + |> expect.is_error + + [any.from(1), any.from("not an int")] + |> any.from + |> any.list(_, any.int) + |> expect.is_error } pub fn struct2_test() { struct(1, []) - |> any:from - |> any:struct2 - |> expect:equal(_, Ok(struct(any:from(1), any:from([])))) + |> any.from + |> any.struct2 + |> expect.equal(_, Ok(struct(any.from(1), any.from([])))) struct("ok", "ok") - |> any:from - |> any:struct2 - |> expect:equal(_, Ok(struct(any:from("ok"), any:from("ok")))) + |> any.from + |> any.struct2 + |> expect.equal(_, Ok(struct(any.from("ok"), any.from("ok")))) struct(1) - |> any:from - |> any:struct2 - |> expect:is_error + |> any.from + |> any.struct2 + |> expect.is_error struct(1, 2, 3) - |> any:from - |> any:struct2 - |> expect:is_error + |> any.from + |> any.struct2 + |> expect.is_error struct(1, 2.0) - |> any:from - |> any:struct2 - |> result:then(_, fn(x) { + |> any.from + |> any.struct2 + |> result.then(_, fn(x) { x - |> tuple:first - |> any:int - |> result:map(_, fn(f) { struct(f, tuple:second(x)) }) + |> tuple.first + |> any.int + |> result.map(_, fn(f) { struct(f, tuple.second(x)) }) }) - |> result:then(_, fn(x) { + |> result.then(_, fn(x) { x - |> tuple:second - |> any:float - |> result:map(_, fn(f) { struct(tuple:first(x), f) }) + |> tuple.second + |> any.float + |> result.map(_, fn(f) { struct(tuple.first(x), f) }) }) - |> expect:equal(_, Ok(struct(1, 2.0))) + |> expect.equal(_, Ok(struct(1, 2.0))) } pub fn field_test() { - let Ok(ok_atom) = atom:from_string("ok") + let Ok(ok_atom) = atom.from_string("ok") {ok = 1} - |> any:from - |> any:field(_, ok_atom) - |> expect:equal(_, Ok(any:from(1))) + |> any.from + |> any.field(_, ok_atom) + |> expect.equal(_, Ok(any.from(1))) {earlier = 2, ok = 3} - |> any:from - |> any:field(_, ok_atom) - |> expect:equal(_, Ok(any:from(3))) + |> any.from + |> any.field(_, ok_atom) + |> expect.equal(_, Ok(any.from(3))) {} - |> any:from - |> any:field(_, ok_atom) - |> expect:is_error + |> any.from + |> any.field(_, ok_atom) + |> expect.is_error 1 - |> any:from - |> any:field(_, ok_atom) - |> expect:is_error + |> any.from + |> any.field(_, ok_atom) + |> expect.is_error [] - |> any:from - |> any:field(_, []) - |> expect:is_error + |> any.from + |> any.field(_, []) + |> expect.is_error } diff --git a/test/gleam/atom_test.gleam b/test/gleam/atom_test.gleam index 8054aaf..861758f 100644 --- a/test/gleam/atom_test.gleam +++ b/test/gleam/atom_test.gleam @@ -3,44 +3,45 @@ import gleam/expect pub fn from_string_test() { "ok" - |> atom:from_string - |> expect:is_ok + |> atom.from_string + |> expect.is_ok "expect" - |> atom:from_string - |> expect:is_ok + |> atom.from_string + |> expect.is_ok "this is not an atom we have seen before" - |> atom:from_string - // |> expect:equal(_, Error(AtomNotLoaded)) - |> expect:is_error + |> atom.from_string + // TODO + // |> expect.equal(_, Error(AtomNotLoaded)) + |> expect.is_error } pub fn create_from_string_test() { "ok" - |> atom:create_from_string + |> atom.create_from_string |> Ok - |> expect:equal(_, atom:from_string("ok")) + |> expect.equal(_, atom.from_string("ok")) "expect" - |> atom:create_from_string + |> atom.create_from_string |> Ok - |> expect:equal(_, atom:from_string("expect")) + |> expect.equal(_, atom.from_string("expect")) "this is another atom we have not seen before" - |> atom:create_from_string + |> atom.create_from_string |> Ok - |> expect:equal(_, atom:from_string("this is another atom we have not seen before")) + |> expect.equal(_, atom.from_string("this is another atom we have not seen before")) } pub fn to_string_test() { "ok" - |> atom:create_from_string - |> atom:to_string - |> expect:equal(_, "ok") + |> atom.create_from_string + |> atom.to_string + |> expect.equal(_, "ok") "expect" - |> atom:create_from_string - |> atom:to_string - |> expect:equal(_, "expect") + |> atom.create_from_string + |> atom.to_string + |> expect.equal(_, "expect") } diff --git a/test/gleam/bool_test.gleam b/test/gleam/bool_test.gleam index 1f18f71..8c30579 100644 --- a/test/gleam/bool_test.gleam +++ b/test/gleam/bool_test.gleam @@ -3,59 +3,59 @@ import gleam/order import gleam/expect pub fn negate_test() { - bool:negate(True) - |> expect:false + bool.negate(True) + |> expect.false - bool:negate(False) - |> expect:true + bool.negate(False) + |> expect.true } pub fn compare_test() { - bool:compare(True, True) - |> expect:equal(_, order:Eq) + bool.compare(True, True) + |> expect.equal(_, order.Eq) - bool:compare(True, False) - |> expect:equal(_, order:Gt) + bool.compare(True, False) + |> expect.equal(_, order.Gt) - bool:compare(False, False) - |> expect:equal(_, order:Eq) + bool.compare(False, False) + |> expect.equal(_, order.Eq) - bool:compare(False, True) - |> expect:equal(_, order:Lt) + bool.compare(False, True) + |> expect.equal(_, order.Lt) } pub fn max_test() { - bool:max(True, True) - |> expect:equal(_, True) + bool.max(True, True) + |> expect.equal(_, True) - bool:max(True, False) - |> expect:equal(_, True) + bool.max(True, False) + |> expect.equal(_, True) - bool:max(False, False) - |> expect:equal(_, False) + bool.max(False, False) + |> expect.equal(_, False) - bool:max(False, True) - |> expect:equal(_, True) + bool.max(False, True) + |> expect.equal(_, True) } pub fn min_test() { - bool:min(True, True) - |> expect:equal(_, True) + bool.min(True, True) + |> expect.equal(_, True) - bool:min(True, False) - |> expect:equal(_, False) + bool.min(True, False) + |> expect.equal(_, False) - bool:min(False, False) - |> expect:equal(_, False) + bool.min(False, False) + |> expect.equal(_, False) - bool:min(False, True) - |> expect:equal(_, False) + bool.min(False, True) + |> expect.equal(_, False) } pub fn to_int_test() { - bool:to_int(True) - |> expect:equal(_, 1) + bool.to_int(True) + |> expect.equal(_, 1) - bool:to_int(False) - |> expect:equal(_, 0) + bool.to_int(False) + |> expect.equal(_, 0) } diff --git a/test/gleam/float_test.gleam b/test/gleam/float_test.gleam index ef063a5..a020cec 100644 --- a/test/gleam/float_test.gleam +++ b/test/gleam/float_test.gleam @@ -4,136 +4,136 @@ import gleam/order pub fn parse_test() { "1.23" - |> float:parse - |> expect:equal(_, Ok(1.23)) + |> float.parse + |> expect.equal(_, Ok(1.23)) "5.0" - |> float:parse - |> expect:equal(_, Ok(5.0)) + |> float.parse + |> expect.equal(_, Ok(5.0)) "0.123456789" - |> float:parse - |> expect:equal(_, Ok(0.123456789)) + |> float.parse + |> expect.equal(_, Ok(0.123456789)) "" - |> float:parse - |> expect:is_error + |> float.parse + |> expect.is_error "what" - |> float:parse - |> expect:is_error + |> float.parse + |> expect.is_error "1" - |> float:parse - |> expect:is_error + |> float.parse + |> expect.is_error } pub fn to_string_test() { 123.0 - |> float:to_string - |> expect:equal(_, "123.0") + |> float.to_string + |> expect.equal(_, "123.0") -8.1 - |> float:to_string - |> expect:equal(_, "-8.1") + |> float.to_string + |> expect.equal(_, "-8.1") } pub fn compare_test() { - float:compare(0., 0.) - |> expect:equal(_, order:Eq) + float.compare(0., 0.) + |> expect.equal(_, order.Eq) - float:compare(0.1, 0.1) - |> expect:equal(_, order:Eq) + float.compare(0.1, 0.1) + |> expect.equal(_, order.Eq) - float:compare(0., 0.1) - |> expect:equal(_, order:Lt) + float.compare(0., 0.1) + |> expect.equal(_, order.Lt) - float:compare(-2., -1.9) - |> expect:equal(_, order:Lt) + float.compare(-2., -1.9) + |> expect.equal(_, order.Lt) - float:compare(2., 1.9) - |> expect:equal(_, order:Gt) + float.compare(2., 1.9) + |> expect.equal(_, order.Gt) - float:compare(-1.9, -2.) - |> expect:equal(_, order:Gt) + float.compare(-1.9, -2.) + |> expect.equal(_, order.Gt) } pub fn ceiling_test() { 8.1 - |> float:ceiling - |> expect:equal(_, 9.0) + |> float.ceiling + |> expect.equal(_, 9.0) -8.1 - |> float:ceiling - |> expect:equal(_, -8.0) + |> float.ceiling + |> expect.equal(_, -8.0) -8.0 - |> float:ceiling - |> expect:equal(_, -8.0) + |> float.ceiling + |> expect.equal(_, -8.0) } pub fn floor_test() { 8.1 - |> float:floor - |> expect:equal(_, 8.0) + |> float.floor + |> expect.equal(_, 8.0) -8.1 - |> float:floor - |> expect:equal(_, -9.0) + |> float.floor + |> expect.equal(_, -9.0) -8.0 - |> float:floor - |> expect:equal(_, -8.0) + |> float.floor + |> expect.equal(_, -8.0) } pub fn round_test() { 8.1 - |> float:round - |> expect:equal(_, 8) + |> float.round + |> expect.equal(_, 8) 8.4 - |> float:round - |> expect:equal(_, 8) + |> float.round + |> expect.equal(_, 8) 8.499 - |> float:round - |> expect:equal(_, 8) + |> float.round + |> expect.equal(_, 8) 8.5 - |> float:round - |> expect:equal(_, 9) + |> float.round + |> expect.equal(_, 9) -8.1 - |> float:round - |> expect:equal(_, -8) + |> float.round + |> expect.equal(_, -8) -7.5 - |> float:round - |> expect:equal(_, -8) + |> float.round + |> expect.equal(_, -8) } pub fn truncate_test() { 8.1 - |> float:truncate - |> expect:equal(_, 8) + |> float.truncate + |> expect.equal(_, 8) 8.4 - |> float:truncate - |> expect:equal(_, 8) + |> float.truncate + |> expect.equal(_, 8) 8.499 - |> float:truncate - |> expect:equal(_, 8) + |> float.truncate + |> expect.equal(_, 8) 8.5 - |> float:truncate - |> expect:equal(_, 8) + |> float.truncate + |> expect.equal(_, 8) -8.1 - |> float:truncate - |> expect:equal(_, -8) + |> float.truncate + |> expect.equal(_, -8) -7.5 - |> float:truncate - |> expect:equal(_, -7) + |> float.truncate + |> expect.equal(_, -7) } diff --git a/test/gleam/int_test.gleam b/test/gleam/int_test.gleam index c7fe9e9..3034e3b 100644 --- a/test/gleam/int_test.gleam +++ b/test/gleam/int_test.gleam @@ -4,70 +4,70 @@ import gleam/order pub fn to_string() { 123 - |> int:to_string - |> expect:equal(_, "123") + |> int.to_string + |> expect.equal(_, "123") -123 - |> int:to_string - |> expect:equal(_, "-123") + |> int.to_string + |> expect.equal(_, "-123") 0123 - |> int:to_string - |> expect:equal(_, "123") + |> int.to_string + |> expect.equal(_, "123") } pub fn parse() { "123" - |> int:parse - |> expect:equal(_, Ok(123)) + |> int.parse + |> expect.equal(_, Ok(123)) "-123" - |> int:parse - |> expect:equal(_, Ok(-123)) + |> int.parse + |> expect.equal(_, Ok(-123)) "0123" - |> int:parse - |> expect:equal(_, Ok(123)) + |> int.parse + |> expect.equal(_, Ok(123)) "" - |> int:parse - |> expect:is_error + |> int.parse + |> expect.is_error "what" - |> int:parse - |> expect:is_error + |> int.parse + |> expect.is_error "1.23" - |> int:parse - |> expect:is_error + |> int.parse + |> expect.is_error } pub fn to_base_string() { 100 - |> int:to_base_string(_, 16) - |> expect:equal(_, "64") + |> int.to_base_string(_, 16) + |> expect.equal(_, "64") -100 - |> int:to_base_string(_, 16) - |> expect:equal(_, "-64") + |> int.to_base_string(_, 16) + |> expect.equal(_, "-64") } pub fn compare_test() { - int:compare(0, 0) - |> expect:equal(_, order:Eq) + int.compare(0, 0) + |> expect.equal(_, order.Eq) - int:compare(1, 1) - |> expect:equal(_, order:Eq) + int.compare(1, 1) + |> expect.equal(_, order.Eq) - int:compare(0, 1) - |> expect:equal(_, order:Lt) + int.compare(0, 1) + |> expect.equal(_, order.Lt) - int:compare(-2, -1) - |> expect:equal(_, order:Lt) + int.compare(-2, -1) + |> expect.equal(_, order.Lt) - int:compare(2, 1) - |> expect:equal(_, order:Gt) + int.compare(2, 1) + |> expect.equal(_, order.Gt) - int:compare(-1, -2) - |> expect:equal(_, order:Gt) + int.compare(-1, -2) + |> expect.equal(_, order.Gt) } diff --git a/test/gleam/iodata_test.gleam b/test/gleam/iodata_test.gleam index 1684a81..0b0e248 100644 --- a/test/gleam/iodata_test.gleam +++ b/test/gleam/iodata_test.gleam @@ -2,89 +2,89 @@ import gleam/expect import gleam/iodata pub fn iodata_test() { - let data = iodata:new("ello") - |> iodata:append(_, ",") - |> iodata:append(_, " world!") - |> iodata:prepend(_, "H") + let data = iodata.new("ello") + |> iodata.append(_, ",") + |> iodata.append(_, " world!") + |> iodata.prepend(_, "H") data - |> iodata:to_string - |> expect:equal(_, "Hello, world!") + |> iodata.to_string + |> expect.equal(_, "Hello, world!") data - |> iodata:byte_size - |> expect:equal(_, 13) + |> iodata.byte_size + |> expect.equal(_, 13) - let data = iodata:new("ello") - |> iodata:append_iodata(_, iodata:new(",")) - |> iodata:append_iodata(_, iodata:concat([iodata:new(" wo"), iodata:new("rld!")])) - |> iodata:prepend_iodata(_, iodata:new("H")) + let data = iodata.new("ello") + |> iodata.append_iodata(_, iodata.new(",")) + |> iodata.append_iodata(_, iodata.concat([iodata.new(" wo"), iodata.new("rld!")])) + |> iodata.prepend_iodata(_, iodata.new("H")) data - |> iodata:to_string - |> expect:equal(_, "Hello, world!") + |> iodata.to_string + |> expect.equal(_, "Hello, world!") data - |> iodata:byte_size - |> expect:equal(_, 13) + |> iodata.byte_size + |> expect.equal(_, 13) } pub fn lowercase_test() { ["Gleam", "Gleam"] - |> iodata:from_strings - |> iodata:lowercase - |> iodata:to_string - |> expect:equal(_, "gleamgleam") + |> iodata.from_strings + |> iodata.lowercase + |> iodata.to_string + |> expect.equal(_, "gleamgleam") } pub fn uppercase_test() { ["Gleam", "Gleam"] - |> iodata:from_strings - |> iodata:uppercase - |> iodata:to_string - |> expect:equal(_, "GLEAMGLEAM") + |> iodata.from_strings + |> iodata.uppercase + |> iodata.to_string + |> expect.equal(_, "GLEAMGLEAM") } pub fn split_test() { "Gleam,Erlang,Elixir" - |> iodata:new - |> iodata:split(_, ",") - |> expect:equal(_, [iodata:new("Gleam"), iodata:new("Erlang"), iodata:new("Elixir")]) + |> iodata.new + |> iodata.split(_, ",") + |> expect.equal(_, [iodata.new("Gleam"), iodata.new("Erlang"), iodata.new("Elixir")]) ["Gleam, Erl", "ang,Elixir"] - |> iodata:from_strings - |> iodata:split(_, ", ") - |> expect:equal(_, [iodata:new("Gleam"), iodata:from_strings(["Erl", "ang,Elixir"])]) + |> iodata.from_strings + |> iodata.split(_, ", ") + |> expect.equal(_, [iodata.new("Gleam"), iodata.from_strings(["Erl", "ang,Elixir"])]) } pub fn is_equal_test() { - iodata:new("12") - |> iodata:is_equal(_, iodata:from_strings(["1", "2"])) - |> expect:true + iodata.new("12") + |> iodata.is_equal(_, iodata.from_strings(["1", "2"])) + |> expect.true - iodata:new("12") - |> iodata:is_equal(_, iodata:new("12")) - |> expect:true + iodata.new("12") + |> iodata.is_equal(_, iodata.new("12")) + |> expect.true - iodata:new("12") - |> iodata:is_equal(_, iodata:new("2")) - |> expect:false + iodata.new("12") + |> iodata.is_equal(_, iodata.new("2")) + |> expect.false } pub fn is_empty_test() { - iodata:new("") - |> iodata:is_empty - |> expect:true + iodata.new("") + |> iodata.is_empty + |> expect.true - iodata:new("12") - |> iodata:is_empty - |> expect:false + iodata.new("12") + |> iodata.is_empty + |> expect.false - iodata:from_strings([]) - |> iodata:is_empty - |> expect:true + iodata.from_strings([]) + |> iodata.is_empty + |> expect.true - iodata:from_strings(["", ""]) - |> iodata:is_empty - |> expect:true + iodata.from_strings(["", ""]) + |> iodata.is_empty + |> expect.true } diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index 9710574..4be190d 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -5,73 +5,73 @@ import gleam/float import gleam/string 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() { - list:reverse([]) |> expect:equal(_, []) - list:reverse([1, 2, 3, 4, 5]) |> expect:equal(_, [5, 4, 3, 2, 1]) + list.reverse([]) |> expect.equal(_, []) + list.reverse([1, 2, 3, 4, 5]) |> expect.equal(_, [5, 4, 3, 2, 1]) } pub fn is_empty_test() { - list:is_empty([]) |> expect:true - list:is_empty([1]) |> expect:false + list.is_empty([]) |> expect.true + list.is_empty([1]) |> expect.false } pub fn contains_test() { - list:contains([0, 4, 5, 1], 1) |> expect:true - list:contains([0, 4, 5, 7], 1) |> expect:false - list:contains([], 1) |> expect:false + list.contains([0, 4, 5, 1], 1) |> expect.true + list.contains([0, 4, 5, 7], 1) |> expect.false + list.contains([], 1) |> expect.false } pub fn head_test() { - list:head([0, 4, 5, 7]) - |> expect:equal(_, Ok(0)) + list.head([0, 4, 5, 7]) + |> expect.equal(_, Ok(0)) - list:head([]) - |> expect:is_error + list.head([]) + |> expect.is_error } pub fn tail_test() { - list:tail([0, 4, 5, 7]) - |> expect:equal(_, Ok([4, 5, 7])) + list.tail([0, 4, 5, 7]) + |> expect.equal(_, Ok([4, 5, 7])) - list:tail([0]) - |> expect:equal(_, Ok([])) + list.tail([0]) + |> expect.equal(_, Ok([])) - list:tail([]) - |> expect:is_error + list.tail([]) + |> expect.is_error } pub fn filter_test() { [] - |> list:filter(_, fn(_) { True }) - |> expect:equal(_, []) + |> list.filter(_, fn(_) { True }) + |> expect.equal(_, []) [0, 4, 5, 7, 3] - |> list:filter(_, fn(_) { True }) - |> expect:equal(_, [0, 4, 5, 7, 3]) + |> list.filter(_, fn(_) { True }) + |> expect.equal(_, [0, 4, 5, 7, 3]) [0, 4, 5, 7, 3] - |> list:filter(_, fn(x) { x > 4 }) - |> expect:equal(_, [5, 7]) + |> list.filter(_, fn(x) { x > 4 }) + |> expect.equal(_, [5, 7]) [0, 4, 5, 7, 3] - |> list:filter(_, fn(x) { x < 4 }) - |> expect:equal(_, [0, 3]) + |> list.filter(_, fn(x) { x < 4 }) + |> expect.equal(_, [0, 3]) } pub fn map_test() { [] - |> list:map(_, fn(x) { x * 2 }) - |> expect:equal(_, []) + |> list.map(_, fn(x) { x * 2 }) + |> expect.equal(_, []) [0, 4, 5, 7, 3] - |> list:map(_, fn(x) { x * 2 }) - |> expect:equal(_, [0, 8, 10, 14, 6]) + |> list.map(_, fn(x) { x * 2 }) + |> expect.equal(_, [0, 8, 10, 14, 6]) } pub fn traverse_test() { @@ -83,66 +83,66 @@ pub fn traverse_test() { } [5, 6, 5, 6] - |> list:traverse(_, fun) - |> expect:equal(_, Ok([10, 12, 10, 12])) + |> list.traverse(_, fun) + |> expect.equal(_, Ok([10, 12, 10, 12])) [4, 6, 5, 7, 3] - |> list:traverse(_, fun) - |> expect:equal(_, Error(7)) + |> list.traverse(_, fun) + |> expect.equal(_, Error(7)) } pub fn drop_test() { [] - |> list:drop(_, 5) - |> expect:equal(_, []) + |> list.drop(_, 5) + |> expect.equal(_, []) [1, 2, 3, 4, 5, 6, 7, 8] - |> list:drop(_, 5) - |> expect:equal(_, [6, 7, 8]) + |> list.drop(_, 5) + |> expect.equal(_, [6, 7, 8]) } pub fn take_test() { [] - |> list:take(_, 5) - |> expect:equal(_, []) + |> list.take(_, 5) + |> expect.equal(_, []) [1, 2, 3, 4, 5, 6, 7, 8] - |> list:take(_, 5) - |> expect:equal(_, [1, 2, 3, 4, 5]) + |> list.take(_, 5) + |> expect.equal(_, [1, 2, 3, 4, 5]) } pub fn new_test() { - list:new() |> expect:equal(_, []) + list.new() |> expect.equal(_, []) } pub fn append_test() { - list:append([1], [2, 3]) - |> expect:equal(_, [1, 2, 3]) + list.append([1], [2, 3]) + |> expect.equal(_, [1, 2, 3]) } pub fn flatten_test() { - list:flatten([]) - |> expect:equal(_, []) + list.flatten([]) + |> expect.equal(_, []) - list:flatten([[]]) - |> expect:equal(_, []) + list.flatten([[]]) + |> expect.equal(_, []) - list:flatten([[], [], []]) - |> expect:equal(_, []) + list.flatten([[], [], []]) + |> expect.equal(_, []) - list:flatten([[1, 2], [], [3, 4]]) - |> expect:equal(_, [1, 2, 3, 4]) + list.flatten([[1, 2], [], [3, 4]]) + |> expect.equal(_, [1, 2, 3, 4]) } pub fn fold_test() { [1, 2, 3] - |> list:fold(_, [], fn(x, acc) { [x | acc] }) - |> expect:equal(_, [3, 2, 1]) + |> list.fold(_, [], fn(x, acc) { [x | acc] }) + |> expect.equal(_, [3, 2, 1]) } pub fn fold_right_test() { [1, 2, 3] - |> list:fold_right(_, [], fn(x, acc) { [x | acc] }) - |> expect:equal(_, [1, 2, 3]) + |> list.fold_right(_, [], fn(x, acc) { [x | acc] }) + |> expect.equal(_, [1, 2, 3]) } pub fn find_test() { @@ -154,206 +154,206 @@ pub fn find_test() { } [1, 2, 3] - |> list:find(_, f) - |> expect:equal(_, Ok(4)) + |> list.find(_, f) + |> expect.equal(_, Ok(4)) [1, 3, 2] - |> list:find(_, f) - |> expect:equal(_, Ok(4)) + |> list.find(_, f) + |> expect.equal(_, Ok(4)) [1, 3] - |> list:find(_, f) - |> expect:is_error + |> list.find(_, f) + |> expect.is_error } pub fn all_test() { - list:all([1, 2, 3, 4, 5], fn(x) { x > 0 }) - |> expect:equal(_, True) + list.all([1, 2, 3, 4, 5], fn(x) { x > 0 }) + |> expect.equal(_, True) - list:all([1, 2, 3, 4, 5], fn(x) { x < 0 }) - |> expect:equal(_, False) + list.all([1, 2, 3, 4, 5], fn(x) { x < 0 }) + |> expect.equal(_, False) - list:all([], fn(_) { False }) - |> expect:equal(_, True) + list.all([], fn(_) { False }) + |> expect.equal(_, True) } pub fn any_test() { - list:any([1, 2, 3, 4, 5], fn(x) { x == 2 }) - |> expect:equal(_, True) + list.any([1, 2, 3, 4, 5], fn(x) { x == 2 }) + |> expect.equal(_, True) - list:any([1, 2, 3, 4, 5], fn(x) { x < 0 }) - |> expect:equal(_, False) + list.any([1, 2, 3, 4, 5], fn(x) { x < 0 }) + |> expect.equal(_, False) - list:any([], fn(_) { False }) - |> expect:equal(_, False) + list.any([], fn(_) { False }) + |> expect.equal(_, False) } pub fn zip_test() { - list:zip([], [1, 2, 3]) - |> expect:equal(_, []) + list.zip([], [1, 2, 3]) + |> expect.equal(_, []) - list:zip([1, 2], []) - |> expect:equal(_, []) + list.zip([1, 2], []) + |> expect.equal(_, []) - list:zip([1, 2, 3], [4, 5, 6]) - |> expect:equal(_, [struct(1, 4), struct(2, 5), struct(3, 6)]) + list.zip([1, 2, 3], [4, 5, 6]) + |> expect.equal(_, [struct(1, 4), struct(2, 5), struct(3, 6)]) - list:zip([5, 6], [1, 2, 3]) - |> expect:equal(_, [struct(5, 1), struct(6, 2)]) + list.zip([5, 6], [1, 2, 3]) + |> expect.equal(_, [struct(5, 1), struct(6, 2)]) - list:zip([5, 6, 7], [1, 2]) - |> expect:equal(_, [struct(5, 1), struct(6, 2)]) + list.zip([5, 6, 7], [1, 2]) + |> expect.equal(_, [struct(5, 1), struct(6, 2)]) } pub fn strict_zip_test() { - list:strict_zip([], [1, 2, 3]) - |> expect:is_error + list.strict_zip([], [1, 2, 3]) + |> expect.is_error - list:strict_zip([1, 2], []) - |> expect:is_error + list.strict_zip([1, 2], []) + |> expect.is_error - list:strict_zip([1, 2, 3], [4, 5, 6]) - |> expect:equal(_, Ok([struct(1, 4), struct(2, 5), struct(3, 6)])) + list.strict_zip([1, 2, 3], [4, 5, 6]) + |> expect.equal(_, Ok([struct(1, 4), struct(2, 5), struct(3, 6)])) - list:strict_zip([5, 6], [1, 2, 3]) - |> expect:is_error + list.strict_zip([5, 6], [1, 2, 3]) + |> expect.is_error - list:strict_zip([5, 6, 7], [1, 2]) - |> expect:is_error + list.strict_zip([5, 6, 7], [1, 2]) + |> expect.is_error } pub fn intersperse_test() { - list:intersperse([1, 2, 3], 4) - |> expect:equal(_, [1, 4, 2, 4, 3]) + list.intersperse([1, 2, 3], 4) + |> expect.equal(_, [1, 4, 2, 4, 3]) - list:intersperse([], 2) - |> expect:equal(_, []) + list.intersperse([], 2) + |> expect.equal(_, []) } pub fn at_test() { - list:at([1, 2, 3], 2) - |> expect:equal(_, Ok(3)) + list.at([1, 2, 3], 2) + |> expect.equal(_, Ok(3)) - list:at([1, 2, 3], 5) - |> expect:is_error + list.at([1, 2, 3], 5) + |> expect.is_error - list:at([], 0) - |> expect:is_error + list.at([], 0) + |> expect.is_error - list:at([1, 2, 3, 4, 5, 6], -1) - |> expect:is_error + list.at([1, 2, 3, 4, 5, 6], -1) + |> expect.is_error } pub fn unique_test() { - list:unique([1, 1, 2, 3, 4, 4, 4, 5, 6]) - |> expect:equal(_, [1, 2, 3, 4, 5, 6]) + list.unique([1, 1, 2, 3, 4, 4, 4, 5, 6]) + |> expect.equal(_, [1, 2, 3, 4, 5, 6]) - list:unique([7, 1, 45, 6, 2, 47, 2, 7, 5]) - |> expect:equal(_, [7, 1, 45, 6, 2, 47, 5]) + list.unique([7, 1, 45, 6, 2, 47, 2, 7, 5]) + |> expect.equal(_, [7, 1, 45, 6, 2, 47, 5]) - list:unique([3, 4, 5]) - |> expect:equal(_, [3, 4, 5]) + list.unique([3, 4, 5]) + |> expect.equal(_, [3, 4, 5]) - list:unique([]) - |> expect:equal(_, []) + list.unique([]) + |> expect.equal(_, []) } pub fn sort_test() { [4, 3, 6, 5, 4] - |> list:sort(_, int:compare) - |> expect:equal(_, [3, 4, 4, 5, 6]) + |> list.sort(_, int.compare) + |> expect.equal(_, [3, 4, 4, 5, 6]) [4, 3, 6, 5, 4, 1] - |> list:sort(_, int:compare) - |> expect:equal(_, [1, 3, 4, 4, 5, 6]) + |> list.sort(_, int.compare) + |> expect.equal(_, [1, 3, 4, 4, 5, 6]) [4.1, 3.1, 6.1, 5.1, 4.1] - |> list:sort(_, float:compare) - |> expect:equal(_, [3.1, 4.1, 4.1, 5.1, 6.1]) + |> list.sort(_, float.compare) + |> expect.equal(_, [3.1, 4.1, 4.1, 5.1, 6.1]) [] - |> list:sort(_, int:compare) - |> expect:equal(_, []) + |> list.sort(_, int.compare) + |> expect.equal(_, []) } pub fn index_map_test() { - list:index_map([3, 4, 5], fn(i, x) { struct(i, x) }) - |> expect:equal(_, [struct(0, 3), struct(1, 4), struct(2, 5)]) + list.index_map([3, 4, 5], fn(i, x) { struct(i, x) }) + |> expect.equal(_, [struct(0, 3), struct(1, 4), struct(2, 5)]) let f = fn(i, x) { - string:append(x, int:to_string(i)) + string.append(x, int.to_string(i)) } - list:index_map(["a", "b", "c"], f) - |> expect:equal(_, ["a0", "b1", "c2"]) + list.index_map(["a", "b", "c"], f) + |> expect.equal(_, ["a0", "b1", "c2"]) } pub fn range_test() { - list:range(0, 0) - |> expect:equal(_, []) + list.range(0, 0) + |> expect.equal(_, []) - list:range(1, 1) - |> expect:equal(_, []) + list.range(1, 1) + |> expect.equal(_, []) - list:range(-1, -1) - |> expect:equal(_, []) + list.range(-1, -1) + |> expect.equal(_, []) - list:range(0, 1) - |> expect:equal(_, [0]) + list.range(0, 1) + |> expect.equal(_, [0]) - list:range(0, 5) - |> expect:equal(_, [0, 1, 2, 3, 4]) + list.range(0, 5) + |> expect.equal(_, [0, 1, 2, 3, 4]) - list:range(1, -5) - |> expect:equal(_, [1, 0, -1, -2, -3, -4]) + list.range(1, -5) + |> expect.equal(_, [1, 0, -1, -2, -3, -4]) } pub fn repeat_test() { - list:repeat(1, -10) - |> expect:equal(_, []) + list.repeat(1, -10) + |> expect.equal(_, []) - list:repeat(1, 0) - |> expect:equal(_, []) + list.repeat(1, 0) + |> expect.equal(_, []) - list:repeat(2, 3) - |> expect:equal(_, [2, 2, 2]) + list.repeat(2, 3) + |> expect.equal(_, [2, 2, 2]) - list:repeat("x", 5) - |> expect:equal(_, ["x", "x", "x", "x", "x"]) + list.repeat("x", 5) + |> expect.equal(_, ["x", "x", "x", "x", "x"]) } pub fn split_test() { - list:split([], 0) - |> expect:equal(_, struct([], [])) + list.split([], 0) + |> expect.equal(_, struct([], [])) - list:split([0, 1, 2, 3, 4], 0) - |> expect:equal(_, struct([], [0, 1, 2, 3, 4])) + list.split([0, 1, 2, 3, 4], 0) + |> expect.equal(_, struct([], [0, 1, 2, 3, 4])) - list:split([0, 1, 2, 3, 4], -2) - |> expect:equal(_, struct([], [0, 1, 2, 3, 4])) + list.split([0, 1, 2, 3, 4], -2) + |> expect.equal(_, struct([], [0, 1, 2, 3, 4])) - list:split([0, 1, 2, 3, 4], 1) - |> expect:equal(_, struct([0], [1, 2, 3, 4])) + list.split([0, 1, 2, 3, 4], 1) + |> expect.equal(_, struct([0], [1, 2, 3, 4])) - list:split([0, 1, 2, 3, 4], 3) - |> expect:equal(_, struct([0, 1, 2], [3, 4])) + list.split([0, 1, 2, 3, 4], 3) + |> expect.equal(_, struct([0, 1, 2], [3, 4])) - list:split([0, 1, 2, 3, 4], 9) - |> expect:equal(_, struct([0, 1, 2, 3, 4], [])) + list.split([0, 1, 2, 3, 4], 9) + |> expect.equal(_, struct([0, 1, 2, 3, 4], [])) } pub fn split_while_test() { - list:split_while([], fn(x) { x <= 5 }) - |> expect:equal(_, struct([], [])) + list.split_while([], fn(x) { x <= 5 }) + |> expect.equal(_, struct([], [])) - list:split_while([1, 2, 3, 4, 5], fn(x) { x <= 5 }) - |> expect:equal(_, struct([1, 2, 3, 4, 5], [])) + list.split_while([1, 2, 3, 4, 5], fn(x) { x <= 5 }) + |> expect.equal(_, struct([1, 2, 3, 4, 5], [])) - list:split_while([1, 2, 3, 4, 5], fn(x) { x == 2 }) - |> expect:equal(_, struct([], [1, 2, 3, 4, 5])) + list.split_while([1, 2, 3, 4, 5], fn(x) { x == 2 }) + |> expect.equal(_, struct([], [1, 2, 3, 4, 5])) - list:split_while([1, 2, 3, 4, 5], fn(x) { x <= 3 }) - |> expect:equal(_, struct([1, 2, 3], [4, 5])) + list.split_while([1, 2, 3, 4, 5], fn(x) { x <= 3 }) + |> expect.equal(_, struct([1, 2, 3], [4, 5])) - list:split_while([1, 2, 3, 4, 5], fn(x) { x <= -3 }) - |> expect:equal(_, struct([], [1, 2, 3, 4, 5])) + list.split_while([1, 2, 3, 4, 5], fn(x) { x <= -3 }) + |> expect.equal(_, struct([], [1, 2, 3, 4, 5])) } diff --git a/test/gleam/map_dict_test.gleam b/test/gleam/map_dict_test.gleam index 2b7dbdb..a258067 100644 --- a/test/gleam/map_dict_test.gleam +++ b/test/gleam/map_dict_test.gleam @@ -7,49 +7,49 @@ pub fn from_list_test() { struct(4, 0), struct(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 [ struct(1, 0), ] - |> map_dict:from_list - |> map_dict:has_key(_, 1) - |> expect:true + |> map_dict.from_list + |> map_dict.has_key(_, 1) + |> expect.true [ struct(4, 0), struct(1, 0), ] - |> map_dict:from_list - |> map_dict:has_key(_, 1) - |> expect:true + |> map_dict.from_list + |> map_dict.has_key(_, 1) + |> expect.true [ struct(4, 0), struct(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.new() + |> map_dict.size + |> expect.equal(_, 0) - map_dict:new() - |> map_dict:to_list - |> expect:equal(_, []) + map_dict.new() + |> map_dict.to_list + |> expect.equal(_, []) } pub fn fetch_test() { @@ -57,27 +57,27 @@ pub fn fetch_test() { struct(4, 0), struct(1, 1), ] - let m = map_dict:from_list(proplist) + 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([ + map_dict.new() + |> map_dict.put(_, "a", 0) + |> map_dict.put(_, "b", 1) + |> map_dict.put(_, "c", 2) + |> expect.equal(_, map_dict.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_dict.from_list + |> map_dict.map_values(_, fn(k, v) { k + v }) + |> expect.equal(_, map_dict.from_list([ struct(1, 1), struct(2, 3), struct(3, 5), @@ -105,9 +105,9 @@ pub fn keys_test() { struct("b", 1), struct("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() { @@ -116,9 +116,9 @@ pub fn values_test() { struct("b", 1), struct("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() { @@ -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_dict.from_list + |> map_dict.take(_, ["a", "b", "d"]) + |> expect.equal(_, map_dict.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_dict.from_list + |> map_dict.drop(_, ["a", "b", "d"]) + |> expect.equal(_, map_dict.from_list([struct("c", 2)])) } pub fn merge_test() { - let a = map_dict:from_list([ + let a = map_dict.from_list([ struct("a", 2), struct("c", 4), struct("d", 3), ]) - let b = map_dict:from_list([ + let b = map_dict.from_list([ struct("a", 0), struct("b", 1), struct("c", 2), ]) - map_dict:merge(a, b) - |> expect:equal(_, map_dict:from_list([ + map_dict.merge(a, b) + |> expect.equal(_, map_dict.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_dict.merge(b, a) + |> expect.equal(_, map_dict.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_dict.from_list + |> map_dict.delete(_, "a") + |> map_dict.delete(_, "d") + |> expect.equal(_, map_dict.from_list([struct("b", 1), struct("c", 2)])) } pub fn update_test() { - let dict = map_dict:from_list([ + let dict = map_dict.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_dict.update(_, "a", inc_or_zero) + |> expect.equal(_, map_dict.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_dict.update(_, "b", inc_or_zero) + |> expect.equal(_, map_dict.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_dict.update(_, "z", inc_or_zero) + |> expect.equal(_, map_dict.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_dict.from_list([ struct("a", 0), struct("b", 1), struct("c", 2), @@ -237,18 +237,18 @@ pub fn fold_test() { } dict - |> map_dict:fold(_, 0, add) - |> expect:equal(_, 6) + |> map_dict.fold(_, 0, add) + |> expect.equal(_, 6) let concat = fn(k, _, acc) { - string:append(acc, k) + string.append(acc, k) } dict - |> map_dict:fold(_, "", concat) - |> expect:equal(_, "abcd") + |> map_dict.fold(_, "", concat) + |> expect.equal(_, "abcd") - map_dict:from_list([]) - |> map_dict:fold(_, 0, add) - |> expect:equal(_, 0) + map_dict.from_list([]) + |> map_dict.fold(_, 0, add) + |> expect.equal(_, 0) } diff --git a/test/gleam/order_test.gleam b/test/gleam/order_test.gleam index 2127b9f..58f1d4e 100644 --- a/test/gleam/order_test.gleam +++ b/test/gleam/order_test.gleam @@ -2,110 +2,110 @@ import gleam/expect import gleam/order pub fn reverse_test() { - order:reverse(order:Lt) - |> expect:equal(_, order:Gt) + order.reverse(order.Lt) + |> expect.equal(_, order.Gt) - order:reverse(order:Eq) - |> expect:equal(_, order:Eq) + order.reverse(order.Eq) + |> expect.equal(_, order.Eq) - order:reverse(order:Gt) - |> expect:equal(_, order:Lt) + order.reverse(order.Gt) + |> expect.equal(_, order.Lt) } pub fn to_int_test() { - order:to_int(order:Lt) - |> expect:equal(_, -1) + order.to_int(order.Lt) + |> expect.equal(_, -1) - order:to_int(order:Eq) - |> expect:equal(_, 0) + order.to_int(order.Eq) + |> expect.equal(_, 0) - order:to_int(order:Gt) - |> expect:equal(_, 1) + order.to_int(order.Gt) + |> expect.equal(_, 1) } pub fn compare_test() { - order:compare(order:Lt, order:Lt) - |> expect:equal(_, order:Eq) + order.compare(order.Lt, order.Lt) + |> expect.equal(_, order.Eq) - order:compare(order:Lt, order:Eq) - |> expect:equal(_, order:Lt) + order.compare(order.Lt, order.Eq) + |> expect.equal(_, order.Lt) - order:compare(order:Lt, order:Gt) - |> expect:equal(_, order:Lt) + order.compare(order.Lt, order.Gt) + |> expect.equal(_, order.Lt) - order:compare(order:Eq, order:Lt) - |> expect:equal(_, order:Gt) + order.compare(order.Eq, order.Lt) + |> expect.equal(_, order.Gt) - order:compare(order:Eq, order:Eq) - |> expect:equal(_, order:Eq) + order.compare(order.Eq, order.Eq) + |> expect.equal(_, order.Eq) - order:compare(order:Eq, order:Gt) - |> expect:equal(_, order:Lt) + order.compare(order.Eq, order.Gt) + |> expect.equal(_, order.Lt) - order:compare(order:Gt, order:Lt) - |> expect:equal(_, order:Gt) + order.compare(order.Gt, order.Lt) + |> expect.equal(_, order.Gt) - order:compare(order:Gt, order:Eq) - |> expect:equal(_, order:Gt) + order.compare(order.Gt, order.Eq) + |> expect.equal(_, order.Gt) - order:compare(order:Gt, order:Gt) - |> expect:equal(_, order:Eq) + order.compare(order.Gt, order.Gt) + |> expect.equal(_, order.Eq) } pub fn max_test() { - order:max(order:Lt, order:Lt) - |> expect:equal(_, order:Lt) + order.max(order.Lt, order.Lt) + |> expect.equal(_, order.Lt) - order:max(order:Lt, order:Eq) - |> expect:equal(_, order:Eq) + order.max(order.Lt, order.Eq) + |> expect.equal(_, order.Eq) - order:max(order:Lt, order:Gt) - |> expect:equal(_, order:Gt) + order.max(order.Lt, order.Gt) + |> expect.equal(_, order.Gt) - order:max(order:Eq, order:Lt) - |> expect:equal(_, order:Eq) + order.max(order.Eq, order.Lt) + |> expect.equal(_, order.Eq) - order:max(order:Eq, order:Eq) - |> 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, order.Gt) + |> expect.equal(_, order.Gt) - order:max(order:Gt, order:Lt) - |> expect:equal(_, order:Gt) + order.max(order.Gt, order.Lt) + |> expect.equal(_, order.Gt) - order:max(order:Gt, order:Eq) - |> expect:equal(_, order:Gt) + order.max(order.Gt, order.Eq) + |> expect.equal(_, order.Gt) - order:max(order:Gt, order:Gt) - |> expect:equal(_, order:Gt) + order.max(order.Gt, order.Gt) + |> expect.equal(_, order.Gt) } pub fn min_test() { - order:min(order:Lt, order:Lt) - |> expect:equal(_, order:Lt) + order.min(order.Lt, order.Lt) + |> expect.equal(_, order.Lt) - order:min(order:Lt, order:Eq) - |> expect:equal(_, order:Lt) + order.min(order.Lt, order.Eq) + |> expect.equal(_, order.Lt) - order:min(order:Lt, order:Gt) - |> expect:equal(_, order:Lt) + order.min(order.Lt, order.Gt) + |> expect.equal(_, order.Lt) - order:min(order:Eq, order:Lt) - |> expect:equal(_, order:Lt) + order.min(order.Eq, order.Lt) + |> expect.equal(_, order.Lt) - order:min(order:Eq, order:Eq) - |> expect:equal(_, order:Eq) + order.min(order.Eq, order.Eq) + |> expect.equal(_, order.Eq) - order:min(order:Eq, order:Gt) - |> expect:equal(_, order:Eq) + order.min(order.Eq, order.Gt) + |> expect.equal(_, order.Eq) - order:min(order:Gt, order:Lt) - |> expect:equal(_, order:Lt) + order.min(order.Gt, order.Lt) + |> expect.equal(_, order.Lt) - order:min(order:Gt, order:Eq) - |> expect:equal(_, order:Eq) + order.min(order.Gt, order.Eq) + |> expect.equal(_, order.Eq) - order:min(order:Gt, order:Gt) - |> expect:equal(_, order:Gt) + order.min(order.Gt, order.Gt) + |> expect.equal(_, order.Gt) } diff --git a/test/gleam/result_test.gleam b/test/gleam/result_test.gleam index c513665..10d2cf6 100644 --- a/test/gleam/result_test.gleam +++ b/test/gleam/result_test.gleam @@ -2,87 +2,87 @@ import gleam/expect import gleam/result pub fn is_ok_test() { - result:is_ok(Ok(1)) - |> expect:true + result.is_ok(Ok(1)) + |> expect.true - result:is_ok(Error(1)) - |> expect:false + result.is_ok(Error(1)) + |> expect.false } pub fn is_error_test() { - result:is_error(Ok(1)) - |> expect:false + result.is_error(Ok(1)) + |> expect.false - result:is_error(Error(1)) - |> expect:true + result.is_error(Error(1)) + |> expect.true } pub fn map_test() { Ok(1) - |> result:map(_, fn(x) { x + 1 }) - |> expect:equal(_, Ok(2)) + |> result.map(_, fn(x) { x + 1 }) + |> expect.equal(_, Ok(2)) Ok(1) - |> result:map(_, fn(_) { "2" }) - |> expect:equal(_, Ok("2")) + |> result.map(_, fn(_) { "2" }) + |> expect.equal(_, Ok("2")) Error(1) - |> result:map(_, fn(x) { x + 1 }) - |> expect:equal(_, Error(1)) + |> result.map(_, fn(x) { x + 1 }) + |> expect.equal(_, Error(1)) } pub fn map_error_test() { Ok(1) - |> result:map_error(_, fn(x) { x + 1 }) - |> expect:equal(_, Ok(1)) + |> result.map_error(_, fn(x) { x + 1 }) + |> expect.equal(_, Ok(1)) Error(1) - |> result:map_error(_, fn(x) { struct("ok", x + 1) }) - |> expect:equal(_, Error(struct("ok", 2))) + |> result.map_error(_, fn(x) { struct("ok", x + 1) }) + |> expect.equal(_, Error(struct("ok", 2))) } pub fn flatten_test() { Ok(Ok(1)) - |> result:flatten - |> expect:equal(_, Ok(1)) + |> result.flatten + |> expect.equal(_, Ok(1)) Ok(Error(1)) - |> result:flatten - |> expect:equal(_, Error(1)) + |> result.flatten + |> expect.equal(_, Error(1)) Error(1) - |> result:flatten - |> expect:equal(_, Error(1)) + |> result.flatten + |> expect.equal(_, Error(1)) Error(Error(1)) - |> result:flatten - |> expect:equal(_, Error(Error(1))) + |> result.flatten + |> expect.equal(_, Error(Error(1))) } pub fn then_test() { Error(1) - |> result:then(_, fn(x) { Ok(x + 1) }) - |> expect:equal(_, Error(1)) + |> result.then(_, fn(x) { Ok(x + 1) }) + |> expect.equal(_, Error(1)) Ok(1) - |> result:then(_, fn(x) { Ok(x + 1) }) - |> expect:equal(_, Ok(2)) + |> result.then(_, fn(x) { Ok(x + 1) }) + |> expect.equal(_, Ok(2)) Ok(1) - |> result:then(_, fn(_) { Ok("type change") }) - |> expect:equal(_, Ok("type change")) + |> result.then(_, fn(_) { Ok("type change") }) + |> expect.equal(_, Ok("type change")) Ok(1) - |> result:then(_, fn(_) { Error(1) }) - |> expect:equal(_, Error(1)) + |> result.then(_, fn(_) { Error(1) }) + |> expect.equal(_, Error(1)) } pub fn unwrap_test() { Ok(1) - |> result:unwrap(_, 50) - |> expect:equal(_, 1) + |> result.unwrap(_, 50) + |> expect.equal(_, 1) Error("nope") - |> result:unwrap(_, 50) - |> expect:equal(_, 50) + |> result.unwrap(_, 50) + |> expect.equal(_, 50) } diff --git a/test/gleam/string_test.gleam b/test/gleam/string_test.gleam index 2a48278..7487686 100644 --- a/test/gleam/string_test.gleam +++ b/test/gleam/string_test.gleam @@ -2,49 +2,49 @@ import gleam/string import gleam/expect pub fn length_test() { - string:length("ß↑e̊") - |> expect:equal(_, 3) + string.length("ß↑e̊") + |> expect.equal(_, 3) - string:length("Gleam") - |> expect:equal(_, 5) + string.length("Gleam") + |> expect.equal(_, 5) - string:length("") - |> expect:equal(_, 0) + string.length("") + |> expect.equal(_, 0) } pub fn lowercase_test() { - string:lowercase("Gleam") - |> expect:equal(_, "gleam") + string.lowercase("Gleam") + |> expect.equal(_, "gleam") } pub fn uppercase_test() { - string:uppercase("Gleam") - |> expect:equal(_, "GLEAM") + string.uppercase("Gleam") + |> expect.equal(_, "GLEAM") } pub fn reverse_test() { - string:reverse("Gleam") - |> expect:equal(_, "maelG") + string.reverse("Gleam") + |> expect.equal(_, "maelG") } pub fn split_test() { "Gleam,Erlang,Elixir" - |> string:split(_, ",") - |> expect:equal(_, ["Gleam", "Erlang", "Elixir"]) + |> string.split(_, ",") + |> expect.equal(_, ["Gleam", "Erlang", "Elixir"]) "Gleam, Erlang,Elixir" - |> string:split(_, ", ") - |> expect:equal(_, ["Gleam", "Erlang,Elixir"]) + |> string.split(_, ", ") + |> expect.equal(_, ["Gleam", "Erlang,Elixir"]) } pub fn replace_test() { "Gleam,Erlang,Elixir" - |> string:replace(_, ",", "++") - |> expect:equal(_, "Gleam++Erlang++Elixir") + |> string.replace(_, ",", "++") + |> expect.equal(_, "Gleam++Erlang++Elixir") } pub fn append_test() { "Test" - |> string:append(_, " Me") - |> expect:equal(_, "Test Me") + |> string.append(_, " Me") + |> expect.equal(_, "Test Me") } diff --git a/test/gleam/tuple_test.gleam b/test/gleam/tuple_test.gleam index 398967b..4876241 100644 --- a/test/gleam/tuple_test.gleam +++ b/test/gleam/tuple_test.gleam @@ -2,43 +2,43 @@ import gleam/expect import gleam/tuple pub fn new_test() { - tuple:new(1, 2) - |> expect:equal(_, struct(1, 2)) + tuple.new(1, 2) + |> expect.equal(_, struct(1, 2)) - tuple:new(2, "3") - |> expect:equal(_, struct(2, "3")) + tuple.new(2, "3") + |> expect.equal(_, struct(2, "3")) } pub fn first_test() { struct(1, 2) - |> tuple:first - |> expect:equal(_, 1) + |> tuple.first + |> expect.equal(_, 1) } pub fn second_test() { struct(1, 2) - |> tuple:second - |> expect:equal(_, 2) + |> tuple.second + |> expect.equal(_, 2) } pub fn swap_test() { struct(1, "2") - |> tuple:swap - |> expect:equal(_, struct("2", 1)) + |> tuple.swap + |> expect.equal(_, struct("2", 1)) } pub fn fetch_test() { let proplist = [struct(0, "1"), struct(1, "2")] proplist - |> tuple:fetch(_, 0) - |> expect:equal(_, Ok("1")) + |> tuple.fetch(_, 0) + |> expect.equal(_, Ok("1")) proplist - |> tuple:fetch(_, 1) - |> expect:equal(_, Ok("2")) + |> tuple.fetch(_, 1) + |> expect.equal(_, Ok("2")) proplist - |> tuple:fetch(_, 2) - |> expect:is_error + |> tuple.fetch(_, 2) + |> expect.is_error } |