mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Add gen test for custom Eq
This commit is contained in:
parent
0045c16b3e
commit
8310230f78
1 changed files with 38 additions and 0 deletions
|
@ -1602,3 +1602,41 @@ mod hash {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, any(feature = "gen-llvm", feature = "gen-wasm")))]
|
||||
mod eq {
|
||||
#[cfg(feature = "gen-llvm")]
|
||||
use crate::helpers::llvm::assert_evals_to;
|
||||
|
||||
#[cfg(feature = "gen-wasm")]
|
||||
use crate::helpers::wasm::assert_evals_to;
|
||||
|
||||
use indoc::indoc;
|
||||
use roc_std::RocStr;
|
||||
|
||||
#[test]
|
||||
fn custom_eq_impl() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [main] to "./platform"
|
||||
|
||||
LyingEq := U8 has [Eq {isEq}]
|
||||
|
||||
isEq = \@LyingEq m, @LyingEq n -> m != n
|
||||
|
||||
main =
|
||||
a = @LyingEq 10
|
||||
b = @LyingEq 5
|
||||
c = @LyingEq 5
|
||||
if Eq.isEq a b && !(Eq.isEq b c) then
|
||||
"okay"
|
||||
else
|
||||
"fail"
|
||||
"#
|
||||
),
|
||||
RocStr::from("okay"),
|
||||
RocStr
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue