Skip to content

Commit

Permalink
Add some basic tests for chain_width use
Browse files Browse the repository at this point in the history
  • Loading branch information
ctz authored and calebcartwright committed Apr 22, 2021
1 parent 78b0728 commit 58157bb
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/source/configs/chain_width/always.rs
Original file line number Diff line number Diff line change
@@ -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();
}
23 changes: 23 additions & 0 deletions tests/source/configs/chain_width/small.rs
Original file line number Diff line number Diff line change
@@ -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();
}
21 changes: 21 additions & 0 deletions tests/source/configs/chain_width/tiny.rs
Original file line number Diff line number Diff line change
@@ -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();
}
29 changes: 29 additions & 0 deletions tests/target/configs/chain_width/always.rs
Original file line number Diff line number Diff line change
@@ -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();
}
32 changes: 32 additions & 0 deletions tests/target/configs/chain_width/small.rs
Original file line number Diff line number Diff line change
@@ -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();
}
26 changes: 26 additions & 0 deletions tests/target/configs/chain_width/tiny.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 58157bb

Please sign in to comment.