Files
AILang/crates/ailang-codegen/tests/eq_primitives_pin.rs
T
Brummel ac4d545570 source: scrub iter-code / Decision-N residue from inline comments
Follow-up to bcd4181: the remaining ~530 inline `//` and `///`
comments still carrying opaque shorthand are now reformulated to
their content phrases. The only surviving `iter-<code>` reference
in source is the literal filename
`docs/journals/2026-05-13-iter-mq.3.md` (a real journal file).

Sweep covered:
  - `// Iter X.Y: <text>` prefixes (Iter 13a / 14a / 14e / 15g-aux /
    16b.x / 16d / 16e / 18b / 18c.x / 18d.x / 18e / 18g.x / 19a /
    19a.1 / 19b / 20a / 20f / 22-floats.x / 22b.x / 22c / 23.x /
    24.1 / cli-diag-human / hs.x / str-concat / etc.) — fully
    removed; the descriptive text that followed each prefix stays.
  - `// (Decision N)` and `per Decision N` and `Decision N axis 3` —
    replaced with the content phrase plus the relevant contract
    file (`design/contracts/tail-calls.md` for Decision 8,
    `design/contracts/memory-model.md` for Decision 10,
    `design/contracts/typeclasses.md` and `design/models/typeclasses.md`
    for Decision 11, `design/contracts/authoring-surface.md` for
    Decision 6, "the transitional dual-allocator" for Decision 9,
    "Effect prose" for Decision 3).
  - `// mq.X / mq.X (Task N) / mq.X journal / mq.X invariant` ->
    "the canonical-class-form rule / Class-class repurpose /
    method-dispatch-refactor journal / canonical-class-form
    invariant".
  - `// ct.X / ct.X (canonical-type-names) / ct.1.5a + ctt.2 /
    ct.2 Task N` -> "the canonical-form rule for type references /
    the canonical-form normalisation step / canonical-type-lookup
    refactor".
  - `// eob.X` -> "heap-Str-ABI" / "the Str carve-out".
  - `// rpe.X` -> "the per-type-print-op retirement".
  - `// post-mq.X / Pre-ct.X / pre-mq.X` -> "post-canonical-class-form" /
    "Pre-canonical-type-form" etc.
  - `/// Iter X regression: / /// Iter X.Y: / /// Iter A arm-close /
    /// Iter ct.4 (...): / /// Iter rpe.1 ...` -> descriptive
    phrases.

The journal filename in `crates/ailang-core/src/workspace.rs:573`
stays verbatim because it points at an actual file under
`docs/journals/`.

Tests: full `cargo test --workspace` green (80/80 test-result blocks
clean, no FAILED line). design_index_pin 5/5 + docs_honesty_pin 5/5
gating tests pass.
2026-05-20 09:58:04 +02:00

83 lines
3.0 KiB
Rust

//! Eq-primitive codegen pin tests, relocated from
//! `ailang-codegen/src/lib.rs` `#[cfg(test)] mod tests` to a `tests/*`
//! integration crate in iter form-a.1 Task 5. The relocation switches
//! workspace loading from `ailang_core::load_workspace` (the JSON-only
//! loader) to `ailang_surface::load_workspace` (the
//! extension-dispatching superset), so the post-iter `.ail` corpus is
//! loaded from Form A rather than the deleted `.ail.json` siblings.
use ailang_check::{check_workspace, monomorphise_workspace, Severity};
use ailang_codegen::lower_workspace;
use ailang_surface::load_workspace;
use std::path::Path;
fn eq_primitives_smoke_path() -> std::path::PathBuf {
let manifest = env!("CARGO_MANIFEST_DIR");
Path::new(manifest)
.parent().unwrap().parent().unwrap()
.join("examples").join("eq_primitives_smoke.ail")
}
fn lower_eq_primitives_smoke() -> String {
let entry = eq_primitives_smoke_path();
let ws = load_workspace(&entry).expect("load workspace");
let diags = check_workspace(&ws);
assert!(
diags.iter().all(|d| !matches!(d.severity, Severity::Error)),
"unexpected check_workspace errors: {diags:?}"
);
let ws = monomorphise_workspace(&ws).expect("monomorphise");
lower_workspace(&ws).expect("lower")
}
/// 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`. Full pipeline: end-of-typecheck → monomorphise →
/// codegen, then substring-shape assertions on the IR.
#[test]
fn eq_int_call_produces_icmp_i64_mono_fn() {
let ir = lower_eq_primitives_smoke();
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}"
);
}
/// 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() {
let ir = lower_eq_primitives_smoke();
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}"
);
}
/// 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() {
let ir = lower_eq_primitives_smoke();
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}"
);
}