OLD | NEW |
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.hierarchy; | 5 library test.services.src.search.hierarchy; |
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/hierarchy.dart'; | 11 import 'package:analysis_server/src/services/search/hierarchy.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:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
15 | 15 |
16 import '../../abstract_single_unit.dart'; | 16 import '../../abstract_single_unit.dart'; |
17 import '../../reflective_tests.dart'; | 17 import '../../reflective_tests.dart'; |
18 | 18 |
19 | |
20 main() { | 19 main() { |
21 groupSep = ' | '; | 20 groupSep = ' | '; |
22 runReflectiveTests(HierarchyTest); | 21 runReflectiveTests(HierarchyTest); |
23 } | 22 } |
24 | 23 |
25 | |
26 @reflectiveTest | 24 @reflectiveTest |
27 class HierarchyTest extends AbstractSingleUnitTest { | 25 class HierarchyTest extends AbstractSingleUnitTest { |
28 Index index; | 26 Index index; |
29 SearchEngineImpl searchEngine; | 27 SearchEngineImpl searchEngine; |
30 | 28 |
31 void setUp() { | 29 void setUp() { |
32 super.setUp(); | 30 super.setUp(); |
33 index = createLocalMemoryIndex(); | 31 index = createLocalMemoryIndex(); |
34 searchEngine = new SearchEngineImpl(index); | 32 searchEngine = new SearchEngineImpl(index); |
35 } | 33 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 class B extends A { | 209 class B extends A { |
212 B() {} | 210 B() {} |
213 B.named() {} | 211 B.named() {} |
214 var mb1; | 212 var mb1; |
215 mb2() {} | 213 mb2() {} |
216 } | 214 } |
217 '''); | 215 '''); |
218 { | 216 { |
219 ClassElement classA = findElement('A'); | 217 ClassElement classA = findElement('A'); |
220 List<Element> members = getMembers(classA); | 218 List<Element> members = getMembers(classA); |
221 expect( | 219 expect(members.map((e) => e.name), |
222 members.map((e) => e.name), | |
223 unorderedEquals(['ma1', 'ma2', '==', 'toString', 'hashCode'])); | 220 unorderedEquals(['ma1', 'ma2', '==', 'toString', 'hashCode'])); |
224 } | 221 } |
225 { | 222 { |
226 ClassElement classB = findElement('B'); | 223 ClassElement classB = findElement('B'); |
227 List<Element> members = getMembers(classB); | 224 List<Element> members = getMembers(classB); |
228 expect( | 225 expect(members.map((e) => e.name), unorderedEquals( |
229 members.map((e) => e.name), | 226 ['mb1', 'mb2', 'ma1', 'ma2', '==', 'toString', 'hashCode'])); |
230 unorderedEquals(['mb1', 'mb2', 'ma1', 'ma2', '==', 'toString', 'hashCo
de'])); | |
231 } | 227 } |
232 } | 228 } |
233 | 229 |
234 Future test_getSubClasses() { | 230 Future test_getSubClasses() { |
235 _indexTestUnit(''' | 231 _indexTestUnit(''' |
236 class A {} | 232 class A {} |
237 class B extends A {} | 233 class B extends A {} |
238 class C extends B {} | 234 class C extends B {} |
239 class D extends B implements A {} | 235 class D extends B implements A {} |
240 class M {} | 236 class M {} |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 Set<ClassElement> supers = getSuperClasses(classF); | 309 Set<ClassElement> supers = getSuperClasses(classF); |
314 expect(supers, unorderedEquals([objectElement, classA])); | 310 expect(supers, unorderedEquals([objectElement, classA])); |
315 } | 311 } |
316 } | 312 } |
317 | 313 |
318 void _indexTestUnit(String code) { | 314 void _indexTestUnit(String code) { |
319 resolveTestUnit(code); | 315 resolveTestUnit(code); |
320 index.indexUnit(context, testUnit); | 316 index.indexUnit(context, testUnit); |
321 } | 317 } |
322 } | 318 } |
OLD | NEW |