Fix formatter bugs

This commit is contained in:
2026-06-26 01:29:51 +02:00
parent e5509e89a4
commit 6c9c0e03d2
13 changed files with 173 additions and 84 deletions
+34 -15
View File
@@ -8,35 +8,50 @@ enum OptionInt {
pub void test_enum_named() {
let x = OptionInt::None;
match x {
OptionInt::None => { assert_eq!(1, 1); }
OptionInt::Some(_) => { assert_eq!(0, 1); }
OptionInt::None => {
assert_eq!(1, 1);
}
OptionInt::Some(_) => {
assert_eq!(0, 1);
}
}
}
pub void test_enum_tuple() {
let x = OptionInt::Some(42);
match x {
OptionInt::None => { assert_eq!(0, 1); }
OptionInt::Some(v) => { assert_eq!(v, 42); }
OptionInt::None => {
assert_eq!(0, 1);
}
OptionInt::Some(v) => {
assert_eq!(v, 42);
}
}
}
enum Shape {
Circle { i32 radius },
Rect { i32 w, i32 h },
Circle {i32 radius},
Rect {i32 w, i32 h},
}
pub void test_enum_struct() {
let c = Shape::Circle { radius: 5 };
let c = Shape::Circle{radius: 5, };
match c {
Shape::Circle { radius } => { assert_eq!(radius, 5); }
Shape::Rect { .. } => { assert_eq!(0, 1); }
Shape::Circle {radius} => {
assert_eq!(radius, 5);
}
Shape::Rect {..} => {
assert_eq!(0, 1);
}
}
let r = Shape::Rect { w: 3, h: 4 };
let r = Shape::Rect{w: 3, h: 4, };
match r {
Shape::Circle { .. } => { assert_eq!(0, 1); }
Shape::Rect { w, h } => { assert_eq!(w * h, 12); }
Shape::Circle {..} => {
assert_eq!(0, 1);
}
Shape::Rect {w, h} => {
assert_eq!(w * h, 12);
}
}
}
@@ -49,8 +64,12 @@ enum Color {
pub void test_enum_eq() {
let c = Color::Red;
match c {
Color::Red => { assert_eq!(1, 1); }
_ => { assert_eq!(0, 1); }
Color::Red => {
assert_eq!(1, 1);
}
_ => {
assert_eq!(0, 1);
}
}
}