Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library test.services.dependencies.library; | |
| 6 | |
| 7 import 'package:analysis_server/src/services/dependencies/library_dependencies.d art'; | |
| 8 import 'package:unittest/unittest.dart'; | |
| 9 | |
| 10 import '../../abstract_context.dart'; | |
| 11 import '../../reflective_tests.dart'; | |
| 12 | |
| 13 main() { | |
| 14 groupSep = ' | '; | |
| 15 runReflectiveTests(LibraryDependenciesTest); | |
| 16 } | |
| 17 | |
| 18 | |
| 19 @reflectiveTest | |
| 20 class LibraryDependenciesTest extends AbstractContextTest { | |
| 21 | |
| 22 test_Dependencies() { | |
| 23 addSource('/lib1.dart', ''); | |
| 24 addSource('/lib2.dart', 'import "lib1.dart";'); | |
| 25 addSource('/lib3.dart', 'import "lib2.dart";'); | |
| 26 addSource('/lib4.dart', 'import "lib5.dart";'); | |
|
scheglov
2015/01/22 22:26:45
I would add a cycle to test that we don't get into
pquitslund
2015/01/22 22:38:47
Good idea!
| |
| 27 provider.newFile('/lib5.dart', 'import "lib6.dart";'); | |
| 28 provider.newFile('/lib6.dart', ''); | |
| 29 | |
| 30 _performAnalysis(); | |
| 31 | |
| 32 var libs = | |
| 33 new LibraryDependencyCollector([context]).collectLibraryDependencies(); | |
| 34 | |
| 35 // Sources | |
| 36 expect(libs, contains('/lib1.dart')); | |
| 37 expect(libs, contains('/lib2.dart')); | |
| 38 expect(libs, contains('/lib3.dart')); | |
| 39 expect(libs, contains('/lib4.dart')); | |
| 40 // Non-source, referenced by source | |
| 41 expect(libs, contains('/lib5.dart')); | |
| 42 // Non-source, referenced by non-source | |
| 43 expect(libs, contains('/lib6.dart')); | |
| 44 } | |
| 45 | |
| 46 void _performAnalysis() { | |
| 47 while (context.performAnalysisTask().hasMoreWork); | |
| 48 } | |
| 49 } | |
| 50 | |
| OLD | NEW |