Skip to content

Commit 3166d71

Browse files
munificentCommit Queue
authored andcommitted
Format tests/language/e*.
Since I regenerated the test expectations, this also fills in a few unspecified errors with more precise information. Change-Id: I4a2450de030a7d38b08f30f46d9d9feca99404f5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/407082 Reviewed-by: Lasse Nielsen <[email protected]> Commit-Queue: Lasse Nielsen <[email protected]> Auto-Submit: Bob Nystrom <[email protected]>
1 parent 8e17d8b commit 3166d71

File tree

43 files changed

+559
-555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+559
-555
lines changed

tests/language/enum/duplicate_lib.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
library enum_duplicate_lib;
66

7-
enum Enum1 {
8-
A,
9-
B,
10-
}
7+
enum Enum1 { A, B }
118

129
class Enum2 {
1310
static Iterable get values => ['Enum2.A', 'Enum2.B'];

tests/language/enum/enhanced_enums_basic_test.dart

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ void main() {
2929
Expect.identical(EnumPlainSemicolon.v3, EnumPlainSemicolon.values[2]);
3030

3131
Expect.equals(3, EnumPlainTrailingCommaSemicolon.values.length);
32-
Expect.identical(EnumPlainTrailingCommaSemicolon.v1,
33-
EnumPlainTrailingCommaSemicolon.values[0]);
34-
Expect.identical(EnumPlainTrailingCommaSemicolon.v2,
35-
EnumPlainTrailingCommaSemicolon.values[1]);
36-
Expect.identical(EnumPlainTrailingCommaSemicolon.v3,
37-
EnumPlainTrailingCommaSemicolon.values[2]);
32+
Expect.identical(
33+
EnumPlainTrailingCommaSemicolon.v1,
34+
EnumPlainTrailingCommaSemicolon.values[0],
35+
);
36+
Expect.identical(
37+
EnumPlainTrailingCommaSemicolon.v2,
38+
EnumPlainTrailingCommaSemicolon.values[1],
39+
);
40+
Expect.identical(
41+
EnumPlainTrailingCommaSemicolon.v3,
42+
EnumPlainTrailingCommaSemicolon.values[2],
43+
);
3844

3945
Expect.equals(6, EnumAll.values.length);
4046
Expect.identical(EnumAll.v1, EnumAll.values[0]);
@@ -105,7 +111,9 @@ void main() {
105111
Expect.identical(EnumAll.v4, EnumAll.v3 ^ EnumAll.v2);
106112

107113
Expect.equals(
108-
"EnumAll.v1:EnumMixin<num>:ObjectMixin:this", EnumAll.v1.thisAndSuper());
114+
"EnumAll.v1:EnumMixin<num>:ObjectMixin:this",
115+
EnumAll.v1.thisAndSuper(),
116+
);
109117

110118
// Which can reference type parameters.
111119
Expect.isTrue(EnumAll.v2.test(2)); // does `is T` with `T` being `int`.
@@ -148,35 +156,22 @@ void main() {
148156
enum EnumPlain { v1, v2, v3 }
149157

150158
// Also with trailing comma.
151-
enum EnumPlainTrailingComma {
152-
v1,
153-
v2,
154-
v3,
155-
}
159+
enum EnumPlainTrailingComma { v1, v2, v3 }
156160

157161
// Also if using type parameters, mixins or interfaces.
158162
// It only matters whether there is something after the values.
159163
enum EnumNoSemicolon<T extends num> with ObjectMixin implements Interface {
160164
v1,
161165
v2,
162-
v3
166+
v3,
163167
}
164168

165169
// Allows semicolon after values, even when not needed.
166170
// Without trailing comma.
167-
enum EnumPlainSemicolon {
168-
v1,
169-
v2,
170-
v3;
171-
}
171+
enum EnumPlainSemicolon { v1, v2, v3 }
172172

173173
// With trailing comma.
174-
enum EnumPlainTrailingCommaSemicolon {
175-
v1,
176-
v2,
177-
v3,
178-
;
179-
}
174+
enum EnumPlainTrailingCommaSemicolon { v1, v2, v3 }
180175

181176
// Full syntax, with every possible option.
182177
@EnumAll.v1
@@ -193,8 +188,7 @@ enum EnumAll<S extends num, T extends num>
193188
v3<int, int>(y: 2),
194189
v4.named(1, y: 2),
195190
v5<int, int>.renamed(1, y: 2),
196-
v6.new(),
197-
;
191+
v6.new();
198192

199193
/// Static members.
200194
///
@@ -216,16 +210,16 @@ enum EnumAll<S extends num, T extends num>
216210
// Constructors.
217211
// Generative, non-redirecting, unnamed.
218212
const EnumAll({T? y})
219-
: constructor = "unnamed",
220-
this.x = 0 as S,
221-
y = y ?? (0 as T);
213+
: constructor = "unnamed",
214+
this.x = 0 as S,
215+
y = y ?? (0 as T);
222216
// Generative, non-redirecting, named.
223217
const EnumAll.named(this.x, {T? y, String? constructor})
224-
: constructor = constructor ?? "named",
225-
y = y ?? (0 as T);
218+
: constructor = constructor ?? "named",
219+
y = y ?? (0 as T);
226220
// Generative, redirecting.
227221
const EnumAll.renamed(S x, {T? y})
228-
: this.named(x, y: y, constructor: "renamed");
222+
: this.named(x, y: y, constructor: "renamed");
229223
// Factory, non-redirecting.
230224
factory EnumAll.factory(int index) => values[index] as EnumAll<S, T>;
231225
// Factory, redirecting (only to other factory constructor).

tests/language/enum/enhanced_enums_error_test.dart

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ enum ConflictClassTypeParameter<ConflictClassTypeParameter> {
264264
// [analyzer] COMPILE_TIME_ERROR.CONFLICTING_TYPE_VARIABLE_AND_CONTAINER
265265
// [cfe] A type variable can't have the same name as its enclosing declaration.
266266
e1;
267-
//^
267+
// [error column 3]
268268
// [cfe] Couldn't find constructor 'ConflictClassTypeParameter'.
269269
}
270270

@@ -405,10 +405,10 @@ enum ConflictClassEnumValue {
405405
// Has conflict with implicitly inserted `values` member.
406406
enum values {
407407
// ^^^^^^
408-
// [analyzer] unspecified
408+
// [analyzer] COMPILE_TIME_ERROR.ENUM_WITH_NAME_VALUES
409409
// [cfe] The name 'values' is not a valid name for an enum. Try using a different name.
410410
e1;
411-
//^
411+
// [error column 3]
412412
// [cfe] Couldn't find constructor 'values'.
413413
}
414414

@@ -449,9 +449,8 @@ enum OverridesEquals {
449449
e1;
450450

451451
bool operator==(Object other) => identical(e1, other);
452-
// ^^^^^^^^
453-
// [analyzer] unspecified
454-
// ^
452+
// ^^
453+
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
455454
// [cfe] An enum can't declare a non-abstract member named '=='.
456455
}
457456

@@ -460,7 +459,7 @@ enum OverridesHashCode {
460459

461460
int get hashCode => 42;
462461
// ^^^^^^^^
463-
// [analyzer] unspecified
462+
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
464463
// [cfe] An enum can't declare a non-abstract member named 'hashCode'.
465464
}
466465

@@ -515,9 +514,9 @@ enum NoConstructorCalls {
515514
// [cfe] Final field 'x' is not initialized by this constructor.
516515
// ^^^^^^^^^^^^^^
517516
// [analyzer] COMPILE_TIME_ERROR.REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR
518-
// [cfe] Couldn't find constructor 'NoConstructorCalls.factory'.
519517
// ^^^^^^^
520518
// [analyzer] COMPILE_TIME_ERROR.REDIRECT_TO_NON_CONST_CONSTRUCTOR
519+
// [cfe] Couldn't find constructor 'NoConstructorCalls.factory'.
521520

522521
factory NoConstructorCalls.factory() => e1; // Valid.
523522

@@ -614,7 +613,7 @@ enum DeclaresStaticIndex {
614613

615614
enum InheritsIndex with IndexGetter {
616615
// ^^^^^^^^^^^^^
617-
// [analyzer] unspecified
616+
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
618617
// [cfe] An enum can't inherit a member named 'index'.
619618
e1;
620619
}
@@ -643,8 +642,8 @@ enum ImplementsNeverIndex {
643642
}
644643

645644
enum NSMImplementsNeverIndex implements NeverIndexGetter {
646-
// ^^^^^^
647-
// [analyzer] unspecified
645+
// ^^^^^^^^^^^^^^^^^^^^^^^
646+
// [analyzer] COMPILE_TIME_ERROR.INVALID_IMPLEMENTATION_OVERRIDE
648647
// [cfe] The implementation of 'index' in the non-abstract class 'NSMImplementsNeverIndex' does not conform to its interface.
649648
e1;
650649

@@ -670,11 +669,10 @@ enum CyclicReference {
670669
// Since `values` contains `e1`,
671670
// we can't have a reference in the other direction.
672671
enum CyclicReferenceValues {
673-
// ^
674-
// [cfe] Constant evaluation error:
675672
e1(values);
676673
//^^
677674
// [analyzer] COMPILE_TIME_ERROR.RECURSIVE_COMPILE_TIME_CONSTANT
675+
// [cfe] Constant evaluation error:
678676
final List<CyclicReferenceValues> list;
679677
const CyclicReferenceValues(this.list);
680678
}

tests/language/enum/enhanced_enums_subtype_error_test.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ abstract class AbstractImplementsWithValues implements Enum {
3535
}
3636

3737
abstract class AbstractExtendsWithValues extends Enum {
38-
// ^
39-
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
38+
// ^
39+
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
4040
int get values => 42;
4141
// ^^^^^^
4242
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_ENUM_VALUES
@@ -51,8 +51,8 @@ abstract class AbstractImplementsWithIndex implements Enum {
5151
}
5252

5353
abstract class AbstractExtendsWithIndex extends Enum {
54-
// ^
55-
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
54+
// ^
55+
// [cfe] The class 'Enum' can't be extended outside of its library because it's an interface class.
5656
int get index => 42;
5757
// ^^^^^
5858
// [analyzer] COMPILE_TIME_ERROR.ILLEGAL_CONCRETE_ENUM_MEMBER
@@ -184,7 +184,7 @@ enum EnumImplementsEnum implements MyEnum {
184184
// [cfe] 'MyEnum' is an enum and can't be extended or implemented.
185185
// ^^^^^^
186186
// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
187-
e1;
187+
e1,
188188
}
189189

190190
enum EnumMixesInEnum with MyEnum {
@@ -195,11 +195,9 @@ enum EnumMixesInEnum with MyEnum {
195195
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
196196
// [cfe] The class 'MyEnum' can't be used as a mixin because it extends a class other than 'Object'.
197197
// [cfe] The class 'MyEnum' can't be used as a mixin because it isn't a mixin class nor a mixin.
198-
e1;
198+
e1,
199199
}
200200

201201
void main() {}
202202

203-
enum MyEnum {
204-
e1;
205-
}
203+
enum MyEnum { e1 }

tests/language/enum/enum_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ enum Enum2 { A }
1010

1111
enum Enum3 { B, C }
1212

13-
enum Enum4 {
14-
D,
15-
E,
16-
}
13+
// Don't format to preserve the trailing comma.
14+
// dart format off
15+
enum Enum4 { D, E, }
16+
// dart format on
1717

1818
enum Enum5 { F, G, H }
1919

@@ -35,7 +35,7 @@ enum JSFunctionPrototype {
3535
constructor,
3636
apply,
3737
bind,
38-
call
38+
call,
3939
}
4040

4141
void expectIs<T>(T t, bool Function(Object?) test) {

tests/language/enum/index_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ library enum_index_test;
88

99
import 'package:expect/expect.dart';
1010

11-
enum Enum {
12-
A,
13-
B,
14-
}
11+
enum Enum { A, B }
1512

1613
class Class {
1714
var index;

tests/language/enum/initialization_near_stack_overflow_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
// how much stack is left and used by the compiler. It should never crash nor
1010
// produce a runtime exception.
1111

12-
enum Fruit {
13-
apple,
14-
banana,
15-
}
12+
enum Fruit { apple, banana }
1613

1714
getFruit() => Fruit.apple;
1815

tests/language/enum/private_lib.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44

55
library enum_private_lib;
66

7-
enum Enum2 {
8-
_A,
9-
_B,
10-
}
7+
enum Enum2 { _A, _B }

tests/language/enum/private_runtime_1_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import 'package:expect/expect.dart';
1313

1414
import 'private_lib.dart';
1515

16-
enum Enum1 {
17-
_A,
18-
_B,
19-
}
16+
enum Enum1 { _A, _B }
2017

2118
main() {
2219
Expect.equals('Enum1._A,Enum1._B', Enum1.values.join(','));

tests/language/enum/private_runtime_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import 'package:expect/expect.dart';
1313

1414
import 'private_lib.dart';
1515

16-
enum Enum1 {
17-
_A,
18-
_B,
19-
}
16+
enum Enum1 { _A, _B }
2017

2118
main() {
2219
Expect.equals('Enum1._A,Enum1._B', Enum1.values.join(','));

0 commit comments

Comments
 (0)