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

Side by Side Diff: pkg/analysis_server/test/search/element_references_test.dart

Issue 567243002: Issue 19696. Test for potential reference to the element defined in a subclass. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 test.search.element_references; 5 library test.search.element_references;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import '../reflective_tests.dart';
11 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
12 11
12 import '../reflective_tests.dart';
13 import 'abstract_search_domain.dart'; 13 import 'abstract_search_domain.dart';
14 14
15 15
16 main() { 16 main() {
17 groupSep = ' | '; 17 groupSep = ' | ';
18 runReflectiveTests(ElementReferencesTest); 18 runReflectiveTests(ElementReferencesTest);
19 } 19 }
20 20
21 21
22 @ReflectiveTestCase() 22 @ReflectiveTestCase()
23 class ElementReferencesTest extends AbstractSearchDomainTest { 23 class ElementReferencesTest extends AbstractSearchDomainTest {
24 Element searchElement; 24 Element searchElement;
25 25
26 void assertHasRef(SearchResultKind kind, String search, bool isPotential) {
27 assertHasResult(kind, search);
28 expect(result.isPotential, isPotential);
29 }
30
26 Future findElementReferences(String search, bool includePotential) { 31 Future findElementReferences(String search, bool includePotential) {
27 int offset = findOffset(search); 32 int offset = findOffset(search);
28 return waitForTasksFinished().then((_) { 33 return waitForTasksFinished().then((_) {
29 Request request = new SearchFindElementReferencesParams( 34 Request request = new SearchFindElementReferencesParams(
30 testFile, 35 testFile,
31 offset, 36 offset,
32 includePotential).toRequest('0'); 37 includePotential).toRequest('0');
33 Response response = handleSuccessfulRequest(request); 38 Response response = handleSuccessfulRequest(request);
34 var result = new SearchFindElementReferencesResult.fromResponse(response); 39 var result = new SearchFindElementReferencesResult.fromResponse(response);
35 searchId = result.id; 40 searchId = result.id;
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 assertHasResult(SearchResultKind.INVOCATION, 'test(1);'); 564 assertHasResult(SearchResultKind.INVOCATION, 'test(1);');
560 expect(result.isPotential, isFalse); 565 expect(result.isPotential, isFalse);
561 } 566 }
562 { 567 {
563 assertHasResult(SearchResultKind.INVOCATION, 'test(2);'); 568 assertHasResult(SearchResultKind.INVOCATION, 'test(2);');
564 expect(result.isPotential, isTrue); 569 expect(result.isPotential, isTrue);
565 } 570 }
566 }); 571 });
567 } 572 }
568 573
574 test_potential_method_definedInSubclass() {
575 addTestFile('''
576 class Base {
577 methodInBase() {
578 test(1);
579 }
580 }
581 class Derived extends Base {
582 test(_) {} // of Derived
583 methodInDerived() {
584 test(2);
585 }
586 }
587 globalFunction(Base b) {
588 b.test(3);
589 }
590 ''');
591 return findElementReferences('test(_) {} // of Derived', true).then((_) {
592 assertHasRef(SearchResultKind.INVOCATION, 'test(1);', true);
593 assertHasRef(SearchResultKind.INVOCATION, 'test(2);', false);
594 assertHasRef(SearchResultKind.INVOCATION, 'test(3);', true);
595 });
596 }
597
569 test_topLevelVariable_explicit() { 598 test_topLevelVariable_explicit() {
570 addTestFile(''' 599 addTestFile('''
571 var vvv = 1; 600 var vvv = 1;
572 main() { 601 main() {
573 print(vvv); 602 print(vvv);
574 vvv += 3; 603 vvv += 3;
575 vvv = 2; 604 vvv = 2;
576 vvv(); 605 vvv();
577 } 606 }
578 '''); 607 ''');
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 674 }
646 '''); 675 ''');
647 return findElementReferences('T> {', false).then((_) { 676 return findElementReferences('T> {', false).then((_) {
648 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); 677 expect(searchElement.kind, ElementKind.TYPE_PARAMETER);
649 expect(results, hasLength(2)); 678 expect(results, hasLength(2));
650 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); 679 assertHasResult(SearchResultKind.REFERENCE, 'T f;');
651 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); 680 assertHasResult(SearchResultKind.REFERENCE, 'T m()');
652 }); 681 });
653 } 682 }
654 } 683 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698