iter 22b.3.1: fix — quality-review (doc reframe + class-present test)
This commit is contained in:
@@ -47,3 +47,49 @@ fn monomorphise_workspace_is_identity_on_class_free_workspace() {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Property: the Task 1 skeleton's class-present branch is also a
|
||||
/// no-op. The fixture has a `Def::Class` and a `Def::Instance` (so
|
||||
/// the early-out does NOT fire) but no concrete class-method call
|
||||
/// sites yet wired through the pipeline; under the skeleton, the
|
||||
/// fall-through `Ok(ws.clone())` must preserve every module's
|
||||
/// canonical hash.
|
||||
///
|
||||
/// NOTE: this test will need updating in Task 5 once the skeleton
|
||||
/// is replaced with the real fixpoint — at that point synth fns
|
||||
/// will be appended to the `defining_module`, breaking module-hash
|
||||
/// equality on that module by design. The test as written
|
||||
/// guarantees the Task 1 contract and catches accidental partial
|
||||
/// rewrites landed before Task 5.
|
||||
#[test]
|
||||
fn monomorphise_workspace_is_identity_when_no_concrete_call_sites() {
|
||||
// `test_22b2_instance_present.ail.json` has `class Show` +
|
||||
// `instance Show Int` and typechecks cleanly; reused across
|
||||
// 22b.2 tests so its shape is stable.
|
||||
let entry = examples_dir().join("test_22b2_instance_present.ail.json");
|
||||
let ws = ailang_core::load_workspace(&entry).expect("load");
|
||||
let diags = ailang_check::check_workspace(&ws);
|
||||
assert!(diags.is_empty(), "fixture must typecheck: {:?}", diags);
|
||||
|
||||
let ws_after = ailang_check::monomorphise_workspace(&ws)
|
||||
.expect("mono on class-present workspace");
|
||||
|
||||
// Module set unchanged.
|
||||
let before = ailang_core::load_workspace(&entry).expect("re-load");
|
||||
assert_eq!(
|
||||
ws_after.modules.keys().collect::<Vec<_>>(),
|
||||
before.modules.keys().collect::<Vec<_>>(),
|
||||
"module set must be identical"
|
||||
);
|
||||
// Each module hashes byte-identical (skeleton clones unchanged).
|
||||
for (mname, m) in &ws_after.modules {
|
||||
let before_m = &before.modules[mname];
|
||||
let h_after = ailang_core::module_hash(m);
|
||||
let h_before = ailang_core::module_hash(before_m);
|
||||
assert_eq!(
|
||||
h_after, h_before,
|
||||
"class-present module `{}` must hash-identical through Task 1 skeleton",
|
||||
mname
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user