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

enhanced enum tests for annotate_overrides #3186

Merged
merged 1 commit into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/rules/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'annotate_overrides.dart' as annotate_overrides;
import 'avoid_annotating_with_dynamic.dart' as avoid_annotating_with_dynamic;
import 'avoid_function_literals_in_foreach_calls.dart'
as avoid_function_literals_in_foreach_calls;
Expand Down Expand Up @@ -48,6 +49,7 @@ import 'use_is_even_rather_than_modulo.dart' as use_is_even_rather_than_modulo;
import 'void_checks.dart' as void_checks;

void main() {
annotate_overrides.main();
avoid_annotating_with_dynamic.main();
avoid_function_literals_in_foreach_calls.main();
avoid_init_to_null.main();
Expand Down
59 changes: 59 additions & 0 deletions test/rules/annotate_overrides.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:test_reflective_loader/test_reflective_loader.dart';

import '../rule_test_support.dart';

main() {
defineReflectiveSuite(() {
defineReflectiveTests(AnnotateOverridesTest);
});
}

@reflectiveTest
class AnnotateOverridesTest extends LintRuleTest {
@override
List<String> get experiments => [
EnableString.enhanced_enums,
];

@override
String get lintRule => 'annotate_overrides';

test_field() async {
await assertDiagnostics(r'''
enum A {
a,b,c;
int get hashCode => 0;
}
''', [
lint('annotate_overrides', 28, 8),
]);
}

test_method() async {
await assertDiagnostics(r'''
enum A {
a,b,c;
String toString() => '';
}
''', [
lint('annotate_overrides', 27, 8),
]);
}

@FailingTest(issue: 'https://github.com/dart-lang/linter/issues/3093')
test_ok() async {
await assertNoDiagnostics(r'''
enum A {
a,b,c;
@override
int get hashCode => 0;
@override
String toString() => '';
}
''');
}
}