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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dump_info.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Test that parameters keep their names in the output. 4 // Test that parameters keep their names in the output.
5 5
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import 'memory_compiler.dart'; 8 import 'memory_compiler.dart';
9 import 'package:compiler/implementation/dump_info.dart'; 9 import 'package:compiler/implementation/dump_info.dart';
10 import 'dart:convert'; 10 import 'dart:convert';
(...skipping 24 matching lines...) Expand all
35 a = 3; 35 a = 3;
36 } 36 }
37 37
38 main() { 38 main() {
39 print(a); 39 print(a);
40 f(); 40 f();
41 print(new c(2).foo()); 41 print(new c(2).foo());
42 } 42 }
43 """; 43 """;
44 44
45 const String TEST_TWO = r"""
45 main() { 46 main() {
46 var compiler = compilerFor({'main.dart': TEST_ONE}, options: ["--dump-info"]); 47 print(bar);
47 asyncTest(() => compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) { 48 print(bar());
48 var dumpTask = compiler.dumpInfoTask; 49 print(new X().foo);
49 dumpTask.collectInfo(); 50 print(new X().foo());
50 var info = dumpTask.infoCollector; 51 }
51 52
52 StringBuffer sb = new StringBuffer(); 53 bar() => [() => [() => [() => [() => [() => [() => [() => [() => [() => [() =>
53 dumpTask.dumpInfoJson(sb); 54 [() => []]]]]]]]]]]];
54 String json = sb.toString(); 55
55 Map<String, dynamic> map = JSON.decode(json); 56 class X {
56 Expect.isTrue(map.isNotEmpty); 57 foo() => [() => [() => [() => [() => [() => [() => [() => [() => [() =>
58 [() => []]]]]]]]]]];
59 }
60 """;
61
62 typedef void JsonTaking(Map<String, dynamic> json);
63
64 void jsonTest(String program, JsonTaking testFn) {
65 var compiler = compilerFor({'main.dart': program}, options: ['--dump-info']);
66 asyncTest(() => compiler.runCompiler(Uri.parse('memory:main.dart')).then(
67 (_) {
68 Expect.isFalse(compiler.compilationFailed);
69 var dumpTask = compiler.dumpInfoTask;
70 dumpTask.collectInfo();
71 var info = dumpTask.infoCollector;
72
73 StringBuffer sb = new StringBuffer();
74 dumpTask.dumpInfoJson(sb);
75 String json = sb.toString();
76 Map<String, dynamic> map = JSON.decode(json);
77
78 testFn(map);
79 }));
80 }
81
82 main() {
83 jsonTest(TEST_ONE, (map) {
57 Expect.isTrue(map['elements'].isNotEmpty); 84 Expect.isTrue(map['elements'].isNotEmpty);
58 Expect.isTrue(map['elements']['function'].isNotEmpty); 85 Expect.isTrue(map['elements']['function'].isNotEmpty);
59 Expect.isTrue(map['elements']['library'].isNotEmpty); 86 Expect.isTrue(map['elements']['library'].isNotEmpty);
60 87
61 Expect.isTrue(map['elements']['library'].values.any((lib) { 88 Expect.isTrue(map['elements']['library'].values.any((lib) {
62 return lib['name'] == "main"; 89 return lib['name'] == "main";
63 })); 90 }));
64 Expect.isTrue(map['elements']['class'].values.any((clazz) { 91 Expect.isTrue(map['elements']['class'].values.any((clazz) {
65 return clazz['name'] == "c"; 92 return clazz['name'] == "c";
66 })); 93 }));
67 Expect.isTrue(map['elements']['function'].values.any((fun) { 94 Expect.isTrue(map['elements']['function'].values.any((fun) {
68 return fun['name'] == 'f'; 95 return fun['name'] == 'f';
69 })); 96 }));
70 })); 97 });
98
99 jsonTest(TEST_TWO, (map) {
100 var functions = map['elements']['function'].values;
101 Expect.isTrue(functions.any((fn) {
102 return fn['name'] == 'bar' && fn['children'].length == 11;
103 }));
104 Expect.isTrue(functions.any((fn) {
105 return fn['name'] == 'foo' && fn['children'].length == 10;
106 }));
107 });
71 } 108 }
OLDNEW
« 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