1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Reference witness: the CompatDiagnostic surface — each diagnostic renders as
// "[severity] message" via Display (COVERAGE.md §2.5 — closes the HiddenFlattening
// row, the convergence/divergence silent-flatten diagnostic).
//
// CompatDiagnostic enumerates the compat-boundary defects (missing witness, raw
// exported as admitted, lossy projection without policy, HIDDEN FLATTENING, etc.).
// This witnesses each renders its severity + guidance message, with HiddenFlattening
// pointing at the LossReport remedy — the silent-flatten counterpart to the named
// LossReport path already witnessed.
use wasm4pm_compat::diagnostic::CompatDiagnostic as D;
#[test]
fn hidden_flattening_diagnostic_points_at_the_lossreport_remedy() {
let s = D::HiddenFlattening.to_string();
assert!(
s.starts_with("[Error]"),
"hidden flattening is an Error; got {s}"
);
assert!(s.contains("hidden flattening"), "names the defect");
assert!(
s.contains("LossReport"),
"points at the named-loss remedy; got {s}"
);
}
#[test]
fn compat_diagnostics_render_severity_and_message() {
// A spread across the diagnostic taxonomy, each rendering "[severity] message".
for d in [
D::MissingWitness,
D::MissingRoundTripFixture,
D::RawEvidenceExportedAsAdmitted,
D::LossyProjectionWithoutPolicy,
D::HiddenFlattening,
D::MissingRefusalPath,
D::MissingReceiptShape,
D::UnreachablePrimitive,
D::MigrationRecommended,
] {
let s = d.to_string();
assert!(
s.starts_with("[Error]") || s.starts_with("[Warning]") || s.starts_with("[Info]"),
"every diagnostic renders a severity tag; got {s}"
);
assert!(
s.len() > 10,
"carries a guidance message, not just a tag: {s}"
);
}
// RawEvidenceExportedAsAdmitted is the T-1 (fiat-admission) hazard, named.
assert!(D::RawEvidenceExportedAsAdmitted
.to_string()
.to_lowercase()
.contains("admitted"));
}