ac4d545570
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.
113 lines
3.6 KiB
Rust
113 lines
3.6 KiB
Rust
//! Prose-projection snapshot tests.
|
|
//!
|
|
//! For each `examples/<name>.ail`, the renderer's output is compared
|
|
//! against the committed `examples/<name>.prose.txt`. The snapshot
|
|
//! files are part of the repo: changing the renderer requires a
|
|
//! deliberate snapshot update, which is the point of this test.
|
|
//!
|
|
//! Update protocol (manual): regenerate the file by running
|
|
//! `cargo run -p ail -- prose <fixture>.ail > <fixture>.prose.txt`
|
|
//! once the renderer change is agreed; commit alongside the change.
|
|
//! There is no `UPDATE_SNAPSHOTS=1` environment short-cut here on
|
|
//! purpose — Iter 20a is the seeding round, and we want every change
|
|
//! after this to be visible in a diff.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
fn examples_dir() -> PathBuf {
|
|
// tests/ runs with CARGO_MANIFEST_DIR == crates/ailang-prose.
|
|
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
p.pop();
|
|
p.pop();
|
|
p.push("examples");
|
|
p
|
|
}
|
|
|
|
fn check_snapshot(stem: &str) {
|
|
let dir = examples_dir();
|
|
let ail_path = dir.join(format!("{stem}.ail"));
|
|
let prose_path = dir.join(format!("{stem}.prose.txt"));
|
|
|
|
let module = ailang_surface::load_module(&ail_path)
|
|
.unwrap_or_else(|e| panic!("failed to load {ail_path:?}: {e}"));
|
|
let actual = ailang_prose::module_to_prose(&module);
|
|
|
|
let expected = std::fs::read_to_string(&prose_path)
|
|
.unwrap_or_else(|e| panic!("failed to read snapshot {prose_path:?}: {e}"));
|
|
|
|
if actual != expected {
|
|
// Write `.actual` for inspection, then fail.
|
|
let actual_path = dir.join(format!("{stem}.prose.txt.actual"));
|
|
std::fs::write(&actual_path, &actual).expect("write .actual");
|
|
panic!(
|
|
"prose snapshot mismatch for {stem}.\n\
|
|
Expected: {prose_path:?}\n\
|
|
Actual: {actual_path:?}\n\
|
|
To accept the new output, replace the expected file with the .actual file."
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_rc_own_param_drop() {
|
|
check_snapshot("rc_own_param_drop");
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_rc_match_arm_partial_drop_leak() {
|
|
check_snapshot("rc_match_arm_partial_drop_leak");
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_rc_app_let_partial_drop_leak() {
|
|
check_snapshot("rc_app_let_partial_drop_leak");
|
|
}
|
|
|
|
/// this fixture exercises the infix renderer + paren elision.
|
|
/// Pre-20b, the body had `if ==(n, 0) { ... }` and `tail sum_acc(-(n,
|
|
/// 1), ICons(-(n, 1), acc))`; after 20b those collapse to `if n == 0`
|
|
/// and `n - 1`. If this regresses, the renderer is broken.
|
|
#[test]
|
|
fn snapshot_bench_list_sum() {
|
|
check_snapshot("bench_list_sum");
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_test_22b3_default_e2e() {
|
|
check_snapshot("test_22b3_default_e2e");
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_test_22b2_instance_present() {
|
|
check_snapshot("test_22b2_instance_present");
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_test_22b2_constraint_declared_via_superclass() {
|
|
check_snapshot("test_22b2_constraint_declared_via_superclass");
|
|
}
|
|
|
|
/// Ct.4.3: snapshot for the canonical ordering-match fixture.
|
|
/// `ordering_match.ail.json` is in the `ordering_match` module
|
|
/// and references `prelude.Ordering` via a cross-module
|
|
/// `Term::Ctor.type_name`. The prose printer drops Ctor
|
|
/// `type_name`s entirely (recoverable from typecheck context),
|
|
/// so the rendered prose carries `LT`/`EQ`/`GT` without any
|
|
/// `prelude.` qualifier — the trim-on-print logic is exercised
|
|
/// by the unit tests on `Type::Con`, which is the surface
|
|
/// where the qualifier survives into the rendered text.
|
|
#[test]
|
|
fn snapshot_ordering_match() {
|
|
check_snapshot("ordering_match");
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_loop_sum_to_run() {
|
|
check_snapshot("loop_sum_to_run");
|
|
}
|
|
|
|
#[test]
|
|
fn snapshot_loop_forever_build() {
|
|
check_snapshot("loop_forever_build");
|
|
}
|