Skip to content

Commit 94abf95

Browse files
authored
Migrate more tests to the new style and reorganize some. (#1398)
No behavioral changes here, just migrating over more of the old tests to the new style. Also, in the process of doing that, I noticed some new tests weren't organized correctly. Yield, await, and throw were under statement but those are all expressions. (Yes, even throw.) Likewise, the generic function instantiation tests were under type/ even though they're expressions, not type annotations.
1 parent d11f8ca commit 94abf95

File tree

15 files changed

+374
-131
lines changed

15 files changed

+374
-131
lines changed

test/declaration/constructor_parameter.unit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,14 @@ class Foo {
8080
required int super.e(),
8181
super.f() = x,
8282
});
83+
}
84+
>>> Covariant initializing formal.
85+
### This isn't semantically valid Dart code, but it's syntactically valid so
86+
### the formatter should handle it correctly.
87+
class A {
88+
A( covariant this.foo);
89+
}
90+
<<<
91+
class A {
92+
A(covariant this.foo);
8393
}

test/declaration/member_comment.unit

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
40 columns |
2+
>>> Ensure blank line above doc comments on members.
3+
class Foo {
4+
var a = 1; /// Doc A.
5+
var b = 2;
6+
/// Doc c.
7+
void c() => body; /// Doc d.
8+
void d() {;}
9+
}
10+
<<<
11+
class Foo {
12+
var a = 1;
13+
14+
/// Doc A.
15+
var b = 2;
16+
17+
/// Doc c.
18+
void c() => body;
19+
20+
/// Doc d.
21+
void d() {
22+
;
23+
}
24+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
40 columns |
2+
>>> Unsplit.
3+
void main() => id < int > ;
4+
<<<
5+
void main() => id<int>;
6+
>>> Unsplit with multiple type arguments.
7+
void main() => id < int , String , bool > ;
8+
<<<
9+
void main() => id<int, String, bool>;
10+
>>> Unsplit generic constructor tear-off.
11+
var x = Class < int >;
12+
<<<
13+
var x = Class<int>;
14+
>>> Split type arguments.
15+
LongClassName<First, Second, Third, Fourth>;
16+
<<<
17+
LongClassName<
18+
First,
19+
Second,
20+
Third,
21+
Fourth
22+
>;
23+
>>> Split type arguments.
24+
LongClassName<First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>;
25+
<<<
26+
LongClassName<
27+
First,
28+
Second,
29+
Third,
30+
Fourth,
31+
Fifth,
32+
Sixth,
33+
Seventh,
34+
Eighth
35+
>;
36+
>>> Split nested type arguments.
37+
LongClassName<First, Inner<Second, Third, Fourth, Fifth, Sixth, Seventh>, Eighth>;
38+
<<<
39+
LongClassName<
40+
First,
41+
Inner<
42+
Second,
43+
Third,
44+
Fourth,
45+
Fifth,
46+
Sixth,
47+
Seventh
48+
>,
49+
Eighth
50+
>;
51+
>>> Split type arguments when nested inside expression.
52+
veryLongFunction(argument, ConstructorTearOff<First, Second, Third, Fourth>, argument);
53+
<<<
54+
veryLongFunction(
55+
argument,
56+
ConstructorTearOff<
57+
First,
58+
Second,
59+
Third,
60+
Fourth
61+
>,
62+
argument,
63+
);

test/expression/other.stmt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,43 @@ this;
3232
>>> Long qualified symbols do not split.
3333
#longComponent.anotherLongComponent.third;
3434
<<<
35-
#longComponent.anotherLongComponent.third;
35+
#longComponent.anotherLongComponent.third;
36+
>>> Yield.
37+
Stream<String> i(String n) async* {
38+
yield i ;
39+
}
40+
<<<
41+
Stream<String> i(String n) async* {
42+
yield i;
43+
}
44+
>>> Yield*.
45+
Stream<int> i(int n) async* {
46+
yield * i ( n - 1 ) ;
47+
}
48+
<<<
49+
Stream<int> i(int n) async* {
50+
yield* i(n - 1);
51+
}
52+
>>> Await.
53+
foo() async {
54+
await i ( 1 + 2 ) ;
55+
}
56+
<<<
57+
foo() async {
58+
await i(1 + 2);
59+
}
60+
>>> Throw.
61+
throw 'error'
62+
;
63+
<<<
64+
throw 'error';
65+
>>> Throw doesn't split after the 'throw' keyword.
66+
throw 'Some extremely long error message.';
67+
<<<
68+
throw 'Some extremely long error message.';
69+
>>> Throw with long string literal.
70+
throw new FormatException('This is a long exception message.');
71+
<<<
72+
throw new FormatException(
73+
'This is a long exception message.',
74+
);

test/expression/set.stmt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,18 @@ const {first, second};
1919
>>> With type argument.
2020
< int > { 1 , 2 };
2121
<<<
22-
<int>{1, 2};
22+
<int>{1, 2};
23+
>>> Split in type argument.
24+
var set = <Inner<First, Second, Third, Fourth, Fifth, Sixth>>{};
25+
<<<
26+
var set =
27+
<
28+
Inner<
29+
First,
30+
Second,
31+
Third,
32+
Fourth,
33+
Fifth,
34+
Sixth
35+
>
36+
>{};

test/invocation/function.stmt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ someFunctionOne(
8080
),
8181
someArgument,
8282
someArgument,
83-
);
83+
);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
40 columns |
2+
### An invocation expression is a function call where the function is itself
3+
### an expression like `(x + y)(arg)` and not a simple name like `foo(arg)`.
4+
>>> With type arguments, unsplit.
5+
(fn)<T, S>(1, 2);
6+
<<<
7+
(fn)<T, S>(1, 2);
8+
>>> Prefer to split value arguments instead of type arguments.
9+
(longFunction)<TypeArgument>(valueArgument);
10+
<<<
11+
(longFunction)<TypeArgument>(
12+
valueArgument,
13+
);
14+
>>> Split both type and value arguments.
15+
(longFunction)<First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(first, second, third, fourth, fifth, sixth, seventh, eighth);
16+
<<<
17+
(longFunction)<
18+
First,
19+
Second,
20+
Third,
21+
Fourth,
22+
Fifth,
23+
Sixth,
24+
Seventh,
25+
Eighth
26+
>(
27+
first,
28+
second,
29+
third,
30+
fourth,
31+
fifth,
32+
sixth,
33+
seventh,
34+
eighth,
35+
);

test/selection/selection.unit

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,85 @@ class Bar {}
1414
<<<
1515
class Foo {}
1616

17-
‹›class Bar {}
17+
‹›class Bar {}
18+
>>> Select entire file.
19+
‹main( ) {
20+
body( ) ;}›
21+
<<<
22+
‹main() {
23+
body();
24+
}›
25+
>>> With trailing comment.
26+
ma‹in() {}
27+
// com›ment
28+
<<<
29+
ma‹in() {}
30+
// com›ment
31+
>>> In discarded whitespace.
32+
foo( ‹ argument){ › }
33+
<<<
34+
foo(‹argument) {›}
35+
>>> In zero-length split whitespace.
36+
main(){veryLongMethodCall(‹veryLongArgumentName);
37+
veryLongMethodCall(›veryLongArgumentName);
38+
}
39+
<<<
40+
main() {
41+
veryLongMethodCall(
42+
‹veryLongArgumentName,
43+
);
44+
veryLongMethodCall(›
45+
veryLongArgumentName,
46+
);
47+
}
48+
>>> In split-inserted space.
49+
main() {shortCall(argument, ‹ argument);
50+
shortCall(argument, › argument);
51+
}
52+
<<<
53+
main() {
54+
shortCall(argument, ‹argument);
55+
shortCall(argument, ›argument);
56+
}
57+
>>> In inserted mandatory newline.
58+
foo() {body; ‹ }
59+
bar() {body; › }
60+
<<<
61+
foo() {
62+
body;
63+
‹}
64+
65+
bar() {
66+
body;›
67+
}
68+
>>> In inserted mandatory space.
69+
main() async {
70+
await‹(1);
71+
throw›(2);
72+
}
73+
<<<
74+
main() async {
75+
await ‹(1);
76+
throw› (2);
77+
}
78+
>>> Across pieces that get solved separately.
79+
foo() {
80+
81+
82+
fir‹st();
83+
}
84+
85+
bar() {sec›ond();}
86+
<<<
87+
foo() {
88+
fir‹st();
89+
}
90+
91+
bar() {
92+
sec›ond();
93+
}
94+
>>> Only whitespace in newline selected.
95+
foo() {} ‹ › bar() {}
96+
<<<
97+
foo() {}
98+
‹›bar() {}

test/statement/other.stmt

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,6 @@ while (true) {
3131
while (true) {
3232
continue someLabel;
3333
}
34-
>>> Yield.
35-
Stream<String> i(String n) async* {
36-
yield i ;
37-
}
38-
<<<
39-
Stream<String> i(String n) async* {
40-
yield i;
41-
}
42-
>>> Yield*.
43-
Stream<int> i(int n) async* {
44-
yield * i ( n - 1 ) ;
45-
}
46-
<<<
47-
Stream<int> i(int n) async* {
48-
yield* i(n - 1);
49-
}
50-
>>> Await.
51-
foo() async {
52-
await i ( 1 + 2 ) ;
53-
}
54-
<<<
55-
foo() async {
56-
await i(1 + 2);
57-
}
58-
>>> Throw.
59-
throw 'error'
60-
;
61-
<<<
62-
throw 'error';
63-
>>> Throw doesn't split after the 'throw' keyword.
64-
throw 'Some extremely long error message.';
65-
<<<
66-
throw 'Some extremely long error message.';
67-
>>> Throw with long string literal.
68-
throw new FormatException('This is a long exception message.');
69-
<<<
70-
throw new FormatException(
71-
'This is a long exception message.',
72-
);
7334
>>> Rethrow.
7435
try {
7536
throw 1 ;

0 commit comments

Comments
 (0)