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

Side by Side Diff: tests/compiler/dart2js/dump_info_test.dart

Issue 382063002: Redo "Information about which functions require other functions is gathered in the enqueuer." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 5 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
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 11
11 const String TEST_ONE = r""" 12 const String TEST_ONE = r"""
12 library main; 13 library main;
13 14
14 int a = 2; 15 int a = 2;
15 16
16 class c { 17 class c {
17 final int m; 18 final int m;
18 c(this.m) { 19 c(this.m) {
19 () {} (); // TODO (sigurdm): Empty closure, hack to avoid inlining. 20 () {} (); // TODO (sigurdm): Empty closure, hack to avoid inlining.
(...skipping 17 matching lines...) Expand all
37 main() { 38 main() {
38 print(a); 39 print(a);
39 f(); 40 f();
40 print(new c(2).foo()); 41 print(new c(2).foo());
41 } 42 }
42 """; 43 """;
43 44
44 main() { 45 main() {
45 var compiler = compilerFor({'main.dart': TEST_ONE}, options: ["--dump-info"]); 46 var compiler = compilerFor({'main.dart': TEST_ONE}, options: ["--dump-info"]);
46 asyncTest(() => compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) { 47 asyncTest(() => compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) {
47 var visitor = compiler.dumpInfoTask.infoDumpVisitor; 48 var dumpTask = compiler.dumpInfoTask;
48 var info = visitor.collectDumpInfo(); 49 dumpTask.collectInfo();
49 var mainlib = info.libraries[0]; 50 var info = dumpTask.infoCollector;
50 Expect.stringEquals("main", mainlib.name); 51
51 List contents = mainlib.contents; 52 StringBuffer sb = new StringBuffer();
52 Expect.stringEquals("main", mainlib.name); 53 dumpTask.dumpInfoJson(sb);
53 print(mainlib.contents.map((e)=> e.name)); 54 String json = sb.toString();
54 var a = contents.singleWhere((e) => e.name == "a"); 55 Map<String, dynamic> map = JSON.decode(json);
55 var c = contents.singleWhere((e) => e.name == "c"); 56 Expect.isTrue(map.isNotEmpty);
56 var f = contents.singleWhere((e) => e.name == "f"); 57 Expect.isTrue(map['elements'].isNotEmpty);
57 var main = contents.singleWhere((e) => e.name == "main"); 58 Expect.isTrue(map['elements']['function'].isNotEmpty);
58 Expect.stringEquals("library", mainlib.kind); 59 Expect.isTrue(map['elements']['library'].isNotEmpty);
59 Expect.stringEquals("field", a.kind); 60
60 Expect.stringEquals("class", c.kind); 61 Expect.isTrue(map['elements']['library'].values.any((lib) {
61 var constructor = c.contents.singleWhere((e) => e.name == "c"); 62 return lib['name'] == "main";
62 Expect.stringEquals("constructor", constructor.kind); 63 }));
63 var method = c.contents.singleWhere((e) => e.name == "foo"); 64 Expect.isTrue(map['elements']['class'].values.any((clazz) {
64 Expect.stringEquals("method", method.kind); 65 return clazz['name'] == "c";
65 var field = c.contents.singleWhere((e) => e.name == "m"); 66 }));
66 Expect.stringEquals("field", field.kind); 67 Expect.isTrue(map['elements']['function'].values.any((fun) {
67 Expect.stringEquals("function", f.kind); 68 return fun['name'] == 'f';
68 Expect.stringEquals("function", main.kind); 69 }));
69 })); 70 }));
70 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698