Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: tests/compiler/dart2js/dump_info_test.dart

Issue 469903002: Added a test for dump-info with lots of closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove unneeded check Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dump_info.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/dump_info_test.dart
diff --git a/tests/compiler/dart2js/dump_info_test.dart b/tests/compiler/dart2js/dump_info_test.dart
index 9d5e04d8a13b1f4fde2b7f1cbe87d8ae99c6c39b..00864e784de22cc40c32d6bb0ddf945aab64a9b3 100644
--- a/tests/compiler/dart2js/dump_info_test.dart
+++ b/tests/compiler/dart2js/dump_info_test.dart
@@ -42,18 +42,45 @@ main() {
}
""";
+const String TEST_TWO = r"""
main() {
- var compiler = compilerFor({'main.dart': TEST_ONE}, options: ["--dump-info"]);
- asyncTest(() => compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) {
- var dumpTask = compiler.dumpInfoTask;
- dumpTask.collectInfo();
- var info = dumpTask.infoCollector;
-
- StringBuffer sb = new StringBuffer();
- dumpTask.dumpInfoJson(sb);
- String json = sb.toString();
- Map<String, dynamic> map = JSON.decode(json);
- Expect.isTrue(map.isNotEmpty);
+ print(bar);
+ print(bar());
+ print(new X().foo);
+ print(new X().foo());
+}
+
+bar() => [() => [() => [() => [() => [() => [() => [() => [() => [() => [() =>
+[() => []]]]]]]]]]]];
+
+class X {
+ foo() => [() => [() => [() => [() => [() => [() => [() => [() => [() =>
+[() => []]]]]]]]]]];
+}
+""";
+
+typedef void JsonTaking(Map<String, dynamic> json);
+
+void jsonTest(String program, JsonTaking testFn) {
+ var compiler = compilerFor({'main.dart': program}, options: ['--dump-info']);
+ asyncTest(() => compiler.runCompiler(Uri.parse('memory:main.dart')).then(
+ (_) {
+ Expect.isFalse(compiler.compilationFailed);
+ var dumpTask = compiler.dumpInfoTask;
+ dumpTask.collectInfo();
+ var info = dumpTask.infoCollector;
+
+ StringBuffer sb = new StringBuffer();
+ dumpTask.dumpInfoJson(sb);
+ String json = sb.toString();
+ Map<String, dynamic> map = JSON.decode(json);
+
+ testFn(map);
+ }));
+}
+
+main() {
+ jsonTest(TEST_ONE, (map) {
Expect.isTrue(map['elements'].isNotEmpty);
Expect.isTrue(map['elements']['function'].isNotEmpty);
Expect.isTrue(map['elements']['library'].isNotEmpty);
@@ -67,5 +94,15 @@ main() {
Expect.isTrue(map['elements']['function'].values.any((fun) {
return fun['name'] == 'f';
}));
- }));
+ });
+
+ jsonTest(TEST_TWO, (map) {
+ var functions = map['elements']['function'].values;
+ Expect.isTrue(functions.any((fn) {
+ return fn['name'] == 'bar' && fn['children'].length == 11;
+ }));
+ Expect.isTrue(functions.any((fn) {
+ return fn['name'] == 'foo' && fn['children'].length == 10;
+ }));
+ });
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dump_info.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698