mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Add gen test for deriving hash for heterogenous tags
This commit is contained in:
parent
ff70832068
commit
00ca8f2f80
1 changed files with 42 additions and 1 deletions
|
@ -1332,7 +1332,7 @@ mod hash {
|
|||
}
|
||||
|
||||
mod derived {
|
||||
use super::{assert_evals_to, build_test};
|
||||
use super::{assert_evals_to, build_test, indoc, TEST_HASHER};
|
||||
use roc_std::RocList;
|
||||
|
||||
#[test]
|
||||
|
@ -1372,5 +1372,46 @@ mod hash {
|
|||
RocList<u8>
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hash_heterogenous_tags() {
|
||||
assert_evals_to!(
|
||||
&format!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
{}
|
||||
|
||||
a : [A U8 U8, B {{ a: U8 }}, C Str]
|
||||
a = A 15 23
|
||||
|
||||
b : [A U8 U8, B {{ a: U8 }}, C Str]
|
||||
b = B {{ a: 37 }}
|
||||
|
||||
c : [A U8 U8, B {{ a: U8 }}, C Str]
|
||||
c = C "abc"
|
||||
|
||||
main =
|
||||
@THasher []
|
||||
|> Hash.hash a
|
||||
|> Hash.hash b
|
||||
|> Hash.hash c
|
||||
|> tRead
|
||||
"#
|
||||
),
|
||||
TEST_HASHER,
|
||||
),
|
||||
RocList::from_slice(&[
|
||||
0, 0, // dicsr A
|
||||
15, 23, // payloads A
|
||||
1, 0, // discr B
|
||||
37, // payloads B
|
||||
2, 0, // discr B
|
||||
97, 98, 99 // payloads C
|
||||
]),
|
||||
RocList<u8>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue