Update gen_abilities tests

This commit is contained in:
Ayaz Hafiz 2022-09-21 10:37:57 -05:00
parent 1de37f042e
commit f10c47ec20
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -227,29 +227,29 @@ fn encode() {
r#"
app "test" provides [myU8Bytes] to "./platform"
Encoder fmt := List U8, fmt -> List U8 | fmt has Format
MEncoder fmt := List U8, fmt -> List U8 | fmt has Format
Encoding has
toEncoder : val -> Encoder fmt | val has Encoding, fmt has Format
MEncoding has
toEncoder : val -> MEncoder fmt | val has MEncoding, fmt has Format
Format has
u8 : U8 -> Encoder fmt | fmt has Format
u8 : U8 -> MEncoder fmt | fmt has Format
appendWith : List U8, Encoder fmt, fmt -> List U8 | fmt has Format
appendWith = \lst, (@Encoder doFormat), fmt -> doFormat lst fmt
appendWith : List U8, MEncoder fmt, fmt -> List U8 | fmt has Format
appendWith = \lst, (@MEncoder doFormat), fmt -> doFormat lst fmt
toBytes : val, fmt -> List U8 | val has Encoding, fmt has Format
toBytes : val, fmt -> List U8 | val has MEncoding, fmt has Format
toBytes = \val, fmt -> appendWith [] (toEncoder val) fmt
Linear := {} has [Format {u8}]
u8 = \n -> @Encoder (\lst, @Linear {} -> List.append lst n)
u8 = \n -> @MEncoder (\lst, @Linear {} -> List.append lst n)
Rgba := { r : U8, g : U8, b : U8, a : U8 } has [Encoding {toEncoder}]
Rgba := { r : U8, g : U8, b : U8, a : U8 } has [MEncoding {toEncoder}]
toEncoder = \@Rgba {r, g, b, a} ->
@Encoder \lst, fmt -> lst
@MEncoder \lst, fmt -> lst
|> appendWith (u8 r) fmt
|> appendWith (u8 g) fmt
|> appendWith (u8 b) fmt
@ -328,7 +328,7 @@ fn encode_use_stdlib() {
indoc!(
r#"
app "test"
imports [Encode.{ Encoding, toEncoder }, Json]
imports [Encode.{ toEncoder }, Json]
provides [main] to "./platform"
HelloWorld := {} has [Encoding {toEncoder}]
@ -356,7 +356,7 @@ fn encode_use_stdlib_without_wrapping_custom() {
indoc!(
r#"
app "test"
imports [Encode.{ Encoding, toEncoder }, Json]
imports [Encode.{ toEncoder }, Json]
provides [main] to "./platform"
HelloWorld := {} has [Encoding {toEncoder}]
@ -381,7 +381,7 @@ fn to_encoder_encode_custom_has_capture() {
indoc!(
r#"
app "test"
imports [Encode.{ Encoding, toEncoder }, Json]
imports [Encode.{ toEncoder }, Json]
provides [main] to "./platform"
HelloWorld := Str has [Encoding {toEncoder}]
@ -915,7 +915,7 @@ fn encode_then_decode_list_of_strings() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
app "test" imports [Decode, Json] provides [main] to "./platform"
main =
when Encode.toBytes ["a", "b", "c"] Json.fromUtf8 |> Decode.fromBytes Json.fromUtf8 is
@ -935,7 +935,7 @@ fn encode_then_decode_list_of_lists_of_strings() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
app "test" imports [Decode, Json] provides [main] to "./platform"
main =
when Encode.toBytes [["a", "b"], ["c", "d", "e"], ["f"]] Json.fromUtf8 |> Decode.fromBytes Json.fromUtf8 is
@ -957,7 +957,7 @@ fn decode_record_two_fields() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
app "test" imports [Decode, Json] provides [main] to "./platform"
main =
when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.fromUtf8 is
@ -979,7 +979,7 @@ fn decode_record_two_fields_string_and_int() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
app "test" imports [Decode, Json] provides [main] to "./platform"
main =
when Str.toUtf8 "{\"first\":\"ab\",\"second\":10}" |> Decode.fromBytes Json.fromUtf8 is
@ -1001,7 +1001,7 @@ fn decode_record_two_fields_string_and_string_infer() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
app "test" imports [Decode, Json] provides [main] to "./platform"
main =
when Str.toUtf8 "{\"first\":\"ab\",\"second\":\"cd\"}" |> Decode.fromBytes Json.fromUtf8 is
@ -1067,7 +1067,7 @@ fn decode_empty_record() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
app "test" imports [Decode, Json] provides [main] to "./platform"
main =
when Str.toUtf8 "{}" |> Decode.fromBytes Json.fromUtf8 is
@ -1090,7 +1090,7 @@ fn decode_record_of_record() {
assert_evals_to!(
indoc!(
r#"
app "test" imports [Encode, Decode, Json] provides [main] to "./platform"
app "test" imports [Decode, Json] provides [main] to "./platform"
main =
when Str.toUtf8 "{\"outer\":{\"inner\":\"a\"},\"other\":{\"one\":\"b\",\"two\":10}}" |> Decode.fromBytes Json.fromUtf8 is