Add some basic tests for chain_width use

This commit is contained in:
Joseph Birr-Pixton 2021-04-02 11:06:35 +01:00 committed by Caleb Cartwright
parent 78b0728887
commit 58157bb4b7
6 changed files with 154 additions and 0 deletions

View File

@ -0,0 +1,23 @@
// rustfmt-chain_width: 1
// setting an unachievable chain_width to always get chains
// on separate lines
struct Fluent {}
impl Fluent {
fn blorp(&self) -> &Self {
self
}
}
fn main() {
let test = Fluent {};
// should be left alone
test.blorp();
// should be wrapped
test.blorp().blorp();
test.blorp().blorp().blorp();
test.blorp().blorp().blorp().blorp();
}

View File

@ -0,0 +1,23 @@
// rustfmt-chain_width: 40
struct Fluent {}
impl Fluent {
fn blorp(&self) -> &Self {
self
}
}
fn main() {
let test = Fluent {};
// should not be wrapped
test.blorp();
test.blorp().blorp();
test.blorp().blorp().blorp();
test.blorp().blorp().blorp().blorp();
// should be wrapped
test.blorp().blorp().blorp().blorp().blorp();
test.blorp().blorp().blorp().blorp().blorp().blorp();
}

View File

@ -0,0 +1,21 @@
// rustfmt-chain_width: 20
struct Fluent {}
impl Fluent {
fn blorp(&self) -> &Self {
self
}
}
fn main() {
let test = Fluent {};
// should not be wrapped
test.blorp();
test.blorp().blorp();
// should be wrapped
test.blorp().blorp().blorp();
test.blorp().blorp().blorp().blorp();
}

View File

@ -0,0 +1,29 @@
// rustfmt-chain_width: 1
// setting an unachievable chain_width to always get chains
// on separate lines
struct Fluent {}
impl Fluent {
fn blorp(&self) -> &Self {
self
}
}
fn main() {
let test = Fluent {};
// should be left alone
test.blorp();
// should be wrapped
test.blorp()
.blorp();
test.blorp()
.blorp()
.blorp();
test.blorp()
.blorp()
.blorp()
.blorp();
}

View File

@ -0,0 +1,32 @@
// rustfmt-chain_width: 40
struct Fluent {}
impl Fluent {
fn blorp(&self) -> &Self {
self
}
}
fn main() {
let test = Fluent {};
// should not be wrapped
test.blorp();
test.blorp().blorp();
test.blorp().blorp().blorp();
test.blorp().blorp().blorp().blorp();
// should be wrapped
test.blorp()
.blorp()
.blorp()
.blorp()
.blorp();
test.blorp()
.blorp()
.blorp()
.blorp()
.blorp()
.blorp();
}

View File

@ -0,0 +1,26 @@
// rustfmt-chain_width: 20
struct Fluent {}
impl Fluent {
fn blorp(&self) -> &Self {
self
}
}
fn main() {
let test = Fluent {};
// should not be wrapped
test.blorp();
test.blorp().blorp();
// should be wrapped
test.blorp()
.blorp()
.blorp();
test.blorp()
.blorp()
.blorp()
.blorp();
}