| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, 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:expect/expect.dart'; | |
| 6 import 'package:async_helper/async_helper.dart'; | |
| 7 import 'package:compiler/src/mirrors/source_mirrors.dart'; | |
| 8 | |
| 9 import 'memory_compiler.dart'; | |
| 10 | |
| 11 const SOURCE_FILES = const { | |
| 12 'main.dart': ''' | |
| 13 import 'a.dart' show A1, A2; | |
| 14 import 'b.dart' as b hide B1; | |
| 15 export 'a.dart' show A2 hide A3, A1; | |
| 16 export 'b.dart' hide B1, B2 show B3; | |
| 17 import 'dart:core' as core; | |
| 18 import 'c.dart' deferred as c; | |
| 19 | |
| 20 main() {} | |
| 21 ''', | |
| 22 'a.dart': ''' | |
| 23 class A1 {} | |
| 24 class A2 {} | |
| 25 class A3 {} | |
| 26 ''', | |
| 27 'b.dart': ''' | |
| 28 class B1 {} | |
| 29 class B2 {} | |
| 30 class B3 {} | |
| 31 ''', | |
| 32 'c.dart': ''' | |
| 33 foo() => 499; | |
| 34 ''' | |
| 35 }; | |
| 36 | |
| 37 void main() { | |
| 38 asyncTest(() => mirrorSystemFor(SOURCE_FILES).then((MirrorSystem mirrors) { | |
| 39 LibrarySourceMirror mainLibrary = | |
| 40 mirrors.libraries[Uri.parse('memory:main.dart')]; | |
| 41 Expect.isNotNull(mainLibrary); | |
| 42 | |
| 43 LibrarySourceMirror aLibrary = | |
| 44 mirrors.libraries[Uri.parse('memory:a.dart')]; | |
| 45 Expect.isNotNull(aLibrary); | |
| 46 | |
| 47 LibrarySourceMirror bLibrary = | |
| 48 mirrors.libraries[Uri.parse('memory:b.dart')]; | |
| 49 Expect.isNotNull(bLibrary); | |
| 50 | |
| 51 LibrarySourceMirror cLibrary = | |
| 52 mirrors.libraries[Uri.parse('memory:c.dart')]; | |
| 53 Expect.isNotNull(cLibrary); | |
| 54 | |
| 55 LibrarySourceMirror coreLibrary = | |
| 56 mirrors.libraries[Uri.parse('dart:core')]; | |
| 57 Expect.isNotNull(coreLibrary); | |
| 58 | |
| 59 var dependencies = mainLibrary.libraryDependencies; | |
| 60 Expect.isNotNull(dependencies); | |
| 61 Expect.equals(6, dependencies.length); | |
| 62 | |
| 63 // import 'a.dart' show A1, A2; | |
| 64 var dependency = dependencies[0]; | |
| 65 Expect.isNotNull(dependency); | |
| 66 Expect.isTrue(dependency.isImport); | |
| 67 Expect.isFalse(dependency.isExport); | |
| 68 Expect.equals(mainLibrary, dependency.sourceLibrary); | |
| 69 Expect.equals(aLibrary, dependency.targetLibrary); | |
| 70 Expect.isNull(dependency.prefix); | |
| 71 Expect.isFalse(dependency.isDeferred); | |
| 72 | |
| 73 var combinators = dependency.combinators; | |
| 74 Expect.isNotNull(combinators); | |
| 75 Expect.equals(1, combinators.length); | |
| 76 | |
| 77 var combinator = combinators[0]; | |
| 78 Expect.isNotNull(combinator); | |
| 79 Expect.isTrue(combinator.isShow); | |
| 80 Expect.isFalse(combinator.isHide); | |
| 81 Expect.listEquals(['A1', 'A2'], combinator.identifiers); | |
| 82 | |
| 83 // import 'b.dart' as b hide B1; | |
| 84 dependency = dependencies[1]; | |
| 85 Expect.isNotNull(dependency); | |
| 86 Expect.isTrue(dependency.isImport); | |
| 87 Expect.isFalse(dependency.isExport); | |
| 88 Expect.equals(mainLibrary, dependency.sourceLibrary); | |
| 89 Expect.equals(bLibrary, dependency.targetLibrary); | |
| 90 Expect.equals('b', dependency.prefix); | |
| 91 Expect.isFalse(dependency.isDeferred); | |
| 92 | |
| 93 combinators = dependency.combinators; | |
| 94 Expect.isNotNull(combinators); | |
| 95 Expect.equals(1, combinators.length); | |
| 96 | |
| 97 combinator = combinators[0]; | |
| 98 Expect.isNotNull(combinator); | |
| 99 Expect.isFalse(combinator.isShow); | |
| 100 Expect.isTrue(combinator.isHide); | |
| 101 Expect.listEquals(['B1'], combinator.identifiers); | |
| 102 | |
| 103 // export 'a.dart' show A2 hide A3, A1; | |
| 104 dependency = dependencies[2]; | |
| 105 Expect.isNotNull(dependency); | |
| 106 Expect.isFalse(dependency.isImport); | |
| 107 Expect.isTrue(dependency.isExport); | |
| 108 Expect.equals(mainLibrary, dependency.sourceLibrary); | |
| 109 Expect.equals(aLibrary, dependency.targetLibrary); | |
| 110 Expect.isNull(dependency.prefix); | |
| 111 Expect.isFalse(dependency.isDeferred); | |
| 112 | |
| 113 combinators = dependency.combinators; | |
| 114 Expect.isNotNull(combinators); | |
| 115 Expect.equals(2, combinators.length); | |
| 116 | |
| 117 combinator = combinators[0]; | |
| 118 Expect.isNotNull(combinator); | |
| 119 Expect.isTrue(combinator.isShow); | |
| 120 Expect.isFalse(combinator.isHide); | |
| 121 Expect.listEquals(['A2'], combinator.identifiers); | |
| 122 | |
| 123 combinator = combinators[1]; | |
| 124 Expect.isNotNull(combinator); | |
| 125 Expect.isFalse(combinator.isShow); | |
| 126 Expect.isTrue(combinator.isHide); | |
| 127 Expect.listEquals(['A3', 'A1'], combinator.identifiers); | |
| 128 | |
| 129 // export 'b.dart' hide B1, B2 show B3; | |
| 130 dependency = dependencies[3]; | |
| 131 Expect.isNotNull(dependency); | |
| 132 Expect.isFalse(dependency.isImport); | |
| 133 Expect.isTrue(dependency.isExport); | |
| 134 Expect.equals(mainLibrary, dependency.sourceLibrary); | |
| 135 Expect.equals(bLibrary, dependency.targetLibrary); | |
| 136 Expect.isNull(dependency.prefix); | |
| 137 Expect.isFalse(dependency.isDeferred); | |
| 138 | |
| 139 combinators = dependency.combinators; | |
| 140 Expect.isNotNull(combinators); | |
| 141 Expect.equals(2, combinators.length); | |
| 142 | |
| 143 combinator = combinators[0]; | |
| 144 Expect.isNotNull(combinator); | |
| 145 Expect.isFalse(combinator.isShow); | |
| 146 Expect.isTrue(combinator.isHide); | |
| 147 Expect.listEquals(['B1', 'B2'], combinator.identifiers); | |
| 148 | |
| 149 combinator = combinators[1]; | |
| 150 Expect.isNotNull(combinator); | |
| 151 Expect.isTrue(combinator.isShow); | |
| 152 Expect.isFalse(combinator.isHide); | |
| 153 Expect.listEquals(['B3'], combinator.identifiers); | |
| 154 | |
| 155 // import 'dart:core' as core; | |
| 156 dependency = dependencies[4]; | |
| 157 Expect.isNotNull(dependency); | |
| 158 Expect.isTrue(dependency.isImport); | |
| 159 Expect.isFalse(dependency.isExport); | |
| 160 Expect.equals(mainLibrary, dependency.sourceLibrary); | |
| 161 Expect.equals(coreLibrary, dependency.targetLibrary); | |
| 162 Expect.equals('core', dependency.prefix); | |
| 163 Expect.isFalse(dependency.isDeferred); | |
| 164 | |
| 165 combinators = dependency.combinators; | |
| 166 Expect.isNotNull(combinators); | |
| 167 Expect.equals(0, combinators.length); | |
| 168 | |
| 169 // import 'c.dart' deferred as c; | |
| 170 dependency = dependencies[5]; | |
| 171 Expect.isNotNull(dependency); | |
| 172 Expect.isTrue(dependency.isImport); | |
| 173 Expect.isFalse(dependency.isExport); | |
| 174 Expect.equals(mainLibrary, dependency.sourceLibrary); | |
| 175 Expect.equals(cLibrary, dependency.targetLibrary); | |
| 176 Expect.equals('c', dependency.prefix); | |
| 177 Expect.isTrue(dependency.isDeferred); | |
| 178 | |
| 179 combinators = dependency.combinators; | |
| 180 Expect.isNotNull(combinators); | |
| 181 Expect.equals(0, combinators.length); | |
| 182 })); | |
| 183 } | |
| OLD | NEW |