diff options
author | Louis Pilfold <louis@lpil.uk> | 2023-12-17 18:36:58 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2023-12-17 18:36:58 +0000 |
commit | f699cef00e70443c270a7c48b45b9df64b2489e1 (patch) | |
tree | e7e1f4d13c0bfb6564dba665b885eb33255204ce /test | |
parent | 78980c30429d4aee2c77dbbb068bfe0d153d32ad (diff) | |
download | gleam_stdlib-f699cef00e70443c270a7c48b45b9df64b2489e1.tar.gz gleam_stdlib-f699cef00e70443c270a7c48b45b9df64b2489e1.zip |
Update version
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam/dynamic_test.gleam | 638 | ||||
-rw-r--r-- | test/gleam/iterator_test.gleam | 7 | ||||
-rw-r--r-- | test/gleam/list_test.gleam | 130 | ||||
-rw-r--r-- | test/gleam/regex_test.gleam | 9 | ||||
-rw-r--r-- | test/gleam/should.gleam | 28 | ||||
-rw-r--r-- | test/gleam/string_builder_test.gleam | 10 | ||||
-rw-r--r-- | test/gleam/string_test.gleam | 3 | ||||
-rw-r--r-- | test/gleam/uri_test.gleam | 160 |
8 files changed, 529 insertions, 456 deletions
diff --git a/test/gleam/dynamic_test.gleam b/test/gleam/dynamic_test.gleam index c072756..732949a 100644 --- a/test/gleam/dynamic_test.gleam +++ b/test/gleam/dynamic_test.gleam @@ -18,16 +18,16 @@ pub fn bit_array_test() { 1 |> dynamic.from |> dynamic.bit_array - |> should.equal(Error([ - DecodeError(expected: "BitArray", found: "Int", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "BitArray", found: "Int", path: [])]), + ) [] |> dynamic.from |> dynamic.bit_array - |> should.equal(Error([ - DecodeError(expected: "BitArray", found: "List", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "BitArray", found: "List", path: [])]), + ) } @target(erlang) @@ -60,7 +60,8 @@ pub fn map_from_atom_test() { ThisIsAnAtom |> dynamic.from |> dynamic.map(dynamic.string, dynamic.int) - |> should.equal(Error([DecodeError(expected: "Map", found: "Atom", path: [])])) + |> should.equal(Error([DecodeError(expected: "Map", found: "Atom", path: [])]), + ) } @target(javascript) @@ -72,7 +73,8 @@ pub fn map_from_null_test() { get_null() |> dynamic.from |> dynamic.map(dynamic.string, dynamic.int) - |> should.equal(Error([DecodeError(expected: "Map", found: "Null", path: [])])) + |> should.equal(Error([DecodeError(expected: "Map", found: "Null", path: [])]), + ) } pub fn string_test() { @@ -89,16 +91,16 @@ pub fn string_test() { 1 |> dynamic.from |> dynamic.string - |> should.equal(Error([ - DecodeError(expected: "String", found: "Int", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "String", found: "Int", path: [])]), + ) [] |> dynamic.from |> dynamic.string - |> should.equal(Error([ - DecodeError(expected: "String", found: "List", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "String", found: "List", path: [])]), + ) } @target(erlang) @@ -106,9 +108,9 @@ pub fn string_non_utf8_test() { <<65_535:16>> |> dynamic.from |> dynamic.string - |> should.equal(Error([ - DecodeError(expected: "String", found: "BitArray", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "String", found: "BitArray", path: [])]), + ) } pub fn int_test() { @@ -125,7 +127,8 @@ pub fn int_test() { [] |> dynamic.from |> dynamic.int - |> should.equal(Error([DecodeError(expected: "Int", found: "List", path: [])])) + |> should.equal(Error([DecodeError(expected: "Int", found: "List", path: [])]), + ) } pub fn float_test() { @@ -142,9 +145,9 @@ pub fn float_test() { [] |> dynamic.from |> dynamic.float - |> should.equal(Error([ - DecodeError(expected: "Float", found: "List", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "Float", found: "List", path: [])]), + ) } @target(erlang) @@ -152,12 +155,16 @@ pub fn float_on_js_is_also_int_test() { 1 |> dynamic.from |> dynamic.float - |> should.equal(Error([DecodeError(expected: "Float", found: "Int", path: [])])) + |> should.equal( + Error([DecodeError(expected: "Float", found: "Int", path: [])]), + ) 1.0 |> dynamic.from |> dynamic.int - |> should.equal(Error([DecodeError(expected: "Int", found: "Float", path: [])])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "Float", path: [])]), + ) } @target(javascript) @@ -187,19 +194,22 @@ pub fn bool_test() { 1 |> dynamic.from |> dynamic.bool - |> should.equal(Error([DecodeError(expected: "Bool", found: "Int", path: [])])) + |> should.equal(Error([DecodeError(expected: "Bool", found: "Int", path: [])]), + ) 1.5 |> dynamic.from |> dynamic.bool - |> should.equal(Error([ - DecodeError(expected: "Bool", found: "Float", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "Bool", found: "Float", path: [])]), + ) [] |> dynamic.from |> dynamic.bool - |> should.equal(Error([DecodeError(expected: "Bool", found: "List", path: [])])) + |> should.equal( + Error([DecodeError(expected: "Bool", found: "List", path: [])]), + ) } pub fn list_test() { @@ -226,28 +236,29 @@ pub fn list_test() { 1 |> dynamic.from |> dynamic.list(dynamic.string) - |> should.equal(Error([DecodeError(expected: "List", found: "Int", path: [])])) + |> should.equal(Error([DecodeError(expected: "List", found: "Int", path: [])]), + ) 1.1 |> dynamic.from |> dynamic.list(dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "List", found: "Float", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "List", found: "Float", path: [])]), + ) [""] |> dynamic.from |> dynamic.list(dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["*"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["*"])]), + ) [dynamic.from(1), dynamic.from("not an int")] |> dynamic.from |> dynamic.list(dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["*"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["*"])]), + ) } pub fn optional_test() { @@ -287,9 +298,9 @@ pub fn javascript_object_field_test() { Ok(123) |> dynamic.from |> dynamic.field("Nope", dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Map", found: "Result", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "Map", found: "Result", path: [])]), + ) } pub fn field_test() { @@ -316,16 +327,16 @@ pub fn field_test() { |> dict.insert("ok", 3) |> dynamic.from |> dynamic.field("ok", dynamic.string) - |> should.equal(Error([ - DecodeError(expected: "String", found: "Int", path: ["ok"]), - ])) + |> should.equal( + Error([DecodeError(expected: "String", found: "Int", path: ["ok"])]), + ) dict.new() |> dynamic.from |> dynamic.field("ok", dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "field", found: "nothing", path: ["ok"]), - ])) + |> should.equal( + Error([DecodeError(expected: "field", found: "nothing", path: ["ok"])]), + ) 1 |> dynamic.from @@ -335,15 +346,16 @@ pub fn field_test() { [] |> dynamic.from |> dynamic.field("ok", dynamic.int) - |> should.equal(Error([DecodeError(expected: "Map", found: "List", path: [])])) + |> should.equal(Error([DecodeError(expected: "Map", found: "List", path: [])]), + ) dict.new() |> dict.insert("ok", 1) |> dynamic.from |> dynamic.field("ok", dynamic.field("not_a_field", dynamic.int)) - |> should.equal(Error([ - DecodeError(expected: "Map", found: "Int", path: ["ok"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Map", found: "Int", path: ["ok"])]), + ) } pub fn optional_field_test() { @@ -370,9 +382,9 @@ pub fn optional_field_test() { |> dict.insert("ok", 3) |> dynamic.from |> dynamic.optional_field("ok", dynamic.string) - |> should.equal(Error([ - DecodeError(expected: "String", found: "Int", path: ["ok"]), - ])) + |> should.equal( + Error([DecodeError(expected: "String", found: "Int", path: ["ok"])]), + ) dict.new() |> dict.insert("ok", None) @@ -399,7 +411,8 @@ pub fn optional_field_test() { [] |> dynamic.from |> dynamic.optional_field("ok", dynamic.int) - |> should.equal(Error([DecodeError(expected: "Map", found: "List", path: [])])) + |> should.equal(Error([DecodeError(expected: "Map", found: "List", path: [])]), + ) } pub fn element_test() { @@ -418,20 +431,22 @@ pub fn element_test() { ok_one_tuple |> dynamic.from |> dynamic.element(1, dynamic.string) - |> should.equal(Error([ - DecodeError(expected: "String", found: "Int", path: ["1"]), - ])) + |> should.equal( + Error([DecodeError(expected: "String", found: "Int", path: ["1"])]), + ) ok_one_tuple |> dynamic.from |> dynamic.element(2, dynamic.int) - |> should.equal(Error([ - DecodeError( - path: [], - expected: "Tuple of at least 3 elements", - found: "Tuple of 2 elements", - ), - ])) + |> should.equal( + Error([ + DecodeError( + path: [], + expected: "Tuple of at least 3 elements", + found: "Tuple of 2 elements", + ), + ]), + ) ok_one_tuple |> dynamic.from @@ -441,29 +456,37 @@ pub fn element_test() { ok_one_tuple |> dynamic.from |> dynamic.element(-3, dynamic.int) - |> should.equal(Error([ - DecodeError( - path: [], - expected: "Tuple of at least 3 elements", - found: "Tuple of 2 elements", - ), - ])) + |> should.equal( + Error([ + DecodeError( + path: [], + expected: "Tuple of at least 3 elements", + found: "Tuple of 2 elements", + ), + ]), + ) 1 |> dynamic.from |> dynamic.element(-3, dynamic.int) - |> should.equal(Error([DecodeError(expected: "Tuple", found: "Int", path: [])])) + |> should.equal( + Error([DecodeError(expected: "Tuple", found: "Int", path: [])]), + ) 1 |> dynamic.from |> dynamic.element(0, dynamic.int) - |> should.equal(Error([DecodeError(expected: "Tuple", found: "Int", path: [])])) + |> should.equal( + Error([DecodeError(expected: "Tuple", found: "Int", path: [])]), + ) dict.new() |> dict.insert(1, "ok") |> dynamic.from |> dynamic.element(0, dynamic.int) - |> should.equal(Error([DecodeError(expected: "Tuple", found: "Map", path: [])])) + |> should.equal( + Error([DecodeError(expected: "Tuple", found: "Map", path: [])]), + ) } pub fn tuple2_test() { @@ -480,35 +503,39 @@ pub fn tuple2_test() { #(1, "") |> dynamic.from |> dynamic.tuple2(dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["1"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["1"])]), + ) #(1.2, "") |> dynamic.from |> dynamic.tuple2(dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + ]), + ) #(1, 2, 3) |> dynamic.from |> dynamic.tuple2(dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError( - path: [], - expected: "Tuple of 2 elements", - found: "Tuple of 3 elements", - ), - ])) + |> should.equal( + Error([ + DecodeError( + path: [], + expected: "Tuple of 2 elements", + found: "Tuple of 3 elements", + ), + ]), + ) 1 |> dynamic.from |> dynamic.tuple2(dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 2 elements", found: "Int"), - ])) + |> should.equal( + Error([DecodeError(path: [], expected: "Tuple of 2 elements", found: "Int")]), + ) [1, 2] |> dynamic.from @@ -523,24 +550,30 @@ pub fn tuple2_test() { ["", ""] |> dynamic.from |> dynamic.tuple2(dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "String", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + ]), + ) [1, 2, 3] |> dynamic.from |> dynamic.tuple2(dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 2 elements", found: "List"), - ])) + |> should.equal( + Error([ + DecodeError(path: [], expected: "Tuple of 2 elements", found: "List"), + ]), + ) [] |> dynamic.from |> dynamic.tuple2(dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 2 elements", found: "List"), - ])) + |> should.equal( + Error([ + DecodeError(path: [], expected: "Tuple of 2 elements", found: "List"), + ]), + ) } pub fn tuple3_test() { @@ -567,52 +600,60 @@ pub fn tuple3_test() { #(1, 2, "") |> dynamic.from |> dynamic.tuple3(dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["2"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["2"])]), + ) #(1.2, "", "") |> dynamic.from |> dynamic.tuple3(dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - DecodeError(expected: "Int", found: "String", path: ["2"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + DecodeError(expected: "Int", found: "String", path: ["2"]), + ]), + ) #(1, 2) |> dynamic.from |> dynamic.tuple3(dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError( - path: [], - expected: "Tuple of 3 elements", - found: "Tuple of 2 elements", - ), - ])) + |> should.equal( + Error([ + DecodeError( + path: [], + expected: "Tuple of 3 elements", + found: "Tuple of 2 elements", + ), + ]), + ) ["", "", ""] |> dynamic.from |> dynamic.tuple3(dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - DecodeError(expected: "Int", found: "String", path: ["2"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "String", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + DecodeError(expected: "Int", found: "String", path: ["2"]), + ]), + ) [1, 2] |> dynamic.from |> dynamic.tuple3(dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 3 elements", found: "List"), - ])) + |> should.equal( + Error([ + DecodeError(path: [], expected: "Tuple of 3 elements", found: "List"), + ]), + ) 1 |> dynamic.from |> dynamic.tuple3(dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 3 elements", found: "Int"), - ])) + |> should.equal( + Error([DecodeError(path: [], expected: "Tuple of 3 elements", found: "Int")]), + ) } pub fn tuple4_test() { @@ -639,54 +680,62 @@ pub fn tuple4_test() { #(1, 2, 3, "") |> dynamic.from |> dynamic.tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["3"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["3"])]), + ) #(1.2, "", "", "") |> dynamic.from |> dynamic.tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - DecodeError(expected: "Int", found: "String", path: ["2"]), - DecodeError(expected: "Int", found: "String", path: ["3"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + DecodeError(expected: "Int", found: "String", path: ["2"]), + DecodeError(expected: "Int", found: "String", path: ["3"]), + ]), + ) #(1, 2) |> dynamic.from |> dynamic.tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError( - path: [], - expected: "Tuple of 4 elements", - found: "Tuple of 2 elements", - ), - ])) + |> should.equal( + Error([ + DecodeError( + path: [], + expected: "Tuple of 4 elements", + found: "Tuple of 2 elements", + ), + ]), + ) ["", "", "", ""] |> dynamic.from |> dynamic.tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - DecodeError(expected: "Int", found: "String", path: ["2"]), - DecodeError(expected: "Int", found: "String", path: ["3"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "String", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + DecodeError(expected: "Int", found: "String", path: ["2"]), + DecodeError(expected: "Int", found: "String", path: ["3"]), + ]), + ) [1, 2] |> dynamic.from |> dynamic.tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 4 elements", found: "List"), - ])) + |> should.equal( + Error([ + DecodeError(path: [], expected: "Tuple of 4 elements", found: "List"), + ]), + ) 1 |> dynamic.from |> dynamic.tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 4 elements", found: "Int"), - ])) + |> should.equal( + Error([DecodeError(path: [], expected: "Tuple of 4 elements", found: "Int")]), + ) } pub fn tuple5_test() { @@ -749,9 +798,9 @@ pub fn tuple5_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["4"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["4"])]), + ) #(1.2, "", "", "", "") |> dynamic.from @@ -762,13 +811,15 @@ pub fn tuple5_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - DecodeError(expected: "Int", found: "String", path: ["2"]), - DecodeError(expected: "Int", found: "String", path: ["3"]), - DecodeError(expected: "Int", found: "String", path: ["4"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + DecodeError(expected: "Int", found: "String", path: ["2"]), + DecodeError(expected: "Int", found: "String", path: ["3"]), + DecodeError(expected: "Int", found: "String", path: ["4"]), + ]), + ) #(1, 2) |> dynamic.from @@ -779,13 +830,15 @@ pub fn tuple5_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError( - path: [], - expected: "Tuple of 5 elements", - found: "Tuple of 2 elements", - ), - ])) + |> should.equal( + Error([ + DecodeError( + path: [], + expected: "Tuple of 5 elements", + found: "Tuple of 2 elements", + ), + ]), + ) ["", "", "", "", ""] |> dynamic.from @@ -796,13 +849,15 @@ pub fn tuple5_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - DecodeError(expected: "Int", found: "String", path: ["2"]), - DecodeError(expected: "Int", found: "String", path: ["3"]), - DecodeError(expected: "Int", found: "String", path: ["4"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "String", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + DecodeError(expected: "Int", found: "String", path: ["2"]), + DecodeError(expected: "Int", found: "String", path: ["3"]), + DecodeError(expected: "Int", found: "String", path: ["4"]), + ]), + ) [1, 2] |> dynamic.from @@ -813,9 +868,11 @@ pub fn tuple5_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 5 elements", found: "List"), - ])) + |> should.equal( + Error([ + DecodeError(path: [], expected: "Tuple of 5 elements", found: "List"), + ]), + ) 1 |> dynamic.from @@ -826,9 +883,9 @@ pub fn tuple5_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 5 elements", found: "Int"), - ])) + |> should.equal( + Error([DecodeError(path: [], expected: "Tuple of 5 elements", found: "Int")]), + ) } pub fn tuple6_test() { @@ -897,9 +954,9 @@ pub fn tuple6_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["5"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["5"])]), + ) #(1.2, "", "", "", "", "") |> dynamic.from @@ -911,14 +968,16 @@ pub fn tuple6_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - DecodeError(expected: "Int", found: "String", path: ["2"]), - DecodeError(expected: "Int", found: "String", path: ["3"]), - DecodeError(expected: "Int", found: "String", path: ["4"]), - DecodeError(expected: "Int", found: "String", path: ["5"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + DecodeError(expected: "Int", found: "String", path: ["2"]), + DecodeError(expected: "Int", found: "String", path: ["3"]), + DecodeError(expected: "Int", found: "String", path: ["4"]), + DecodeError(expected: "Int", found: "String", path: ["5"]), + ]), + ) #(1, 2) |> dynamic.from @@ -930,13 +989,15 @@ pub fn tuple6_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError( - path: [], - expected: "Tuple of 6 elements", - found: "Tuple of 2 elements", - ), - ])) + |> should.equal( + Error([ + DecodeError( + path: [], + expected: "Tuple of 6 elements", + found: "Tuple of 2 elements", + ), + ]), + ) ["", "", "", "", "", ""] |> dynamic.from @@ -948,14 +1009,16 @@ pub fn tuple6_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["0"]), - DecodeError(expected: "Int", found: "String", path: ["1"]), - DecodeError(expected: "Int", found: "String", path: ["2"]), - DecodeError(expected: "Int", found: "String", path: ["3"]), - DecodeError(expected: "Int", found: "String", path: ["4"]), - DecodeError(expected: "Int", found: "String", path: ["5"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "String", path: ["0"]), + DecodeError(expected: "Int", found: "String", path: ["1"]), + DecodeError(expected: "Int", found: "String", path: ["2"]), + DecodeError(expected: "Int", found: "String", path: ["3"]), + DecodeError(expected: "Int", found: "String", path: ["4"]), + DecodeError(expected: "Int", found: "String", path: ["5"]), + ]), + ) [1, 2] |> dynamic.from @@ -967,9 +1030,11 @@ pub fn tuple6_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 6 elements", found: "List"), - ])) + |> should.equal( + Error([ + DecodeError(path: [], expected: "Tuple of 6 elements", found: "List"), + ]), + ) 1 |> dynamic.from @@ -981,9 +1046,9 @@ pub fn tuple6_test() { dynamic.int, dynamic.int, ) - |> should.equal(Error([ - DecodeError(path: [], expected: "Tuple of 6 elements", found: "Int"), - ])) + |> should.equal( + Error([DecodeError(path: [], expected: "Tuple of 6 elements", found: "Int")]), + ) } pub fn nested_tuples_test() { @@ -993,9 +1058,9 @@ pub fn nested_tuples_test() { dynamic.int, dynamic.tuple2(dynamic.int, dynamic.tuple2(dynamic.int, dynamic.int)), ) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["1", "1", "0"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["1", "1", "0"])]), + ) } pub fn map_test() { @@ -1012,16 +1077,16 @@ pub fn map_test() { dict.from_list([#("a", 1), #("b", 2)]) |> dynamic.from |> dynamic.map(dynamic.int, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["keys"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["keys"])]), + ) dict.from_list([#("a", 1), #("b", 2)]) |> dynamic.from |> dynamic.map(dynamic.string, dynamic.string) - |> should.equal(Error([ - DecodeError(expected: "String", found: "Int", path: ["values"]), - ])) + |> should.equal( + Error([DecodeError(expected: "String", found: "Int", path: ["values"])]), + ) 1 |> dynamic.from @@ -1031,16 +1096,16 @@ pub fn map_test() { #() |> dynamic.from |> dynamic.map(dynamic.string, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Map", found: "Tuple of 0 elements", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "Map", found: "Tuple of 0 elements", path: [])]), + ) fn() { Nil } |> dynamic.from |> dynamic.map(dynamic.string, dynamic.int) - |> should.equal(Error([ - DecodeError(expected: "Map", found: "Function", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "Map", found: "Function", path: [])]), + ) Nil |> dynamic.from @@ -1067,7 +1132,8 @@ pub fn shallow_list_test() { 1 |> dynamic.from |> dynamic.shallow_list - |> should.equal(Error([DecodeError(expected: "List", found: "Int", path: [])])) + |> should.equal(Error([DecodeError(expected: "List", found: "Int", path: [])]), + ) } @target(javascript) @@ -1097,23 +1163,23 @@ pub fn result_test() { Ok("1") |> dynamic.from |> dynamic.result(ok: dynamic.int, error: dynamic.string) - |> should.equal(Error([ - DecodeError(expected: "Int", found: "String", path: ["ok"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "String", path: ["ok"])]), + ) Error(1) |> dynamic.from |> dynamic.result(ok: dynamic.int, error: dynamic.string) - |> should.equal(Error([ - DecodeError(expected: "String", found: "Int", path: ["error"]), - ])) + |> should.equal( + Error([DecodeError(expected: "String", found: "Int", path: ["error"])]), + ) 1 |> dynamic.from |> dynamic.result(ok: dynamic.int, error: dynamic.string) - |> should.equal(Error([ - DecodeError(expected: "Result", found: "Int", path: []), - ])) + |> should.equal( + Error([DecodeError(expected: "Result", found: "Int", path: [])]), + ) } pub fn any_test() { @@ -1154,9 +1220,9 @@ pub fn decode1_test() { #(1.3) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - ])) + |> should.equal( + Error([DecodeError(expected: "Int", found: "Float", path: ["0"])]), + ) } type Two(a, b) { @@ -1179,10 +1245,12 @@ pub fn decode2_test() { #(1.3, 2) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "String", found: "Int", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "String", found: "Int", path: ["1"]), + ]), + ) } type Three(a, b, c) { @@ -1206,10 +1274,12 @@ pub fn decode3_test() { #(1.3, 2.1, 3) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "String", found: "Float", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "String", found: "Float", path: ["1"]), + ]), + ) } type Four(a, b, c, d) { @@ -1234,10 +1304,12 @@ pub fn decode4_test() { #(1.3, 2.1, 3, 4) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "String", found: "Float", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "String", found: "Float", path: ["1"]), + ]), + ) } type Five(a, b, c, d, e) { @@ -1263,10 +1335,12 @@ pub fn decode5_test() { #(1.3, 2.1, 3, 4, 5) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "String", found: "Float", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "String", found: "Float", path: ["1"]), + ]), + ) } type Six(a, b, c, d, e, f) { @@ -1293,10 +1367,12 @@ pub fn decode6_test() { #(1.3, 2.1, 3, 4, 5, 6) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "String", found: "Float", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "String", found: "Float", path: ["1"]), + ]), + ) } type Seven(a, b, c, d, e, f, g) { @@ -1324,10 +1400,12 @@ pub fn decode7_test() { #(1.3, 2.1, 3, 4, 5, 6, 7) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "String", found: "Float", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "String", found: "Float", path: ["1"]), + ]), + ) } type Eight(a, b, c, d, e, f, g, h) { @@ -1356,10 +1434,12 @@ pub fn decode8_test() { #(1.3, 2.1, 3, 4, 5, 6, 7, 8) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "String", found: "Float", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "String", found: "Float", path: ["1"]), + ]), + ) } type Nine(a, b, c, d, e, f, g, h, i) { @@ -1389,8 +1469,10 @@ pub fn decode9_test() { #(1.3, 2.1, 3, 4, 5, 6, 7, 8, 9) |> dynamic.from |> decoder - |> should.equal(Error([ - DecodeError(expected: "Int", found: "Float", path: ["0"]), - DecodeError(expected: "String", found: "Float", path: ["1"]), - ])) + |> should.equal( + Error([ + DecodeError(expected: "Int", found: "Float", path: ["0"]), + DecodeError(expected: "String", found: "Float", path: ["1"]), + ]), + ) } diff --git a/test/gleam/iterator_test.gleam b/test/gleam/iterator_test.gleam index 3066c16..046a814 100644 --- a/test/gleam/iterator_test.gleam +++ b/test/gleam/iterator_test.gleam @@ -350,10 +350,9 @@ pub fn find_test() { |> iterator.find(fn(_x) { True }) |> should.equal(Error(Nil)) - iterator.unfold( - Cat(id: 1), - fn(cat: Cat) { iterator.Next(cat, Cat(id: cat.id + 1)) }, - ) + iterator.unfold(Cat(id: 1), fn(cat: Cat) { + iterator.Next(cat, Cat(id: cat.id + 1)) + }) |> iterator.find(fn(cat: Cat) { cat.id == 10 }) |> should.equal(Ok(Cat(id: 10))) } diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index a89add7..0027920 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -353,66 +353,51 @@ pub fn index_fold_test() { pub fn fold_until_test() { [1, 2, 3, 4] - |> list.fold_until( - from: 0, - with: fn(acc, n) { - case n < 4 { - True -> list.Continue(acc + n) - False -> list.Stop(acc) - } - }, - ) + |> list.fold_until(from: 0, with: fn(acc, n) { + case n < 4 { + True -> list.Continue(acc + n) + False -> list.Stop(acc) + } + }) |> should.equal(6) // TCO test list.range(0, recursion_test_cycles) - |> list.fold_until( - from: 0, - with: fn(acc, n) { - case n < recursion_test_cycles { - True -> list.Continue(acc + n) - False -> list.Stop(acc) - } - }, - ) + |> list.fold_until(from: 0, with: fn(acc, n) { + case n < recursion_test_cycles { + True -> list.Continue(acc + n) + False -> list.Stop(acc) + } + }) } pub fn try_fold_test() { [1, 2, 3] - |> list.try_fold( - 0, - fn(acc, i) { - case i < 4 { - True -> Ok(acc + i) - False -> Error(Nil) - } - }, - ) + |> list.try_fold(0, fn(acc, i) { + case i < 4 { + True -> Ok(acc + i) + False -> Error(Nil) + } + }) |> should.equal(Ok(6)) [1, 2, 3] - |> list.try_fold( - 0, - fn(acc, i) { - case i < 3 { - True -> Ok(acc + i) - False -> Error(Nil) - } - }, - ) + |> list.try_fold(0, fn(acc, i) { + case i < 3 { + True -> Ok(acc + i) + False -> Error(Nil) + } + }) |> should.equal(Error(Nil)) // TCO test list.range(0, recursion_test_cycles) - |> list.try_fold( - 0, - fn(acc, i) { - case i < recursion_test_cycles { - True -> Ok(acc + i) - False -> Error(Nil) - } - }, - ) + |> list.try_fold(0, fn(acc, i) { + case i < recursion_test_cycles { + True -> Ok(acc + i) + False -> Error(Nil) + } + }) } pub fn find_map_test() { @@ -903,42 +888,30 @@ pub fn key_set_test() { } pub fn each_test() { - list.each( - [1, 1, 1], - fn(x) { - let assert 1 = x - }, - ) + list.each([1, 1, 1], fn(x) { + let assert 1 = x + }) |> should.equal(Nil) // TCO test - list.each( - list.repeat(1, recursion_test_cycles), - fn(x) { - let assert 1 = x - }, - ) + list.each(list.repeat(1, recursion_test_cycles), fn(x) { + let assert 1 = x + }) } pub fn try_each_test() { let assert Ok(Nil) = - list.try_each( - over: [1, 1, 1], - with: fn(x) { - should.equal(x, 1) - Ok(Nil) - }, - ) + list.try_each(over: [1, 1, 1], with: fn(x) { + should.equal(x, 1) + Ok(Nil) + }) // `try_each` actually stops when `fun` returns error let assert Error(1) = - list.try_each( - over: [1, 2, 3], - with: fn(x) { - should.equal(x, 1) - Error(x) - }, - ) + list.try_each(over: [1, 2, 3], with: fn(x) { + should.equal(x, 1) + Error(x) + }) // TCO test let assert Ok(Nil) = @@ -1161,15 +1134,12 @@ pub fn scan_test() { |> should.equal([2, 6, 12, 20]) [1, 2, 3, 4] - |> list.scan( - from: [], - with: fn(acc, i) { - case int.is_even(i) { - True -> ["Even", ..acc] - False -> ["Odd", ..acc] - } - }, - ) + |> list.scan(from: [], with: fn(acc, i) { + case int.is_even(i) { + True -> ["Even", ..acc] + False -> ["Odd", ..acc] + } + }) |> should.equal([ ["Odd"], ["Even", "Odd"], diff --git a/test/gleam/regex_test.gleam b/test/gleam/regex_test.gleam index d97c8fa..8c13827 100644 --- a/test/gleam/regex_test.gleam +++ b/test/gleam/regex_test.gleam @@ -131,10 +131,11 @@ pub fn scan_test() { regex.from_string("var\\s*(\\w+)\\s*(int|string)?\\s*=\\s*(.*)") regex.scan(re, "var age int = 32") |> should.equal([ - Match( - content: "var age int = 32", - submatches: [Some("age"), Some("int"), Some("32")], - ), + Match(content: "var age int = 32", submatches: [ + Some("age"), + Some("int"), + Some("32"), + ]), ]) regex.scan(re, "var age = 32") diff --git a/test/gleam/should.gleam b/test/gleam/should.gleam index acfeacd..4618d73 100644 --- a/test/gleam/should.gleam +++ b/test/gleam/should.gleam @@ -36,12 +36,14 @@ pub fn equal(a, b) { case a == b { True -> Nil _ -> - crash(string.concat([ - "\n\t", - stringify(a), - "\n\tshould equal \n\t", - stringify(b), - ])) + crash( + string.concat([ + "\n\t", + stringify(a), + "\n\tshould equal \n\t", + stringify(b), + ]), + ) } } @@ -50,12 +52,14 @@ pub fn not_equal(a, b) { case a != b { True -> Nil _ -> - crash(string.concat([ - "\n", - stringify(a), - "\nshould not equal \n", - stringify(b), - ])) + crash( + string.concat([ + "\n", + stringify(a), + "\nshould not equal \n", + stringify(b), + ]), + ) } } diff --git a/test/gleam/string_builder_test.gleam b/test/gleam/string_builder_test.gleam index 1de514f..f8a50b7 100644 --- a/test/gleam/string_builder_test.gleam +++ b/test/gleam/string_builder_test.gleam @@ -19,10 +19,12 @@ pub fn string_builder_test() { let data = string_builder.from_string("ello") |> string_builder.append_builder(string_builder.from_string(",")) - |> string_builder.append_builder(string_builder.concat([ - string_builder.from_string(" wo"), - string_builder.from_string("rld!"), - ])) + |> string_builder.append_builder( + string_builder.concat([ + string_builder.from_string(" wo"), + string_builder.from_string("rld!"), + ]), + ) |> string_builder.prepend_builder(string_builder.from_string("H")) data diff --git a/test/gleam/string_test.gleam b/test/gleam/string_test.gleam index bb3f502..f923365 100644 --- a/test/gleam/string_test.gleam +++ b/test/gleam/string_test.gleam @@ -965,8 +965,7 @@ pub fn target_inspect_test() { // Looks like: `//erl(#Ref<0.1809744150.4035444737.100468>)`. let assert Ok(regular_expression) = - regex.from_string( - "^\\/\\/erl\\(#Ref<[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+>\\)$", + regex.from_string("^\\/\\/erl\\(#Ref<[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+>\\)$", ) string.inspect(create_erlang_reference()) |> regex.check(regular_expression, _) diff --git a/test/gleam/uri_test.gleam b/test/gleam/uri_test.gleam index e2b345b..7de6fd5 100644 --- a/test/gleam/uri_test.gleam +++ b/test/gleam/uri_test.gleam @@ -42,111 +42,127 @@ pub fn parse_only_host_test() { pub fn parse_scheme_test() { uri.parse("http://one.com/path/to/something?one=two&two=one#fragment") - |> should.equal(Ok(uri.Uri( - scheme: Some("http"), - host: Some("one.com"), - path: "/path/to/something", - query: Some("one=two&two=one"), - fragment: Some("fragment"), - port: None, - userinfo: None, - ))) + |> should.equal( + Ok(uri.Uri( + scheme: Some("http"), + host: Some("one.com"), + path: "/path/to/something", + query: Some("one=two&two=one"), + fragment: Some("fragment"), + port: None, + userinfo: None, + )), + ) } pub fn parse_https_scheme_test() { uri.parse("https://foo.com") - |> should.equal(Ok(uri.Uri( - scheme: Some("https"), - host: Some("foo.com"), - path: "", - query: None, - fragment: None, - port: None, - userinfo: None, - ))) + |> should.equal( + Ok(uri.Uri( + scheme: Some("https"), + host: Some("foo.com"), + path: "", + query: None, + fragment: None, + port: None, + userinfo: None, + )), + ) } pub fn parse_file_scheme_test() { uri.parse("file:///one/two/three") - |> should.equal(Ok(uri.Uri( - scheme: Some("file"), - host: Some(""), - path: "/one/two/three", - query: None, - fragment: None, - port: None, - userinfo: None, - ))) + |> should.equal( + Ok(uri.Uri( + scheme: Some("file"), + host: Some(""), + path: "/one/two/three", + query: None, + fragment: None, + port: None, + userinfo: None, + )), + ) } pub fn parse_ftp_scheme_test() { "ftp://user001:password@private.ftp-server.example.com/my_directory/my_file.txt" |> uri.parse - |> should.equal(Ok(uri.Uri( - scheme: Some("ftp"), - host: Some("private.ftp-server.example.com"), - userinfo: Some("user001:password"), - path: "/my_directory/my_file.txt", - query: None, - fragment: None, - port: None, - ))) + |> should.equal( + Ok(uri.Uri( + scheme: Some("ftp"), + host: Some("private.ftp-server.example.com"), + userinfo: Some("user001:password"), + path: "/my_directory/my_file.txt", + query: None, + fragment: None, + port: None, + )), + ) } pub fn parse_sftp_scheme_test() { "sftp://user001:password@private.ftp-server.example.com/my_directory/my_file.txt" |> uri.parse - |> should.equal(Ok(uri.Uri( - scheme: Some("sftp"), - host: Some("private.ftp-server.example.com"), - userinfo: Some("user001:password"), - path: "/my_directory/my_file.txt", - query: None, - fragment: None, - port: None, - ))) + |> should.equal( + Ok(uri.Uri( + scheme: Some("sftp"), + host: Some("private.ftp-server.example.com"), + userinfo: Some("user001:password"), + path: "/my_directory/my_file.txt", + query: None, + fragment: None, + port: None, + )), + ) } pub fn parse_tftp_scheme_test() { "tftp://user001:password@private.ftp-server.example.com/my_directory/my_file.txt" |> uri.parse - |> should.equal(Ok(uri.Uri( - scheme: Some("tftp"), - host: Some("private.ftp-server.example.com"), - userinfo: Some("user001:password"), - path: "/my_directory/my_file.txt", - query: None, - fragment: None, - port: None, - ))) + |> should.equal( + Ok(uri.Uri( + scheme: Some("tftp"), + host: Some("private.ftp-server.example.com"), + userinfo: Some("user001:password"), + path: "/my_directory/my_file.txt", + query: None, + fragment: None, + port: None, + )), + ) } pub fn parse_ldap_scheme_test() { "ldap:///dc=example,dc=com??sub?(givenName=John)" |> uri.parse - |> should.equal(Ok(uri.Uri( - scheme: Some("ldap"), - host: Some(""), - userinfo: None, - path: "/dc=example,dc=com", - query: Some("?sub?(givenName=John)"), - fragment: None, - port: None, - ))) + |> should.equal( + Ok(uri.Uri( + scheme: Some("ldap"), + host: Some(""), + userinfo: None, + path: "/dc=example,dc=com", + query: Some("?sub?(givenName=John)"), + fragment: None, + port: None, + )), + ) } pub fn parse_ldap_2_scheme_test() { "ldap://ldap.example.com/cn=John%20Doe,dc=foo,dc=com" |> uri.parse - |> should.equal(Ok(uri.Uri( - scheme: Some("ldap"), - host: Some("ldap.example.com"), - userinfo: None, - path: "/cn=John%20Doe,dc=foo,dc=com", - query: None, - fragment: None, - port: None, - ))) + |> should.equal( + Ok(uri.Uri( + scheme: Some("ldap"), + host: Some("ldap.example.com"), + userinfo: None, + path: "/cn=John%20Doe,dc=foo,dc=com", + query: None, + fragment: None, + port: None, + )), + ) } fn assert_parse(s) { |