| 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/search/hierarchy.dart'; | 10 import 'package:analysis_server/src/services/search/hierarchy.dart'; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 { | 282 { |
| 283 ClassElement classB = findElement('B'); | 283 ClassElement classB = findElement('B'); |
| 284 List<Element> members = getMembers(classB); | 284 List<Element> members = getMembers(classB); |
| 285 expect( | 285 expect( |
| 286 members.map((e) => e.name), | 286 members.map((e) => e.name), |
| 287 unorderedEquals( | 287 unorderedEquals( |
| 288 ['mb1', 'mb2', 'ma1', 'ma2', '==', 'toString', 'hashCode'])); | 288 ['mb1', 'mb2', 'ma1', 'ma2', '==', 'toString', 'hashCode'])); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 Future test_getSubClasses() { | |
| 293 _indexTestUnit(''' | |
| 294 class A {} | |
| 295 class B extends A {} | |
| 296 class C extends B {} | |
| 297 class D extends B implements A {} | |
| 298 class M {} | |
| 299 class E extends A with M {} | |
| 300 '''); | |
| 301 ClassElement classA = findElement("A"); | |
| 302 ClassElement classB = findElement("B"); | |
| 303 ClassElement classC = findElement("C"); | |
| 304 ClassElement classD = findElement("D"); | |
| 305 ClassElement classM = findElement("M"); | |
| 306 ClassElement classE = findElement("E"); | |
| 307 var futureA = getSubClasses(searchEngine, classA).then((subs) { | |
| 308 expect(subs, unorderedEquals([classB, classC, classD, classE])); | |
| 309 }); | |
| 310 var futureB = getSubClasses(searchEngine, classB).then((subs) { | |
| 311 expect(subs, unorderedEquals([classC, classD])); | |
| 312 }); | |
| 313 var futureC = getSubClasses(searchEngine, classC).then((subs) { | |
| 314 expect(subs, isEmpty); | |
| 315 }); | |
| 316 var futureM = getSubClasses(searchEngine, classM).then((subs) { | |
| 317 expect(subs, unorderedEquals([classE])); | |
| 318 }); | |
| 319 return Future.wait([futureA, futureB, futureC, futureM]); | |
| 320 } | |
| 321 | |
| 322 void test_getSuperClasses() { | 292 void test_getSuperClasses() { |
| 323 _indexTestUnit(''' | 293 _indexTestUnit(''' |
| 324 class A {} | 294 class A {} |
| 325 class B extends A {} | 295 class B extends A {} |
| 326 class C extends B {} | 296 class C extends B {} |
| 327 class D extends B implements A {} | 297 class D extends B implements A {} |
| 328 class M {} | 298 class M {} |
| 329 class E extends A with M {} | 299 class E extends A with M {} |
| 330 class F implements A {} | 300 class F implements A {} |
| 331 '''); | 301 '''); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 Set<ClassElement> supers = getSuperClasses(classF); | 341 Set<ClassElement> supers = getSuperClasses(classF); |
| 372 expect(supers, unorderedEquals([objectElement, classA])); | 342 expect(supers, unorderedEquals([objectElement, classA])); |
| 373 } | 343 } |
| 374 } | 344 } |
| 375 | 345 |
| 376 void _indexTestUnit(String code) { | 346 void _indexTestUnit(String code) { |
| 377 resolveTestUnit(code); | 347 resolveTestUnit(code); |
| 378 index.indexUnit(testUnit); | 348 index.indexUnit(testUnit); |
| 379 } | 349 } |
| 380 } | 350 } |
| OLD | NEW |