Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit c3d4570

Browse files
committed
enhanced enum tests for annotate_overrides
1 parent bd57859 commit c3d4570

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

test/rules/all.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'annotate_overrides.dart' as annotate_overrides;
56
import 'avoid_annotating_with_dynamic.dart' as avoid_annotating_with_dynamic;
67
import 'avoid_function_literals_in_foreach_calls.dart'
78
as avoid_function_literals_in_foreach_calls;
@@ -48,6 +49,7 @@ import 'use_is_even_rather_than_modulo.dart' as use_is_even_rather_than_modulo;
4849
import 'void_checks.dart' as void_checks;
4950

5051
void main() {
52+
annotate_overrides.main();
5153
avoid_annotating_with_dynamic.main();
5254
avoid_function_literals_in_foreach_calls.main();
5355
avoid_init_to_null.main();

test/rules/annotate_overrides.dart

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:test_reflective_loader/test_reflective_loader.dart';
6+
7+
import '../rule_test_support.dart';
8+
9+
main() {
10+
defineReflectiveSuite(() {
11+
defineReflectiveTests(AnnotateOverridesTest);
12+
});
13+
}
14+
15+
@reflectiveTest
16+
class AnnotateOverridesTest extends LintRuleTest {
17+
@override
18+
List<String> get experiments => [
19+
EnableString.enhanced_enums,
20+
];
21+
22+
@override
23+
String get lintRule => 'annotate_overrides';
24+
25+
test_field() async {
26+
await assertDiagnostics(r'''
27+
enum A {
28+
a,b,c;
29+
int get hashCode => 0;
30+
}
31+
''', [
32+
lint('annotate_overrides', 28, 8),
33+
]);
34+
}
35+
36+
test_method() async {
37+
await assertDiagnostics(r'''
38+
enum A {
39+
a,b,c;
40+
String toString() => '';
41+
}
42+
''', [
43+
lint('annotate_overrides', 27, 8),
44+
]);
45+
}
46+
47+
@FailingTest(issue: 'https://github.com/dart-lang/linter/issues/3093')
48+
test_ok() async {
49+
await assertNoDiagnostics(r'''
50+
enum A {
51+
a,b,c;
52+
@override
53+
int get hashCode => 0;
54+
@override
55+
String toString() => '';
56+
}
57+
''');
58+
}
59+
}

0 commit comments

Comments
 (0)