File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 5
5
import 'annotate_overrides_test.dart' as annotate_overrides;
6
6
import 'avoid_annotating_with_dynamic_test.dart'
7
7
as avoid_annotating_with_dynamic;
8
+ import 'avoid_equals_and_hash_code_on_mutable_classes_test.dart'
9
+ as avoid_equals_and_hash_code_on_mutable_classes;
8
10
import 'avoid_function_literals_in_foreach_calls_test.dart'
9
11
as avoid_function_literals_in_foreach_calls;
10
12
import 'avoid_init_to_null_test.dart' as avoid_init_to_null;
@@ -68,6 +70,7 @@ import 'void_checks_test.dart' as void_checks;
68
70
void main () {
69
71
annotate_overrides.main ();
70
72
avoid_annotating_with_dynamic.main ();
73
+ avoid_equals_and_hash_code_on_mutable_classes.main ();
71
74
avoid_function_literals_in_foreach_calls.main ();
72
75
avoid_setters_without_getters.main ();
73
76
avoid_init_to_null.main ();
Original file line number Diff line number Diff line change
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 (AvoidEqualsAndHashCodeOnMutableClassesTest );
12
+ });
13
+ }
14
+
15
+ @reflectiveTest
16
+ class AvoidEqualsAndHashCodeOnMutableClassesTest extends LintRuleTest {
17
+ @override
18
+ bool get addMetaPackageDep => true ;
19
+
20
+ @override
21
+ List <String > get experiments => [
22
+ EnableString .enhanced_enums,
23
+ ];
24
+
25
+ @override
26
+ String get lintRule => 'avoid_equals_and_hash_code_on_mutable_classes' ;
27
+
28
+ @FailingTest (
29
+ issue: 'https://github.com/dart-lang/linter/issues/3094' ,
30
+ reason: 'Needs new analyzer' )
31
+ test_enums () async {
32
+ // Enums are constant by design.
33
+ await assertNoDiagnostics (r'''
34
+ enum E {
35
+ e(1), f(2), g(3);
36
+ final int key;
37
+ const E(this.key);
38
+ bool operator ==(Object other) => other is E && other.key == key;
39
+ int get hashCode => key.hashCode;
40
+ }
41
+ ''' );
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments