OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'memory_compiler.dart'; | 8 import 'memory_compiler.dart'; |
9 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; | 9 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mirror
s.dart'; |
10 | 10 |
11 const SOURCE_FILES = const { | 11 const SOURCE_FILES = const { |
12 'main.dart': ''' | 12 'main.dart': ''' |
13 import 'a.dart' show A1, A2; | 13 import 'a.dart' show A1, A2; |
14 import 'b.dart' as b hide B1; | 14 import 'b.dart' as b hide B1; |
15 export 'a.dart' show A2 hide A3, A1; | 15 export 'a.dart' show A2 hide A3, A1; |
16 export 'b.dart' hide B1, B2 show B3; | 16 export 'b.dart' hide B1, B2 show B3; |
17 import 'dart:core' as core; | 17 import 'dart:core' as core; |
18 | 18 |
19 main() {} | 19 main() {} |
20 ''', | 20 ''', |
21 'a.dart': ''' | 21 'a.dart': ''' |
22 class A1 {} | 22 class A1 {} |
23 class A2 {} | 23 class A2 {} |
24 class A3 {} | 24 class A3 {} |
25 ''', | 25 ''', |
26 'b.dart': ''' | 26 'b.dart': ''' |
27 class B1 {} | 27 class B1 {} |
28 class B2 {} | 28 class B2 {} |
29 class B3 {} | 29 class B3 {} |
30 ''' | 30 ''' |
31 }; | 31 }; |
32 | 32 |
33 void main() { | 33 void main() { |
34 asyncTest(() => mirrorSystemFor(SOURCE_FILES).then((MirrorSystem mirrors) { | 34 asyncTest(() => mirrorSystemFor(SOURCE_FILES).then((MirrorSystem mirrors) { |
35 LibraryMirror mainLibrary = | 35 LibrarySourceMirror mainLibrary = |
36 mirrors.libraries[Uri.parse('memory:main.dart')]; | 36 mirrors.libraries[Uri.parse('memory:main.dart')]; |
37 Expect.isNotNull(mainLibrary); | 37 Expect.isNotNull(mainLibrary); |
38 | 38 |
39 LibraryMirror aLibrary = | 39 LibrarySourceMirror aLibrary = |
40 mirrors.libraries[Uri.parse('memory:a.dart')]; | 40 mirrors.libraries[Uri.parse('memory:a.dart')]; |
41 Expect.isNotNull(aLibrary); | 41 Expect.isNotNull(aLibrary); |
42 | 42 |
43 LibraryMirror bLibrary = | 43 LibrarySourceMirror bLibrary = |
44 mirrors.libraries[Uri.parse('memory:b.dart')]; | 44 mirrors.libraries[Uri.parse('memory:b.dart')]; |
45 Expect.isNotNull(bLibrary); | 45 Expect.isNotNull(bLibrary); |
46 | 46 |
47 LibraryMirror coreLibrary = | 47 LibrarySourceMirror coreLibrary = |
48 mirrors.libraries[Uri.parse('dart:core')]; | 48 mirrors.libraries[Uri.parse('dart:core')]; |
49 Expect.isNotNull(coreLibrary); | 49 Expect.isNotNull(coreLibrary); |
50 | 50 |
51 var dependencies = mainLibrary.libraryDependencies; | 51 var dependencies = mainLibrary.libraryDependencies; |
52 Expect.isNotNull(dependencies); | 52 Expect.isNotNull(dependencies); |
53 Expect.equals(5, dependencies.length); | 53 Expect.equals(5, dependencies.length); |
54 | 54 |
55 // import 'a.dart' show A1, A2; | 55 // import 'a.dart' show A1, A2; |
56 var dependency = dependencies[0]; | 56 var dependency = dependencies[0]; |
57 Expect.isNotNull(dependency); | 57 Expect.isNotNull(dependency); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 Expect.isFalse(dependency.isExport); | 147 Expect.isFalse(dependency.isExport); |
148 Expect.equals(mainLibrary, dependency.sourceLibrary); | 148 Expect.equals(mainLibrary, dependency.sourceLibrary); |
149 Expect.equals(coreLibrary, dependency.targetLibrary); | 149 Expect.equals(coreLibrary, dependency.targetLibrary); |
150 Expect.equals('core', dependency.prefix); | 150 Expect.equals('core', dependency.prefix); |
151 | 151 |
152 combinators = dependency.combinators; | 152 combinators = dependency.combinators; |
153 Expect.isNotNull(combinators); | 153 Expect.isNotNull(combinators); |
154 Expect.equals(0, combinators.length); | 154 Expect.equals(0, combinators.length); |
155 })); | 155 })); |
156 } | 156 } |
OLD | NEW |