Merge pull request #5041 from thehabbos007/eq

gen_dev x86: misc low-level bool comparison functions
This commit is contained in:
Folkert de Vries 2023-02-20 08:51:11 +01:00 committed by GitHub
commit c6089ebb6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 147 additions and 8 deletions

View file

@ -27,7 +27,7 @@ fn eq_i64() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn neq_i64() {
assert_evals_to!(
indoc!(
@ -61,7 +61,7 @@ fn eq_u64() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn neq_u64() {
assert_evals_to!(
indoc!(
@ -78,7 +78,7 @@ fn neq_u64() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn eq_bool_tag() {
assert_evals_to!(
indoc!(
@ -95,7 +95,7 @@ fn eq_bool_tag() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn neq_bool_tag() {
assert_evals_to!(
indoc!(
@ -111,6 +111,52 @@ fn neq_bool_tag() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn bool_logic() {
assert_evals_to!(
indoc!(
r#"
bool1 = Bool.true
bool2 = Bool.false
bool3 = !bool1
(bool1 && bool2) || bool2 && bool3
"#
),
false,
bool
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn and_bool() {
assert_evals_to!("Bool.true && Bool.true", true, bool);
assert_evals_to!("Bool.true && Bool.false", false, bool);
assert_evals_to!("Bool.false && Bool.true", false, bool);
assert_evals_to!("Bool.false && Bool.false", false, bool);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn or_bool() {
assert_evals_to!("Bool.true || Bool.true", true, bool);
assert_evals_to!("Bool.true || Bool.false", true, bool);
assert_evals_to!("Bool.false || Bool.true", true, bool);
assert_evals_to!("Bool.false || Bool.false", false, bool);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn not_bool() {
assert_evals_to!("!Bool.true", false, bool);
assert_evals_to!("!Bool.false", true, bool);
assert_evals_to!("!(!Bool.true)", true, bool);
assert_evals_to!("!(!Bool.false)", false, bool);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn empty_record() {
@ -152,7 +198,7 @@ fn unit() {
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn newtype() {
assert_evals_to!("Identity 42 == Identity 42", true, bool);
assert_evals_to!("Identity 42 != Identity 42", false, bool);