diff options
author | Michael Jones <m.pricejones@gmail.com> | 2021-08-08 14:07:10 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2021-08-13 18:13:35 +0100 |
commit | afe9581a11c2f183b8778c40a89412fa3e233c99 (patch) | |
tree | 77e6008a5f830e242027953b1a5d5290c288d0ce | |
parent | acd72b47efb8957ed3f608c98c774603b426f4cd (diff) | |
download | gleam_stdlib-afe9581a11c2f183b8778c40a89412fa3e233c99.tar.gz gleam_stdlib-afe9581a11c2f183b8778c40a89412fa3e233c99.zip |
Rename 'got' to 'found'
I think that it might be clearer.
-rw-r--r-- | src/gleam/dynamic.gleam | 71 | ||||
-rw-r--r-- | test/gleam/dynamic_test.gleam | 86 |
2 files changed, 79 insertions, 78 deletions
diff --git a/src/gleam/dynamic.gleam b/src/gleam/dynamic.gleam index 6e68162..c180884 100644 --- a/src/gleam/dynamic.gleam +++ b/src/gleam/dynamic.gleam @@ -12,7 +12,7 @@ if erlang { pub external type Dynamic pub type DecodeError { - DecodeError(expected: String, got: String) + DecodeError(expected: String, found: String) } pub type Decoder(t) = @@ -42,7 +42,7 @@ if erlang { /// True /// /// > bit_string(from(123)) - /// Error("Expected a BitString, got `123`") + /// Error("Expected a BitString, found `123`") /// pub external fn bit_string(from: Dynamic) -> Result(BitString, DecodeError) = "gleam_stdlib" "decode_bit_string" @@ -56,14 +56,15 @@ if erlang { /// Ok("Hello") /// /// > string(from(123)) - /// Error("Expected a String, got `123`") + /// Error("Expected a String, found `123`") /// pub fn string(from: Dynamic) -> Result(String, DecodeError) { bit_string(from) |> result.then(fn(raw) { case bit_string.to_string(raw) { Ok(string) -> Ok(string) - Error(Nil) -> Error(DecodeError(expected: "string", got: "bit_string")) + Error(Nil) -> + Error(DecodeError(expected: "string", found: "bit_string")) } }) } @@ -77,7 +78,7 @@ if erlang { /// Ok(123) /// /// > int(from("Hello")) - /// Error("Expected an Int, got `\"Hello World\"`") + /// Error("Expected an Int, found `\"Hello World\"`") /// pub external fn int(from: Dynamic) -> Result(Int, DecodeError) = "gleam_stdlib" "decode_int" @@ -91,7 +92,7 @@ if erlang { /// Ok(2.0) /// /// > float(from(123)) - /// Error("Expected a Float, got `123`") + /// Error("Expected a Float, found `123`") /// pub external fn float(from: Dynamic) -> Result(Float, DecodeError) = "gleam_stdlib" "decode_float" @@ -105,7 +106,7 @@ if erlang { /// Ok(True) /// /// > bool(from(123)) - /// Error("Expected a Bool, got `123`") + /// Error("Expected a Bool, found `123`") /// pub external fn bool(from: Dynamic) -> Result(Bool, DecodeError) = "gleam_stdlib" "decode_bool" @@ -121,7 +122,7 @@ if erlang { /// True /// /// > thunk(from(123)) - /// Error("Expected a zero arity function, got `123`") + /// Error("Expected a zero arity function, found `123`") /// pub external fn thunk(from: Dynamic) -> Result(fn() -> Dynamic, DecodeError) = "gleam_stdlib" "decode_thunk" @@ -138,7 +139,7 @@ if erlang { /// Ok([from("a"), from("b"), from("c")]) /// /// > list(1) - /// Error("Expected an Int, got a binary") + /// Error("Expected an Int, found a binary") /// pub external fn list(from: Dynamic) -> Result(List(Dynamic), DecodeError) = "gleam_stdlib" "decode_list" @@ -155,7 +156,7 @@ if erlang { /// Ok(Error(from("boom"))) /// /// > result(from(123)) - /// Error("Expected a 2 element tuple, got an int") + /// Error("Expected a 2 element tuple, found an int") /// pub external fn result( Dynamic, @@ -177,7 +178,7 @@ if erlang { /// Ok(Error("boom")) /// /// > typed_result(of: from(123), ok: int, error: string) - /// Error("Expected a 2 element tuple, got an int") + /// Error("Expected a 2 element tuple, found an int") /// pub fn typed_result( of dynamic: Dynamic, @@ -214,10 +215,10 @@ if erlang { /// Ok(["a", "b", "c"]) /// /// > typed_list(from([1, 2, 3]), of: string) - /// Error("Expected an Int, got a binary") + /// Error("Expected an Int, found a binary") /// /// > typed_list(from("ok"), of: string) - /// Error("Expected a List, got a binary") + /// Error("Expected a List, found a binary") /// pub fn typed_list( from dynamic: Dynamic, @@ -249,7 +250,7 @@ if erlang { /// Ok(None) /// /// > option(from(123), string) - /// Error("Expected a bit_string, got an int") + /// Error("Expected a bit_string, found an int") /// pub external fn optional( from: Dynamic, @@ -269,7 +270,7 @@ if erlang { /// Ok(Dynamic) /// /// > field(from(123), "Hello") - /// Error("Expected a map with key `\"Hello\"`, got an Int") + /// Error("Expected a map with key `\"Hello\"`, found an Int") /// pub external fn field(from: Dynamic, named: a) -> Result(Dynamic, DecodeError) = "gleam_stdlib" "decode_field" @@ -283,10 +284,10 @@ if erlang { /// Ok(from(1)) /// /// > element(from(#(1, 2)), 2) - /// Error("Expected a tuple of at least 3 size, got a tuple of 2 size") + /// Error("Expected a tuple of at least 3 size, found a tuple of 2 size") /// /// > element(from(""), 2) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub external fn element( from: Dynamic, @@ -308,7 +309,7 @@ if erlang { /// Error("Expected a 2 element tuple") /// /// > tuple2(from("")) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub external fn tuple2( from: Dynamic, @@ -330,10 +331,10 @@ if erlang { /// Ok(#(1, 2.0)) /// /// > typed_tuple2(from(#(1, 2, 3)), int, float) - /// Error("Expected a 2 element tuple, got a 3 element tuple") + /// Error("Expected a 2 element tuple, found a 3 element tuple") /// /// > typed_tuple2(from(""), int, float) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub fn typed_tuple2( from tup: Dynamic, @@ -360,7 +361,7 @@ if erlang { /// Error("Expected a 3 element tuple") /// /// > tuple3(from("")) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub external fn tuple3( from: Dynamic, @@ -382,10 +383,10 @@ if erlang { /// Ok(#(1, 2.0, "3")) /// /// > typed_tuple3(from(#(1, 2)), int, float, string) - /// Error("Expected a 3 element tuple, got a 2 element tuple") + /// Error("Expected a 3 element tuple, found a 2 element tuple") /// /// > typed_tuple3(from(""), int, float, string) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub fn typed_tuple3( from tup: Dynamic, @@ -414,7 +415,7 @@ if erlang { /// Error("Expected a 4 element tuple") /// /// > tuple4(from("")) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub external fn tuple4( from: Dynamic, @@ -436,10 +437,10 @@ if erlang { /// Ok(#(1, 2.0, "3", 4)) /// /// > typed_tuple4(from(#(1, 2)), int, float, string, int) - /// Error("Expected a 4 element tuple, got a 2 element tuple") + /// Error("Expected a 4 element tuple, found a 2 element tuple") /// /// > typed_tuple4(from(""), int, float, string, int) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub fn typed_tuple4( from tup: Dynamic, @@ -470,7 +471,7 @@ if erlang { /// Error("Expected a 5 element tuple") /// /// > tuple5(from("")) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub external fn tuple5( from: Dynamic, @@ -492,10 +493,10 @@ if erlang { /// Ok(#(1, 2.0, "3", 4, 5)) /// /// > typed_tuple5(from(#(1, 2)), int, float, string, int, int) - /// Error("Expected a 5 element tuple, got a 2 element tuple") + /// Error("Expected a 5 element tuple, found a 2 element tuple") /// /// > typed_tuple5(from(""), int, float, string, int, int) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub fn typed_tuple5( from tup: Dynamic, @@ -528,7 +529,7 @@ if erlang { /// Error("Expected a 6 element tuple") /// /// > tuple6(from("")) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub external fn tuple6( from: Dynamic, @@ -553,10 +554,10 @@ if erlang { /// Ok(#(1, 2.0, "3", 4, 5, 6)) /// /// > typed_tuple6(from(#(1, 2)), int, float, string, int, int, int) - /// Error("Expected a 6 element tuple, got a 2 element tuple") + /// Error("Expected a 6 element tuple, found a 2 element tuple") /// /// > typed_tuple6(from(""), int, float, string, int, int, int) - /// Error("Expected a tuple, got a binary") + /// Error("Expected a tuple, found a binary") /// pub fn typed_tuple6( from tup: Dynamic, @@ -586,10 +587,10 @@ if erlang { /// Ok(map.new()) /// /// > map(from(1)) - /// Error("Expected a 2 element tuple, got an int") + /// Error("Expected a 2 element tuple, found an int") /// /// > map(from("")) - /// Error("Expected a map, got a binary") + /// Error("Expected a map, found a binary") /// pub external fn map( from: Dynamic, @@ -622,7 +623,7 @@ if erlang { decoders |> list.find_map(fn(decoder) { decoder(data) }) |> result.map_error(fn(_) { - DecodeError(expected: "any", got: "unexpected") + DecodeError(expected: "any", found: "unexpected") }) } } diff --git a/test/gleam/dynamic_test.gleam b/test/gleam/dynamic_test.gleam index bdd7bfa..8f90635 100644 --- a/test/gleam/dynamic_test.gleam +++ b/test/gleam/dynamic_test.gleam @@ -26,12 +26,12 @@ if erlang { 1 |> dynamic.from |> dynamic.bit_string - |> should.equal(Error(DecodeError(expected: "bit_string", got: "int"))) + |> should.equal(Error(DecodeError(expected: "bit_string", found: "int"))) [] |> dynamic.from |> dynamic.bit_string - |> should.equal(Error(DecodeError(expected: "bit_string", got: "list"))) + |> should.equal(Error(DecodeError(expected: "bit_string", found: "list"))) } pub fn string_test() { @@ -48,17 +48,17 @@ if erlang { <<65535:16>> |> dynamic.from |> dynamic.string - |> should.equal(Error(DecodeError(expected: "string", got: "bit_string"))) + |> should.equal(Error(DecodeError(expected: "string", found: "bit_string"))) 1 |> dynamic.from |> dynamic.string - |> should.equal(Error(DecodeError(expected: "bit_string", got: "int"))) + |> should.equal(Error(DecodeError(expected: "bit_string", found: "int"))) [] |> dynamic.from |> dynamic.string - |> should.equal(Error(DecodeError(expected: "bit_string", got: "list"))) + |> should.equal(Error(DecodeError(expected: "bit_string", found: "list"))) } pub fn int_test() { @@ -75,12 +75,12 @@ if erlang { 1.0 |> dynamic.from |> dynamic.int - |> should.equal(Error(DecodeError(expected: "int", got: "float"))) + |> should.equal(Error(DecodeError(expected: "int", found: "float"))) [] |> dynamic.from |> dynamic.int - |> should.equal(Error(DecodeError(expected: "int", got: "list"))) + |> should.equal(Error(DecodeError(expected: "int", found: "list"))) } pub fn float_test() { @@ -97,12 +97,12 @@ if erlang { 1 |> dynamic.from |> dynamic.float - |> should.equal(Error(DecodeError(expected: "float", got: "int"))) + |> should.equal(Error(DecodeError(expected: "float", found: "int"))) [] |> dynamic.from |> dynamic.float - |> should.equal(Error(DecodeError(expected: "float", got: "list"))) + |> should.equal(Error(DecodeError(expected: "float", found: "list"))) } pub fn thunk_test() { @@ -147,12 +147,12 @@ if erlang { 1 |> dynamic.from |> dynamic.bool - |> should.equal(Error(DecodeError(expected: "bool", got: "int"))) + |> should.equal(Error(DecodeError(expected: "bool", found: "int"))) [] |> dynamic.from |> dynamic.bool - |> should.equal(Error(DecodeError(expected: "bool", got: "list"))) + |> should.equal(Error(DecodeError(expected: "bool", found: "list"))) } pub fn typed_list_test() { @@ -300,13 +300,13 @@ if erlang { |> dynamic.tuple2 |> should.equal(Error(DecodeError( expected: "2 element tuple", - got: "3 element tuple", + found: "3 element tuple", ))) 1 |> dynamic.from |> dynamic.tuple2 - |> should.equal(Error(DecodeError(expected: "2 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "2 element tuple", found: "int"))) } pub fn typed_tuple2_test() { @@ -323,20 +323,20 @@ if erlang { #(1, "") |> dynamic.from |> dynamic.typed_tuple2(dynamic.int, dynamic.int) - |> should.equal(Error(DecodeError(expected: "int", got: "binary"))) + |> should.equal(Error(DecodeError(expected: "int", found: "binary"))) #(1, 2, 3) |> dynamic.from |> dynamic.typed_tuple2(dynamic.int, dynamic.int) |> should.equal(Error(DecodeError( expected: "2 element tuple", - got: "3 element tuple", + found: "3 element tuple", ))) 1 |> dynamic.from |> dynamic.typed_tuple2(dynamic.int, dynamic.int) - |> should.equal(Error(DecodeError(expected: "2 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "2 element tuple", found: "int"))) } pub fn tuple3_test() { @@ -355,13 +355,13 @@ if erlang { |> dynamic.tuple3 |> should.equal(Error(DecodeError( expected: "3 element tuple", - got: "2 element tuple", + found: "2 element tuple", ))) 1 |> dynamic.from |> dynamic.tuple3 - |> should.equal(Error(DecodeError(expected: "3 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "3 element tuple", found: "int"))) } pub fn typed_tuple3_test() { @@ -378,20 +378,20 @@ if erlang { #(1, 2, "") |> dynamic.from |> dynamic.typed_tuple3(dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error(DecodeError(expected: "int", got: "binary"))) + |> should.equal(Error(DecodeError(expected: "int", found: "binary"))) #(1, 2) |> dynamic.from |> dynamic.typed_tuple3(dynamic.int, dynamic.int, dynamic.int) |> should.equal(Error(DecodeError( expected: "3 element tuple", - got: "2 element tuple", + found: "2 element tuple", ))) 1 |> dynamic.from |> dynamic.typed_tuple3(dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error(DecodeError(expected: "3 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "3 element tuple", found: "int"))) } pub fn tuple4_test() { @@ -420,13 +420,13 @@ if erlang { |> dynamic.tuple4 |> should.equal(Error(DecodeError( expected: "4 element tuple", - got: "2 element tuple", + found: "2 element tuple", ))) 1 |> dynamic.from |> dynamic.tuple4 - |> should.equal(Error(DecodeError(expected: "4 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "4 element tuple", found: "int"))) } pub fn typed_tuple4_test() { @@ -448,20 +448,20 @@ if erlang { #(1, 2, 3, "") |> dynamic.from |> dynamic.typed_tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error(DecodeError(expected: "int", got: "binary"))) + |> should.equal(Error(DecodeError(expected: "int", found: "binary"))) #(1, 2) |> dynamic.from |> dynamic.typed_tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) |> should.equal(Error(DecodeError( expected: "4 element tuple", - got: "2 element tuple", + found: "2 element tuple", ))) 1 |> dynamic.from |> dynamic.typed_tuple4(dynamic.int, dynamic.int, dynamic.int, dynamic.int) - |> should.equal(Error(DecodeError(expected: "4 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "4 element tuple", found: "int"))) } pub fn tuple5_test() { @@ -492,13 +492,13 @@ if erlang { |> dynamic.tuple5 |> should.equal(Error(DecodeError( expected: "5 element tuple", - got: "2 element tuple", + found: "2 element tuple", ))) 1 |> dynamic.from |> dynamic.tuple5 - |> should.equal(Error(DecodeError(expected: "5 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "5 element tuple", found: "int"))) } pub fn typed_tuple5_test() { @@ -533,7 +533,7 @@ if erlang { dynamic.int, dynamic.int, ) - |> should.equal(Error(DecodeError(expected: "int", got: "binary"))) + |> should.equal(Error(DecodeError(expected: "int", found: "binary"))) #(1, 2) |> dynamic.from @@ -546,7 +546,7 @@ if erlang { ) |> should.equal(Error(DecodeError( expected: "5 element tuple", - got: "2 element tuple", + found: "2 element tuple", ))) 1 @@ -558,7 +558,7 @@ if erlang { dynamic.int, dynamic.int, ) - |> should.equal(Error(DecodeError(expected: "5 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "5 element tuple", found: "int"))) } pub fn tuple6_test() { @@ -591,13 +591,13 @@ if erlang { |> dynamic.tuple6 |> should.equal(Error(DecodeError( expected: "6 element tuple", - got: "2 element tuple", + found: "2 element tuple", ))) 1 |> dynamic.from |> dynamic.tuple6 - |> should.equal(Error(DecodeError(expected: "6 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "6 element tuple", found: "int"))) } pub fn typed_tuple6_test() { @@ -635,7 +635,7 @@ if erlang { dynamic.int, dynamic.int, ) - |> should.equal(Error(DecodeError(expected: "int", got: "binary"))) + |> should.equal(Error(DecodeError(expected: "int", found: "binary"))) #(1, 2) |> dynamic.from @@ -649,7 +649,7 @@ if erlang { ) |> should.equal(Error(DecodeError( expected: "6 element tuple", - got: "2 element tuple", + found: "2 element tuple", ))) 1 @@ -662,7 +662,7 @@ if erlang { dynamic.int, dynamic.int, ) - |> should.equal(Error(DecodeError(expected: "6 element tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "6 element tuple", found: "int"))) } pub fn map_test() { @@ -674,7 +674,7 @@ if erlang { 1 |> dynamic.from |> dynamic.map - |> should.equal(Error(DecodeError(expected: "map", got: "int"))) + |> should.equal(Error(DecodeError(expected: "map", found: "int"))) } pub fn list_test() { @@ -696,7 +696,7 @@ if erlang { 1 |> dynamic.from |> dynamic.list - |> should.equal(Error(DecodeError(expected: "list", got: "int"))) + |> should.equal(Error(DecodeError(expected: "list", found: "int"))) } pub fn result_test() { @@ -713,14 +713,14 @@ if erlang { 1 |> dynamic.from |> dynamic.result - |> should.equal(Error(DecodeError(expected: "result tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "result tuple", found: "int"))) #("bad", "value") |> dynamic.from |> dynamic.result |> should.equal(Error(DecodeError( expected: "result tuple", - got: "2 element tuple", + found: "2 element tuple", ))) } @@ -738,16 +738,16 @@ if erlang { Ok("1") |> dynamic.from |> dynamic.typed_result(ok: dynamic.int, error: dynamic.string) - |> should.equal(Error(DecodeError(expected: "int", got: "binary"))) + |> should.equal(Error(DecodeError(expected: "int", found: "binary"))) Error(1) |> dynamic.from |> dynamic.typed_result(ok: dynamic.int, error: dynamic.string) - |> should.equal(Error(DecodeError(expected: "bit_string", got: "int"))) + |> should.equal(Error(DecodeError(expected: "bit_string", found: "int"))) 1 |> dynamic.from |> dynamic.typed_result(ok: dynamic.int, error: dynamic.string) - |> should.equal(Error(DecodeError(expected: "result tuple", got: "int"))) + |> should.equal(Error(DecodeError(expected: "result tuple", found: "int"))) } } |