mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Add first ability gen tests
This commit is contained in:
parent
b79b351136
commit
8694ea9d33
2 changed files with 62 additions and 0 deletions
61
compiler/test_gen/src/gen_abilities.rs
Normal file
61
compiler/test_gen/src/gen_abilities.rs
Normal file
|
@ -0,0 +1,61 @@
|
|||
#[cfg(feature = "gen-llvm")]
|
||||
use crate::helpers::llvm::assert_evals_to;
|
||||
|
||||
#[cfg(feature = "gen-dev")]
|
||||
use crate::helpers::dev::assert_evals_to;
|
||||
|
||||
#[cfg(feature = "gen-wasm")]
|
||||
use crate::helpers::wasm::assert_evals_to;
|
||||
|
||||
#[cfg(test)]
|
||||
use indoc::indoc;
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn hash_specialization() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
Hash has
|
||||
hash : a -> U64 | a has Hash
|
||||
|
||||
Id := U64
|
||||
|
||||
hash = \$Id n -> n
|
||||
|
||||
main = hash ($Id 1234)
|
||||
"#
|
||||
),
|
||||
1234,
|
||||
u64
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||
fn hash_specialization_multiple_add() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
Hash has
|
||||
hash : a -> U64 | a has Hash
|
||||
|
||||
Id := U64
|
||||
|
||||
hash = \$Id n -> n
|
||||
|
||||
One := {}
|
||||
|
||||
hash = \$One _ -> 1
|
||||
|
||||
main = hash ($Id 1234) + hash ($One {})
|
||||
"#
|
||||
),
|
||||
1235,
|
||||
u64
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue