| 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 import 'package:analysis_server/src/services/dependencies/reachable_source_colle
ctor.dart'; | |
| 6 import 'package:analyzer/src/generated/source.dart'; | |
| 7 import 'package:test/test.dart'; | |
| 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | |
| 9 | |
| 10 import '../../abstract_context.dart'; | |
| 11 | |
| 12 main() { | |
| 13 defineReflectiveSuite(() { | |
| 14 defineReflectiveTests(ReachableSourceCollectorTest); | |
| 15 }); | |
| 16 } | |
| 17 | |
| 18 @reflectiveTest | |
| 19 class ReachableSourceCollectorTest extends AbstractContextTest { | |
| 20 Map<String, List<String>> importsFor(Source source) => | |
| 21 new ReachableSourceCollector(source, null).collectSources(); | |
| 22 | |
| 23 test_null_context() { | |
| 24 Source lib = addSource('/lib.dart', ''); | |
| 25 expect(() => new ReachableSourceCollector(lib, null), | |
| 26 throwsA(new isInstanceOf<ArgumentError>())); | |
| 27 } | |
| 28 | |
| 29 @failingTest | |
| 30 test_null_source() { | |
| 31 // See https://github.com/dart-lang/sdk/issues/29311 | |
| 32 fail('The analysis.getReachableSources is not implemented.'); | |
| 33 expect(() => new ReachableSourceCollector(null, null), | |
| 34 throwsA(new isInstanceOf<ArgumentError>())); | |
| 35 } | |
| 36 | |
| 37 @failingTest | |
| 38 test_sources() { | |
| 39 // See https://github.com/dart-lang/sdk/issues/29311 | |
| 40 fail('The analysis.getReachableSources is not implemented.'); | |
| 41 Source lib1 = addSource('/lib1.dart', ''' | |
| 42 import "lib2.dart"; | |
| 43 import "dart:html";'''); | |
| 44 Source lib2 = addSource('/lib2.dart', 'import "lib1.dart";'); | |
| 45 | |
| 46 Source lib3 = addSource('/lib3.dart', 'import "lib4.dart";'); | |
| 47 addSource('/lib4.dart', 'import "lib3.dart";'); | |
| 48 | |
| 49 Map<String, List<String>> imports = importsFor(lib1); | |
| 50 | |
| 51 // Verify keys. | |
| 52 expect( | |
| 53 imports.keys, | |
| 54 unorderedEquals([ | |
| 55 'dart:_internal', | |
| 56 'dart:async', | |
| 57 'dart:core', | |
| 58 'dart:html', | |
| 59 'dart:math', | |
| 60 'file:///lib1.dart', | |
| 61 'file:///lib2.dart', | |
| 62 ])); | |
| 63 // Values. | |
| 64 expect(imports['file:///lib1.dart'], | |
| 65 unorderedEquals(['dart:core', 'dart:html', 'file:///lib2.dart'])); | |
| 66 | |
| 67 // Check transitivity. | |
| 68 expect(importsFor(lib2).keys, contains('dart:html')); | |
| 69 | |
| 70 // Cycles should be OK. | |
| 71 expect( | |
| 72 importsFor(lib3).keys, | |
| 73 unorderedEquals([ | |
| 74 'dart:_internal', | |
| 75 'dart:async', | |
| 76 'dart:core', | |
| 77 'dart:math', | |
| 78 'file:///lib3.dart', | |
| 79 'file:///lib4.dart' | |
| 80 ])); | |
| 81 } | |
| 82 } | |
| OLD | NEW |