iter 23.2.4: e2e smoke fixture + ir-shape integration tests for eq__T mono symbols
This commit is contained in:
@@ -3563,4 +3563,86 @@ mod tests {
|
||||
"eq__Str must emit a static closure pair; ir was:\n{ir}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Iter 23.2: integration with the auto-loaded prelude. Compiling
|
||||
/// a workspace that calls `eq` on an Int pair must produce a
|
||||
/// mono-synthesised `@ail_prelude_eq__Int` whose body lowers to
|
||||
/// `icmp eq i64`. The test runs the full pipeline end-of-typecheck →
|
||||
/// monomorphise → codegen, then asserts substring shape on the IR.
|
||||
#[test]
|
||||
fn eq_int_call_produces_icmp_i64_mono_fn() {
|
||||
use ailang_core::load_workspace;
|
||||
use ailang_check::{check_workspace, monomorphise_workspace};
|
||||
let manifest = env!("CARGO_MANIFEST_DIR");
|
||||
let entry = std::path::Path::new(manifest)
|
||||
.parent().unwrap().parent().unwrap()
|
||||
.join("examples").join("eq_primitives_smoke.ail.json");
|
||||
let ws = load_workspace(&entry).expect("load workspace");
|
||||
let diags = check_workspace(&ws);
|
||||
assert!(
|
||||
diags.iter().all(|d| !matches!(d.severity, ailang_check::Severity::Error)),
|
||||
"unexpected check_workspace errors: {diags:?}"
|
||||
);
|
||||
let ws = monomorphise_workspace(&ws).expect("monomorphise");
|
||||
let ir = lower_workspace(&ws).expect("lower");
|
||||
assert!(
|
||||
ir.contains("@ail_prelude_eq__Int"),
|
||||
"ir must contain mono-synthesised @ail_prelude_eq__Int; ir was:\n{ir}"
|
||||
);
|
||||
assert!(
|
||||
ir.contains("icmp eq i64"),
|
||||
"eq__Int body must lower to icmp eq i64; ir was:\n{ir}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Iter 23.2: same shape as `eq_int_call_produces_icmp_i64_mono_fn`
|
||||
/// for Bool. Asserts the mono-synthesised `@ail_prelude_eq__Bool`
|
||||
/// lowers to `icmp eq i1`.
|
||||
#[test]
|
||||
fn eq_bool_call_produces_icmp_i1_mono_fn() {
|
||||
use ailang_core::load_workspace;
|
||||
use ailang_check::{check_workspace, monomorphise_workspace};
|
||||
let manifest = env!("CARGO_MANIFEST_DIR");
|
||||
let entry = std::path::Path::new(manifest)
|
||||
.parent().unwrap().parent().unwrap()
|
||||
.join("examples").join("eq_primitives_smoke.ail.json");
|
||||
let ws = load_workspace(&entry).expect("load workspace");
|
||||
let _ = check_workspace(&ws);
|
||||
let ws = monomorphise_workspace(&ws).expect("monomorphise");
|
||||
let ir = lower_workspace(&ws).expect("lower");
|
||||
assert!(
|
||||
ir.contains("@ail_prelude_eq__Bool"),
|
||||
"ir must contain mono-synthesised @ail_prelude_eq__Bool; ir was:\n{ir}"
|
||||
);
|
||||
assert!(
|
||||
ir.contains("icmp eq i1"),
|
||||
"eq__Bool body must lower to icmp eq i1; ir was:\n{ir}"
|
||||
);
|
||||
}
|
||||
|
||||
/// Iter 23.2: Str's mono-symbol body is hand-rolled by the
|
||||
/// `try_emit_primitive_instance_body` intercept. Asserts the
|
||||
/// intercept fires for the prelude-loaded `eq__Str` synthesised
|
||||
/// against a real user fixture that calls `eq` on Str.
|
||||
#[test]
|
||||
fn eq_str_call_produces_ail_str_eq_call_mono_fn() {
|
||||
use ailang_core::load_workspace;
|
||||
use ailang_check::{check_workspace, monomorphise_workspace};
|
||||
let manifest = env!("CARGO_MANIFEST_DIR");
|
||||
let entry = std::path::Path::new(manifest)
|
||||
.parent().unwrap().parent().unwrap()
|
||||
.join("examples").join("eq_primitives_smoke.ail.json");
|
||||
let ws = load_workspace(&entry).expect("load workspace");
|
||||
let _ = check_workspace(&ws);
|
||||
let ws = monomorphise_workspace(&ws).expect("monomorphise");
|
||||
let ir = lower_workspace(&ws).expect("lower");
|
||||
assert!(
|
||||
ir.contains("@ail_prelude_eq__Str"),
|
||||
"ir must contain mono-synthesised @ail_prelude_eq__Str; ir was:\n{ir}"
|
||||
);
|
||||
assert!(
|
||||
ir.contains("call zeroext i1 @ail_str_eq("),
|
||||
"eq__Str body must call @ail_str_eq; ir was:\n{ir}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user