Add test for width heuristics

This commit is contained in:
Trevor Spiteri 2018-05-02 11:38:23 +02:00
parent 31ce8ee185
commit 48df8f8dc0
3 changed files with 54 additions and 2 deletions

View File

@ -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(),
&_ => (),
}

View 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;
}
}
}

View 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;
}
}
}