Update derive tests

This commit is contained in:
Sam Mohr 2025-01-05 07:34:53 -08:00
parent ad950a1ee9
commit f95d0f8df6
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
3 changed files with 116 additions and 116 deletions

View file

@ -104,7 +104,7 @@ fn derivable_record_with_record_ext() {
#[test]
fn list() {
derive_test(Decoder, v!(Symbol::LIST_LIST v!(STR)), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for List Str
# Decoder (List val) fmt where fmt implements DecoderFormatting, val implements Decoding
# List U8, fmt -[[custom(3)]]-> { rest : List U8, result : [Err [TooShort], Ok (List val)] } where fmt implements DecoderFormatting, val implements Decoding
@ -113,8 +113,8 @@ fn list() {
#Derived.decoder_list =
custom
\#Derived.bytes, #Derived.fmt ->
decodeWith #Derived.bytes (list decoder) #Derived.fmt
"###
decode_with #Derived.bytes (list decoder) #Derived.fmt
"
)
})
}
@ -122,7 +122,7 @@ fn list() {
#[test]
fn record_2_fields() {
derive_test(Decoder, v!({first: v!(STR), second: v!(STR),}), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r##"
# derived for { first : Str, second : Str }
# Decoder { first : val, second : val1 } fmt where fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding
# List U8, fmt -[[custom(25)]]-> { rest : List U8, result : [Err [TooShort], Ok { first : val, second : val1 }] } where fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding
@ -131,55 +131,55 @@ fn record_2_fields() {
#Derived.decoder_{first,second} =
custom
\#Derived.bytes3, #Derived.fmt4 ->
decodeWith
decode_with
#Derived.bytes3
(record
{ second: Err NoField, first: Err NoField }
\#Derived.stateRecord2, #Derived.field ->
\#Derived.state_record2, #Derived.field ->
when #Derived.field is
"first" ->
Keep (custom
\#Derived.bytes, #Derived.fmt2 ->
when decodeWith #Derived.bytes decoder #Derived.fmt2 is
when decode_with #Derived.bytes decoder #Derived.fmt2 is
#Derived.rec ->
{
result: when #Derived.rec.result is
Ok #Derived.val ->
Ok { stateRecord2 & first: Ok #Derived.val }
Ok { state_record2 & first: Ok #Derived.val }
Err #Derived.err -> Err #Derived.err,
rest: #Derived.rec.rest
})
"second" ->
Keep (custom
\#Derived.bytes2, #Derived.fmt3 ->
when decodeWith #Derived.bytes2 decoder #Derived.fmt3 is
when decode_with #Derived.bytes2 decoder #Derived.fmt3 is
#Derived.rec2 ->
{
result: when #Derived.rec2.result is
Ok #Derived.val2 ->
Ok { stateRecord2 & second: Ok #Derived.val2 }
Ok { state_record2 & second: Ok #Derived.val2 }
Err #Derived.err2 -> Err #Derived.err2,
rest: #Derived.rec2.rest
})
_ -> Skip
\#Derived.stateRecord, #Derived.fmt ->
when when #Derived.stateRecord.first is
\#Derived.state_record, #Derived.fmt ->
when when #Derived.state_record.first is
Ok #Derived.first -> Ok #Derived.first
Err (NoField) ->
when decodeWith [] decoder #Derived.fmt is
#Derived.decRec2 -> #Derived.decRec2.result is
when decode_with [] decoder #Derived.fmt is
#Derived.dec_rec2 -> #Derived.dec_rec2.result is
Ok #Derived.first ->
when when #Derived.stateRecord.second is
when when #Derived.state_record.second is
Ok #Derived.second -> Ok #Derived.second
Err (NoField) ->
when decodeWith [] decoder #Derived.fmt is
#Derived.decRec -> #Derived.decRec.result is
when decode_with [] decoder #Derived.fmt is
#Derived.dec_rec -> #Derived.dec_rec.result is
Ok #Derived.second ->
Ok { second: #Derived.second, first: #Derived.first }
_ -> Err TooShort
_ -> Err TooShort)
#Derived.fmt4
"###
"##
)
})
}
@ -187,7 +187,7 @@ fn record_2_fields() {
#[test]
fn tuple_2_fields() {
derive_test(Decoder, v!((v!(STR), v!(U8),)), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for ( Str, U8 )*
# Decoder ( val, val1 )* fmt where fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding
# List U8, fmt -[[custom(22)]]-> { rest : List U8, result : [Err [TooShort], Ok ( val, val1 )a] } where fmt implements DecoderFormatting, val implements Decoding, val1 implements Decoding
@ -196,7 +196,7 @@ fn tuple_2_fields() {
#Derived.decoder_(arity:2) =
custom
\#Derived.bytes3, #Derived.fmt3 ->
decodeWith
decode_with
#Derived.bytes3
(tuple
{ e1: Err NoElem, e0: Err NoElem }
@ -205,7 +205,7 @@ fn tuple_2_fields() {
0 ->
Next (custom
\#Derived.bytes, #Derived.fmt ->
when decodeWith #Derived.bytes decoder #Derived.fmt is
when decode_with #Derived.bytes decoder #Derived.fmt is
#Derived.rec ->
{
result: when #Derived.rec.result is
@ -217,7 +217,7 @@ fn tuple_2_fields() {
1 ->
Next (custom
\#Derived.bytes2, #Derived.fmt2 ->
when decodeWith #Derived.bytes2 decoder #Derived.fmt2 is
when decode_with #Derived.bytes2 decoder #Derived.fmt2 is
#Derived.rec2 ->
{
result: when #Derived.rec2.result is
@ -235,7 +235,7 @@ fn tuple_2_fields() {
_ -> Err TooShort
_ -> Err TooShort)
#Derived.fmt3
"###
"
)
})
}

View file

@ -186,19 +186,19 @@ fn derivable_tag_with_tag_ext() {
#[test]
fn empty_record() {
derive_test(ToEncoder, v!(EMPTY_RECORD), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for {}
# {} -[[toEncoder_{}(0)]]-> Encoder fmt where fmt implements EncoderFormatting
# {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) where fmt implements EncoderFormatting
# {} -[[to_encoder_{}(0)]]-> Encoder fmt where fmt implements EncoderFormatting
# {} -[[to_encoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) where fmt implements EncoderFormatting
# Specialization lambda sets:
# @<1>: [[toEncoder_{}(0)]]
# @<1>: [[to_encoder_{}(0)]]
# @<2>: [[custom(2) {}]]
#Derived.toEncoder_{} =
#Derived.to_encoder_{} =
\#Derived.rcd ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith #Derived.bytes (record []) #Derived.fmt
"###
append_with #Derived.bytes (record []) #Derived.fmt
"
)
})
}
@ -206,19 +206,19 @@ fn empty_record() {
#[test]
fn zero_field_record() {
derive_test(ToEncoder, v!({}), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for {}
# {} -[[toEncoder_{}(0)]]-> Encoder fmt where fmt implements EncoderFormatting
# {} -[[toEncoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) where fmt implements EncoderFormatting
# {} -[[to_encoder_{}(0)]]-> Encoder fmt where fmt implements EncoderFormatting
# {} -[[to_encoder_{}(0)]]-> (List U8, fmt -[[custom(2) {}]]-> List U8) where fmt implements EncoderFormatting
# Specialization lambda sets:
# @<1>: [[toEncoder_{}(0)]]
# @<1>: [[to_encoder_{}(0)]]
# @<2>: [[custom(2) {}]]
#Derived.toEncoder_{} =
#Derived.to_encoder_{} =
\#Derived.rcd ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith #Derived.bytes (record []) #Derived.fmt
"###
append_with #Derived.bytes (record []) #Derived.fmt
"
)
})
}
@ -226,22 +226,22 @@ fn zero_field_record() {
#[test]
fn one_field_record() {
derive_test(ToEncoder, v!({ a: v!(U8), }), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r##"
# derived for { a : U8 }
# { a : val } -[[toEncoder_{a}(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding
# { a : val } -[[toEncoder_{a}(0)]]-> (List U8, fmt -[[custom(2) { a : val }]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding
# { a : val } -[[to_encoder_{a}(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding
# { a : val } -[[to_encoder_{a}(0)]]-> (List U8, fmt -[[custom(2) { a : val }]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_{a}(0)]]
# @<1>: [[to_encoder_{a}(0)]]
# @<2>: [[custom(2) { a : val }]] where val implements Encoding
#Derived.toEncoder_{a} =
#Derived.to_encoder_{a} =
\#Derived.rcd ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith
append_with
#Derived.bytes
(record [{ value: toEncoder #Derived.rcd.a, key: "a" }])
(record [{ value: to_encoder #Derived.rcd.a, key: "a" }])
#Derived.fmt
"###
"##
)
})
}
@ -249,26 +249,26 @@ fn one_field_record() {
#[test]
fn two_field_record() {
derive_test(ToEncoder, v!({ a: v!(U8), b: v!(STR), }), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r##"
# derived for { a : U8, b : Str }
# { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# { a : val, b : val1 } -[[toEncoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# { a : val, b : val1 } -[[to_encoder_{a,b}(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# { a : val, b : val1 } -[[to_encoder_{a,b}(0)]]-> (List U8, fmt -[[custom(2) { a : val, b : val1 }]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_{a,b}(0)]]
# @<1>: [[to_encoder_{a,b}(0)]]
# @<2>: [[custom(2) { a : val, b : val1 }]] where val implements Encoding, val1 implements Encoding
#Derived.toEncoder_{a,b} =
#Derived.to_encoder_{a,b} =
\#Derived.rcd ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith
append_with
#Derived.bytes
(record
[
{ value: toEncoder #Derived.rcd.a, key: "a" },
{ value: toEncoder #Derived.rcd.b, key: "b" },
{ value: to_encoder #Derived.rcd.a, key: "a" },
{ value: to_encoder #Derived.rcd.b, key: "b" },
])
#Derived.fmt
"###
"##
)
})
}
@ -276,22 +276,22 @@ fn two_field_record() {
#[test]
fn two_field_tuple() {
derive_test(ToEncoder, v!((v!(U8), v!(STR),)), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for ( U8, Str )*
# ( val, val1 )* -[[toEncoder_(arity:2)(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# ( val, val1 )a -[[toEncoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# ( val, val1 )* -[[to_encoder_(arity:2)(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# ( val, val1 )a -[[to_encoder_(arity:2)(0)]]-> (List U8, fmt -[[custom(2) ( val, val1 )a]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_(arity:2)(0)]]
# @<1>: [[to_encoder_(arity:2)(0)]]
# @<2>: [[custom(2) ( val, val1 )*]] where val implements Encoding, val1 implements Encoding
#Derived.toEncoder_(arity:2) =
#Derived.to_encoder_(arity:2) =
\#Derived.tup ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith
append_with
#Derived.bytes
(tuple [toEncoder #Derived.tup.0, toEncoder #Derived.tup.1])
(tuple [to_encoder #Derived.tup.0, to_encoder #Derived.tup.1])
#Derived.fmt
"###
"
)
})
}
@ -312,23 +312,23 @@ fn empty_tag_union() {
#[test]
fn tag_one_label_zero_args() {
derive_test(ToEncoder, v!([A]), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r##"
# derived for [A]
# [A] -[[toEncoder_[A 0](0)]]-> Encoder fmt where fmt implements EncoderFormatting
# [A] -[[toEncoder_[A 0](0)]]-> (List U8, fmt -[[custom(2) [A]]]-> List U8) where fmt implements EncoderFormatting
# [A] -[[to_encoder_[A 0](0)]]-> Encoder fmt where fmt implements EncoderFormatting
# [A] -[[to_encoder_[A 0](0)]]-> (List U8, fmt -[[custom(2) [A]]]-> List U8) where fmt implements EncoderFormatting
# Specialization lambda sets:
# @<1>: [[toEncoder_[A 0](0)]]
# @<1>: [[to_encoder_[A 0](0)]]
# @<2>: [[custom(2) [A]]]
#Derived.toEncoder_[A 0] =
#Derived.to_encoder_[A 0] =
\#Derived.tag ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith
append_with
#Derived.bytes
(when #Derived.tag is
A -> tag "A" [])
#Derived.fmt
"###
"##
)
})
}
@ -336,24 +336,24 @@ fn tag_one_label_zero_args() {
#[test]
fn tag_one_label_two_args() {
derive_test(ToEncoder, v!([A v!(U8) v!(STR)]), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r##"
# derived for [A U8 Str]
# [A val val1] -[[toEncoder_[A 2](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [A val val1] -[[toEncoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [A val val1] -[[to_encoder_[A 2](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [A val val1] -[[to_encoder_[A 2](0)]]-> (List U8, fmt -[[custom(4) [A val val1]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_[A 2](0)]]
# @<1>: [[to_encoder_[A 2](0)]]
# @<2>: [[custom(4) [A val val1]]] where val implements Encoding, val1 implements Encoding
#Derived.toEncoder_[A 2] =
#Derived.to_encoder_[A 2] =
\#Derived.tag ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith
append_with
#Derived.bytes
(when #Derived.tag is
A #Derived.2 #Derived.3 ->
tag "A" [toEncoder #Derived.2, toEncoder #Derived.3])
tag "A" [to_encoder #Derived.2, to_encoder #Derived.3])
#Derived.fmt
"###
"##
)
})
}
@ -364,31 +364,31 @@ fn tag_two_labels() {
ToEncoder,
v!([A v!(U8) v!(STR) v!(U16), B v!(STR)]),
|golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r##"
# derived for [A U8 Str U16, B Str]
# [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [A val val1 val1, B val1] -[[toEncoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [A val val1 val1, B val1] -[[to_encoder_[A 3,B 1](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [A val val1 val1, B val1] -[[to_encoder_[A 3,B 1](0)]]-> (List U8, fmt -[[custom(6) [A val val1 val1, B val1]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_[A 3,B 1](0)]]
# @<1>: [[to_encoder_[A 3,B 1](0)]]
# @<2>: [[custom(6) [A val val1 val1, B val1]]] where val implements Encoding, val1 implements Encoding
#Derived.toEncoder_[A 3,B 1] =
#Derived.to_encoder_[A 3,B 1] =
\#Derived.tag ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith
append_with
#Derived.bytes
(when #Derived.tag is
A #Derived.2 #Derived.3 #Derived.4 ->
tag
"A"
[
toEncoder #Derived.2,
toEncoder #Derived.3,
toEncoder #Derived.4,
to_encoder #Derived.2,
to_encoder #Derived.3,
to_encoder #Derived.4,
]
B #Derived.5 -> tag "B" [toEncoder #Derived.5])
B #Derived.5 -> tag "B" [to_encoder #Derived.5])
#Derived.fmt
"###
"##
)
},
)
@ -400,25 +400,25 @@ fn recursive_tag_union() {
ToEncoder,
v!([Nil, Cons v!(U8) v!(^lst) ] as lst),
|golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r##"
# derived for [Cons U8 $rec, Nil] as $rec
# [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [Cons val val1, Nil] -[[toEncoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [Cons val val1, Nil] -[[to_encoder_[Cons 2,Nil 0](0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# [Cons val val1, Nil] -[[to_encoder_[Cons 2,Nil 0](0)]]-> (List U8, fmt -[[custom(4) [Cons val val1, Nil]]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding, val1 implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_[Cons 2,Nil 0](0)]]
# @<1>: [[to_encoder_[Cons 2,Nil 0](0)]]
# @<2>: [[custom(4) [Cons val val1, Nil]]] where val implements Encoding, val1 implements Encoding
#Derived.toEncoder_[Cons 2,Nil 0] =
#Derived.to_encoder_[Cons 2,Nil 0] =
\#Derived.tag ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith
append_with
#Derived.bytes
(when #Derived.tag is
Cons #Derived.2 #Derived.3 ->
tag "Cons" [toEncoder #Derived.2, toEncoder #Derived.3]
tag "Cons" [to_encoder #Derived.2, to_encoder #Derived.3]
Nil -> tag "Nil" [])
#Derived.fmt
"###
"##
)
},
)
@ -427,22 +427,22 @@ fn recursive_tag_union() {
#[test]
fn list() {
derive_test(ToEncoder, v!(Symbol::LIST_LIST v!(STR)), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for List Str
# List val -[[toEncoder_list(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding
# List val -[[toEncoder_list(0)]]-> (List U8, fmt -[[custom(4) (List val)]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding
# List val -[[to_encoder_list(0)]]-> Encoder fmt where fmt implements EncoderFormatting, val implements Encoding
# List val -[[to_encoder_list(0)]]-> (List U8, fmt -[[custom(4) (List val)]]-> List U8) where fmt implements EncoderFormatting, val implements Encoding
# Specialization lambda sets:
# @<1>: [[toEncoder_list(0)]]
# @<1>: [[to_encoder_list(0)]]
# @<2>: [[custom(4) (List val)]] where val implements Encoding
#Derived.toEncoder_list =
#Derived.to_encoder_list =
\#Derived.lst ->
custom
\#Derived.bytes, #Derived.fmt ->
appendWith
append_with
#Derived.bytes
(list #Derived.lst \#Derived.elem -> toEncoder #Derived.elem)
(list #Derived.lst \#Derived.elem -> to_encoder #Derived.elem)
#Derived.fmt
"###
"
)
})
}

View file

@ -261,7 +261,7 @@ fn tag_one_label_newtype() {
#[test]
fn tag_two_labels() {
derive_test(Hash, v!([A v!(U8) v!(STR) v!(U16), B v!(STR)]), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for [A U8 Str U16, B Str]
# a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a where a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash
# a, [A a1 a2 a3, B a3] -[[hash_[A 3,B 1](0)]]-> a where a implements Hasher, a1 implements Hash, a2 implements Hash, a3 implements Hash
@ -272,10 +272,10 @@ fn tag_two_labels() {
when #Derived.union is
A #Derived.3 #Derived.4 #Derived.5 ->
hash
(hash (hash (addU8 #Derived.hasher 0) #Derived.3) #Derived.4)
(hash (hash (add_u8 #Derived.hasher 0) #Derived.3) #Derived.4)
#Derived.5
B #Derived.6 -> hash (addU8 #Derived.hasher 1) #Derived.6
"###
B #Derived.6 -> hash (add_u8 #Derived.hasher 1) #Derived.6
"
)
})
}
@ -283,7 +283,7 @@ fn tag_two_labels() {
#[test]
fn tag_two_labels_no_payloads() {
derive_test(Hash, v!([A, B]), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for [A, B]
# a, [A, B] -[[hash_[A 0,B 0](0)]]-> a where a implements Hasher
# a, [A, B] -[[hash_[A 0,B 0](0)]]-> a where a implements Hasher
@ -292,9 +292,9 @@ fn tag_two_labels_no_payloads() {
#Derived.hash_[A 0,B 0] =
\#Derived.hasher, #Derived.union ->
when #Derived.union is
A -> addU8 #Derived.hasher 0
B -> addU8 #Derived.hasher 1
"###
A -> add_u8 #Derived.hasher 0
B -> add_u8 #Derived.hasher 1
"
)
})
}
@ -302,7 +302,7 @@ fn tag_two_labels_no_payloads() {
#[test]
fn recursive_tag_union() {
derive_test(Hash, v!([Nil, Cons v!(U8) v!(^lst) ] as lst), |golden| {
assert_snapshot!(golden, @r###"
assert_snapshot!(golden, @r"
# derived for [Cons U8 $rec, Nil] as $rec
# a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a where a implements Hasher, a1 implements Hash, a2 implements Hash
# a, [Cons a1 a2, Nil] -[[hash_[Cons 2,Nil 0](0)]]-> a where a implements Hasher, a1 implements Hash, a2 implements Hash
@ -312,9 +312,9 @@ fn recursive_tag_union() {
\#Derived.hasher, #Derived.union ->
when #Derived.union is
Cons #Derived.3 #Derived.4 ->
hash (hash (addU8 #Derived.hasher 0) #Derived.3) #Derived.4
Nil -> addU8 #Derived.hasher 1
"###
hash (hash (add_u8 #Derived.hasher 0) #Derived.3) #Derived.4
Nil -> add_u8 #Derived.hasher 1
"
)
})
}