Fix formatter for unary operation

Was wrongly converting any unary operation into '!'
This commit is contained in:
KtorZ
2022-12-28 17:51:00 +01:00
parent 013fe886f5
commit bae8267f18
2 changed files with 25 additions and 5 deletions

View File

@@ -14,7 +14,7 @@ fn assert_fmt(src: &str, expected: &str) {
let (module2, extra2) = parser::module(&out, ModuleKind::Lib).unwrap();
let mut out2 = String::new();
format::pretty(&mut out2, module2, extra2, &out);
assert_eq!(out, out2);
assert!(out == out2, "formatting isn't idempotent");
}
#[test]
@@ -197,3 +197,20 @@ fn test_format_imports() {
assert_fmt(src, expected)
}
#[test]
fn test_negate() {
let src = indoc! {r#"
fn foo() {
- 42
}
"#};
let expected = indoc! {r#"
fn foo() {
-42
}
"#};
assert_fmt(src, expected)
}