Make sure we're generating correct code with has annotations

This commit is contained in:
Ayaz Hafiz 2022-04-19 16:21:06 -04:00
parent cbfd76380a
commit 0387eeed23
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 80 additions and 17 deletions

View file

@ -88,6 +88,31 @@ fn alias_member_specialization() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn ability_constrained_in_non_member_usage() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [ result ] to "./platform"
Hash has
hash : a -> U64 | a has Hash
mulHashes : a, a -> U64 | a has Hash
mulHashes = \x, y -> hash x * hash y
Id := U64
hash = \$Id n -> n
result = mulHashes ($Id 5) ($Id 7)
"#
),
35,
u64
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn ability_constrained_in_non_member_usage_inferred() {
assert_evals_to!(
indoc!(
r#"
@ -112,6 +137,34 @@ fn ability_constrained_in_non_member_usage() {
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn ability_constrained_in_non_member_multiple_specializations() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [ result ] to "./platform"
Hash has
hash : a -> U64 | a has Hash
mulHashes : a, b -> U64 | a has Hash, b has Hash
mulHashes = \x, y -> hash x * hash y
Id := U64
hash = \$Id n -> n
Three := {}
hash = \$Three _ -> 3
result = mulHashes ($Id 100) ($Three {})
"#
),
300,
u64
)
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn ability_constrained_in_non_member_multiple_specializations_inferred() {
assert_evals_to!(
indoc!(
r#"