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
// ========== format_text() grade spelling ==========
//
// `BaselineComparison::format_text` rendered grades with `{:?}`, so
// `pmat tdg baseline compare` printed the Rust variant name:
// - ./src/lib.rs: APlus (100.0) → F (25.2) [-74.8]
// Every sibling printer (check-regression, tdg, analyze tdg, check-quality,
// and the JSON/SARIF payloads) goes through `Grade`'s `Display`, which
// emits the symbolic form. One spelling, one impl.
#[test]
fn format_text_prints_symbolic_grades_not_debug_variant_names() {
let mut old = TdgBaseline::new(None);
let mut new = TdgBaseline::new(None);
// Regressed: A+ → F
old.add_entry(
PathBuf::from("regressed.rs"),
create_test_entry(100.0, Grade::APlus),
);
new.add_entry(
PathBuf::from("regressed.rs"),
create_test_entry(25.2, Grade::F),
);
// Improved: B- → A+
old.add_entry(
PathBuf::from("improved.rs"),
create_test_entry(80.0, Grade::BMinus),
);
new.add_entry(
PathBuf::from("improved.rs"),
create_test_entry(100.0, Grade::APlus),
);
let text = old.compare(&new).format_text();
for debug_spelling in [
"APlus", "AMinus", "BPlus", "BMinus", "CPlus", "CMinus",
] {
assert!(
!text.contains(debug_spelling),
"format_text leaked the Debug variant name {debug_spelling:?}:\n{text}"
);
}
assert!(
text.contains("A+ (100.0) → F (25.2)"),
"expected the symbolic spelling Display emits, got:\n{text}"
);
assert!(
text.contains("B- (80.0) → A+ (100.0)"),
"expected the symbolic spelling Display emits, got:\n{text}"
);
}