OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Prints all information about all mirrors. This tests that it is possible to | 5 /// Prints all information about all mirrors. This tests that it is possible to |
6 /// enumerate all reflective information without crashing. | 6 /// enumerate all reflective information without crashing. |
7 | 7 |
8 // Note: Adding imports below is fine for regression tests. For example, | 8 // Note: Adding imports below is fine for regression tests. For example, |
9 // 'crash_library_metadata.dart' is imported to ensure the compiler doesn't | 9 // 'crash_library_metadata.dart' is imported to ensure the compiler doesn't |
10 // crash. | 10 // crash. |
11 | 11 |
12 // TODO(ahe): This test should be extended until we are sure all data is | 12 // TODO(ahe): This test should be extended until we are sure all data is |
13 // printed. | 13 // printed. |
14 | 14 |
15 library test.mirror_printer_test; | 15 library test.mirror_printer_test; |
16 | 16 |
17 @MirrorsUsed(targets: '*') | 17 @MirrorsUsed(targets: '*') |
18 import 'dart:mirrors'; | 18 import 'dart:mirrors'; |
19 | 19 |
20 import 'crash_library_metadata.dart'; // This would crash dart2js. | 20 import 'crash_library_metadata.dart'; // This would crash dart2js. |
21 | 21 |
22 // Importing dart:html to make things interesting. | 22 // Importing dart:html to make things interesting. |
23 import 'dart:html'; /// 01: ok | 23 import 'dart:html'; //# 01: ok |
24 | 24 |
25 class MirrorPrinter { | 25 class MirrorPrinter { |
26 final StringBuffer buffer; | 26 final StringBuffer buffer; |
27 final TypeMirror dynamicType = currentMirrorSystem().dynamicType; | 27 final TypeMirror dynamicType = currentMirrorSystem().dynamicType; |
28 | 28 |
29 int indentationLevel = 0; | 29 int indentationLevel = 0; |
30 | 30 |
31 MirrorPrinter(this.buffer); | 31 MirrorPrinter(this.buffer); |
32 | 32 |
33 void w(object) { | 33 void w(object) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 StringBuffer buffer = new StringBuffer(); | 178 StringBuffer buffer = new StringBuffer(); |
179 libraries.values.forEach(new MirrorPrinter(buffer).writeLibrary); | 179 libraries.values.forEach(new MirrorPrinter(buffer).writeLibrary); |
180 return buffer; | 180 return buffer; |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 main() { | 184 main() { |
185 print(MirrorPrinter.stringify(currentMirrorSystem().libraries)); | 185 print(MirrorPrinter.stringify(currentMirrorSystem().libraries)); |
186 // Clear the nodes to avoid confusing the fine test framework (by "fine" I | 186 // Clear the nodes to avoid confusing the fine test framework (by "fine" I |
187 // mean something else) -- ahe. | 187 // mean something else) -- ahe. |
188 document.body.nodes.clear(); /// 01: continued | 188 document.body.nodes.clear(); //# 01: continued |
189 } | 189 } |
OLD | NEW |