Skip to content

Commit ebc645c

Browse files
SiegeLordExSiegeLord
authored andcommitted
Add some tests for hard tab mode.
1 parent 4609834 commit ebc645c

File tree

2 files changed

+164
-0
lines changed

2 files changed

+164
-0
lines changed

tests/source/hard-tabs.rs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// rustfmt-hard_tabs: true
2+
3+
fn main() {
4+
let x = Bar;
5+
6+
let y = Foo {a: x };
7+
8+
Foo { a: foo() /* comment*/, /* comment*/ b: bar(), ..something };
9+
10+
fn foo(a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32) {}
11+
12+
let str = "AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAa";
13+
14+
if let (some_very_large, tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1
15+
+ 2 + 3 {
16+
}
17+
18+
if cond() {
19+
something();
20+
} else if different_cond() {
21+
something_else();
22+
} else {
23+
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
24+
}
25+
26+
unsafe /* very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment */ {}
27+
28+
unsafe // So this is a very long comment.
29+
// Multi-line, too.
30+
// Will it still format correctly?
31+
{
32+
}
33+
34+
let z = [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyy, zzzzzzzzzzzzzzzzzz, q];
35+
36+
fn generic<T>(arg: T) -> &SomeType
37+
where T: Fn(// First arg
38+
A,
39+
// Second argument
40+
B, C, D, /* pre comment */ E /* last comment */) -> &SomeType {
41+
arg(a, b, c, d, e)
42+
}
43+
44+
loong_func().quux(move || {
45+
if true {
46+
1
47+
} else {
48+
2
49+
}
50+
});
51+
52+
fffffffffffffffffffffffffffffffffff(a,
53+
{
54+
SCRIPT_TASK_ROOT
55+
.with(|root| {
56+
*root.borrow_mut() = Some(&script_task);
57+
});
58+
});
59+
a.b
60+
.c
61+
.d();
62+
63+
x().y(|| {
64+
match cond() {
65+
true => (),
66+
false => (),
67+
}
68+
});
69+
}

tests/target/hard-tabs.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// rustfmt-hard_tabs: true
2+
3+
fn main() {
4+
let x = Bar;
5+
6+
let y = Foo { a: x };
7+
8+
Foo {
9+
a: foo(), // comment
10+
// comment
11+
b: bar(),
12+
..something
13+
};
14+
15+
fn foo(a: i32,
16+
a: i32,
17+
a: i32,
18+
a: i32,
19+
a: i32,
20+
a: i32,
21+
a: i32,
22+
a: i32,
23+
a: i32,
24+
a: i32,
25+
a: i32) {
26+
}
27+
28+
let str = "AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAA\
29+
AAAAAAAAAAAAaAa";
30+
31+
if let (some_very_large, tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) =
32+
1 + 2 + 3 {
33+
}
34+
35+
if cond() {
36+
something();
37+
} else if different_cond() {
38+
something_else();
39+
} else {
40+
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
41+
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
42+
}
43+
44+
unsafe /* very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
45+
* comment */ {
46+
}
47+
48+
unsafe /* So this is a very long comment.
49+
* Multi-line, too.
50+
* Will it still format correctly? */ {
51+
}
52+
53+
let z = [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
54+
yyyyyyyyyyyyyyyyyyyyyyyyyyy,
55+
zzzzzzzzzzzzzzzzzz,
56+
q];
57+
58+
fn generic<T>(arg: T) -> &SomeType
59+
where T: Fn(// First arg
60+
A,
61+
// Second argument
62+
B,
63+
C,
64+
D,
65+
// pre comment
66+
E /* last comment */) -> &SomeType
67+
{
68+
arg(a, b, c, d, e)
69+
}
70+
71+
loong_func().quux(move || {
72+
if true {
73+
1
74+
} else {
75+
2
76+
}
77+
});
78+
79+
fffffffffffffffffffffffffffffffffff(a,
80+
{
81+
SCRIPT_TASK_ROOT.with(|root| {
82+
*root.borrow_mut() = Some(&script_task);
83+
});
84+
});
85+
a.b
86+
.c
87+
.d();
88+
89+
x().y(|| {
90+
match cond() {
91+
true => (),
92+
false => (),
93+
}
94+
});
95+
}

0 commit comments

Comments
 (0)