mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Add support for deriving Hash for opaques
This commit is contained in:
parent
a4ed5a582d
commit
40e05d5a00
3 changed files with 213 additions and 22 deletions
|
@ -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>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue