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

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

Issue 778153003: Consider adding/editing a method as a resolvable mismatch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library engine.incremental_resolver_test; 5 library engine.incremental_resolver_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 17 matching lines...) Expand all
28 main() { 28 main() {
29 groupSep = ' | '; 29 groupSep = ' | ';
30 runReflectiveTests(DeclarationMatcherTest); 30 runReflectiveTests(DeclarationMatcherTest);
31 runReflectiveTests(IncrementalResolverTest); 31 runReflectiveTests(IncrementalResolverTest);
32 runReflectiveTests(PoorMansIncrementalResolutionTest); 32 runReflectiveTests(PoorMansIncrementalResolutionTest);
33 runReflectiveTests(ResolutionContextBuilderTest); 33 runReflectiveTests(ResolutionContextBuilderTest);
34 } 34 }
35 35
36 36
37 class DeclarationMatcherTest extends ResolverTestCase { 37 class DeclarationMatcherTest extends ResolverTestCase {
38 void setUp() {
39 super.setUp();
40 test_resolveApiChanges = true;
41 }
42
38 void test_false_class_list_add() { 43 void test_false_class_list_add() {
39 _assertCompilationUnitMatches(false, r''' 44 _assertCompilationUnitMatchesFalse(r'''
40 class A {} 45 class A {}
41 class B {} 46 class B {}
42 ''', r''' 47 ''', r'''
43 class A {} 48 class A {}
44 class B {} 49 class B {}
45 class C {} 50 class C {}
46 '''); 51 ''');
47 } 52 }
48 53
49 void test_false_class_list_remove() { 54 void test_false_class_list_remove() {
50 _assertCompilationUnitMatches(false, r''' 55 _assertCompilationUnitMatchesFalse(r'''
51 class A {} 56 class A {}
52 class B {} 57 class B {}
53 class C {} 58 class C {}
54 ''', r''' 59 ''', r'''
55 class A {} 60 class A {}
56 class B {} 61 class B {}
57 '''); 62 ''');
58 } 63 }
59 64
60 void test_false_class_typeParameters_bounds_add() { 65 void test_false_class_typeParameters_bounds_add() {
61 _assertCompilationUnitMatches(false, r''' 66 _assertCompilationUnitMatchesFalse(r'''
62 class A {} 67 class A {}
63 class B<T> { 68 class B<T> {
64 T f; 69 T f;
65 } 70 }
66 ''', r''' 71 ''', r'''
67 class A {} 72 class A {}
68 class B<T extends A> { 73 class B<T extends A> {
69 T f; 74 T f;
70 } 75 }
71 '''); 76 ''');
72 } 77 }
73 78
74 void test_false_class_typeParameters_bounds_remove() { 79 void test_false_class_typeParameters_bounds_remove() {
75 _assertCompilationUnitMatches(false, r''' 80 _assertCompilationUnitMatchesFalse(r'''
76 class A {} 81 class A {}
77 class B<T extends A> { 82 class B<T extends A> {
78 T f; 83 T f;
79 } 84 }
80 ''', r''' 85 ''', r'''
81 class A {} 86 class A {}
82 class B<T> { 87 class B<T> {
83 T f; 88 T f;
84 } 89 }
85 '''); 90 ''');
86 } 91 }
87 92
88 void test_false_classMemberAccessor_list_add() { 93 void test_false_classMemberAccessor_list_add() {
89 _assertCompilationUnitMatches(false, r''' 94 _assertCompilationUnitMatches(DeclarationMatchKind.MISMATCH_OK, r'''
90 class A { 95 class A {
91 get a => 1; 96 get a => 1;
92 get b => 2; 97 get b => 2;
93 } 98 }
94 ''', r''' 99 ''', r'''
95 class A { 100 class A {
96 get a => 1; 101 get a => 1;
97 get b => 2; 102 get b => 2;
98 get c => 3; 103 get c => 3;
99 } 104 }
100 '''); 105 ''');
101 } 106 }
102 107
103 void test_false_classMemberAccessor_list_remove() { 108 void test_false_classMemberAccessor_list_remove() {
104 _assertCompilationUnitMatches(false, r''' 109 _assertCompilationUnitMatchesFalse(r'''
105 class A { 110 class A {
106 get a => 1; 111 get a => 1;
107 get b => 2; 112 get b => 2;
108 get c => 3; 113 get c => 3;
109 } 114 }
110 ''', r''' 115 ''', r'''
111 class A { 116 class A {
112 get a => 1; 117 get a => 1;
113 get b => 2; 118 get b => 2;
114 } 119 }
115 '''); 120 ''');
116 } 121 }
117 122
118 void test_false_classMemberAccessor_wasGetter() { 123 void test_false_classMemberAccessor_wasGetter() {
119 _assertCompilationUnitMatches(false, r''' 124 _assertCompilationUnitMatches(DeclarationMatchKind.MISMATCH_OK, r'''
120 class A { 125 class A {
121 get a => 1; 126 get a => 1;
122 } 127 }
123 ''', r''' 128 ''', r'''
124 class A { 129 class A {
125 set a(x) {} 130 set a(x) {}
126 } 131 }
127 '''); 132 ''');
128 } 133 }
129 134
130 void test_false_classMemberAccessor_wasInstance() { 135 void test_false_classMemberAccessor_wasInstance() {
131 _assertCompilationUnitMatches(false, r''' 136 _assertCompilationUnitMatches(DeclarationMatchKind.MISMATCH_OK, r'''
132 class A { 137 class A {
133 get a => 1; 138 get a => 1;
134 } 139 }
135 ''', r''' 140 ''', r'''
136 class A { 141 class A {
137 static get a => 1; 142 static get a => 1;
138 } 143 }
139 '''); 144 ''');
140 } 145 }
141 146
142 void test_false_classMemberAccessor_wasSetter() { 147 void test_false_classMemberAccessor_wasSetter() {
143 _assertCompilationUnitMatches(false, r''' 148 _assertCompilationUnitMatches(DeclarationMatchKind.MISMATCH_OK, r'''
144 class A { 149 class A {
145 set a(x) {} 150 set a(x) {}
146 } 151 }
147 ''', r''' 152 ''', r'''
148 class A { 153 class A {
149 get a => 1; 154 get a => 1;
150 } 155 }
151 '''); 156 ''');
152 } 157 }
153 158
154 void test_false_classMemberAccessor_wasStatic() { 159 void test_false_classMemberAccessor_wasStatic() {
155 _assertCompilationUnitMatches(false, r''' 160 _assertCompilationUnitMatches(DeclarationMatchKind.MISMATCH_OK, r'''
156 class A { 161 class A {
157 static get a => 1; 162 static get a => 1;
158 } 163 }
159 ''', r''' 164 ''', r'''
160 class A { 165 class A {
161 get a => 1; 166 get a => 1;
162 } 167 }
163 '''); 168 ''');
164 } 169 }
165 170
166 void test_false_classTypeAlias_list_add() { 171 void test_false_classTypeAlias_list_add() {
167 _assertCompilationUnitMatches(false, r''' 172 _assertCompilationUnitMatchesFalse(r'''
168 class M {} 173 class M {}
169 class A = Object with M; 174 class A = Object with M;
170 ''', r''' 175 ''', r'''
171 class M {} 176 class M {}
172 class A = Object with M; 177 class A = Object with M;
173 class B = Object with M; 178 class B = Object with M;
174 '''); 179 ''');
175 } 180 }
176 181
177 void test_false_classTypeAlias_list_remove() { 182 void test_false_classTypeAlias_list_remove() {
178 _assertCompilationUnitMatches(false, r''' 183 _assertCompilationUnitMatchesFalse(r'''
179 class M {} 184 class M {}
180 class A = Object with M; 185 class A = Object with M;
181 class B = Object with M; 186 class B = Object with M;
182 ''', r''' 187 ''', r'''
183 class M {} 188 class M {}
184 class A = Object with M; 189 class A = Object with M;
185 '''); 190 ''');
186 } 191 }
187 192
188 void test_false_classTypeAlias_typeParameters_bounds_add() { 193 void test_false_classTypeAlias_typeParameters_bounds_add() {
189 _assertCompilationUnitMatches(false, r''' 194 _assertCompilationUnitMatchesFalse(r'''
190 class M<T> {} 195 class M<T> {}
191 class A {} 196 class A {}
192 class B<T> = Object with M<T>; 197 class B<T> = Object with M<T>;
193 ''', r''' 198 ''', r'''
194 class M<T> {} 199 class M<T> {}
195 class A {} 200 class A {}
196 class B<T extends A> = Object with M<T>; 201 class B<T extends A> = Object with M<T>;
197 '''); 202 ''');
198 } 203 }
199 204
200 void test_false_classTypeAlias_typeParameters_bounds_remove() { 205 void test_false_classTypeAlias_typeParameters_bounds_remove() {
201 _assertCompilationUnitMatches(false, r''' 206 _assertCompilationUnitMatchesFalse(r'''
202 class M<T> {} 207 class M<T> {}
203 class A {} 208 class A {}
204 class B<T extends A> = Object with M<T>; 209 class B<T extends A> = Object with M<T>;
205 ''', r''' 210 ''', r'''
206 class M<T> {} 211 class M<T> {}
207 class A {} 212 class A {}
208 class B<T> = Object with M<T>; 213 class B<T> = Object with M<T>;
209 '''); 214 ''');
210 } 215 }
211 216
212 void test_false_constructor_parameters_list_add() { 217 void test_false_constructor_parameters_list_add() {
213 _assertCompilationUnitMatches(false, r''' 218 _assertCompilationUnitMatchesFalse(r'''
214 class A { 219 class A {
215 A(); 220 A();
216 } 221 }
217 ''', r''' 222 ''', r'''
218 class A { 223 class A {
219 A(int p); 224 A(int p);
220 } 225 }
221 '''); 226 ''');
222 } 227 }
223 228
224 void test_false_constructor_parameters_list_remove() { 229 void test_false_constructor_parameters_list_remove() {
225 _assertCompilationUnitMatches(false, r''' 230 _assertCompilationUnitMatchesFalse(r'''
226 class A { 231 class A {
227 A(int p); 232 A(int p);
228 } 233 }
229 ''', r''' 234 ''', r'''
230 class A { 235 class A {
231 A(); 236 A();
232 } 237 }
233 '''); 238 ''');
234 } 239 }
235 240
236 void test_false_constructor_parameters_type_edit() { 241 void test_false_constructor_parameters_type_edit() {
237 _assertCompilationUnitMatches(false, r''' 242 _assertCompilationUnitMatchesFalse(r'''
238 class A { 243 class A {
239 A(int p); 244 A(int p);
240 } 245 }
241 ''', r''' 246 ''', r'''
242 class A { 247 class A {
243 A(String p); 248 A(String p);
244 } 249 }
245 '''); 250 ''');
246 } 251 }
247 252
248 void test_false_constructor_unnamed_add_hadParameters() { 253 void test_false_constructor_unnamed_add_hadParameters() {
249 _assertCompilationUnitMatches(false, r''' 254 _assertCompilationUnitMatchesFalse(r'''
250 class A { 255 class A {
251 } 256 }
252 ''', r''' 257 ''', r'''
253 class A { 258 class A {
254 A(int p) {} 259 A(int p) {}
255 } 260 }
256 '''); 261 ''');
257 } 262 }
258 263
259 void test_false_constructor_unnamed_remove_hadParameters() { 264 void test_false_constructor_unnamed_remove_hadParameters() {
260 _assertCompilationUnitMatches(false, r''' 265 _assertCompilationUnitMatchesFalse(r'''
261 class A { 266 class A {
262 A(int p) {} 267 A(int p) {}
263 } 268 }
264 ''', r''' 269 ''', r'''
265 class A { 270 class A {
266 } 271 }
267 '''); 272 ''');
268 } 273 }
269 274
270 void test_false_defaultFieldFormalParameterElement_wasSimple() { 275 void test_false_defaultFieldFormalParameterElement_wasSimple() {
271 _assertCompilationUnitMatches(false, r''' 276 _assertCompilationUnitMatchesFalse(r'''
272 class A { 277 class A {
273 int field; 278 int field;
274 A(int field); 279 A(int field);
275 } 280 }
276 ''', r''' 281 ''', r'''
277 class A { 282 class A {
278 int field; 283 int field;
279 A([this.field = 0]); 284 A([this.field = 0]);
280 } 285 }
281 '''); 286 ''');
282 } 287 }
283 288
284 void test_false_enum_constants_add() { 289 void test_false_enum_constants_add() {
285 resetWithEnum(); 290 resetWithEnum();
286 _assertCompilationUnitMatches(false, r''' 291 _assertCompilationUnitMatchesFalse(r'''
287 enum E {A, B} 292 enum E {A, B}
288 ''', r''' 293 ''', r'''
289 enum E {A, B, C} 294 enum E {A, B, C}
290 '''); 295 ''');
291 } 296 }
292 297
293 void test_false_enum_constants_remove() { 298 void test_false_enum_constants_remove() {
294 resetWithEnum(); 299 resetWithEnum();
295 _assertCompilationUnitMatches(false, r''' 300 _assertCompilationUnitMatchesFalse(r'''
296 enum E {A, B, C} 301 enum E {A, B, C}
297 ''', r''' 302 ''', r'''
298 enum E {A, B} 303 enum E {A, B}
299 '''); 304 ''');
300 } 305 }
301 306
302 void test_false_export_hide_add() { 307 void test_false_export_hide_add() {
303 _assertCompilationUnitMatches(false, r''' 308 _assertCompilationUnitMatchesFalse(r'''
304 export 'dart:async' hide Future; 309 export 'dart:async' hide Future;
305 ''', r''' 310 ''', r'''
306 export 'dart:async' hide Future, Stream; 311 export 'dart:async' hide Future, Stream;
307 '''); 312 ''');
308 } 313 }
309 314
310 void test_false_export_hide_remove() { 315 void test_false_export_hide_remove() {
311 _assertCompilationUnitMatches(false, r''' 316 _assertCompilationUnitMatchesFalse(r'''
312 export 'dart:async' hide Future, Stream; 317 export 'dart:async' hide Future, Stream;
313 ''', r''' 318 ''', r'''
314 export 'dart:async' hide Future; 319 export 'dart:async' hide Future;
315 '''); 320 ''');
316 } 321 }
317 322
318 void test_false_export_list_add() { 323 void test_false_export_list_add() {
319 _assertCompilationUnitMatches(false, r''' 324 _assertCompilationUnitMatchesFalse(r'''
320 export 'dart:async'; 325 export 'dart:async';
321 ''', r''' 326 ''', r'''
322 export 'dart:async'; 327 export 'dart:async';
323 export 'dart:math'; 328 export 'dart:math';
324 '''); 329 ''');
325 } 330 }
326 331
327 void test_false_export_list_remove() { 332 void test_false_export_list_remove() {
328 _assertCompilationUnitMatches(false, r''' 333 _assertCompilationUnitMatchesFalse(r'''
329 export 'dart:async'; 334 export 'dart:async';
330 export 'dart:math'; 335 export 'dart:math';
331 ''', r''' 336 ''', r'''
332 export 'dart:async'; 337 export 'dart:async';
333 '''); 338 ''');
334 } 339 }
335 340
336 void test_false_export_show_add() { 341 void test_false_export_show_add() {
337 _assertCompilationUnitMatches(false, r''' 342 _assertCompilationUnitMatchesFalse(r'''
338 export 'dart:async' show Future; 343 export 'dart:async' show Future;
339 ''', r''' 344 ''', r'''
340 export 'dart:async' show Future, Stream; 345 export 'dart:async' show Future, Stream;
341 '''); 346 ''');
342 } 347 }
343 348
344 void test_false_export_show_remove() { 349 void test_false_export_show_remove() {
345 _assertCompilationUnitMatches(false, r''' 350 _assertCompilationUnitMatchesFalse(r'''
346 export 'dart:async' show Future, Stream; 351 export 'dart:async' show Future, Stream;
347 ''', r''' 352 ''', r'''
348 export 'dart:async' show Future; 353 export 'dart:async' show Future;
349 '''); 354 ''');
350 } 355 }
351 356
352 void test_false_extendsClause_add() { 357 void test_false_extendsClause_add() {
353 _assertCompilationUnitMatches(false, r''' 358 _assertCompilationUnitMatchesFalse(r'''
354 class A {} 359 class A {}
355 class B {} 360 class B {}
356 ''', r''' 361 ''', r'''
357 class A {} 362 class A {}
358 class B extends A {} 363 class B extends A {}
359 '''); 364 ''');
360 } 365 }
361 366
362 void test_false_extendsClause_different() { 367 void test_false_extendsClause_different() {
363 _assertCompilationUnitMatches(false, r''' 368 _assertCompilationUnitMatchesFalse(r'''
364 class A {} 369 class A {}
365 class B {} 370 class B {}
366 class C extends A {} 371 class C extends A {}
367 ''', r''' 372 ''', r'''
368 class A {} 373 class A {}
369 class B {} 374 class B {}
370 class C extends B {} 375 class C extends B {}
371 '''); 376 ''');
372 } 377 }
373 378
374 void test_false_extendsClause_remove() { 379 void test_false_extendsClause_remove() {
375 _assertCompilationUnitMatches(false, r''' 380 _assertCompilationUnitMatchesFalse(r'''
376 class A {} 381 class A {}
377 class B extends A{} 382 class B extends A{}
378 ''', r''' 383 ''', r'''
379 class A {} 384 class A {}
380 class B {} 385 class B {}
381 '''); 386 ''');
382 } 387 }
383 388
384 void test_false_field_list_add() { 389 void test_false_field_list_add() {
385 _assertCompilationUnitMatches(false, r''' 390 _assertCompilationUnitMatchesFalse(r'''
386 class T { 391 class T {
387 int A = 1; 392 int A = 1;
388 int C = 3; 393 int C = 3;
389 } 394 }
390 ''', r''' 395 ''', r'''
391 class T { 396 class T {
392 int A = 1; 397 int A = 1;
393 int B = 2; 398 int B = 2;
394 int C = 3; 399 int C = 3;
395 } 400 }
396 '''); 401 ''');
397 } 402 }
398 403
399 void test_false_field_list_remove() { 404 void test_false_field_list_remove() {
400 _assertCompilationUnitMatches(false, r''' 405 _assertCompilationUnitMatchesFalse(r'''
401 class T { 406 class T {
402 int A = 1; 407 int A = 1;
403 int B = 2; 408 int B = 2;
404 int C = 3; 409 int C = 3;
405 } 410 }
406 ''', r''' 411 ''', r'''
407 class T { 412 class T {
408 int A = 1; 413 int A = 1;
409 int C = 3; 414 int C = 3;
410 } 415 }
411 '''); 416 ''');
412 } 417 }
413 418
414 void test_false_field_modifier_isConst() { 419 void test_false_field_modifier_isConst() {
415 _assertCompilationUnitMatches(false, r''' 420 _assertCompilationUnitMatchesFalse(r'''
416 class T { 421 class T {
417 static final A = 1; 422 static final A = 1;
418 } 423 }
419 ''', r''' 424 ''', r'''
420 class T { 425 class T {
421 static const A = 1; 426 static const A = 1;
422 } 427 }
423 '''); 428 ''');
424 } 429 }
425 430
426 void test_false_field_modifier_isFinal() { 431 void test_false_field_modifier_isFinal() {
427 _assertCompilationUnitMatches(false, r''' 432 _assertCompilationUnitMatchesFalse(r'''
428 class T { 433 class T {
429 int A = 1; 434 int A = 1;
430 } 435 }
431 ''', r''' 436 ''', r'''
432 class T { 437 class T {
433 final int A = 1; 438 final int A = 1;
434 } 439 }
435 '''); 440 ''');
436 } 441 }
437 442
438 void test_false_field_modifier_isStatic() { 443 void test_false_field_modifier_isStatic() {
439 _assertCompilationUnitMatches(false, r''' 444 _assertCompilationUnitMatchesFalse(r'''
440 class T { 445 class T {
441 int A = 1; 446 int A = 1;
442 } 447 }
443 ''', r''' 448 ''', r'''
444 class T { 449 class T {
445 static int A = 1; 450 static int A = 1;
446 } 451 }
447 '''); 452 ''');
448 } 453 }
449 454
450 void test_false_field_modifier_wasConst() { 455 void test_false_field_modifier_wasConst() {
451 _assertCompilationUnitMatches(false, r''' 456 _assertCompilationUnitMatchesFalse(r'''
452 class T { 457 class T {
453 static const A = 1; 458 static const A = 1;
454 } 459 }
455 ''', r''' 460 ''', r'''
456 class T { 461 class T {
457 static final A = 1; 462 static final A = 1;
458 } 463 }
459 '''); 464 ''');
460 } 465 }
461 466
462 void test_false_field_modifier_wasFinal() { 467 void test_false_field_modifier_wasFinal() {
463 _assertCompilationUnitMatches(false, r''' 468 _assertCompilationUnitMatchesFalse(r'''
464 class T { 469 class T {
465 final int A = 1; 470 final int A = 1;
466 } 471 }
467 ''', r''' 472 ''', r'''
468 class T { 473 class T {
469 int A = 1; 474 int A = 1;
470 } 475 }
471 '''); 476 ''');
472 } 477 }
473 478
474 void test_false_field_modifier_wasStatic() { 479 void test_false_field_modifier_wasStatic() {
475 _assertCompilationUnitMatches(false, r''' 480 _assertCompilationUnitMatchesFalse(r'''
476 class T { 481 class T {
477 static int A = 1; 482 static int A = 1;
478 } 483 }
479 ''', r''' 484 ''', r'''
480 class T { 485 class T {
481 int A = 1; 486 int A = 1;
482 } 487 }
483 '''); 488 ''');
484 } 489 }
485 490
486 void test_false_field_type_differentArgs() { 491 void test_false_field_type_differentArgs() {
487 _assertCompilationUnitMatches(false, r''' 492 _assertCompilationUnitMatchesFalse(r'''
488 class T { 493 class T {
489 List<int> A; 494 List<int> A;
490 } 495 }
491 ''', r''' 496 ''', r'''
492 class T { 497 class T {
493 List<String> A; 498 List<String> A;
494 } 499 }
495 '''); 500 ''');
496 } 501 }
497 502
498 void test_false_fieldFormalParameterElement_wasSimple() { 503 void test_false_fieldFormalParameterElement_wasSimple() {
499 _assertCompilationUnitMatches(false, r''' 504 _assertCompilationUnitMatchesFalse(r'''
500 class A { 505 class A {
501 int field; 506 int field;
502 A(int field); 507 A(int field);
503 } 508 }
504 ''', r''' 509 ''', r'''
505 class A { 510 class A {
506 int field; 511 int field;
507 A(this.field); 512 A(this.field);
508 } 513 }
509 '''); 514 ''');
510 } 515 }
511 516
512 void test_false_final_type_different() { 517 void test_false_final_type_different() {
513 _assertCompilationUnitMatches(false, r''' 518 _assertCompilationUnitMatchesFalse(r'''
514 class T { 519 class T {
515 int A; 520 int A;
516 } 521 }
517 ''', r''' 522 ''', r'''
518 class T { 523 class T {
519 String A; 524 String A;
520 } 525 }
521 '''); 526 ''');
522 } 527 }
523 528
524 void test_false_functionTypeAlias_list_add() { 529 void test_false_functionTypeAlias_list_add() {
525 _assertCompilationUnitMatches(false, r''' 530 _assertCompilationUnitMatchesFalse(r'''
526 typedef A(int pa); 531 typedef A(int pa);
527 typedef B(String pb); 532 typedef B(String pb);
528 ''', r''' 533 ''', r'''
529 typedef A(int pa); 534 typedef A(int pa);
530 typedef B(String pb); 535 typedef B(String pb);
531 typedef C(pc); 536 typedef C(pc);
532 '''); 537 ''');
533 } 538 }
534 539
535 void test_false_functionTypeAlias_list_remove() { 540 void test_false_functionTypeAlias_list_remove() {
536 _assertCompilationUnitMatches(false, r''' 541 _assertCompilationUnitMatchesFalse(r'''
537 typedef A(int pa); 542 typedef A(int pa);
538 typedef B(String pb); 543 typedef B(String pb);
539 typedef C(pc); 544 typedef C(pc);
540 ''', r''' 545 ''', r'''
541 typedef A(int pa); 546 typedef A(int pa);
542 typedef B(String pb); 547 typedef B(String pb);
543 '''); 548 ''');
544 } 549 }
545 550
546 void test_false_functionTypeAlias_parameters_list_add() { 551 void test_false_functionTypeAlias_parameters_list_add() {
547 _assertCompilationUnitMatches(false, r''' 552 _assertCompilationUnitMatchesFalse(r'''
548 typedef A(a); 553 typedef A(a);
549 ''', r''' 554 ''', r'''
550 typedef A(a, b); 555 typedef A(a, b);
551 '''); 556 ''');
552 } 557 }
553 558
554 void test_false_functionTypeAlias_parameters_list_remove() { 559 void test_false_functionTypeAlias_parameters_list_remove() {
555 _assertCompilationUnitMatches(false, r''' 560 _assertCompilationUnitMatchesFalse(r'''
556 typedef A(a, b); 561 typedef A(a, b);
557 ''', r''' 562 ''', r'''
558 typedef A(a); 563 typedef A(a);
559 '''); 564 ''');
560 } 565 }
561 566
562 void test_false_functionTypeAlias_parameters_type_edit() { 567 void test_false_functionTypeAlias_parameters_type_edit() {
563 _assertCompilationUnitMatches(false, r''' 568 _assertCompilationUnitMatchesFalse(r'''
564 typedef A(int p); 569 typedef A(int p);
565 ''', r''' 570 ''', r'''
566 typedef A(String p); 571 typedef A(String p);
567 '''); 572 ''');
568 } 573 }
569 574
570 void test_false_functionTypeAlias_returnType_edit() { 575 void test_false_functionTypeAlias_returnType_edit() {
571 _assertCompilationUnitMatches(false, r''' 576 _assertCompilationUnitMatchesFalse(r'''
572 typedef int A(); 577 typedef int A();
573 ''', r''' 578 ''', r'''
574 typedef String A(); 579 typedef String A();
575 '''); 580 ''');
576 } 581 }
577 582
578 void test_false_functionTypeAlias_typeParameters_bounds_add() { 583 void test_false_functionTypeAlias_typeParameters_bounds_add() {
579 _assertCompilationUnitMatches(false, r''' 584 _assertCompilationUnitMatchesFalse(r'''
580 class A {} 585 class A {}
581 typedef F<T>(); 586 typedef F<T>();
582 ''', r''' 587 ''', r'''
583 class A {} 588 class A {}
584 typedef F<T extends A>(); 589 typedef F<T extends A>();
585 '''); 590 ''');
586 } 591 }
587 592
588 void test_false_functionTypeAlias_typeParameters_bounds_edit() { 593 void test_false_functionTypeAlias_typeParameters_bounds_edit() {
589 _assertCompilationUnitMatches(false, r''' 594 _assertCompilationUnitMatchesFalse(r'''
590 class A {} 595 class A {}
591 class B {} 596 class B {}
592 typedef F<T extends A>(); 597 typedef F<T extends A>();
593 ''', r''' 598 ''', r'''
594 class A {} 599 class A {}
595 typedef F<T extends B>(); 600 typedef F<T extends B>();
596 '''); 601 ''');
597 } 602 }
598 603
599 void test_false_functionTypeAlias_typeParameters_bounds_remove() { 604 void test_false_functionTypeAlias_typeParameters_bounds_remove() {
600 _assertCompilationUnitMatches(false, r''' 605 _assertCompilationUnitMatchesFalse(r'''
601 class A {} 606 class A {}
602 typedef F<T extends A>(); 607 typedef F<T extends A>();
603 ''', r''' 608 ''', r'''
604 class A {} 609 class A {}
605 typedef F<T>(); 610 typedef F<T>();
606 '''); 611 ''');
607 } 612 }
608 613
609 void test_false_functionTypeAlias_typeParameters_list_add() { 614 void test_false_functionTypeAlias_typeParameters_list_add() {
610 _assertCompilationUnitMatches(false, r''' 615 _assertCompilationUnitMatchesFalse(r'''
611 typedef F<A>(); 616 typedef F<A>();
612 ''', r''' 617 ''', r'''
613 typedef F<A, B>(); 618 typedef F<A, B>();
614 '''); 619 ''');
615 } 620 }
616 621
617 void test_false_functionTypeAlias_typeParameters_list_remove() { 622 void test_false_functionTypeAlias_typeParameters_list_remove() {
618 _assertCompilationUnitMatches(false, r''' 623 _assertCompilationUnitMatchesFalse(r'''
619 typedef F<A, B>(); 624 typedef F<A, B>();
620 ''', r''' 625 ''', r'''
621 typedef F<A>(); 626 typedef F<A>();
622 '''); 627 ''');
623 } 628 }
624 629
625 void test_false_FunctionTypedFormalParameter_parameters_list_add() { 630 void test_false_FunctionTypedFormalParameter_parameters_list_add() {
626 _assertCompilationUnitMatches(false, r''' 631 _assertCompilationUnitMatchesFalse(r'''
627 main(int callback(int a)) { 632 main(int callback(int a)) {
628 } 633 }
629 ''', r''' 634 ''', r'''
630 main(int callback(int a, String b)) { 635 main(int callback(int a, String b)) {
631 } 636 }
632 '''); 637 ''');
633 } 638 }
634 639
635 void test_false_FunctionTypedFormalParameter_parameters_list_remove() { 640 void test_false_FunctionTypedFormalParameter_parameters_list_remove() {
636 _assertCompilationUnitMatches(false, r''' 641 _assertCompilationUnitMatchesFalse(r'''
637 main(int callback(int a, String b)) { 642 main(int callback(int a, String b)) {
638 } 643 }
639 ''', r''' 644 ''', r'''
640 main(int callback(int a)) { 645 main(int callback(int a)) {
641 } 646 }
642 '''); 647 ''');
643 } 648 }
644 649
645 void test_false_FunctionTypedFormalParameter_parameterType() { 650 void test_false_FunctionTypedFormalParameter_parameterType() {
646 _assertCompilationUnitMatches(false, r''' 651 _assertCompilationUnitMatchesFalse(r'''
647 main(int callback(int p)) { 652 main(int callback(int p)) {
648 } 653 }
649 ''', r''' 654 ''', r'''
650 main(int callback(String p)) { 655 main(int callback(String p)) {
651 } 656 }
652 '''); 657 ''');
653 } 658 }
654 659
655 void test_false_FunctionTypedFormalParameter_returnType() { 660 void test_false_FunctionTypedFormalParameter_returnType() {
656 _assertCompilationUnitMatches(false, r''' 661 _assertCompilationUnitMatchesFalse(r'''
657 main(int callback()) { 662 main(int callback()) {
658 } 663 }
659 ''', r''' 664 ''', r'''
660 main(String callback()) { 665 main(String callback()) {
661 } 666 }
662 '''); 667 ''');
663 } 668 }
664 669
665 void test_false_FunctionTypedFormalParameter_wasSimple() { 670 void test_false_FunctionTypedFormalParameter_wasSimple() {
666 _assertCompilationUnitMatches(false, r''' 671 _assertCompilationUnitMatchesFalse(r'''
667 main(int callback) { 672 main(int callback) {
668 } 673 }
669 ''', r''' 674 ''', r'''
670 main(int callback(int a, String b)) { 675 main(int callback(int a, String b)) {
671 } 676 }
672 '''); 677 ''');
673 } 678 }
674 679
675 void test_false_implementsClause_add() { 680 void test_false_implementsClause_add() {
676 _assertCompilationUnitMatches(false, r''' 681 _assertCompilationUnitMatchesFalse(r'''
677 class A {} 682 class A {}
678 class B {} 683 class B {}
679 ''', r''' 684 ''', r'''
680 class A {} 685 class A {}
681 class B implements A {} 686 class B implements A {}
682 '''); 687 ''');
683 } 688 }
684 689
685 void test_false_implementsClause_remove() { 690 void test_false_implementsClause_remove() {
686 _assertCompilationUnitMatches(false, r''' 691 _assertCompilationUnitMatchesFalse(r'''
687 class A {} 692 class A {}
688 class B implements A {} 693 class B implements A {}
689 ''', r''' 694 ''', r'''
690 class A {} 695 class A {}
691 class B {} 696 class B {}
692 '''); 697 ''');
693 } 698 }
694 699
695 void test_false_implementsClause_reorder() { 700 void test_false_implementsClause_reorder() {
696 _assertCompilationUnitMatches(false, r''' 701 _assertCompilationUnitMatchesFalse(r'''
697 class A {} 702 class A {}
698 class B {} 703 class B {}
699 class C implements A, B {} 704 class C implements A, B {}
700 ''', r''' 705 ''', r'''
701 class A {} 706 class A {}
702 class B {} 707 class B {}
703 class C implements B, A {} 708 class C implements B, A {}
704 '''); 709 ''');
705 } 710 }
706 711
707 void test_false_import_hide_add() { 712 void test_false_import_hide_add() {
708 _assertCompilationUnitMatches(false, r''' 713 _assertCompilationUnitMatchesFalse(r'''
709 import 'dart:async' hide Future; 714 import 'dart:async' hide Future;
710 ''', r''' 715 ''', r'''
711 import 'dart:async' hide Future, Stream; 716 import 'dart:async' hide Future, Stream;
712 '''); 717 ''');
713 } 718 }
714 719
715 void test_false_import_hide_remove() { 720 void test_false_import_hide_remove() {
716 _assertCompilationUnitMatches(false, r''' 721 _assertCompilationUnitMatchesFalse(r'''
717 import 'dart:async' hide Future, Stream; 722 import 'dart:async' hide Future, Stream;
718 ''', r''' 723 ''', r'''
719 import 'dart:async' hide Future; 724 import 'dart:async' hide Future;
720 '''); 725 ''');
721 } 726 }
722 727
723 void test_false_import_list_add() { 728 void test_false_import_list_add() {
724 _assertCompilationUnitMatches(false, r''' 729 _assertCompilationUnitMatchesFalse(r'''
725 import 'dart:async'; 730 import 'dart:async';
726 ''', r''' 731 ''', r'''
727 import 'dart:async'; 732 import 'dart:async';
728 import 'dart:math'; 733 import 'dart:math';
729 '''); 734 ''');
730 } 735 }
731 736
732 void test_false_import_list_remove() { 737 void test_false_import_list_remove() {
733 _assertCompilationUnitMatches(false, r''' 738 _assertCompilationUnitMatchesFalse(r'''
734 import 'dart:async'; 739 import 'dart:async';
735 import 'dart:math'; 740 import 'dart:math';
736 ''', r''' 741 ''', r'''
737 import 'dart:async'; 742 import 'dart:async';
738 '''); 743 ''');
739 } 744 }
740 745
741 void test_false_import_prefix_add() { 746 void test_false_import_prefix_add() {
742 _assertCompilationUnitMatches(false, r''' 747 _assertCompilationUnitMatchesFalse(r'''
743 import 'dart:async'; 748 import 'dart:async';
744 ''', r''' 749 ''', r'''
745 import 'dart:async' as async; 750 import 'dart:async' as async;
746 '''); 751 ''');
747 } 752 }
748 753
749 void test_false_import_prefix_edit() { 754 void test_false_import_prefix_edit() {
750 _assertCompilationUnitMatches(false, r''' 755 _assertCompilationUnitMatchesFalse(r'''
751 import 'dart:async' as oldPrefix; 756 import 'dart:async' as oldPrefix;
752 ''', r''' 757 ''', r'''
753 import 'dart:async' as newPrefix; 758 import 'dart:async' as newPrefix;
754 '''); 759 ''');
755 } 760 }
756 761
757 void test_false_import_prefix_remove() { 762 void test_false_import_prefix_remove() {
758 _assertCompilationUnitMatches(false, r''' 763 _assertCompilationUnitMatchesFalse(r'''
759 import 'dart:async' as async; 764 import 'dart:async' as async;
760 ''', r''' 765 ''', r'''
761 import 'dart:async'; 766 import 'dart:async';
762 '''); 767 ''');
763 } 768 }
764 769
765 void test_false_import_show_add() { 770 void test_false_import_show_add() {
766 _assertCompilationUnitMatches(false, r''' 771 _assertCompilationUnitMatchesFalse(r'''
767 import 'dart:async' show Future; 772 import 'dart:async' show Future;
768 ''', r''' 773 ''', r'''
769 import 'dart:async' show Future, Stream; 774 import 'dart:async' show Future, Stream;
770 '''); 775 ''');
771 } 776 }
772 777
773 void test_false_import_show_remove() { 778 void test_false_import_show_remove() {
774 _assertCompilationUnitMatches(false, r''' 779 _assertCompilationUnitMatchesFalse(r'''
775 import 'dart:async' show Future, Stream; 780 import 'dart:async' show Future, Stream;
776 ''', r''' 781 ''', r'''
777 import 'dart:async' show Future; 782 import 'dart:async' show Future;
778 '''); 783 ''');
779 } 784 }
780 785
781 void test_false_method_list_add() { 786 void test_false_method_list_add() {
782 _assertCompilationUnitMatches(false, r''' 787 _assertCompilationUnitMatches(DeclarationMatchKind.MISMATCH_OK, r'''
783 class A { 788 class A {
784 a() {} 789 a() {}
785 b() {} 790 b() {}
786 } 791 }
787 ''', r''' 792 ''', r'''
788 class A { 793 class A {
789 a() {} 794 a() {}
790 b() {} 795 b() {}
791 c() {} 796 c() {}
792 } 797 }
793 '''); 798 ''');
794 } 799 }
795 800
796 void test_false_method_list_remove() { 801 void test_false_method_list_remove() {
797 _assertCompilationUnitMatches(false, r''' 802 _assertCompilationUnitMatchesFalse(r'''
798 class A { 803 class A {
799 a() {} 804 a() {}
800 b() {} 805 b() {}
801 c() {} 806 c() {}
802 } 807 }
803 ''', r''' 808 ''', r'''
804 class A { 809 class A {
805 a() {} 810 a() {}
806 b() {} 811 b() {}
807 } 812 }
808 '''); 813 ''');
809 } 814 }
810 815
816 void test_false_method_parameters_type_edit() {
817 // TODO
818 _assertCompilationUnitMatches(DeclarationMatchKind.MISMATCH_OK, r'''
819 class A {
820 m(int p) {
821 }
822 }
823 ''', r'''
824 class A {
825 m(String p) {
826 }
827 }
828 ''');
829 }
830
811 void test_false_method_returnType_edit() { 831 void test_false_method_returnType_edit() {
812 _assertCompilationUnitMatches(false, r''' 832 _assertCompilationUnitMatches(DeclarationMatchKind.MISMATCH_OK, r'''
813 class A { 833 class A {
814 int m() {} 834 int m() {}
815 } 835 }
816 ''', r''' 836 ''', r'''
817 class A { 837 class A {
818 String m() {} 838 String m() {}
819 } 839 }
820 '''); 840 ''');
821 } 841 }
822 842
823 void test_false_part_list_add() { 843 void test_false_part_list_add() {
824 addNamedSource('/unitA.dart', 'part of lib; class A {}'); 844 addNamedSource('/unitA.dart', 'part of lib; class A {}');
825 addNamedSource('/unitB.dart', 'part of lib; class B {}'); 845 addNamedSource('/unitB.dart', 'part of lib; class B {}');
826 _assertCompilationUnitMatches(false, r''' 846 _assertCompilationUnitMatchesFalse(r'''
827 library lib; 847 library lib;
828 part 'unitA.dart'; 848 part 'unitA.dart';
829 ''', r''' 849 ''', r'''
830 library lib; 850 library lib;
831 part 'unitA.dart'; 851 part 'unitA.dart';
832 part 'unitB.dart'; 852 part 'unitB.dart';
833 '''); 853 ''');
834 } 854 }
835 855
836 void test_false_part_list_remove() { 856 void test_false_part_list_remove() {
837 addNamedSource('/unitA.dart', 'part of lib; class A {}'); 857 addNamedSource('/unitA.dart', 'part of lib; class A {}');
838 addNamedSource('/unitB.dart', 'part of lib; class B {}'); 858 addNamedSource('/unitB.dart', 'part of lib; class B {}');
839 _assertCompilationUnitMatches(false, r''' 859 _assertCompilationUnitMatchesFalse(r'''
840 library lib; 860 library lib;
841 part 'unitA.dart'; 861 part 'unitA.dart';
842 part 'unitB.dart'; 862 part 'unitB.dart';
843 ''', r''' 863 ''', r'''
844 library lib; 864 library lib;
845 part 'unitA.dart'; 865 part 'unitA.dart';
846 '''); 866 ''');
847 } 867 }
848 868
849 void test_false_SimpleFormalParameter_named_differentName() { 869 void test_false_SimpleFormalParameter_named_differentName() {
850 _assertCompilationUnitMatches(false, r''' 870 _assertCompilationUnitMatchesFalse(r'''
851 main({int oldName}) { 871 main({int oldName}) {
852 } 872 }
853 ''', r''' 873 ''', r'''
854 main({int newName}) { 874 main({int newName}) {
855 } 875 }
856 '''); 876 ''');
857 } 877 }
858 878
859 void test_false_SimpleFormalParameter_namedDefault_addValue() { 879 void test_false_SimpleFormalParameter_namedDefault_addValue() {
860 _assertCompilationUnitMatches(false, r''' 880 _assertCompilationUnitMatchesFalse(r'''
861 main({int p}) { 881 main({int p}) {
862 } 882 }
863 ''', r''' 883 ''', r'''
864 main({int p: 2}) { 884 main({int p: 2}) {
865 } 885 }
866 '''); 886 ''');
867 } 887 }
868 888
869 void test_false_SimpleFormalParameter_namedDefault_differentValue() { 889 void test_false_SimpleFormalParameter_namedDefault_differentValue() {
870 _assertCompilationUnitMatches(false, r''' 890 _assertCompilationUnitMatchesFalse(r'''
871 main({int p: 1}) { 891 main({int p: 1}) {
872 } 892 }
873 ''', r''' 893 ''', r'''
874 main({int p: 2}) { 894 main({int p: 2}) {
875 } 895 }
876 '''); 896 ''');
877 } 897 }
878 898
879 void test_false_SimpleFormalParameter_namedDefault_removeValue() { 899 void test_false_SimpleFormalParameter_namedDefault_removeValue() {
880 _assertCompilationUnitMatches(false, r''' 900 _assertCompilationUnitMatchesFalse(r'''
881 main({int p: 1}) { 901 main({int p: 1}) {
882 } 902 }
883 ''', r''' 903 ''', r'''
884 main({int p}) { 904 main({int p}) {
885 } 905 }
886 '''); 906 ''');
887 } 907 }
888 908
889 void test_false_SimpleFormalParameter_optionalDefault_addValue() { 909 void test_false_SimpleFormalParameter_optionalDefault_addValue() {
890 _assertCompilationUnitMatches(false, r''' 910 _assertCompilationUnitMatchesFalse(r'''
891 main([int p]) { 911 main([int p]) {
892 } 912 }
893 ''', r''' 913 ''', r'''
894 main([int p = 2]) { 914 main([int p = 2]) {
895 } 915 }
896 '''); 916 ''');
897 } 917 }
898 918
899 void test_false_SimpleFormalParameter_optionalDefault_differentValue() { 919 void test_false_SimpleFormalParameter_optionalDefault_differentValue() {
900 _assertCompilationUnitMatches(false, r''' 920 _assertCompilationUnitMatchesFalse(r'''
901 main([int p = 1]) { 921 main([int p = 1]) {
902 } 922 }
903 ''', r''' 923 ''', r'''
904 main([int p = 2]) { 924 main([int p = 2]) {
905 } 925 }
906 '''); 926 ''');
907 } 927 }
908 928
909 void test_false_SimpleFormalParameter_optionalDefault_removeValue() { 929 void test_false_SimpleFormalParameter_optionalDefault_removeValue() {
910 _assertCompilationUnitMatches(false, r''' 930 _assertCompilationUnitMatchesFalse(r'''
911 main([int p = 1]) { 931 main([int p = 1]) {
912 } 932 }
913 ''', r''' 933 ''', r'''
914 main([int p]) { 934 main([int p]) {
915 } 935 }
916 '''); 936 ''');
917 } 937 }
918 938
919 void test_false_topLevelAccessor_list_add() { 939 void test_false_topLevelAccessor_list_add() {
920 _assertCompilationUnitMatches(false, r''' 940 _assertCompilationUnitMatchesFalse(r'''
921 get a => 1; 941 get a => 1;
922 get b => 2; 942 get b => 2;
923 ''', r''' 943 ''', r'''
924 get a => 1; 944 get a => 1;
925 get b => 2; 945 get b => 2;
926 get c => 3; 946 get c => 3;
927 '''); 947 ''');
928 } 948 }
929 949
930 void test_false_topLevelAccessor_list_remove() { 950 void test_false_topLevelAccessor_list_remove() {
931 _assertCompilationUnitMatches(false, r''' 951 _assertCompilationUnitMatchesFalse(r'''
932 get a => 1; 952 get a => 1;
933 get b => 2; 953 get b => 2;
934 get c => 3; 954 get c => 3;
935 ''', r''' 955 ''', r'''
936 get a => 1; 956 get a => 1;
937 get b => 2; 957 get b => 2;
938 '''); 958 ''');
939 } 959 }
940 960
941 void test_false_topLevelAccessor_wasGetter() { 961 void test_false_topLevelAccessor_wasGetter() {
942 _assertCompilationUnitMatches(false, r''' 962 _assertCompilationUnitMatchesFalse(r'''
943 get a => 1; 963 get a => 1;
944 ''', r''' 964 ''', r'''
945 set a(x) {} 965 set a(x) {}
946 '''); 966 ''');
947 } 967 }
948 968
949 void test_false_topLevelAccessor_wasSetter() { 969 void test_false_topLevelAccessor_wasSetter() {
950 _assertCompilationUnitMatches(false, r''' 970 _assertCompilationUnitMatchesFalse(r'''
951 set a(x) {} 971 set a(x) {}
952 ''', r''' 972 ''', r'''
953 get a => 1; 973 get a => 1;
954 '''); 974 ''');
955 } 975 }
956 976
957 void test_false_topLevelFunction_list_add() { 977 void test_false_topLevelFunction_list_add() {
958 _assertCompilationUnitMatches(false, r''' 978 _assertCompilationUnitMatchesFalse(r'''
959 a() {} 979 a() {}
960 b() {} 980 b() {}
961 ''', r''' 981 ''', r'''
962 a() {} 982 a() {}
963 b() {} 983 b() {}
964 c() {} 984 c() {}
965 '''); 985 ''');
966 } 986 }
967 987
968 void test_false_topLevelFunction_list_remove() { 988 void test_false_topLevelFunction_list_remove() {
969 _assertCompilationUnitMatches(false, r''' 989 _assertCompilationUnitMatchesFalse(r'''
970 a() {} 990 a() {}
971 b() {} 991 b() {}
972 c() {} 992 c() {}
973 ''', r''' 993 ''', r'''
974 a() {} 994 a() {}
975 b() {} 995 b() {}
976 '''); 996 ''');
977 } 997 }
978 998
979 void test_false_topLevelFunction_parameters_list_add() { 999 void test_false_topLevelFunction_parameters_list_add() {
980 _assertCompilationUnitMatches(false, r''' 1000 _assertCompilationUnitMatchesFalse(r'''
981 main(int a, int b) { 1001 main(int a, int b) {
982 } 1002 }
983 ''', r''' 1003 ''', r'''
984 main(int a, int b, int c) { 1004 main(int a, int b, int c) {
985 } 1005 }
986 '''); 1006 ''');
987 } 1007 }
988 1008
989 void test_false_topLevelFunction_parameters_list_remove() { 1009 void test_false_topLevelFunction_parameters_list_remove() {
990 _assertCompilationUnitMatches(false, r''' 1010 _assertCompilationUnitMatchesFalse(r'''
991 main(int a, int b, int c) { 1011 main(int a, int b, int c) {
992 } 1012 }
993 ''', r''' 1013 ''', r'''
994 main(int a, int b) { 1014 main(int a, int b) {
995 } 1015 }
996 '''); 1016 ''');
997 } 1017 }
998 1018
999 void test_false_topLevelFunction_parameters_type_edit() { 1019 void test_false_topLevelFunction_parameters_type_edit() {
1000 _assertCompilationUnitMatches(false, r''' 1020 _assertCompilationUnitMatchesFalse(r'''
1001 main(int a, int b, int c) { 1021 main(int a, int b, int c) {
1002 } 1022 }
1003 ''', r''' 1023 ''', r'''
1004 main(int a, String b, int c) { 1024 main(int a, String b, int c) {
1005 } 1025 }
1006 '''); 1026 ''');
1007 } 1027 }
1008 1028
1009 void test_false_topLevelFunction_returnType_edit() { 1029 void test_false_topLevelFunction_returnType_edit() {
1010 _assertCompilationUnitMatches(false, r''' 1030 _assertCompilationUnitMatchesFalse(r'''
1011 int a() {} 1031 int a() {}
1012 ''', r''' 1032 ''', r'''
1013 String a() {} 1033 String a() {}
1014 '''); 1034 ''');
1015 } 1035 }
1016 1036
1017 void test_false_topLevelVariable_list_add() { 1037 void test_false_topLevelVariable_list_add() {
1018 _assertCompilationUnitMatches(false, r''' 1038 _assertCompilationUnitMatchesFalse(r'''
1019 const int A = 1; 1039 const int A = 1;
1020 const int C = 3; 1040 const int C = 3;
1021 ''', r''' 1041 ''', r'''
1022 const int A = 1; 1042 const int A = 1;
1023 const int B = 2; 1043 const int B = 2;
1024 const int C = 3; 1044 const int C = 3;
1025 '''); 1045 ''');
1026 } 1046 }
1027 1047
1028 void test_false_topLevelVariable_list_remove() { 1048 void test_false_topLevelVariable_list_remove() {
1029 _assertCompilationUnitMatches(false, r''' 1049 _assertCompilationUnitMatchesFalse(r'''
1030 const int A = 1; 1050 const int A = 1;
1031 const int B = 2; 1051 const int B = 2;
1032 const int C = 3; 1052 const int C = 3;
1033 ''', r''' 1053 ''', r'''
1034 const int A = 1; 1054 const int A = 1;
1035 const int C = 3; 1055 const int C = 3;
1036 '''); 1056 ''');
1037 } 1057 }
1038 1058
1039 void test_false_topLevelVariable_modifier_isConst() { 1059 void test_false_topLevelVariable_modifier_isConst() {
1040 _assertCompilationUnitMatches(false, r''' 1060 _assertCompilationUnitMatchesFalse(r'''
1041 final int A = 1; 1061 final int A = 1;
1042 ''', r''' 1062 ''', r'''
1043 const int A = 1; 1063 const int A = 1;
1044 '''); 1064 ''');
1045 } 1065 }
1046 1066
1047 void test_false_topLevelVariable_modifier_isFinal() { 1067 void test_false_topLevelVariable_modifier_isFinal() {
1048 _assertCompilationUnitMatches(false, r''' 1068 _assertCompilationUnitMatchesFalse(r'''
1049 int A = 1; 1069 int A = 1;
1050 ''', r''' 1070 ''', r'''
1051 final int A = 1; 1071 final int A = 1;
1052 '''); 1072 ''');
1053 } 1073 }
1054 1074
1055 void test_false_topLevelVariable_modifier_wasConst() { 1075 void test_false_topLevelVariable_modifier_wasConst() {
1056 _assertCompilationUnitMatches(false, r''' 1076 _assertCompilationUnitMatchesFalse(r'''
1057 const int A = 1; 1077 const int A = 1;
1058 ''', r''' 1078 ''', r'''
1059 final int A = 1; 1079 final int A = 1;
1060 '''); 1080 ''');
1061 } 1081 }
1062 1082
1063 void test_false_topLevelVariable_modifier_wasFinal() { 1083 void test_false_topLevelVariable_modifier_wasFinal() {
1064 _assertCompilationUnitMatches(false, r''' 1084 _assertCompilationUnitMatchesFalse(r'''
1065 final int A = 1; 1085 final int A = 1;
1066 ''', r''' 1086 ''', r'''
1067 int A = 1; 1087 int A = 1;
1068 '''); 1088 ''');
1069 } 1089 }
1070 1090
1071 void test_false_topLevelVariable_synthetic_wasGetter() { 1091 void test_false_topLevelVariable_synthetic_wasGetter() {
1072 _assertCompilationUnitMatches(false, r''' 1092 _assertCompilationUnitMatchesFalse(r'''
1073 int get A => 1; 1093 int get A => 1;
1074 ''', r''' 1094 ''', r'''
1075 final int A = 1; 1095 final int A = 1;
1076 '''); 1096 ''');
1077 } 1097 }
1078 1098
1079 void test_false_topLevelVariable_type_different() { 1099 void test_false_topLevelVariable_type_different() {
1080 _assertCompilationUnitMatches(false, r''' 1100 _assertCompilationUnitMatchesFalse(r'''
1081 int A; 1101 int A;
1082 ''', r''' 1102 ''', r'''
1083 String A; 1103 String A;
1084 '''); 1104 ''');
1085 } 1105 }
1086 1106
1087 void test_false_topLevelVariable_type_differentArgs() { 1107 void test_false_topLevelVariable_type_differentArgs() {
1088 _assertCompilationUnitMatches(false, r''' 1108 _assertCompilationUnitMatchesFalse(r'''
1089 List<int> A; 1109 List<int> A;
1090 ''', r''' 1110 ''', r'''
1091 List<String> A; 1111 List<String> A;
1092 '''); 1112 ''');
1093 } 1113 }
1094 1114
1095 void test_false_type_noTypeArguments_hadTypeArguments() { 1115 void test_false_type_noTypeArguments_hadTypeArguments() {
1096 _assertCompilationUnitMatches(false, r''' 1116 _assertCompilationUnitMatchesFalse(r'''
1097 class A<T> {} 1117 class A<T> {}
1098 A<int> main() { 1118 A<int> main() {
1099 } 1119 }
1100 ''', r''' 1120 ''', r'''
1101 class A<T> {} 1121 class A<T> {}
1102 A main() { 1122 A main() {
1103 } 1123 }
1104 '''); 1124 ''');
1105 } 1125 }
1106 1126
1107 void test_false_withClause_add() { 1127 void test_false_withClause_add() {
1108 _assertCompilationUnitMatches(false, r''' 1128 _assertCompilationUnitMatchesFalse(r'''
1109 class A {} 1129 class A {}
1110 class B {} 1130 class B {}
1111 ''', r''' 1131 ''', r'''
1112 class A {} 1132 class A {}
1113 class B extends Object with A {} 1133 class B extends Object with A {}
1114 '''); 1134 ''');
1115 } 1135 }
1116 1136
1117 void test_false_withClause_remove() { 1137 void test_false_withClause_remove() {
1118 _assertCompilationUnitMatches(false, r''' 1138 _assertCompilationUnitMatchesFalse(r'''
1119 class A {} 1139 class A {}
1120 class B extends Object with A {} 1140 class B extends Object with A {}
1121 ''', r''' 1141 ''', r'''
1122 class A {} 1142 class A {}
1123 class B {} 1143 class B {}
1124 '''); 1144 ''');
1125 } 1145 }
1126 1146
1127 void test_false_withClause_reorder() { 1147 void test_false_withClause_reorder() {
1128 _assertCompilationUnitMatches(false, r''' 1148 _assertCompilationUnitMatchesFalse(r'''
1129 class A {} 1149 class A {}
1130 class B {} 1150 class B {}
1131 class C extends Object with A, B {} 1151 class C extends Object with A, B {}
1132 ''', r''' 1152 ''', r'''
1133 class A {} 1153 class A {}
1134 class B {} 1154 class B {}
1135 class C extends Object with B, A {} 1155 class C extends Object with B, A {}
1136 '''); 1156 ''');
1137 } 1157 }
1138 1158
1139 void test_true_class_list_reorder() { 1159 void test_true_class_list_reorder() {
1140 _assertCompilationUnitMatches(true, r''' 1160 _assertCompilationUnitMatchesTrue(r'''
1141 class A {} 1161 class A {}
1142 class B {} 1162 class B {}
1143 class C {} 1163 class C {}
1144 ''', r''' 1164 ''', r'''
1145 class C {} 1165 class C {}
1146 class A {} 1166 class A {}
1147 class B {} 1167 class B {}
1148 '''); 1168 ''');
1149 } 1169 }
1150 1170
1151 void test_true_class_list_same() { 1171 void test_true_class_list_same() {
1152 _assertCompilationUnitMatches(true, r''' 1172 _assertCompilationUnitMatchesTrue(r'''
1153 class A {} 1173 class A {}
1154 class B {} 1174 class B {}
1155 class C {} 1175 class C {}
1156 ''', r''' 1176 ''', r'''
1157 class A {} 1177 class A {}
1158 class B {} 1178 class B {}
1159 class C {} 1179 class C {}
1160 '''); 1180 ''');
1161 } 1181 }
1162 1182
1163 void test_true_class_typeParameters_same() { 1183 void test_true_class_typeParameters_same() {
1164 _assertCompilationUnitMatches(true, r''' 1184 _assertCompilationUnitMatchesTrue(r'''
1165 class A<T> {} 1185 class A<T> {}
1166 ''', r''' 1186 ''', r'''
1167 class A<T> {} 1187 class A<T> {}
1168 '''); 1188 ''');
1169 } 1189 }
1170 1190
1171 void test_true_classMemberAccessor_getterSetter() { 1191 void test_true_classMemberAccessor_getterSetter() {
1172 _assertCompilationUnitMatches(true, r''' 1192 _assertCompilationUnitMatchesTrue(r'''
1173 class A { 1193 class A {
1174 int _test; 1194 int _test;
1175 get test => _test; 1195 get test => _test;
1176 set test(v) { 1196 set test(v) {
1177 _test = v; 1197 _test = v;
1178 } 1198 }
1179 } 1199 }
1180 ''', r''' 1200 ''', r'''
1181 class A { 1201 class A {
1182 int _test; 1202 int _test;
1183 get test => _test; 1203 get test => _test;
1184 set test(v) { 1204 set test(v) {
1185 _test = v; 1205 _test = v;
1186 } 1206 }
1187 } 1207 }
1188 '''); 1208 ''');
1189 } 1209 }
1190 1210
1191 void test_true_classMemberAccessor_list_reorder() { 1211 void test_true_classMemberAccessor_list_reorder() {
1192 _assertCompilationUnitMatches(true, r''' 1212 _assertCompilationUnitMatchesTrue(r'''
1193 class A { 1213 class A {
1194 get a => 1; 1214 get a => 1;
1195 get b => 2; 1215 get b => 2;
1196 get c => 3; 1216 get c => 3;
1197 } 1217 }
1198 ''', r''' 1218 ''', r'''
1199 class A { 1219 class A {
1200 get c => 3; 1220 get c => 3;
1201 get a => 1; 1221 get a => 1;
1202 get b => 2; 1222 get b => 2;
1203 } 1223 }
1204 '''); 1224 ''');
1205 } 1225 }
1206 1226
1207 void test_true_classMemberAccessor_list_same() { 1227 void test_true_classMemberAccessor_list_same() {
1208 _assertCompilationUnitMatches(true, r''' 1228 _assertCompilationUnitMatchesTrue(r'''
1209 class A { 1229 class A {
1210 get a => 1; 1230 get a => 1;
1211 get b => 2; 1231 get b => 2;
1212 get c => 3; 1232 get c => 3;
1213 } 1233 }
1214 ''', r''' 1234 ''', r'''
1215 class A { 1235 class A {
1216 get a => 1; 1236 get a => 1;
1217 get b => 2; 1237 get b => 2;
1218 get c => 3; 1238 get c => 3;
1219 } 1239 }
1220 '''); 1240 ''');
1221 } 1241 }
1222 1242
1223 void test_true_classTypeAlias_list_reorder() { 1243 void test_true_classTypeAlias_list_reorder() {
1224 _assertCompilationUnitMatches(true, r''' 1244 _assertCompilationUnitMatchesTrue(r'''
1225 class M {} 1245 class M {}
1226 class A = Object with M; 1246 class A = Object with M;
1227 class B = Object with M; 1247 class B = Object with M;
1228 class C = Object with M; 1248 class C = Object with M;
1229 ''', r''' 1249 ''', r'''
1230 class M {} 1250 class M {}
1231 class C = Object with M; 1251 class C = Object with M;
1232 class A = Object with M; 1252 class A = Object with M;
1233 class B = Object with M; 1253 class B = Object with M;
1234 '''); 1254 ''');
1235 } 1255 }
1236 1256
1237 void test_true_classTypeAlias_list_same() { 1257 void test_true_classTypeAlias_list_same() {
1238 _assertCompilationUnitMatches(true, r''' 1258 _assertCompilationUnitMatchesTrue(r'''
1239 class M {} 1259 class M {}
1240 class A = Object with M; 1260 class A = Object with M;
1241 class B = Object with M; 1261 class B = Object with M;
1242 class C = Object with M; 1262 class C = Object with M;
1243 ''', r''' 1263 ''', r'''
1244 class M {} 1264 class M {}
1245 class A = Object with M; 1265 class A = Object with M;
1246 class B = Object with M; 1266 class B = Object with M;
1247 class C = Object with M; 1267 class C = Object with M;
1248 '''); 1268 ''');
1249 } 1269 }
1250 1270
1251 void test_true_classTypeAlias_typeParameters_same() { 1271 void test_true_classTypeAlias_typeParameters_same() {
1252 _assertCompilationUnitMatches(true, r''' 1272 _assertCompilationUnitMatchesTrue(r'''
1253 class M<T> {} 1273 class M<T> {}
1254 class A<T> {} 1274 class A<T> {}
1255 class B<T> = A<T> with M<T>; 1275 class B<T> = A<T> with M<T>;
1256 ''', r''' 1276 ''', r'''
1257 class M<T> {} 1277 class M<T> {}
1258 class A<T> {} 1278 class A<T> {}
1259 class B<T> = A<T> with M<T>; 1279 class B<T> = A<T> with M<T>;
1260 '''); 1280 ''');
1261 } 1281 }
1262 1282
1263 void test_true_constructor_named_same() { 1283 void test_true_constructor_named_same() {
1264 _assertCompilationUnitMatches(true, r''' 1284 _assertCompilationUnitMatchesTrue(r'''
1265 class A { 1285 class A {
1266 A.name(int p); 1286 A.name(int p);
1267 } 1287 }
1268 ''', r''' 1288 ''', r'''
1269 class A { 1289 class A {
1270 A.name(int p); 1290 A.name(int p);
1271 } 1291 }
1272 '''); 1292 ''');
1273 } 1293 }
1274 1294
1275 void test_true_constructor_unnamed_add_noParameters() { 1295 void test_true_constructor_unnamed_add_noParameters() {
1276 _assertCompilationUnitMatches(true, r''' 1296 _assertCompilationUnitMatchesTrue(r'''
1277 class A { 1297 class A {
1278 } 1298 }
1279 ''', r''' 1299 ''', r'''
1280 class A { 1300 class A {
1281 A() {} 1301 A() {}
1282 } 1302 }
1283 '''); 1303 ''');
1284 } 1304 }
1285 1305
1286 void test_true_constructor_unnamed_remove_noParameters() { 1306 void test_true_constructor_unnamed_remove_noParameters() {
1287 _assertCompilationUnitMatches(true, r''' 1307 _assertCompilationUnitMatchesTrue(r'''
1288 class A { 1308 class A {
1289 A() {} 1309 A() {}
1290 } 1310 }
1291 ''', r''' 1311 ''', r'''
1292 class A { 1312 class A {
1293 } 1313 }
1294 '''); 1314 ''');
1295 } 1315 }
1296 1316
1297 void test_true_constructor_unnamed_same() { 1317 void test_true_constructor_unnamed_same() {
1298 _assertCompilationUnitMatches(true, r''' 1318 _assertCompilationUnitMatchesTrue(r'''
1299 class A { 1319 class A {
1300 A(int p); 1320 A(int p);
1301 } 1321 }
1302 ''', r''' 1322 ''', r'''
1303 class A { 1323 class A {
1304 A(int p); 1324 A(int p);
1305 } 1325 }
1306 '''); 1326 ''');
1307 } 1327 }
1308 1328
1309 void test_true_defaultFieldFormalParameterElement() { 1329 void test_true_defaultFieldFormalParameterElement() {
1310 _assertCompilationUnitMatches(true, r''' 1330 _assertCompilationUnitMatchesTrue(r'''
1311 class A { 1331 class A {
1312 int field; 1332 int field;
1313 A([this.field = 0]); 1333 A([this.field = 0]);
1314 } 1334 }
1315 ''', r''' 1335 ''', r'''
1316 class A { 1336 class A {
1317 int field; 1337 int field;
1318 A([this.field = 0]); 1338 A([this.field = 0]);
1319 } 1339 }
1320 '''); 1340 ''');
1321 } 1341 }
1322 1342
1323 void test_true_enum_constants_reorder() { 1343 void test_true_enum_constants_reorder() {
1324 resetWithEnum(); 1344 resetWithEnum();
1325 _assertCompilationUnitMatches(true, r''' 1345 _assertCompilationUnitMatchesTrue(r'''
1326 enum E {A, B, C} 1346 enum E {A, B, C}
1327 ''', r''' 1347 ''', r'''
1328 enum E {C, A, B} 1348 enum E {C, A, B}
1329 '''); 1349 ''');
1330 } 1350 }
1331 1351
1332 void test_true_enum_list_reorder() { 1352 void test_true_enum_list_reorder() {
1333 resetWithEnum(); 1353 resetWithEnum();
1334 _assertCompilationUnitMatches(true, r''' 1354 _assertCompilationUnitMatchesTrue(r'''
1335 enum A {A1, A2, A3} 1355 enum A {A1, A2, A3}
1336 enum B {B1, B2, B3} 1356 enum B {B1, B2, B3}
1337 enum C {C1, C2, C3} 1357 enum C {C1, C2, C3}
1338 ''', r''' 1358 ''', r'''
1339 enum C {C1, C2, C3} 1359 enum C {C1, C2, C3}
1340 enum A {A1, A2, A3} 1360 enum A {A1, A2, A3}
1341 enum B {B1, B2, B3} 1361 enum B {B1, B2, B3}
1342 '''); 1362 ''');
1343 } 1363 }
1344 1364
1345 void test_true_enum_list_same() { 1365 void test_true_enum_list_same() {
1346 resetWithEnum(); 1366 resetWithEnum();
1347 _assertCompilationUnitMatches(true, r''' 1367 _assertCompilationUnitMatchesTrue(r'''
1348 enum A {A1, A2, A3} 1368 enum A {A1, A2, A3}
1349 enum B {B1, B2, B3} 1369 enum B {B1, B2, B3}
1350 enum C {C1, C2, C3} 1370 enum C {C1, C2, C3}
1351 ''', r''' 1371 ''', r'''
1352 enum A {A1, A2, A3} 1372 enum A {A1, A2, A3}
1353 enum B {B1, B2, B3} 1373 enum B {B1, B2, B3}
1354 enum C {C1, C2, C3} 1374 enum C {C1, C2, C3}
1355 '''); 1375 ''');
1356 } 1376 }
1357 1377
1358 void test_true_executable_same_hasLabel() { 1378 void test_true_executable_same_hasLabel() {
1359 _assertCompilationUnitMatches(true, r''' 1379 _assertCompilationUnitMatchesTrue(r'''
1360 main() { 1380 main() {
1361 label: return 42; 1381 label: return 42;
1362 } 1382 }
1363 ''', r''' 1383 ''', r'''
1364 main() { 1384 main() {
1365 label: return 42; 1385 label: return 42;
1366 } 1386 }
1367 '''); 1387 ''');
1368 } 1388 }
1369 1389
1370 void test_true_executable_same_hasLocalVariable() { 1390 void test_true_executable_same_hasLocalVariable() {
1371 _assertCompilationUnitMatches(true, r''' 1391 _assertCompilationUnitMatchesTrue(r'''
1372 main() { 1392 main() {
1373 int a = 42; 1393 int a = 42;
1374 } 1394 }
1375 ''', r''' 1395 ''', r'''
1376 main() { 1396 main() {
1377 int a = 42; 1397 int a = 42;
1378 } 1398 }
1379 '''); 1399 ''');
1380 } 1400 }
1381 1401
1382 void test_true_export_hide_reorder() { 1402 void test_true_export_hide_reorder() {
1383 _assertCompilationUnitMatches(true, r''' 1403 _assertCompilationUnitMatchesTrue(r'''
1384 export 'dart:async' hide Future, Stream; 1404 export 'dart:async' hide Future, Stream;
1385 ''', r''' 1405 ''', r'''
1386 export 'dart:async' hide Stream, Future; 1406 export 'dart:async' hide Stream, Future;
1387 '''); 1407 ''');
1388 } 1408 }
1389 1409
1390 void test_true_export_list_reorder() { 1410 void test_true_export_list_reorder() {
1391 _assertCompilationUnitMatches(true, r''' 1411 _assertCompilationUnitMatchesTrue(r'''
1392 export 'dart:async'; 1412 export 'dart:async';
1393 export 'dart:math'; 1413 export 'dart:math';
1394 ''', r''' 1414 ''', r'''
1395 export 'dart:math'; 1415 export 'dart:math';
1396 export 'dart:async'; 1416 export 'dart:async';
1397 '''); 1417 ''');
1398 } 1418 }
1399 1419
1400 void test_true_export_list_same() { 1420 void test_true_export_list_same() {
1401 _assertCompilationUnitMatches(true, r''' 1421 _assertCompilationUnitMatchesTrue(r'''
1402 export 'dart:async'; 1422 export 'dart:async';
1403 export 'dart:math'; 1423 export 'dart:math';
1404 ''', r''' 1424 ''', r'''
1405 export 'dart:async'; 1425 export 'dart:async';
1406 export 'dart:math'; 1426 export 'dart:math';
1407 '''); 1427 ''');
1408 } 1428 }
1409 1429
1410 void test_true_export_show_reorder() { 1430 void test_true_export_show_reorder() {
1411 _assertCompilationUnitMatches(true, r''' 1431 _assertCompilationUnitMatchesTrue(r'''
1412 export 'dart:async' show Future, Stream; 1432 export 'dart:async' show Future, Stream;
1413 ''', r''' 1433 ''', r'''
1414 export 'dart:async' show Stream, Future; 1434 export 'dart:async' show Stream, Future;
1415 '''); 1435 ''');
1416 } 1436 }
1417 1437
1418 void test_true_extendsClause_same() { 1438 void test_true_extendsClause_same() {
1419 _assertCompilationUnitMatches(true, r''' 1439 _assertCompilationUnitMatchesTrue(r'''
1420 class A {} 1440 class A {}
1421 class B extends A {} 1441 class B extends A {}
1422 ''', r''' 1442 ''', r'''
1423 class A {} 1443 class A {}
1424 class B extends A {} 1444 class B extends A {}
1425 '''); 1445 ''');
1426 } 1446 }
1427 1447
1428 void test_true_field_list_reorder() { 1448 void test_true_field_list_reorder() {
1429 _assertCompilationUnitMatches(true, r''' 1449 _assertCompilationUnitMatchesTrue(r'''
1430 class T { 1450 class T {
1431 int A = 1; 1451 int A = 1;
1432 int B = 2; 1452 int B = 2;
1433 int C = 3; 1453 int C = 3;
1434 } 1454 }
1435 ''', r''' 1455 ''', r'''
1436 class T { 1456 class T {
1437 int C = 3; 1457 int C = 3;
1438 int A = 1; 1458 int A = 1;
1439 int B = 2; 1459 int B = 2;
1440 } 1460 }
1441 '''); 1461 ''');
1442 } 1462 }
1443 1463
1444 void test_true_field_list_same() { 1464 void test_true_field_list_same() {
1445 _assertCompilationUnitMatches(true, r''' 1465 _assertCompilationUnitMatchesTrue(r'''
1446 class T { 1466 class T {
1447 int A = 1; 1467 int A = 1;
1448 int B = 2; 1468 int B = 2;
1449 int C = 3; 1469 int C = 3;
1450 } 1470 }
1451 ''', r''' 1471 ''', r'''
1452 class T { 1472 class T {
1453 int A = 1; 1473 int A = 1;
1454 int B = 2; 1474 int B = 2;
1455 int C = 3; 1475 int C = 3;
1456 } 1476 }
1457 '''); 1477 ''');
1458 } 1478 }
1459 1479
1460 void test_true_fieldFormalParameter() { 1480 void test_true_fieldFormalParameter() {
1461 _assertCompilationUnitMatches(true, r''' 1481 _assertCompilationUnitMatchesTrue(r'''
1462 class A { 1482 class A {
1463 int field; 1483 int field;
1464 A(this.field); 1484 A(this.field);
1465 } 1485 }
1466 ''', r''' 1486 ''', r'''
1467 class A { 1487 class A {
1468 int field; 1488 int field;
1469 A(this.field); 1489 A(this.field);
1470 } 1490 }
1471 '''); 1491 ''');
1472 } 1492 }
1473 1493
1474 void test_true_functionTypeAlias_list_reorder() { 1494 void test_true_functionTypeAlias_list_reorder() {
1475 _assertCompilationUnitMatches(true, r''' 1495 _assertCompilationUnitMatchesTrue(r'''
1476 typedef A(int pa); 1496 typedef A(int pa);
1477 typedef B(String pb); 1497 typedef B(String pb);
1478 typedef C(pc); 1498 typedef C(pc);
1479 ''', r''' 1499 ''', r'''
1480 typedef C(pc); 1500 typedef C(pc);
1481 typedef A(int pa); 1501 typedef A(int pa);
1482 typedef B(String pb); 1502 typedef B(String pb);
1483 '''); 1503 ''');
1484 } 1504 }
1485 1505
1486 void test_true_functionTypeAlias_list_same() { 1506 void test_true_functionTypeAlias_list_same() {
1487 _assertCompilationUnitMatches(true, r''' 1507 _assertCompilationUnitMatchesTrue(r'''
1488 typedef String A(int pa); 1508 typedef String A(int pa);
1489 typedef int B(String pb); 1509 typedef int B(String pb);
1490 typedef C(pc); 1510 typedef C(pc);
1491 ''', r''' 1511 ''', r'''
1492 typedef String A(int pa); 1512 typedef String A(int pa);
1493 typedef int B(String pb); 1513 typedef int B(String pb);
1494 typedef C(pc); 1514 typedef C(pc);
1495 '''); 1515 ''');
1496 } 1516 }
1497 1517
1498 void test_true_functionTypeAlias_typeParameters_list_same() { 1518 void test_true_functionTypeAlias_typeParameters_list_same() {
1499 _assertCompilationUnitMatches(true, r''' 1519 _assertCompilationUnitMatchesTrue(r'''
1500 typedef F<A, B, C>(); 1520 typedef F<A, B, C>();
1501 ''', r''' 1521 ''', r'''
1502 typedef F<A, B, C>(); 1522 typedef F<A, B, C>();
1503 '''); 1523 ''');
1504 } 1524 }
1505 1525
1506 void test_true_FunctionTypedFormalParameter() { 1526 void test_true_FunctionTypedFormalParameter() {
1507 _assertCompilationUnitMatches(true, r''' 1527 _assertCompilationUnitMatchesTrue(r'''
1508 main(int callback(int a, String b)) { 1528 main(int callback(int a, String b)) {
1509 } 1529 }
1510 ''', r''' 1530 ''', r'''
1511 main(int callback(int a, String b)) { 1531 main(int callback(int a, String b)) {
1512 } 1532 }
1513 '''); 1533 ''');
1514 } 1534 }
1515 1535
1516 void test_true_implementsClause_same() { 1536 void test_true_implementsClause_same() {
1517 _assertCompilationUnitMatches(true, r''' 1537 _assertCompilationUnitMatchesTrue(r'''
1518 class A {} 1538 class A {}
1519 class B implements A {} 1539 class B implements A {}
1520 ''', r''' 1540 ''', r'''
1521 class A {} 1541 class A {}
1522 class B implements A {} 1542 class B implements A {}
1523 '''); 1543 ''');
1524 } 1544 }
1525 1545
1526 void test_true_import_hide_reorder() { 1546 void test_true_import_hide_reorder() {
1527 _assertCompilationUnitMatches(true, r''' 1547 _assertCompilationUnitMatchesTrue(r'''
1528 import 'dart:async' hide Future, Stream; 1548 import 'dart:async' hide Future, Stream;
1529 ''', r''' 1549 ''', r'''
1530 import 'dart:async' hide Stream, Future; 1550 import 'dart:async' hide Stream, Future;
1531 '''); 1551 ''');
1532 } 1552 }
1533 1553
1534 void test_true_import_list_reorder() { 1554 void test_true_import_list_reorder() {
1535 _assertCompilationUnitMatches(true, r''' 1555 _assertCompilationUnitMatchesTrue(r'''
1536 import 'dart:async'; 1556 import 'dart:async';
1537 import 'dart:math'; 1557 import 'dart:math';
1538 ''', r''' 1558 ''', r'''
1539 import 'dart:math'; 1559 import 'dart:math';
1540 import 'dart:async'; 1560 import 'dart:async';
1541 '''); 1561 ''');
1542 } 1562 }
1543 1563
1544 void test_true_import_list_same() { 1564 void test_true_import_list_same() {
1545 _assertCompilationUnitMatches(true, r''' 1565 _assertCompilationUnitMatchesTrue(r'''
1546 import 'dart:async'; 1566 import 'dart:async';
1547 import 'dart:math'; 1567 import 'dart:math';
1548 ''', r''' 1568 ''', r'''
1549 import 'dart:async'; 1569 import 'dart:async';
1550 import 'dart:math'; 1570 import 'dart:math';
1551 '''); 1571 ''');
1552 } 1572 }
1553 1573
1554 void test_true_import_prefix() { 1574 void test_true_import_prefix() {
1555 _assertCompilationUnitMatches(true, r''' 1575 _assertCompilationUnitMatchesTrue(r'''
1556 import 'dart:async' as async; 1576 import 'dart:async' as async;
1557 ''', r''' 1577 ''', r'''
1558 import 'dart:async' as async; 1578 import 'dart:async' as async;
1559 '''); 1579 ''');
1560 } 1580 }
1561 1581
1562 void test_true_import_show_reorder() { 1582 void test_true_import_show_reorder() {
1563 _assertCompilationUnitMatches(true, r''' 1583 _assertCompilationUnitMatchesTrue(r'''
1564 import 'dart:async' show Future, Stream; 1584 import 'dart:async' show Future, Stream;
1565 ''', r''' 1585 ''', r'''
1566 import 'dart:async' show Stream, Future; 1586 import 'dart:async' show Stream, Future;
1567 '''); 1587 ''');
1568 } 1588 }
1569 1589
1570 void test_true_method_list_reorder() { 1590 void test_true_method_list_reorder() {
1571 _assertCompilationUnitMatches(true, r''' 1591 _assertCompilationUnitMatchesTrue(r'''
1572 class A { 1592 class A {
1573 a() {} 1593 a() {}
1574 b() {} 1594 b() {}
1575 c() {} 1595 c() {}
1576 } 1596 }
1577 ''', r''' 1597 ''', r'''
1578 class A { 1598 class A {
1579 c() {} 1599 c() {}
1580 a() {} 1600 a() {}
1581 b() {} 1601 b() {}
1582 } 1602 }
1583 '''); 1603 ''');
1584 } 1604 }
1585 1605
1586 void test_true_method_list_same() { 1606 void test_true_method_list_same() {
1587 _assertCompilationUnitMatches(true, r''' 1607 _assertCompilationUnitMatchesTrue(r'''
1588 class A { 1608 class A {
1589 a() {} 1609 a() {}
1590 b() {} 1610 b() {}
1591 c() {} 1611 c() {}
1592 } 1612 }
1593 ''', r''' 1613 ''', r'''
1594 class A { 1614 class A {
1595 a() {} 1615 a() {}
1596 b() {} 1616 b() {}
1597 c() {} 1617 c() {}
1598 } 1618 }
1599 '''); 1619 ''');
1600 } 1620 }
1601 1621
1602 void test_true_method_operator_minus() { 1622 void test_true_method_operator_minus() {
1603 _assertCompilationUnitMatches(true, r''' 1623 _assertCompilationUnitMatchesTrue(r'''
1604 class A { 1624 class A {
1605 operator -(other) {} 1625 operator -(other) {}
1606 } 1626 }
1607 ''', r''' 1627 ''', r'''
1608 class A { 1628 class A {
1609 operator -(other) {} 1629 operator -(other) {}
1610 } 1630 }
1611 '''); 1631 ''');
1612 } 1632 }
1613 1633
1614 void test_true_method_operator_minusUnary() { 1634 void test_true_method_operator_minusUnary() {
1615 _assertCompilationUnitMatches(true, r''' 1635 _assertCompilationUnitMatchesTrue(r'''
1616 class A { 1636 class A {
1617 operator -() {} 1637 operator -() {}
1618 } 1638 }
1619 ''', r''' 1639 ''', r'''
1620 class A { 1640 class A {
1621 operator -() {} 1641 operator -() {}
1622 } 1642 }
1623 '''); 1643 ''');
1624 } 1644 }
1625 1645
1626 void test_true_method_operator_plus() { 1646 void test_true_method_operator_plus() {
1627 _assertCompilationUnitMatches(true, r''' 1647 _assertCompilationUnitMatchesTrue(r'''
1628 class A { 1648 class A {
1629 operator +(other) {} 1649 operator +(other) {}
1630 } 1650 }
1631 ''', r''' 1651 ''', r'''
1632 class A { 1652 class A {
1633 operator +(other) {} 1653 operator +(other) {}
1634 } 1654 }
1635 '''); 1655 ''');
1636 } 1656 }
1637 1657
1638 void test_true_part_list_reorder() { 1658 void test_true_part_list_reorder() {
1639 addNamedSource('/unitA.dart', 'part of lib; class A {}'); 1659 addNamedSource('/unitA.dart', 'part of lib; class A {}');
1640 addNamedSource('/unitB.dart', 'part of lib; class B {}'); 1660 addNamedSource('/unitB.dart', 'part of lib; class B {}');
1641 _assertCompilationUnitMatches(true, r''' 1661 _assertCompilationUnitMatchesTrue(r'''
1642 library lib; 1662 library lib;
1643 part 'unitA.dart'; 1663 part 'unitA.dart';
1644 part 'unitB.dart'; 1664 part 'unitB.dart';
1645 ''', r''' 1665 ''', r'''
1646 library lib; 1666 library lib;
1647 part 'unitB.dart'; 1667 part 'unitB.dart';
1648 part 'unitA.dart'; 1668 part 'unitA.dart';
1649 '''); 1669 ''');
1650 } 1670 }
1651 1671
1652 void test_true_part_list_same() { 1672 void test_true_part_list_same() {
1653 addNamedSource('/unitA.dart', 'part of lib; class A {}'); 1673 addNamedSource('/unitA.dart', 'part of lib; class A {}');
1654 addNamedSource('/unitB.dart', 'part of lib; class B {}'); 1674 addNamedSource('/unitB.dart', 'part of lib; class B {}');
1655 _assertCompilationUnitMatches(true, r''' 1675 _assertCompilationUnitMatchesTrue(r'''
1656 library lib; 1676 library lib;
1657 part 'unitA.dart'; 1677 part 'unitA.dart';
1658 part 'unitB.dart'; 1678 part 'unitB.dart';
1659 ''', r''' 1679 ''', r'''
1660 library lib; 1680 library lib;
1661 part 'unitA.dart'; 1681 part 'unitA.dart';
1662 part 'unitB.dart'; 1682 part 'unitB.dart';
1663 '''); 1683 ''');
1664 } 1684 }
1665 1685
1666 void test_true_SimpleFormalParameter_optional_differentName() { 1686 void test_true_SimpleFormalParameter_optional_differentName() {
1667 _assertCompilationUnitMatches(true, r''' 1687 _assertCompilationUnitMatchesTrue(r'''
1668 main([int oldName]) { 1688 main([int oldName]) {
1669 } 1689 }
1670 ''', r''' 1690 ''', r'''
1671 main([int newName]) { 1691 main([int newName]) {
1672 } 1692 }
1673 '''); 1693 ''');
1674 } 1694 }
1675 1695
1676 void test_true_SimpleFormalParameter_optionalDefault_differentName() { 1696 void test_true_SimpleFormalParameter_optionalDefault_differentName() {
1677 _assertCompilationUnitMatches(true, r''' 1697 _assertCompilationUnitMatchesTrue(r'''
1678 main([int oldName = 1]) { 1698 main([int oldName = 1]) {
1679 } 1699 }
1680 ''', r''' 1700 ''', r'''
1681 main([int newName = 1]) { 1701 main([int newName = 1]) {
1682 } 1702 }
1683 '''); 1703 ''');
1684 } 1704 }
1685 1705
1686 void test_true_SimpleFormalParameter_required_differentName() { 1706 void test_true_SimpleFormalParameter_required_differentName() {
1687 _assertCompilationUnitMatches(true, r''' 1707 _assertCompilationUnitMatchesTrue(r'''
1688 main(int oldName) { 1708 main(int oldName) {
1689 } 1709 }
1690 ''', r''' 1710 ''', r'''
1691 main(int newName) { 1711 main(int newName) {
1692 } 1712 }
1693 '''); 1713 ''');
1694 } 1714 }
1695 1715
1696 void test_true_topLevelAccessor_list_reorder() { 1716 void test_true_topLevelAccessor_list_reorder() {
1697 _assertCompilationUnitMatches(true, r''' 1717 _assertCompilationUnitMatchesTrue(r'''
1698 set a(x) {} 1718 set a(x) {}
1699 set b(x) {} 1719 set b(x) {}
1700 set c(x) {} 1720 set c(x) {}
1701 ''', r''' 1721 ''', r'''
1702 set c(x) {} 1722 set c(x) {}
1703 set a(x) {} 1723 set a(x) {}
1704 set b(x) {} 1724 set b(x) {}
1705 '''); 1725 ''');
1706 } 1726 }
1707 1727
1708 void test_true_topLevelAccessor_list_same() { 1728 void test_true_topLevelAccessor_list_same() {
1709 _assertCompilationUnitMatches(true, r''' 1729 _assertCompilationUnitMatchesTrue(r'''
1710 get a => 1; 1730 get a => 1;
1711 get b => 2; 1731 get b => 2;
1712 get c => 3; 1732 get c => 3;
1713 ''', r''' 1733 ''', r'''
1714 get a => 1; 1734 get a => 1;
1715 get b => 2; 1735 get b => 2;
1716 get c => 3; 1736 get c => 3;
1717 '''); 1737 ''');
1718 } 1738 }
1719 1739
1720 void test_true_topLevelFunction_list_reorder() { 1740 void test_true_topLevelFunction_list_reorder() {
1721 _assertCompilationUnitMatches(true, r''' 1741 _assertCompilationUnitMatchesTrue(r'''
1722 a() {} 1742 a() {}
1723 b() {} 1743 b() {}
1724 c() {} 1744 c() {}
1725 ''', r''' 1745 ''', r'''
1726 c() {} 1746 c() {}
1727 a() {} 1747 a() {}
1728 b() {} 1748 b() {}
1729 '''); 1749 ''');
1730 } 1750 }
1731 1751
1732 void test_true_topLevelFunction_list_same() { 1752 void test_true_topLevelFunction_list_same() {
1733 _assertCompilationUnitMatches(true, r''' 1753 _assertCompilationUnitMatchesTrue(r'''
1734 a() {} 1754 a() {}
1735 b() {} 1755 b() {}
1736 c() {} 1756 c() {}
1737 ''', r''' 1757 ''', r'''
1738 a() {} 1758 a() {}
1739 b() {} 1759 b() {}
1740 c() {} 1760 c() {}
1741 '''); 1761 ''');
1742 } 1762 }
1743 1763
1744 void test_true_topLevelVariable_list_reorder() { 1764 void test_true_topLevelVariable_list_reorder() {
1745 _assertCompilationUnitMatches(true, r''' 1765 _assertCompilationUnitMatchesTrue(r'''
1746 const int A = 1; 1766 const int A = 1;
1747 const int B = 2; 1767 const int B = 2;
1748 const int C = 3; 1768 const int C = 3;
1749 ''', r''' 1769 ''', r'''
1750 const int C = 3; 1770 const int C = 3;
1751 const int A = 1; 1771 const int A = 1;
1752 const int B = 2; 1772 const int B = 2;
1753 '''); 1773 ''');
1754 } 1774 }
1755 1775
1756 void test_true_topLevelVariable_list_same() { 1776 void test_true_topLevelVariable_list_same() {
1757 _assertCompilationUnitMatches(true, r''' 1777 _assertCompilationUnitMatchesTrue(r'''
1758 const int A = 1; 1778 const int A = 1;
1759 const int B = 2; 1779 const int B = 2;
1760 const int C = 3; 1780 const int C = 3;
1761 ''', r''' 1781 ''', r'''
1762 const int A = 1; 1782 const int A = 1;
1763 const int B = 2; 1783 const int B = 2;
1764 const int C = 3; 1784 const int C = 3;
1765 '''); 1785 ''');
1766 } 1786 }
1767 1787
1768 void test_true_topLevelVariable_type_sameArgs() { 1788 void test_true_topLevelVariable_type_sameArgs() {
1769 _assertCompilationUnitMatches(true, r''' 1789 _assertCompilationUnitMatchesTrue(r'''
1770 Map<int, String> A; 1790 Map<int, String> A;
1771 ''', r''' 1791 ''', r'''
1772 Map<int, String> A; 1792 Map<int, String> A;
1773 '''); 1793 ''');
1774 } 1794 }
1775 1795
1776 void test_true_type_dynamic() { 1796 void test_true_type_dynamic() {
1777 _assertCompilationUnitMatches(true, r''' 1797 _assertCompilationUnitMatchesTrue(r'''
1778 dynamic a() {} 1798 dynamic a() {}
1779 ''', r''' 1799 ''', r'''
1780 dynamic a() {} 1800 dynamic a() {}
1781 '''); 1801 ''');
1782 } 1802 }
1783 1803
1784 void test_true_type_hasImportPrefix() { 1804 void test_true_type_hasImportPrefix() {
1785 _assertCompilationUnitMatches(true, r''' 1805 _assertCompilationUnitMatchesTrue(r'''
1786 import 'dart:async' as async; 1806 import 'dart:async' as async;
1787 async.Future F; 1807 async.Future F;
1788 ''', r''' 1808 ''', r'''
1789 import 'dart:async' as async; 1809 import 'dart:async' as async;
1790 async.Future F; 1810 async.Future F;
1791 '''); 1811 ''');
1792 } 1812 }
1793 1813
1794 void test_true_type_noTypeArguments_implyAllDynamic() { 1814 void test_true_type_noTypeArguments_implyAllDynamic() {
1795 _assertCompilationUnitMatches(true, r''' 1815 _assertCompilationUnitMatchesTrue(r'''
1796 class A<T> {} 1816 class A<T> {}
1797 A main() { 1817 A main() {
1798 } 1818 }
1799 ''', r''' 1819 ''', r'''
1800 class A<T> {} 1820 class A<T> {}
1801 A main() { 1821 A main() {
1802 } 1822 }
1803 '''); 1823 ''');
1804 } 1824 }
1805 1825
1806 void test_true_type_void() { 1826 void test_true_type_void() {
1807 _assertCompilationUnitMatches(true, r''' 1827 _assertCompilationUnitMatchesTrue(r'''
1808 void a() {} 1828 void a() {}
1809 ''', r''' 1829 ''', r'''
1810 void a() {} 1830 void a() {}
1811 '''); 1831 ''');
1812 } 1832 }
1813 1833
1814 void test_true_withClause_same() { 1834 void test_true_withClause_same() {
1815 _assertCompilationUnitMatches(true, r''' 1835 _assertCompilationUnitMatchesTrue(r'''
1816 class A {} 1836 class A {}
1817 class B extends Object with A {} 1837 class B extends Object with A {}
1818 ''', r''' 1838 ''', r'''
1819 class A {} 1839 class A {}
1820 class B extends Object with A {} 1840 class B extends Object with A {}
1821 '''); 1841 ''');
1822 } 1842 }
1823 1843
1824 void _assertCompilationUnitMatches(bool expectMatch, String oldContent, 1844 void _assertCompilationUnitMatches(DeclarationMatchKind expectMatch,
1825 String newContent) { 1845 String oldContent, String newContent) {
1826 Source source = addSource(oldContent); 1846 Source source = addSource(oldContent);
1827 LibraryElement library = resolve(source); 1847 LibraryElement library = resolve(source);
1828 CompilationUnit oldUnit = resolveCompilationUnit(source, library); 1848 CompilationUnit oldUnit = resolveCompilationUnit(source, library);
1829 // parse 1849 // parse
1830 CompilationUnit newUnit = ParserTestCase.parseCompilationUnit(newContent); 1850 CompilationUnit newUnit = ParserTestCase.parseCompilationUnit(newContent);
1831 // build elements 1851 // build elements
1832 { 1852 {
1833 ElementHolder holder = new ElementHolder(); 1853 ElementHolder holder = new ElementHolder();
1834 ElementBuilder builder = new ElementBuilder(holder); 1854 ElementBuilder builder = new ElementBuilder(holder);
1835 newUnit.accept(builder); 1855 newUnit.accept(builder);
1836 } 1856 }
1837 // match 1857 // match
1838 DeclarationMatcher matcher = new DeclarationMatcher(); 1858 DeclarationMatcher matcher = new DeclarationMatcher();
1839 expect(matcher.matches(newUnit, oldUnit.element), expectMatch); 1859 DeclarationMatchKind matchKind = matcher.matches(newUnit, oldUnit.element);
1860 expect(matchKind, same(expectMatch));
1861 }
1862
1863 void _assertCompilationUnitMatchesFalse(String oldContent,
Brian Wilkerson 2014/12/05 19:38:05 Consider "_assertCompilationUnitDoesNotMatch".
1864 String newContent) {
1865 _assertCompilationUnitMatches(
1866 DeclarationMatchKind.MISMATCH,
1867 oldContent,
1868 newContent);
1869 }
1870
1871 void _assertCompilationUnitMatchesTrue(String oldContent, String newContent) {
Brian Wilkerson 2014/12/05 19:38:05 Consider "_assertCompilationUnitMatches".
1872 _assertCompilationUnitMatches(
1873 DeclarationMatchKind.MATCH,
1874 oldContent,
1875 newContent);
1840 } 1876 }
1841 } 1877 }
1842 1878
1843 1879
1844 class IncrementalResolverTest extends ResolverTestCase { 1880 class IncrementalResolverTest extends ResolverTestCase {
1845 Source source; 1881 Source source;
1846 String code; 1882 String code;
1847 LibraryElement library; 1883 LibraryElement library;
1848 CompilationUnit unit; 1884 CompilationUnit unit;
1849 1885
(...skipping 2177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4027 _visitList(node.metadata, other.metadata); 4063 _visitList(node.metadata, other.metadata);
4028 _visitNode(node.identifier, other.identifier); 4064 _visitNode(node.identifier, other.identifier);
4029 } 4065 }
4030 4066
4031 static void assertSameResolution(CompilationUnit actual, 4067 static void assertSameResolution(CompilationUnit actual,
4032 CompilationUnit expected) { 4068 CompilationUnit expected) {
4033 _SameResolutionValidator validator = new _SameResolutionValidator(expected); 4069 _SameResolutionValidator validator = new _SameResolutionValidator(expected);
4034 actual.accept(validator); 4070 actual.accept(validator);
4035 } 4071 }
4036 } 4072 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698