Add test for width heuristics
This commit is contained in:
parent
31ce8ee185
commit
48df8f8dc0
@ -130,7 +130,7 @@ macro_rules! create_config {
|
||||
pub fn $i(&mut self, value: $ty) {
|
||||
(self.0).$i.2 = value;
|
||||
match stringify!($i) {
|
||||
"use_small_heuristics" => self.0.set_heuristics(),
|
||||
"max_width" | "use_small_heuristics" => self.0.set_heuristics(),
|
||||
"license_template_path" => self.0.set_license_template(),
|
||||
&_ => (),
|
||||
}
|
||||
@ -292,7 +292,7 @@ macro_rules! create_config {
|
||||
}
|
||||
|
||||
match key {
|
||||
"use_small_heuristics" => self.set_heuristics(),
|
||||
"max_width" | "use_small_heuristics" => self.set_heuristics(),
|
||||
"license_template_path" => self.set_license_template(),
|
||||
&_ => (),
|
||||
}
|
||||
|
28
tests/source/width-heuristics.rs
Normal file
28
tests/source/width-heuristics.rs
Normal file
@ -0,0 +1,28 @@
|
||||
// rustfmt-max_width: 120
|
||||
|
||||
// elems on multiple lines for max_width 100, but same line for max_width 120
|
||||
fn foo(e: Enum) {
|
||||
match e {
|
||||
Enum::Var {
|
||||
elem1,
|
||||
elem2,
|
||||
elem3,
|
||||
} => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// elems not on same line for either max_width 100 or 120
|
||||
fn bar(e: Enum) {
|
||||
match e {
|
||||
Enum::Var {
|
||||
elem1,
|
||||
elem2,
|
||||
elem3,
|
||||
elem4,
|
||||
} => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
24
tests/target/width-heuristics.rs
Normal file
24
tests/target/width-heuristics.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// rustfmt-max_width: 120
|
||||
|
||||
// elems on multiple lines for max_width 100, but same line for max_width 120
|
||||
fn foo(e: Enum) {
|
||||
match e {
|
||||
Enum::Var { elem1, elem2, elem3 } => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// elems not on same line for either max_width 100 or 120
|
||||
fn bar(e: Enum) {
|
||||
match e {
|
||||
Enum::Var {
|
||||
elem1,
|
||||
elem2,
|
||||
elem3,
|
||||
elem4,
|
||||
} => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user