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