Expand encode gen test

This commit is contained in:
Ayaz Hafiz 2022-05-06 14:55:20 -04:00 committed by ayazhafiz
parent 474c18ab83
commit bc0b82b97c

View file

@ -222,7 +222,6 @@ fn ability_used_as_type_still_compiles() {
#[test] #[test]
#[cfg(any(feature = "gen-llvm"))] #[cfg(any(feature = "gen-llvm"))]
#[ignore]
fn encode() { fn encode() {
assert_evals_to!( assert_evals_to!(
indoc!( indoc!(
@ -249,15 +248,20 @@ fn encode() {
# impl Format for Linear # impl Format for Linear
u8 = \n -> @Encoder (\lst, @Linear {} -> List.append lst n) u8 = \n -> @Encoder (\lst, @Linear {} -> List.append lst n)
MyU8 := U8 Rgba := { r : U8, g : U8, b : U8, a : U8 }
# impl Encoding for MyU8 # impl Encoding for Rgba
toEncoder = \@MyU8 n -> u8 n toEncoder = \@Rgba {r, g, b, a} ->
@Encoder \lst, fmt -> lst
|> appendWith (u8 r) fmt
|> appendWith (u8 g) fmt
|> appendWith (u8 b) fmt
|> appendWith (u8 a) fmt
myU8Bytes = toBytes (@MyU8 15) (@Linear {}) myU8Bytes = toBytes (@Rgba { r: 106, g: 90, b: 205, a: 255 }) (@Linear {})
"# "#
), ),
RocList::from_slice(&[15]), RocList::from_slice(&[106, 90, 205, 255]),
RocList<u8> RocList<u8>
) )
} }