Skip to content

Commit 58157bb

Browse files
ctzcalebcartwright
authored andcommitted
Add some basic tests for chain_width use
1 parent 78b0728 commit 58157bb

File tree

6 files changed

+154
-0
lines changed

6 files changed

+154
-0
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// rustfmt-chain_width: 1
2+
// setting an unachievable chain_width to always get chains
3+
// on separate lines
4+
5+
struct Fluent {}
6+
7+
impl Fluent {
8+
fn blorp(&self) -> &Self {
9+
self
10+
}
11+
}
12+
13+
fn main() {
14+
let test = Fluent {};
15+
16+
// should be left alone
17+
test.blorp();
18+
19+
// should be wrapped
20+
test.blorp().blorp();
21+
test.blorp().blorp().blorp();
22+
test.blorp().blorp().blorp().blorp();
23+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// rustfmt-chain_width: 40
2+
3+
struct Fluent {}
4+
5+
impl Fluent {
6+
fn blorp(&self) -> &Self {
7+
self
8+
}
9+
}
10+
11+
fn main() {
12+
let test = Fluent {};
13+
14+
// should not be wrapped
15+
test.blorp();
16+
test.blorp().blorp();
17+
test.blorp().blorp().blorp();
18+
test.blorp().blorp().blorp().blorp();
19+
20+
// should be wrapped
21+
test.blorp().blorp().blorp().blorp().blorp();
22+
test.blorp().blorp().blorp().blorp().blorp().blorp();
23+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// rustfmt-chain_width: 20
2+
3+
struct Fluent {}
4+
5+
impl Fluent {
6+
fn blorp(&self) -> &Self {
7+
self
8+
}
9+
}
10+
11+
fn main() {
12+
let test = Fluent {};
13+
14+
// should not be wrapped
15+
test.blorp();
16+
test.blorp().blorp();
17+
18+
// should be wrapped
19+
test.blorp().blorp().blorp();
20+
test.blorp().blorp().blorp().blorp();
21+
}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// rustfmt-chain_width: 1
2+
// setting an unachievable chain_width to always get chains
3+
// on separate lines
4+
5+
struct Fluent {}
6+
7+
impl Fluent {
8+
fn blorp(&self) -> &Self {
9+
self
10+
}
11+
}
12+
13+
fn main() {
14+
let test = Fluent {};
15+
16+
// should be left alone
17+
test.blorp();
18+
19+
// should be wrapped
20+
test.blorp()
21+
.blorp();
22+
test.blorp()
23+
.blorp()
24+
.blorp();
25+
test.blorp()
26+
.blorp()
27+
.blorp()
28+
.blorp();
29+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// rustfmt-chain_width: 40
2+
3+
struct Fluent {}
4+
5+
impl Fluent {
6+
fn blorp(&self) -> &Self {
7+
self
8+
}
9+
}
10+
11+
fn main() {
12+
let test = Fluent {};
13+
14+
// should not be wrapped
15+
test.blorp();
16+
test.blorp().blorp();
17+
test.blorp().blorp().blorp();
18+
test.blorp().blorp().blorp().blorp();
19+
20+
// should be wrapped
21+
test.blorp()
22+
.blorp()
23+
.blorp()
24+
.blorp()
25+
.blorp();
26+
test.blorp()
27+
.blorp()
28+
.blorp()
29+
.blorp()
30+
.blorp()
31+
.blorp();
32+
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// rustfmt-chain_width: 20
2+
3+
struct Fluent {}
4+
5+
impl Fluent {
6+
fn blorp(&self) -> &Self {
7+
self
8+
}
9+
}
10+
11+
fn main() {
12+
let test = Fluent {};
13+
14+
// should not be wrapped
15+
test.blorp();
16+
test.blorp().blorp();
17+
18+
// should be wrapped
19+
test.blorp()
20+
.blorp()
21+
.blorp();
22+
test.blorp()
23+
.blorp()
24+
.blorp()
25+
.blorp();
26+
}

0 commit comments

Comments
 (0)