Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1382)

Side by Side Diff: pkg/analyzer/test/generated/error_suppression_test.dart

Issue 2626653002: Remove computeLibrarySourceErrors(). (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:analyzer/src/error/codes.dart'; 5 import 'package:analyzer/src/error/codes.dart';
6 import 'package:analyzer/src/generated/source.dart'; 6 import 'package:analyzer/src/generated/source.dart';
7 import 'package:analyzer/src/generated/source_io.dart'; 7 import 'package:analyzer/src/generated/source_io.dart';
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; 8 import 'package:test_reflective_loader/test_reflective_loader.dart';
9 9
10 import 'resolver_test_case.dart'; 10 import 'resolver_test_case.dart';
11 11
12 main() { 12 main() {
13 defineReflectiveSuite(() { 13 defineReflectiveSuite(() {
14 defineReflectiveTests(ErrorSuppressionTest); 14 defineReflectiveTests(ErrorSuppressionTest);
15 }); 15 });
16 } 16 }
17 17
18 @reflectiveTest 18 @reflectiveTest
19 class ErrorSuppressionTest extends ResolverTestCase { 19 class ErrorSuppressionTest extends ResolverTestCase {
20 void test_error_code_mismatch() { 20 void test_error_code_mismatch() {
21 Source source = addSource(''' 21 Source source = addSource('''
22 // ignore: const_initialized_with_non_constant_value 22 // ignore: const_initialized_with_non_constant_value
23 int x = ''; 23 int x = '';
24 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 24 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
25 '''); 25 ''');
26 computeLibrarySourceErrors(source);
27 assertErrors(source, [ 26 assertErrors(source, [
28 StaticTypeWarningCode.INVALID_ASSIGNMENT, 27 StaticTypeWarningCode.INVALID_ASSIGNMENT,
29 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 28 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
30 ]); 29 ]);
31 } 30 }
32 31
33 void test_ignore_first() { 32 void test_ignore_first() {
34 Source source = addSource(''' 33 Source source = addSource('''
35 // ignore: invalid_assignment 34 // ignore: invalid_assignment
36 int x = ''; 35 int x = '';
37 // ... but no ignore here ... 36 // ... but no ignore here ...
38 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 37 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
39 '''); 38 ''');
40 computeLibrarySourceErrors(source);
41 assertErrors(source, 39 assertErrors(source,
42 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 40 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
43 } 41 }
44 42
45 void test_ignore_first_trailing() { 43 void test_ignore_first_trailing() {
46 Source source = addSource(''' 44 Source source = addSource('''
47 int x = ''; // ignore: invalid_assignment 45 int x = ''; // ignore: invalid_assignment
48 // ... but no ignore here ... 46 // ... but no ignore here ...
49 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 47 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
50 '''); 48 ''');
51 computeLibrarySourceErrors(source);
52 assertErrors(source, 49 assertErrors(source,
53 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 50 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
54 } 51 }
55 52
56 void test_ignore_only_trailing() { 53 void test_ignore_only_trailing() {
57 Source source = addSource(''' 54 Source source = addSource('''
58 int x = ''; // ignore: invalid_assignment 55 int x = ''; // ignore: invalid_assignment
59 '''); 56 ''');
60 computeLibrarySourceErrors(source);
61 assertErrors(source, []); 57 assertErrors(source, []);
62 } 58 }
63 59
64 void test_ignore_second() { 60 void test_ignore_second() {
65 Source source = addSource(''' 61 Source source = addSource('''
66 //INVALID_ASSIGNMENT 62 //INVALID_ASSIGNMENT
67 int x = ''; 63 int x = '';
68 // ignore: const_initialized_with_non_constant_value 64 // ignore: const_initialized_with_non_constant_value
69 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 65 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
70 '''); 66 ''');
71 computeLibrarySourceErrors(source);
72 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); 67 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
73 } 68 }
74 69
75 void test_ignore_second_trailing() { 70 void test_ignore_second_trailing() {
76 Source source = addSource(''' 71 Source source = addSource('''
77 //INVALID_ASSIGNMENT 72 //INVALID_ASSIGNMENT
78 int x = ''; 73 int x = '';
79 const y = x; // ignore: const_initialized_with_non_constant_value 74 const y = x; // ignore: const_initialized_with_non_constant_value
80 '''); 75 ''');
81 computeLibrarySourceErrors(source);
82 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); 76 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
83 } 77 }
84 78
85 void test_ignore_upper_case() { 79 void test_ignore_upper_case() {
86 Source source = addSource(''' 80 Source source = addSource('''
87 int x = ''; // ignore: INVALID_ASSIGNMENT 81 int x = ''; // ignore: INVALID_ASSIGNMENT
88 '''); 82 ''');
89 computeLibrarySourceErrors(source);
90 assertErrors(source, []); 83 assertErrors(source, []);
91 } 84 }
92 85
93 void test_invalid_error_code() { 86 void test_invalid_error_code() {
94 Source source = addSource(''' 87 Source source = addSource('''
95 // ignore: right_format_wrong_code 88 // ignore: right_format_wrong_code
96 int x = ''; 89 int x = '';
97 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 90 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
98 '''); 91 ''');
99 computeLibrarySourceErrors(source);
100 assertErrors(source, [ 92 assertErrors(source, [
101 StaticTypeWarningCode.INVALID_ASSIGNMENT, 93 StaticTypeWarningCode.INVALID_ASSIGNMENT,
102 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 94 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
103 ]); 95 ]);
104 } 96 }
105 97
106 void test_missing_error_codes() { 98 void test_missing_error_codes() {
107 Source source = addSource(''' 99 Source source = addSource('''
108 int x = 3; 100 int x = 3;
109 // ignore: 101 // ignore:
110 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE 102 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE
111 '''); 103 ''');
112 computeLibrarySourceErrors(source);
113 assertErrors(source, [ 104 assertErrors(source, [
114 StaticTypeWarningCode.INVALID_ASSIGNMENT, 105 StaticTypeWarningCode.INVALID_ASSIGNMENT,
115 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 106 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
116 ]); 107 ]);
117 } 108 }
118 109
119 void test_missing_metadata_suffix() { 110 void test_missing_metadata_suffix() {
120 Source source = addSource(''' 111 Source source = addSource('''
121 // ignore invalid_assignment 112 // ignore invalid_assignment
122 String y = 3; //INVALID_ASSIGNMENT 113 String y = 3; //INVALID_ASSIGNMENT
123 '''); 114 ''');
124 computeLibrarySourceErrors(source);
125 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); 115 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
126 } 116 }
127 117
128 void test_multiple_comments() { 118 void test_multiple_comments() {
129 Source source = addSource(''' 119 Source source = addSource('''
130 int x = ''; //This is the first comment... 120 int x = ''; //This is the first comment...
131 // ignore: const_initialized_with_non_constant_value 121 // ignore: const_initialized_with_non_constant_value
132 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 122 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
133 '''); 123 ''');
134 computeLibrarySourceErrors(source);
135 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); 124 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
136 } 125 }
137 126
138 void test_multiple_ignores() { 127 void test_multiple_ignores() {
139 Source source = addSource(''' 128 Source source = addSource('''
140 int x = 3; 129 int x = 3;
141 // ignore: invalid_assignment, const_initialized_with_non_constant_value 130 // ignore: invalid_assignment, const_initialized_with_non_constant_value
142 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE 131 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE
143 '''); 132 ''');
144 computeLibrarySourceErrors(source);
145 assertErrors(source, []); 133 assertErrors(source, []);
146 } 134 }
147 135
148 void test_multiple_ignores_traling() { 136 void test_multiple_ignores_traling() {
149 Source source = addSource(''' 137 Source source = addSource('''
150 int x = 3; 138 int x = 3;
151 const String y = x; // ignore: invalid_assignment, const_initialized_with_non_co nstant_value 139 const String y = x; // ignore: invalid_assignment, const_initialized_with_non_co nstant_value
152 '''); 140 ''');
153 computeLibrarySourceErrors(source);
154 assertErrors(source, []); 141 assertErrors(source, []);
155 } 142 }
156 143
157 void test_multiple_ignores_whitespace_variant_1() { 144 void test_multiple_ignores_whitespace_variant_1() {
158 Source source = addSource(''' 145 Source source = addSource('''
159 int x = 3; 146 int x = 3;
160 //ignore:invalid_assignment,const_initialized_with_non_constant_value 147 //ignore:invalid_assignment,const_initialized_with_non_constant_value
161 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE 148 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE
162 '''); 149 ''');
163 computeLibrarySourceErrors(source);
164 assertErrors(source, []); 150 assertErrors(source, []);
165 } 151 }
166 152
167 void test_multiple_ignores_whitespace_variant_2() { 153 void test_multiple_ignores_whitespace_variant_2() {
168 Source source = addSource(''' 154 Source source = addSource('''
169 int x = 3; 155 int x = 3;
170 //ignore: invalid_assignment,const_initialized_with_non_constant_value 156 //ignore: invalid_assignment,const_initialized_with_non_constant_value
171 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE 157 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE
172 '''); 158 ''');
173 computeLibrarySourceErrors(source);
174 assertErrors(source, []); 159 assertErrors(source, []);
175 } 160 }
176 161
177 void test_multiple_ignores_whitespace_variant_3() { 162 void test_multiple_ignores_whitespace_variant_3() {
178 Source source = addSource(''' 163 Source source = addSource('''
179 int x = 3; 164 int x = 3;
180 // ignore: invalid_assignment,const_initialized_with_non_constant_value 165 // ignore: invalid_assignment,const_initialized_with_non_constant_value
181 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE 166 const String y = x; //INVALID_ASSIGNMENT, CONST_INITIALIZED_WITH_NON_CONSTANT_VA LUE
182 '''); 167 ''');
183 computeLibrarySourceErrors(source);
184 assertErrors(source, []); 168 assertErrors(source, []);
185 } 169 }
186 170
187 void test_no_ignores() { 171 void test_no_ignores() {
188 Source source = addSource(''' 172 Source source = addSource('''
189 int x = ''; //INVALID_ASSIGNMENT 173 int x = ''; //INVALID_ASSIGNMENT
190 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 174 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
191 '''); 175 ''');
192 computeLibrarySourceErrors(source);
193 assertErrors(source, [ 176 assertErrors(source, [
194 StaticTypeWarningCode.INVALID_ASSIGNMENT, 177 StaticTypeWarningCode.INVALID_ASSIGNMENT,
195 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 178 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
196 ]); 179 ]);
197 } 180 }
198 } 181 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/compile_time_error_code_test.dart ('k') | pkg/analyzer/test/generated/hint_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698