Add support for deriving Hash for opaques

This commit is contained in:
Ayaz Hafiz 2022-10-18 13:36:41 -05:00
parent a4ed5a582d
commit 40e05d5a00
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 213 additions and 22 deletions

View file

@ -1590,6 +1590,33 @@ mod hash {
RocList<u8>
)
}
#[test]
fn derived_hash_for_opaque_record() {
assert_evals_to!(
&format!(
indoc!(
r#"
app "test" provides [main] to "./platform"
{}
Q := {{ a: U8, b: U8, c: U8 }} has [Hash]
q = @Q {{ a: 15, b: 27, c: 31 }}
main =
@THasher []
|> Hash.hash q
|> tRead
"#
),
TEST_HASHER,
),
RocList::from_slice(&[15, 27, 31]),
RocList<u8>
)
}
}
}