Merge pull request #2857 from rtfeldman/abilities-mono

Codegen for abilities
This commit is contained in:
Richard Feldman 2022-04-16 22:59:16 -04:00 committed by GitHub
commit 718b999751
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 442 additions and 103 deletions

View file

@ -0,0 +1,86 @@
#[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
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn alias_member_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 =
aliasedHash = hash
aliasedHash ($Id 1234)
"#
),
1234,
u64
);
}

View file

@ -4,6 +4,7 @@
// we actually want to compare against the literal float bits
#![allow(clippy::float_cmp)]
pub mod gen_abilities;
pub mod gen_compare;
pub mod gen_dict;
pub mod gen_list;