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

Side by Side Diff: pkg/analysis_server/test/services/search/search_engine_test.dart

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 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.services.src.search.search_engine; 5 library test.services.src.search.search_engine;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/services/index/index.dart'; 9 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 10 import 'package:analysis_server/src/services/index/local_memory_index.dart';
11 import 'package:analysis_server/src/services/search/search_engine.dart'; 11 import 'package:analysis_server/src/services/search/search_engine.dart';
12 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ; 12 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ;
13 import 'package:analyzer/src/generated/element.dart'; 13 import 'package:analyzer/src/generated/element.dart';
14 import 'package:analyzer/src/generated/source.dart'; 14 import 'package:analyzer/src/generated/source.dart';
15 import 'package:test_reflective_loader/test_reflective_loader.dart'; 15 import 'package:test_reflective_loader/test_reflective_loader.dart';
16 import 'package:typed_mock/typed_mock.dart'; 16 import 'package:typed_mock/typed_mock.dart';
17 import 'package:unittest/unittest.dart'; 17 import 'package:unittest/unittest.dart';
18 18
19 import '../../abstract_single_unit.dart'; 19 import '../../abstract_single_unit.dart';
20 import '../../utils.dart';
20 21
21 main() { 22 main() {
22 groupSep = ' | '; 23 initializeTestEnvironment();
23 defineReflectiveTests(SearchEngineImplTest); 24 defineReflectiveTests(SearchEngineImplTest);
24 } 25 }
25 26
26 class ExpectedMatch { 27 class ExpectedMatch {
27 final Element element; 28 final Element element;
28 final MatchKind kind; 29 final MatchKind kind;
29 SourceRange range; 30 SourceRange range;
30 final bool isResolved; 31 final bool isResolved;
31 final bool isQualified; 32 final bool isQualified;
32 33
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 Element pElement = findElement('p'); 179 Element pElement = findElement('p');
179 Element vElement = findElement('v'); 180 Element vElement = findElement('v');
180 var expected = [ 181 var expected = [
181 _expectId(pElement, MatchKind.REFERENCE, 'A p'), 182 _expectId(pElement, MatchKind.REFERENCE, 'A p'),
182 _expectId(vElement, MatchKind.REFERENCE, 'A v') 183 _expectId(vElement, MatchKind.REFERENCE, 'A v')
183 ]; 184 ];
184 return _verifyReferences(element, expected); 185 return _verifyReferences(element, expected);
185 } 186 }
186 187
187 Future test_searchReferences_CompilationUnitElement() { 188 Future test_searchReferences_CompilationUnitElement() {
188 addSource('/my_part.dart', ''' 189 addSource(
190 '/my_part.dart',
191 '''
189 part of lib; 192 part of lib;
190 '''); 193 ''');
191 _indexTestUnit(''' 194 _indexTestUnit('''
192 library lib; 195 library lib;
193 part 'my_part.dart'; 196 part 'my_part.dart';
194 '''); 197 ''');
195 CompilationUnitElement element = testLibraryElement.parts[0]; 198 CompilationUnitElement element = testLibraryElement.parts[0];
196 var expected = [ 199 var expected = [
197 _expectId(testUnitElement, MatchKind.REFERENCE, "'my_part.dart'", 200 _expectId(testUnitElement, MatchKind.REFERENCE, "'my_part.dart'",
198 length: "'my_part.dart'".length) 201 length: "'my_part.dart'".length)
199 ]; 202 ];
200 return _verifyReferences(element, expected); 203 return _verifyReferences(element, expected);
201 } 204 }
202 205
203 Future test_searchReferences_ConstructorElement() { 206 Future test_searchReferences_ConstructorElement() {
204 _indexTestUnit(''' 207 _indexTestUnit('''
205 class A { 208 class A {
206 A.named() {} 209 A.named() {}
207 } 210 }
208 main() { 211 main() {
209 new A.named(); 212 new A.named();
210 } 213 }
211 '''); 214 ''');
212 ConstructorElement element = findElement('named'); 215 ConstructorElement element = findElement('named');
213 Element mainElement = findElement('main'); 216 Element mainElement = findElement('main');
214 var expected = 217 var expected = [
215 [_expectId(mainElement, MatchKind.REFERENCE, '.named();', length: 6)]; 218 _expectId(mainElement, MatchKind.REFERENCE, '.named();', length: 6)
219 ];
216 return _verifyReferences(element, expected); 220 return _verifyReferences(element, expected);
217 } 221 }
218 222
219 Future test_searchReferences_Element_unknown() { 223 Future test_searchReferences_Element_unknown() {
220 return _verifyReferences(DynamicElementImpl.instance, []); 224 return _verifyReferences(DynamicElementImpl.instance, []);
221 } 225 }
222 226
223 Future test_searchReferences_FieldElement() { 227 Future test_searchReferences_FieldElement() {
224 _indexTestUnit(''' 228 _indexTestUnit('''
225 class A { 229 class A {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 Future test_searchReferences_ImportElement_withPrefix() { 310 Future test_searchReferences_ImportElement_withPrefix() {
307 _indexTestUnit(''' 311 _indexTestUnit('''
308 import 'dart:math' as math; 312 import 'dart:math' as math;
309 main() { 313 main() {
310 print(math.PI); 314 print(math.PI);
311 } 315 }
312 '''); 316 ''');
313 ImportElement element = testLibraryElement.imports[0]; 317 ImportElement element = testLibraryElement.imports[0];
314 Element mainElement = findElement('main'); 318 Element mainElement = findElement('main');
315 var kind = MatchKind.REFERENCE; 319 var kind = MatchKind.REFERENCE;
316 var expected = 320 var expected = [
317 [_expectId(mainElement, kind, 'math.PI);', length: 'math.'.length)]; 321 _expectId(mainElement, kind, 'math.PI);', length: 'math.'.length)
322 ];
318 return _verifyReferences(element, expected); 323 return _verifyReferences(element, expected);
319 } 324 }
320 325
321 Future test_searchReferences_LabelElement() { 326 Future test_searchReferences_LabelElement() {
322 _indexTestUnit(''' 327 _indexTestUnit('''
323 main() { 328 main() {
324 label: 329 label:
325 while (true) { 330 while (true) {
326 if (true) { 331 if (true) {
327 break label; // 1 332 break label; // 1
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 _indexTestUnit(''' 416 _indexTestUnit('''
412 class A<T> { 417 class A<T> {
413 T m() => null; 418 T m() => null;
414 } 419 }
415 main(A<int> a) { 420 main(A<int> a) {
416 a.m(); // ref 421 a.m(); // ref
417 } 422 }
418 '''); 423 ''');
419 MethodMember method = findNodeElementAtString('m(); // ref'); 424 MethodMember method = findNodeElementAtString('m(); // ref');
420 Element mainElement = findElement('main'); 425 Element mainElement = findElement('main');
421 var expected = 426 var expected = [
422 [_expectIdQ(mainElement, MatchKind.INVOCATION, 'm(); // ref')]; 427 _expectIdQ(mainElement, MatchKind.INVOCATION, 'm(); // ref')
428 ];
423 return _verifyReferences(method, expected); 429 return _verifyReferences(method, expected);
424 } 430 }
425 431
426 Future test_searchReferences_ParameterElement() { 432 Future test_searchReferences_ParameterElement() {
427 _indexTestUnit(''' 433 _indexTestUnit('''
428 foo({p}) { 434 foo({p}) {
429 p = 1; 435 p = 1;
430 p += 2; 436 p += 2;
431 print(p); 437 print(p);
432 p(); 438 p();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 PropertyAccessorElement element = findElement('s='); 504 PropertyAccessorElement element = findElement('s=');
499 Element mainElement = findElement('main'); 505 Element mainElement = findElement('main');
500 var expected = [ 506 var expected = [
501 _expectId(mainElement, MatchKind.REFERENCE, 's = 1'), 507 _expectId(mainElement, MatchKind.REFERENCE, 's = 1'),
502 _expectIdQ(mainElement, MatchKind.REFERENCE, 's = 2') 508 _expectIdQ(mainElement, MatchKind.REFERENCE, 's = 2')
503 ]; 509 ];
504 return _verifyReferences(element, expected); 510 return _verifyReferences(element, expected);
505 } 511 }
506 512
507 Future test_searchReferences_TopLevelVariableElement() { 513 Future test_searchReferences_TopLevelVariableElement() {
508 addSource('/lib.dart', ''' 514 addSource(
515 '/lib.dart',
516 '''
509 library lib; 517 library lib;
510 var V; 518 var V;
511 '''); 519 ''');
512 _indexTestUnit(''' 520 _indexTestUnit('''
513 import 'lib.dart' show V; // imp 521 import 'lib.dart' show V; // imp
514 import 'lib.dart' as pref; 522 import 'lib.dart' as pref;
515 main() { 523 main() {
516 pref.V = 1; // q 524 pref.V = 1; // q
517 print(pref.V); // q 525 print(pref.V); // q
518 pref.V(); // q 526 pref.V(); // q
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 .then((List<SearchMatch> matches) { 647 .then((List<SearchMatch> matches) {
640 _assertMatches(matches, expectedMatches); 648 _assertMatches(matches, expectedMatches);
641 }); 649 });
642 } 650 }
643 651
644 static void _assertMatches( 652 static void _assertMatches(
645 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { 653 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) {
646 expect(matches, unorderedEquals(expectedMatches)); 654 expect(matches, unorderedEquals(expectedMatches));
647 } 655 }
648 } 656 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/search/hierarchy_test.dart ('k') | pkg/analysis_server/test/services/search/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698