@@ -17,6 +17,146 @@ class AvoidAnnotatingWithDynamicTest extends LintRuleTest {
17
17
@override
18
18
String get lintRule => 'avoid_annotating_with_dynamic' ;
19
19
20
+ test_augmentationClass () async {
21
+ var a = newFile ('$testPackageLibPath /a.dart' , r'''
22
+ import augment 'b.dart';
23
+
24
+ class A { }
25
+ ''' );
26
+
27
+ var b = newFile ('$testPackageLibPath /b.dart' , r'''
28
+ augment library 'a.dart';
29
+
30
+ augment class A {
31
+ void f(dynamic o) { }
32
+ }
33
+ ''' );
34
+
35
+ result = await resolveFile (a.path);
36
+ await assertNoDiagnosticsIn (errors);
37
+
38
+ result = await resolveFile (b.path);
39
+ await assertDiagnosticsIn (errors, [
40
+ lint (54 , 9 ),
41
+ ]);
42
+ }
43
+
44
+ test_augmentationTopLevelFunction () async {
45
+ var a = newFile ('$testPackageLibPath /a.dart' , r'''
46
+ import augment 'b.dart';
47
+ ''' );
48
+
49
+ var b = newFile ('$testPackageLibPath /b.dart' , r'''
50
+ augment library 'a.dart';
51
+
52
+ void f(dynamic o) { }
53
+ ''' );
54
+
55
+ result = await resolveFile (a.path);
56
+ await assertNoDiagnosticsIn (errors);
57
+
58
+ result = await resolveFile (b.path);
59
+ await assertDiagnosticsIn (errors, [
60
+ lint (34 , 9 ),
61
+ ]);
62
+ }
63
+
64
+ test_augmentationTopLevelFunction_localDynamic () async {
65
+ var a = newFile ('$testPackageLibPath /a.dart' , r'''
66
+ import augment 'b.dart';
67
+
68
+ void f(int i) {}
69
+ ''' );
70
+
71
+ var b = newFile ('$testPackageLibPath /b.dart' , r'''
72
+ augment library 'a.dart';
73
+
74
+ augment void f(int i) {
75
+ var g = (dynamic x) {};
76
+ g(i);
77
+ }
78
+ ''' );
79
+
80
+ result = await resolveFile (a.path);
81
+ await assertNoDiagnosticsIn (errors);
82
+
83
+ result = await resolveFile (b.path);
84
+ await assertDiagnosticsIn (errors, [
85
+ lint (62 , 9 ),
86
+ ]);
87
+ }
88
+
89
+ test_augmentedMethod () async {
90
+ var a = newFile ('$testPackageLibPath /a.dart' , r'''
91
+ import augment 'b.dart';
92
+
93
+ class A {
94
+ void f(dynamic o) { }
95
+ }
96
+ ''' );
97
+
98
+ var b = newFile ('$testPackageLibPath /b.dart' , r'''
99
+ augment library 'a.dart';
100
+
101
+ augment class A {
102
+ augment void f(dynamic o) { }
103
+ }
104
+ ''' );
105
+
106
+ result = await resolveFile (a.path);
107
+ await assertDiagnosticsIn (errors, [
108
+ lint (45 , 9 ),
109
+ ]);
110
+
111
+ result = await resolveFile (b.path);
112
+ await assertNoDiagnosticsIn (errors);
113
+ }
114
+
115
+ test_augmentedTopLevelFunction () async {
116
+ var a = newFile ('$testPackageLibPath /a.dart' , r'''
117
+ import augment 'b.dart';
118
+
119
+ void f(dynamic o) { }
120
+ ''' );
121
+
122
+ var b = newFile ('$testPackageLibPath /b.dart' , r'''
123
+ augment library 'a.dart';
124
+
125
+ augment void f(dynamic o) { }
126
+ ''' );
127
+
128
+ result = await resolveFile (a.path);
129
+ await assertDiagnosticsIn (errors, [
130
+ lint (33 , 9 ),
131
+ ]);
132
+
133
+ result = await resolveFile (b.path);
134
+ await assertNoDiagnosticsIn (errors);
135
+ }
136
+
137
+ test_augmentedTopLevelFunction_multiple () async {
138
+ var a = newFile ('$testPackageLibPath /a.dart' , r'''
139
+ import augment 'b.dart';
140
+
141
+ void f(dynamic o) { }
142
+ ''' );
143
+
144
+ var b = newFile ('$testPackageLibPath /b.dart' , r'''
145
+ augment library 'a.dart';
146
+
147
+ augment void f(dynamic o) { }
148
+ augment void f(dynamic o) { }
149
+ ''' );
150
+
151
+ result = await resolveFile (a.path);
152
+ await assertDiagnosticsIn (errors, [
153
+ lint (33 , 9 ),
154
+ ]);
155
+
156
+ result = await resolveFile (b.path);
157
+ await assertNoDiagnosticsIn (errors);
158
+ }
159
+
20
160
// TODO(srawlins): Test parameter of function-typed typedef (both old and
21
161
// new style).
22
162
// Test parameter of function-typed parameter (`f(void g(dynamic x))`).
0 commit comments