Merge pull request #1941 from mliszcz/master

Fix test output formatting for rules starting with M/U
This commit is contained in:
Max Brunsfeld 2022-11-15 17:13:39 -08:00 committed by GitHub
commit 8883d43bee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 10 deletions

View file

@ -294,15 +294,10 @@ fn format_sexp_indented(sexp: &String, initial_indent_level: u32) -> String {
// "(node_name"
write!(formatted, "{}", s).unwrap();
let mut c_iter = s.chars();
c_iter.next();
match c_iter.next() {
Some('M') | Some('U') => {
// "(MISSING node_name" or "(UNEXPECTED 'x'"
let s = s_iter.next().unwrap();
write!(formatted, " {}", s).unwrap();
}
Some(_) | None => {}
// "(MISSING node_name" or "(UNEXPECTED 'x'"
if s.starts_with("(MISSING") || s.starts_with("(UNEXPECTED") {
let s = s_iter.next().unwrap();
write!(formatted, " {}", s).unwrap();
}
} else if s.ends_with(':') {
// "field:"
@ -597,6 +592,14 @@ abc
.to_string()
);
assert_eq!(format_sexp(&"()".to_string()), "()".to_string());
assert_eq!(
format_sexp(&"(A (M (B)))".to_string()),
"(A\n (M\n (B)))"
);
assert_eq!(
format_sexp(&"(A (U (B)))".to_string()),
"(A\n (U\n (B)))"
);
}
#[test]