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

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

Issue 2624793002: Make error producing tests ansynchronous. (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 test_error_code_mismatch() async {
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 assertErrors(source, [ 26 await assertErrors(source, [
27 StaticTypeWarningCode.INVALID_ASSIGNMENT, 27 StaticTypeWarningCode.INVALID_ASSIGNMENT,
28 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 28 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
29 ]); 29 ]);
30 } 30 }
31 31
32 void test_ignore_first() { 32 test_ignore_first() async {
33 Source source = addSource(''' 33 Source source = addSource('''
34 // ignore: invalid_assignment 34 // ignore: invalid_assignment
35 int x = ''; 35 int x = '';
36 // ... but no ignore here ... 36 // ... but no ignore here ...
37 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 37 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
38 '''); 38 ''');
39 assertErrors(source, 39 await assertErrors(source,
40 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 40 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
41 } 41 }
42 42
43 void test_ignore_first_trailing() { 43 test_ignore_first_trailing() async {
44 Source source = addSource(''' 44 Source source = addSource('''
45 int x = ''; // ignore: invalid_assignment 45 int x = ''; // ignore: invalid_assignment
46 // ... but no ignore here ... 46 // ... but no ignore here ...
47 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 47 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
48 '''); 48 ''');
49 assertErrors(source, 49 await assertErrors(source,
50 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 50 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
51 } 51 }
52 52
53 void test_ignore_only_trailing() { 53 test_ignore_only_trailing() async {
54 Source source = addSource(''' 54 Source source = addSource('''
55 int x = ''; // ignore: invalid_assignment 55 int x = ''; // ignore: invalid_assignment
56 '''); 56 ''');
57 assertErrors(source, []); 57 await assertErrors(source, []);
58 } 58 }
59 59
60 void test_ignore_second() { 60 test_ignore_second() async {
61 Source source = addSource(''' 61 Source source = addSource('''
62 //INVALID_ASSIGNMENT 62 //INVALID_ASSIGNMENT
63 int x = ''; 63 int x = '';
64 // ignore: const_initialized_with_non_constant_value 64 // ignore: const_initialized_with_non_constant_value
65 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 65 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
66 '''); 66 ''');
67 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); 67 await assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
68 } 68 }
69 69
70 void test_ignore_second_trailing() { 70 test_ignore_second_trailing() async {
71 Source source = addSource(''' 71 Source source = addSource('''
72 //INVALID_ASSIGNMENT 72 //INVALID_ASSIGNMENT
73 int x = ''; 73 int x = '';
74 const y = x; // ignore: const_initialized_with_non_constant_value 74 const y = x; // ignore: const_initialized_with_non_constant_value
75 '''); 75 ''');
76 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); 76 await assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
77 } 77 }
78 78
79 void test_ignore_upper_case() { 79 test_ignore_upper_case() async {
80 Source source = addSource(''' 80 Source source = addSource('''
81 int x = ''; // ignore: INVALID_ASSIGNMENT 81 int x = ''; // ignore: INVALID_ASSIGNMENT
82 '''); 82 ''');
83 assertErrors(source, []); 83 await assertErrors(source, []);
84 } 84 }
85 85
86 void test_invalid_error_code() { 86 test_invalid_error_code() async {
87 Source source = addSource(''' 87 Source source = addSource('''
88 // ignore: right_format_wrong_code 88 // ignore: right_format_wrong_code
89 int x = ''; 89 int x = '';
90 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 90 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
91 '''); 91 ''');
92 assertErrors(source, [ 92 await assertErrors(source, [
93 StaticTypeWarningCode.INVALID_ASSIGNMENT, 93 StaticTypeWarningCode.INVALID_ASSIGNMENT,
94 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 94 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
95 ]); 95 ]);
96 } 96 }
97 97
98 void test_missing_error_codes() { 98 test_missing_error_codes() async {
99 Source source = addSource(''' 99 Source source = addSource('''
100 int x = 3; 100 int x = 3;
101 // ignore: 101 // ignore:
102 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
103 '''); 103 ''');
104 assertErrors(source, [ 104 await assertErrors(source, [
105 StaticTypeWarningCode.INVALID_ASSIGNMENT, 105 StaticTypeWarningCode.INVALID_ASSIGNMENT,
106 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 106 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
107 ]); 107 ]);
108 } 108 }
109 109
110 void test_missing_metadata_suffix() { 110 test_missing_metadata_suffix() async {
111 Source source = addSource(''' 111 Source source = addSource('''
112 // ignore invalid_assignment 112 // ignore invalid_assignment
113 String y = 3; //INVALID_ASSIGNMENT 113 String y = 3; //INVALID_ASSIGNMENT
114 '''); 114 ''');
115 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); 115 await assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
116 } 116 }
117 117
118 void test_multiple_comments() { 118 test_multiple_comments() async {
119 Source source = addSource(''' 119 Source source = addSource('''
120 int x = ''; //This is the first comment... 120 int x = ''; //This is the first comment...
121 // ignore: const_initialized_with_non_constant_value 121 // ignore: const_initialized_with_non_constant_value
122 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 122 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
123 '''); 123 ''');
124 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]); 124 await assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
125 } 125 }
126 126
127 void test_multiple_ignores() { 127 test_multiple_ignores() async {
128 Source source = addSource(''' 128 Source source = addSource('''
129 int x = 3; 129 int x = 3;
130 // ignore: invalid_assignment, const_initialized_with_non_constant_value 130 // ignore: invalid_assignment, const_initialized_with_non_constant_value
131 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
132 '''); 132 ''');
133 assertErrors(source, []); 133 await assertErrors(source, []);
134 } 134 }
135 135
136 void test_multiple_ignores_traling() { 136 test_multiple_ignores_traling() async {
137 Source source = addSource(''' 137 Source source = addSource('''
138 int x = 3; 138 int x = 3;
139 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
140 '''); 140 ''');
141 assertErrors(source, []); 141 await assertErrors(source, []);
142 } 142 }
143 143
144 void test_multiple_ignores_whitespace_variant_1() { 144 test_multiple_ignores_whitespace_variant_1() async {
145 Source source = addSource(''' 145 Source source = addSource('''
146 int x = 3; 146 int x = 3;
147 //ignore:invalid_assignment,const_initialized_with_non_constant_value 147 //ignore:invalid_assignment,const_initialized_with_non_constant_value
148 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
149 '''); 149 ''');
150 assertErrors(source, []); 150 await assertErrors(source, []);
151 } 151 }
152 152
153 void test_multiple_ignores_whitespace_variant_2() { 153 test_multiple_ignores_whitespace_variant_2() async {
154 Source source = addSource(''' 154 Source source = addSource('''
155 int x = 3; 155 int x = 3;
156 //ignore: invalid_assignment,const_initialized_with_non_constant_value 156 //ignore: invalid_assignment,const_initialized_with_non_constant_value
157 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
158 '''); 158 ''');
159 assertErrors(source, []); 159 await assertErrors(source, []);
160 } 160 }
161 161
162 void test_multiple_ignores_whitespace_variant_3() { 162 test_multiple_ignores_whitespace_variant_3() async {
163 Source source = addSource(''' 163 Source source = addSource('''
164 int x = 3; 164 int x = 3;
165 // ignore: invalid_assignment,const_initialized_with_non_constant_value 165 // ignore: invalid_assignment,const_initialized_with_non_constant_value
166 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
167 '''); 167 ''');
168 assertErrors(source, []); 168 await assertErrors(source, []);
169 } 169 }
170 170
171 void test_no_ignores() { 171 test_no_ignores() async {
172 Source source = addSource(''' 172 Source source = addSource('''
173 int x = ''; //INVALID_ASSIGNMENT 173 int x = ''; //INVALID_ASSIGNMENT
174 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 174 const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
175 '''); 175 ''');
176 assertErrors(source, [ 176 await assertErrors(source, [
177 StaticTypeWarningCode.INVALID_ASSIGNMENT, 177 StaticTypeWarningCode.INVALID_ASSIGNMENT,
178 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE 178 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE
179 ]); 179 ]);
180 } 180 }
181 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698