This repository was archived by the owner on Nov 20, 2024. It is now read-only.
File tree 2 files changed +61
-0
lines changed 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ import 'use_is_even_rather_than_modulo_test.dart'
127
127
as use_is_even_rather_than_modulo;
128
128
import 'use_late_for_private_fields_and_variables_test.dart'
129
129
as use_late_for_private_fields_and_variables;
130
+ import 'use_named_constants_test.dart' as use_named_constants;
130
131
import 'use_super_parameters_test.dart' as use_super_parameters;
131
132
import 'void_checks_test.dart' as void_checks;
132
133
@@ -222,6 +223,7 @@ void main() {
222
223
use_enums.main ();
223
224
use_is_even_rather_than_modulo.main ();
224
225
use_late_for_private_fields_and_variables.main ();
226
+ use_named_constants.main ();
225
227
use_super_parameters.main ();
226
228
void_checks.main ();
227
229
}
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2023, 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 (UseNamedConstantsTestLanguage300 );
12
+ });
13
+ }
14
+
15
+ @reflectiveTest
16
+ class UseNamedConstantsTestLanguage300 extends LintRuleTest
17
+ with LanguageVersion300Mixin {
18
+ @override
19
+ String get lintRule => 'use_named_constants' ;
20
+
21
+ /// https://github.com/dart-lang/linter/issues/4201
22
+ test_constantPattern_ifCase () async {
23
+ await assertDiagnostics (r'''
24
+ class A {
25
+ const A(this.value);
26
+ final int value;
27
+
28
+ static const zero = A(0);
29
+ }
30
+
31
+ void f(A a) {
32
+ if (a case const A(0)) print(a);
33
+ }
34
+ ''' , [
35
+ lint (117 , 4 ),
36
+ ]);
37
+ }
38
+
39
+ /// https://github.com/dart-lang/linter/issues/4201
40
+ test_constantPattern_switch () async {
41
+ await assertDiagnostics (r'''
42
+ class A {
43
+ const A(this.value);
44
+ final int value;
45
+
46
+ static const zero = A(0);
47
+ static const one = A(1);
48
+ }
49
+
50
+ void f(A a) {
51
+ switch (a) {
52
+ case const A(1):
53
+ }
54
+ }
55
+ ''' , [
56
+ lint (155 , 4 ),
57
+ ]);
58
+ }
59
+ }
You can’t perform that action at this time.
0 commit comments