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

Side by Side Diff: pkg/analyzer_plugin/test/utilities/completion/inherited_reference_contributor_test.dart

Issue 2925163002: More test fixed (TBR) (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart » ('j') | 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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_plugin/protocol/protocol_common.dart'; 5 import 'package:analyzer_plugin/protocol/protocol_common.dart';
6 import 'package:analyzer_plugin/utilities/completion/completion_core.dart'; 6 import 'package:analyzer_plugin/utilities/completion/completion_core.dart';
7 import 'package:analyzer_plugin/utilities/completion/inherited_reference_contrib utor.dart'; 7 import 'package:analyzer_plugin/utilities/completion/inherited_reference_contrib utor.dart';
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 10
(...skipping 21 matching lines...) Expand all
32 resolveSource( 32 resolveSource(
33 '/testB.dart', 33 '/testB.dart',
34 ''' 34 '''
35 import 'package:meta/meta.dart'; 35 import 'package:meta/meta.dart';
36 36
37 lib libB; 37 lib libB;
38 class A { 38 class A {
39 bool foo(int bar, {bool boo, @required int baz}) => false; 39 bool foo(int bar, {bool boo, @required int baz}) => false;
40 }'''); 40 }''');
41 addTestSource(''' 41 addTestSource('''
42 import "/testB.dart"; 42 import "testB.dart";
43 class B extends A { 43 class B extends A {
44 b() => f^ 44 b() => f^
45 } 45 }
46 '''); 46 ''');
47 await computeSuggestions(); 47 await computeSuggestions();
48 48
49 assertSuggestMethod('foo', 'A', 'bool', 49 assertSuggestMethod('foo', 'A', 'bool',
50 defaultArgListString: 'bar, baz: null'); 50 defaultArgListString: 'bar, baz: null');
51 } 51 }
52 52
53 test_AwaitExpression_inherited() async { 53 test_AwaitExpression_inherited() async {
54 // SimpleIdentifier AwaitExpression ExpressionStatement 54 // SimpleIdentifier AwaitExpression ExpressionStatement
55 resolveSource( 55 resolveSource(
56 '/testB.dart', 56 '/testB.dart',
57 ''' 57 '''
58 lib libB; 58 lib libB;
59 class A { 59 class A {
60 Future y() async {return 0;} 60 Future y() async {return 0;}
61 }'''); 61 }''');
62 addTestSource(''' 62 addTestSource('''
63 import "/testB.dart"; 63 import "testB.dart";
64 class B extends A { 64 class B extends A {
65 Future a() async {return 0;} 65 Future a() async {return 0;}
66 foo() async {await ^} 66 foo() async {await ^}
67 } 67 }
68 '''); 68 ''');
69 69
70 await computeSuggestions(); 70 await computeSuggestions();
71 expect(replacementOffset, completionOffset); 71 expect(replacementOffset, completionOffset);
72 expect(replacementLength, 0); 72 expect(replacementLength, 0);
73 assertNotSuggested('a'); 73 assertNotSuggested('a');
74 assertNotSuggested('foo'); 74 assertNotSuggested('foo');
75 assertNotSuggested('B'); 75 assertNotSuggested('B');
76 assertNotSuggested('A'); 76 assertNotSuggested('A');
77 assertNotSuggested('Object'); 77 assertNotSuggested('Object');
78 assertSuggestMethod('y', 'A', 'dynamic'); 78 assertSuggestMethod('y', 'A', 'dynamic');
79 } 79 }
80 80
81 test_Block_inherited_imported() async { 81 test_Block_inherited_imported() async {
82 // Block BlockFunctionBody MethodDeclaration ClassDeclaration 82 // Block BlockFunctionBody MethodDeclaration ClassDeclaration
83 resolveSource( 83 resolveSource(
84 '/testB.dart', 84 '/testB.dart',
85 ''' 85 '''
86 lib B; 86 lib B;
87 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } var _pf; } 87 class F { var f1; f2() { } get f3 => 0; set f4(fx) { } var _pf; }
88 class E extends F { var e1; e2() { } } 88 class E extends F { var e1; e2() { } }
89 class I { int i1; i2() { } } 89 class I { int i1; i2() { } }
90 class M { var m1; int m2() { } }'''); 90 class M { var m1; int m2() { } }''');
91 addTestSource(''' 91 addTestSource('''
92 import "/testB.dart"; 92 import "testB.dart";
93 class A extends E implements I with M {a() {^}}'''); 93 class A extends E implements I with M {a() {^}}''');
94 await computeSuggestions(); 94 await computeSuggestions();
95 expect(replacementOffset, completionOffset); 95 expect(replacementOffset, completionOffset);
96 expect(replacementLength, 0); 96 expect(replacementLength, 0);
97 assertSuggestField('e1', null); 97 assertSuggestField('e1', null);
98 assertSuggestField('f1', null); 98 assertSuggestField('f1', null);
99 assertSuggestField('i1', 'int'); 99 assertSuggestField('i1', 'int');
100 assertSuggestField('m1', null); 100 assertSuggestField('m1', null);
101 assertSuggestGetter('f3', null); 101 assertSuggestGetter('f3', null);
102 assertSuggestSetter('f4'); 102 assertSuggestSetter('f4');
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 '/testB.dart', 136 '/testB.dart',
137 ''' 137 '''
138 lib libB; 138 lib libB;
139 class A2 { 139 class A2 {
140 int x; 140 int x;
141 int y() {return 0;} 141 int y() {return 0;}
142 int x2; 142 int x2;
143 int y2() {return 0;} 143 int y2() {return 0;}
144 }'''); 144 }''');
145 addTestSource(''' 145 addTestSource('''
146 import "/testB.dart"; 146 import "testB.dart";
147 class A1 { 147 class A1 {
148 int x; 148 int x;
149 int y() {return 0;} 149 int y() {return 0;}
150 int x1; 150 int x1;
151 int y1() {return 0;} 151 int y1() {return 0;}
152 } 152 }
153 class B extends A1 with A2 { 153 class B extends A1 with A2 {
154 int a; 154 int a;
155 int b() {return 0;} 155 int b() {return 0;}
156 foo() {^} 156 foo() {^}
(...skipping 30 matching lines...) Expand all
187 187
188 test_method_parameters_mixed_required_and_named() async { 188 test_method_parameters_mixed_required_and_named() async {
189 resolveSource( 189 resolveSource(
190 '/libA.dart', 190 '/libA.dart',
191 ''' 191 '''
192 class A { 192 class A {
193 void m(x, {int y}) {} 193 void m(x, {int y}) {}
194 } 194 }
195 '''); 195 ''');
196 addTestSource(''' 196 addTestSource('''
197 import '/libA.dart'; 197 import 'libA.dart';
198 class B extends A { 198 class B extends A {
199 main() {^} 199 main() {^}
200 } 200 }
201 '''); 201 ''');
202 await computeSuggestions(); 202 await computeSuggestions();
203 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void'); 203 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void');
204 expect(suggestion.parameterNames, hasLength(2)); 204 expect(suggestion.parameterNames, hasLength(2));
205 expect(suggestion.parameterNames[0], 'x'); 205 expect(suggestion.parameterNames[0], 'x');
206 expect(suggestion.parameterTypes[0], 'dynamic'); 206 expect(suggestion.parameterTypes[0], 'dynamic');
207 expect(suggestion.parameterNames[1], 'y'); 207 expect(suggestion.parameterNames[1], 'y');
(...skipping 24 matching lines...) Expand all
232 232
233 test_method_parameters_mixed_required_and_positional() async { 233 test_method_parameters_mixed_required_and_positional() async {
234 resolveSource( 234 resolveSource(
235 '/libA.dart', 235 '/libA.dart',
236 ''' 236 '''
237 class A { 237 class A {
238 void m(x, [int y]) {} 238 void m(x, [int y]) {}
239 } 239 }
240 '''); 240 ''');
241 addTestSource(''' 241 addTestSource('''
242 import '/libA.dart'; 242 import 'libA.dart';
243 class B extends A { 243 class B extends A {
244 main() {^} 244 main() {^}
245 } 245 }
246 '''); 246 ''');
247 await computeSuggestions(); 247 await computeSuggestions();
248 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void'); 248 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void');
249 expect(suggestion.parameterNames, hasLength(2)); 249 expect(suggestion.parameterNames, hasLength(2));
250 expect(suggestion.parameterNames[0], 'x'); 250 expect(suggestion.parameterNames[0], 'x');
251 expect(suggestion.parameterTypes[0], 'dynamic'); 251 expect(suggestion.parameterTypes[0], 'dynamic');
252 expect(suggestion.parameterNames[1], 'y'); 252 expect(suggestion.parameterNames[1], 'y');
(...skipping 24 matching lines...) Expand all
277 277
278 test_method_parameters_named() async { 278 test_method_parameters_named() async {
279 resolveSource( 279 resolveSource(
280 '/libA.dart', 280 '/libA.dart',
281 ''' 281 '''
282 class A { 282 class A {
283 void m({x, int y}) {} 283 void m({x, int y}) {}
284 } 284 }
285 '''); 285 ''');
286 addTestSource(''' 286 addTestSource('''
287 import '/libA.dart'; 287 import 'libA.dart';
288 class B extends A { 288 class B extends A {
289 main() {^} 289 main() {^}
290 } 290 }
291 '''); 291 ''');
292 await computeSuggestions(); 292 await computeSuggestions();
293 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void'); 293 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void');
294 expect(suggestion.parameterNames, hasLength(2)); 294 expect(suggestion.parameterNames, hasLength(2));
295 expect(suggestion.parameterNames[0], 'x'); 295 expect(suggestion.parameterNames[0], 'x');
296 expect(suggestion.parameterTypes[0], 'dynamic'); 296 expect(suggestion.parameterTypes[0], 'dynamic');
297 expect(suggestion.parameterNames[1], 'y'); 297 expect(suggestion.parameterNames[1], 'y');
(...skipping 24 matching lines...) Expand all
322 322
323 test_method_parameters_none() async { 323 test_method_parameters_none() async {
324 resolveSource( 324 resolveSource(
325 '/libA.dart', 325 '/libA.dart',
326 ''' 326 '''
327 class A { 327 class A {
328 void m() {} 328 void m() {}
329 } 329 }
330 '''); 330 ''');
331 addTestSource(''' 331 addTestSource('''
332 import '/libA.dart'; 332 import 'libA.dart';
333 class B extends A { 333 class B extends A {
334 main() {^} 334 main() {^}
335 } 335 }
336 '''); 336 ''');
337 await computeSuggestions(); 337 await computeSuggestions();
338 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void'); 338 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void');
339 expect(suggestion.parameterNames, isEmpty); 339 expect(suggestion.parameterNames, isEmpty);
340 expect(suggestion.parameterTypes, isEmpty); 340 expect(suggestion.parameterTypes, isEmpty);
341 expect(suggestion.requiredParameterCount, 0); 341 expect(suggestion.requiredParameterCount, 0);
342 expect(suggestion.hasNamedParameters, false); 342 expect(suggestion.hasNamedParameters, false);
(...skipping 18 matching lines...) Expand all
361 361
362 test_method_parameters_positional() async { 362 test_method_parameters_positional() async {
363 resolveSource( 363 resolveSource(
364 '/libA.dart', 364 '/libA.dart',
365 ''' 365 '''
366 class A { 366 class A {
367 void m([x, int y]) {} 367 void m([x, int y]) {}
368 } 368 }
369 '''); 369 ''');
370 addTestSource(''' 370 addTestSource('''
371 import '/libA.dart'; 371 import 'libA.dart';
372 class B extends A { 372 class B extends A {
373 main() {^} 373 main() {^}
374 } 374 }
375 '''); 375 ''');
376 await computeSuggestions(); 376 await computeSuggestions();
377 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void'); 377 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void');
378 expect(suggestion.parameterNames, hasLength(2)); 378 expect(suggestion.parameterNames, hasLength(2));
379 expect(suggestion.parameterNames[0], 'x'); 379 expect(suggestion.parameterNames[0], 'x');
380 expect(suggestion.parameterTypes[0], 'dynamic'); 380 expect(suggestion.parameterTypes[0], 'dynamic');
381 expect(suggestion.parameterNames[1], 'y'); 381 expect(suggestion.parameterNames[1], 'y');
(...skipping 24 matching lines...) Expand all
406 406
407 test_method_parameters_required() async { 407 test_method_parameters_required() async {
408 resolveSource( 408 resolveSource(
409 '/libA.dart', 409 '/libA.dart',
410 ''' 410 '''
411 class A { 411 class A {
412 void m(x, int y) {} 412 void m(x, int y) {}
413 } 413 }
414 '''); 414 ''');
415 addTestSource(''' 415 addTestSource('''
416 import '/libA.dart'; 416 import 'libA.dart';
417 class B extends A { 417 class B extends A {
418 main() {^} 418 main() {^}
419 } 419 }
420 '''); 420 ''');
421 await computeSuggestions(); 421 await computeSuggestions();
422 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void'); 422 CompletionSuggestion suggestion = assertSuggestMethod('m', 'A', 'void');
423 expect(suggestion.parameterNames, hasLength(2)); 423 expect(suggestion.parameterNames, hasLength(2));
424 expect(suggestion.parameterNames[0], 'x'); 424 expect(suggestion.parameterNames[0], 'x');
425 expect(suggestion.parameterTypes[0], 'dynamic'); 425 expect(suggestion.parameterTypes[0], 'dynamic');
426 expect(suggestion.parameterNames[1], 'y'); 426 expect(suggestion.parameterNames[1], 'y');
427 expect(suggestion.parameterTypes[1], 'int'); 427 expect(suggestion.parameterTypes[1], 'int');
428 expect(suggestion.requiredParameterCount, 2); 428 expect(suggestion.requiredParameterCount, 2);
429 expect(suggestion.hasNamedParameters, false); 429 expect(suggestion.hasNamedParameters, false);
430 } 430 }
431 431
432 test_mixin_ordering() async { 432 test_mixin_ordering() async {
433 resolveSource( 433 resolveSource(
434 '/libA.dart', 434 '/libA.dart',
435 ''' 435 '''
436 class B {} 436 class B {}
437 class M1 { 437 class M1 {
438 void m() {} 438 void m() {}
439 } 439 }
440 class M2 { 440 class M2 {
441 void m() {} 441 void m() {}
442 } 442 }
443 '''); 443 ''');
444 addTestSource(''' 444 addTestSource('''
445 import '/libA.dart'; 445 import 'libA.dart';
446 class C extends B with M1, M2 { 446 class C extends B with M1, M2 {
447 void f() { 447 void f() {
448 ^ 448 ^
449 } 449 }
450 } 450 }
451 '''); 451 ''');
452 await computeSuggestions(); 452 await computeSuggestions();
453 assertSuggestMethod('m', 'M1', 'void'); 453 assertSuggestMethod('m', 'M1', 'void');
454 } 454 }
455 455
456 test_no_parameters_field() async { 456 test_no_parameters_field() async {
457 resolveSource( 457 resolveSource(
458 '/libA.dart', 458 '/libA.dart',
459 ''' 459 '''
460 class A { 460 class A {
461 int x; 461 int x;
462 } 462 }
463 '''); 463 ''');
464 addTestSource(''' 464 addTestSource('''
465 import '/libA.dart'; 465 import 'libA.dart';
466 class B extends A { 466 class B extends A {
467 main() {^} 467 main() {^}
468 } 468 }
469 '''); 469 ''');
470 await computeSuggestions(); 470 await computeSuggestions();
471 CompletionSuggestion suggestion = assertSuggestField('x', 'int'); 471 CompletionSuggestion suggestion = assertSuggestField('x', 'int');
472 assertHasNoParameterInfo(suggestion); 472 assertHasNoParameterInfo(suggestion);
473 } 473 }
474 474
475 test_no_parameters_getter() async { 475 test_no_parameters_getter() async {
476 resolveSource( 476 resolveSource(
477 '/libA.dart', 477 '/libA.dart',
478 ''' 478 '''
479 class A { 479 class A {
480 int get x => null; 480 int get x => null;
481 } 481 }
482 '''); 482 ''');
483 addTestSource(''' 483 addTestSource('''
484 import '/libA.dart'; 484 import 'libA.dart';
485 class B extends A { 485 class B extends A {
486 main() {^} 486 main() {^}
487 } 487 }
488 '''); 488 ''');
489 await computeSuggestions(); 489 await computeSuggestions();
490 CompletionSuggestion suggestion = assertSuggestGetter('x', 'int'); 490 CompletionSuggestion suggestion = assertSuggestGetter('x', 'int');
491 assertHasNoParameterInfo(suggestion); 491 assertHasNoParameterInfo(suggestion);
492 } 492 }
493 493
494 test_no_parameters_setter() async { 494 test_no_parameters_setter() async {
495 resolveSource( 495 resolveSource(
496 '/libA.dart', 496 '/libA.dart',
497 ''' 497 '''
498 class A { 498 class A {
499 set x(int value) {}; 499 set x(int value) {};
500 } 500 }
501 '''); 501 ''');
502 addTestSource(''' 502 addTestSource('''
503 import '/libA.dart'; 503 import 'libA.dart';
504 class B extends A { 504 class B extends A {
505 main() {^} 505 main() {^}
506 } 506 }
507 '''); 507 ''');
508 await computeSuggestions(); 508 await computeSuggestions();
509 CompletionSuggestion suggestion = assertSuggestSetter('x'); 509 CompletionSuggestion suggestion = assertSuggestSetter('x');
510 assertHasNoParameterInfo(suggestion); 510 assertHasNoParameterInfo(suggestion);
511 } 511 }
512 512
513 test_ouside_class() async { 513 test_outside_class() async {
514 resolveSource( 514 resolveSource(
515 '/testB.dart', 515 '/testB.dart',
516 ''' 516 '''
517 lib libB; 517 lib libB;
518 class A2 { 518 class A2 {
519 int x; 519 int x;
520 int y() {return 0;} 520 int y() {return 0;}
521 int x2; 521 int x2;
522 int y2() {return 0;} 522 int y2() {return 0;}
523 }'''); 523 }''');
524 addTestSource(''' 524 addTestSource('''
525 import "/testB.dart"; 525 import "testB.dart";
526 class A1 { 526 class A1 {
527 int x; 527 int x;
528 int y() {return 0;} 528 int y() {return 0;}
529 int x1; 529 int x1;
530 int y1() {return 0;} 530 int y1() {return 0;}
531 } 531 }
532 class B extends A1 with A2 { 532 class B extends A1 with A2 {
533 int a; 533 int a;
534 int b() {return 0;} 534 int b() {return 0;}
535 } 535 }
(...skipping 22 matching lines...) Expand all
558 '/testB.dart', 558 '/testB.dart',
559 ''' 559 '''
560 lib libB; 560 lib libB;
561 class A2 { 561 class A2 {
562 int x; 562 int x;
563 int y() {return 0;} 563 int y() {return 0;}
564 int x2; 564 int x2;
565 int y2() {return 0;} 565 int y2() {return 0;}
566 }'''); 566 }''');
567 addTestSource(''' 567 addTestSource('''
568 import "/testB.dart"; 568 import "testB.dart";
569 class A1 { 569 class A1 {
570 int x; 570 int x;
571 int y() {return 0;} 571 int y() {return 0;}
572 int x1; 572 int x1;
573 int y1() {return 0;} 573 int y1() {return 0;}
574 } 574 }
575 class B extends A1 with A2 { 575 class B extends A1 with A2 {
576 int a; 576 int a;
577 int b() {return 0;} 577 int b() {return 0;}
578 static foo = ^ 578 static foo = ^
(...skipping 22 matching lines...) Expand all
601 '/testB.dart', 601 '/testB.dart',
602 ''' 602 '''
603 lib libB; 603 lib libB;
604 class A2 { 604 class A2 {
605 int x; 605 int x;
606 int y() {return 0;} 606 int y() {return 0;}
607 int x2; 607 int x2;
608 int y2() {return 0;} 608 int y2() {return 0;}
609 }'''); 609 }''');
610 addTestSource(''' 610 addTestSource('''
611 import "/testB.dart"; 611 import "testB.dart";
612 class A1 { 612 class A1 {
613 int x; 613 int x;
614 int y() {return 0;} 614 int y() {return 0;}
615 int x1; 615 int x1;
616 int y1() {return 0;} 616 int y1() {return 0;}
617 } 617 }
618 class B extends A1 with A2 { 618 class B extends A1 with A2 {
619 int a; 619 int a;
620 int b() {return 0;} 620 int b() {return 0;}
621 static foo() {^} 621 static foo() {^}
(...skipping 10 matching lines...) Expand all
632 assertNotSuggested('foo'); 632 assertNotSuggested('foo');
633 assertNotSuggested('A'); 633 assertNotSuggested('A');
634 assertNotSuggested('x'); 634 assertNotSuggested('x');
635 assertNotSuggested('y'); 635 assertNotSuggested('y');
636 assertNotSuggested('x1'); 636 assertNotSuggested('x1');
637 assertNotSuggested('y1'); 637 assertNotSuggested('y1');
638 assertNotSuggested('x2'); 638 assertNotSuggested('x2');
639 assertNotSuggested('y2'); 639 assertNotSuggested('y2');
640 } 640 }
641 } 641 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698