Chromium Code Reviews| Index: pkg/analysis_server/test/services/dependencies/library_dependencies_test.dart |
| =================================================================== |
| --- pkg/analysis_server/test/services/dependencies/library_dependencies_test.dart (revision 0) |
| +++ pkg/analysis_server/test/services/dependencies/library_dependencies_test.dart (revision 0) |
| @@ -0,0 +1,50 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library test.services.dependencies.library; |
| + |
| +import 'package:analysis_server/src/services/dependencies/library_dependencies.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +import '../../abstract_context.dart'; |
| +import '../../reflective_tests.dart'; |
| + |
| +main() { |
| + groupSep = ' | '; |
| + runReflectiveTests(LibraryDependenciesTest); |
| +} |
| + |
| + |
| +@reflectiveTest |
| +class LibraryDependenciesTest extends AbstractContextTest { |
| + |
| + test_Dependencies() { |
| + addSource('/lib1.dart', ''); |
| + addSource('/lib2.dart', 'import "lib1.dart";'); |
| + addSource('/lib3.dart', 'import "lib2.dart";'); |
| + 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!
|
| + provider.newFile('/lib5.dart', 'import "lib6.dart";'); |
| + provider.newFile('/lib6.dart', ''); |
| + |
| + _performAnalysis(); |
| + |
| + var libs = |
| + new LibraryDependencyCollector([context]).collectLibraryDependencies(); |
| + |
| + // Sources |
| + expect(libs, contains('/lib1.dart')); |
| + expect(libs, contains('/lib2.dart')); |
| + expect(libs, contains('/lib3.dart')); |
| + expect(libs, contains('/lib4.dart')); |
| + // Non-source, referenced by source |
| + expect(libs, contains('/lib5.dart')); |
| + // Non-source, referenced by non-source |
| + expect(libs, contains('/lib6.dart')); |
| + } |
| + |
| + void _performAnalysis() { |
| + while (context.performAnalysisTask().hasMoreWork); |
| + } |
| +} |
| + |