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 '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; | 6 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart'
; |
7 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart'; | 7 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.
dart'; |
8 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro
r.dart'; | 8 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro
r.dart'; |
| 9 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart' |
| 10 show currentDirectory, nativeToUriPath; |
| 11 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.
dart'; |
9 | 12 |
10 import 'dart:io'; | 13 import 'dart:io'; |
11 import 'dart:uri'; | 14 import 'dart:uri'; |
12 | 15 |
13 const Uri DART_MIRRORS_URI = | 16 const Uri DART_MIRRORS_URI = |
14 const Uri.fromComponents(scheme: 'dart', path: 'mirrors'); | 17 const Uri.fromComponents(scheme: 'dart', path: 'mirrors'); |
15 | 18 |
16 int count(Iterable iterable) { | 19 int count(Iterable iterable) { |
17 var count = 0; | 20 var count = 0; |
18 for (var element in iterable) { | 21 for (var element in iterable) { |
(...skipping 14 matching lines...) Expand all Loading... |
33 DeclarationMirror findMirror(Iterable<DeclarationMirror> list, String name) { | 36 DeclarationMirror findMirror(Iterable<DeclarationMirror> list, String name) { |
34 for (DeclarationMirror mirror in list) { | 37 for (DeclarationMirror mirror in list) { |
35 if (mirror.simpleName == name) { | 38 if (mirror.simpleName == name) { |
36 return mirror; | 39 return mirror; |
37 } | 40 } |
38 } | 41 } |
39 return null; | 42 return null; |
40 } | 43 } |
41 | 44 |
42 main() { | 45 main() { |
43 var scriptPath = new Path(new Options().script); | 46 Uri scriptUri = |
44 var dirPath = scriptPath.directoryPath; | 47 currentDirectory.resolve(nativeToUriPath(new Options().script)); |
45 var libPath = dirPath.join(new Path('../../../sdk/')); | 48 Uri libUri = scriptUri.resolve('../../../sdk/'); |
46 var inputPath = dirPath.join(new Path('mirrors_helper.dart')); | 49 Uri inputUri = scriptUri.resolve('mirrors_helper.dart'); |
47 var result = analyze([inputPath], libPath, | 50 var provider = new SourceFileProvider(); |
48 options: <String>['--preserve-comments']); | 51 var diagnosticHandler = |
| 52 new FormattingDiagnosticHandler(provider).diagnosticHandler; |
| 53 var result = analyze([inputUri], libUri, null, |
| 54 provider.readStringFromUri, diagnosticHandler, |
| 55 <String>['--preserve-comments']); |
49 result.then((MirrorSystem mirrors) { | 56 result.then((MirrorSystem mirrors) { |
50 test(mirrors); | 57 test(mirrors); |
51 }); | 58 }); |
52 } | 59 } |
53 | 60 |
54 void test(MirrorSystem mirrors) { | 61 void test(MirrorSystem mirrors) { |
55 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); | 62 Expect.isNotNull(mirrors, "No mirror system returned from compilation"); |
56 | 63 |
57 var libraries = mirrors.libraries; | 64 var libraries = mirrors.libraries; |
58 Expect.isNotNull(libraries, "No libraries map returned"); | 65 Expect.isNotNull(libraries, "No libraries map returned"); |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 Expect.isTrue(privateFactoryConstructor.isPrivate); | 1059 Expect.isTrue(privateFactoryConstructor.isPrivate); |
1053 Expect.isFalse(privateFactoryConstructor.isConstConstructor); | 1060 Expect.isFalse(privateFactoryConstructor.isConstConstructor); |
1054 Expect.isFalse(privateFactoryConstructor.isRedirectingConstructor); | 1061 Expect.isFalse(privateFactoryConstructor.isRedirectingConstructor); |
1055 Expect.isFalse(privateFactoryConstructor.isGenerativeConstructor); | 1062 Expect.isFalse(privateFactoryConstructor.isGenerativeConstructor); |
1056 Expect.isTrue(privateFactoryConstructor.isFactoryConstructor); | 1063 Expect.isTrue(privateFactoryConstructor.isFactoryConstructor); |
1057 | 1064 |
1058 var metadata = privateClass.metadata; | 1065 var metadata = privateClass.metadata; |
1059 Expect.isNotNull(metadata); | 1066 Expect.isNotNull(metadata); |
1060 Expect.equals(0, metadata.length); | 1067 Expect.equals(0, metadata.length); |
1061 } | 1068 } |
OLD | NEW |