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

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

Issue 448943004: Refactor and simplify the dart2dart renamer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix minifying name generation 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
OLDNEW
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 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import 'memory_compiler.dart' show compilerFor; 8 import 'memory_compiler.dart' show compilerFor;
9 import 'package:compiler/implementation/apiimpl.dart' show 9 import 'package:compiler/implementation/apiimpl.dart' show
10 Compiler; 10 Compiler;
(...skipping 24 matching lines...) Expand all
35 return 35 return
36 compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) => compiler); 36 compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) => compiler);
37 } 37 }
38 38
39 void testWithMirrorRenaming({bool minify}) { 39 void testWithMirrorRenaming({bool minify}) {
40 asyncTest(() => runCompiler(useMirrorHelperLibrary: true, minify: minify). 40 asyncTest(() => runCompiler(useMirrorHelperLibrary: true, minify: minify).
41 then((Compiler compiler) { 41 then((Compiler compiler) {
42 42
43 DartBackend backend = compiler.backend; 43 DartBackend backend = compiler.backend;
44 MirrorRenamer mirrorRenamer = backend.mirrorRenamer; 44 MirrorRenamer mirrorRenamer = backend.mirrorRenamer;
45 Map<Node, String> renames = backend.renames; 45 Map<Node, String> renames = backend.placeholderRenamer.renames;
46 Map<LibraryElement, String> imports = backend.imports; 46 Set<LibraryElement> imports =
47 backend.placeholderRenamer.platformImports;
47 48
48 FunctionExpression node = backend.memberNodes.values.first.first; 49 FunctionExpression node = backend.memberNodes.values.first.first;
49 Block block = node.body; 50 Block block = node.body;
50 ExpressionStatement getNameFunctionNode = block.statements.nodes.head; 51 ExpressionStatement getNameFunctionNode = block.statements.nodes.head;
51 Send send = getNameFunctionNode.expression; 52 Send send = getNameFunctionNode.expression;
52 53
53 Expect.equals(renames[mirrorRenamer.mirrorHelperGetNameFunctionNode.name], 54 Expect.equals(renames[mirrorRenamer.mirrorHelperGetNameFunctionNode.name],
54 renames[send.selector]); 55 renames[send.selector]);
55 Expect.equals("", 56 Expect.equals("",
56 renames[send.receiver]); 57 renames[send.receiver]);
57 Expect.equals(1, imports.keys.length); 58 Expect.equals(1, imports.length);
58 })); 59 }));
59 } 60 }
60 61
61 void testWithoutMirrorRenaming({bool minify}) { 62 void testWithoutMirrorRenaming({bool minify}) {
62 asyncTest(() => runCompiler(useMirrorHelperLibrary: false, minify: minify). 63 asyncTest(() => runCompiler(useMirrorHelperLibrary: false, minify: minify).
63 then((Compiler compiler) { 64 then((Compiler compiler) {
64 65
65 DartBackend backend = compiler.backend; 66 DartBackend backend = compiler.backend;
66 Map<Node, String> renames = backend.renames; 67 Map<Node, String> renames = backend.placeholderRenamer.renames;
67 Map<LibraryElement, String> imports = backend.imports; 68 Set<LibraryElement> imports =
68 69 backend.placeholderRenamer.platformImports;
69 FunctionExpression node = backend.memberNodes.values.first.first; 70 FunctionExpression node = backend.memberNodes.values.first.first;
70 Block block = node.body; 71 Block block = node.body;
71 ExpressionStatement getNameFunctionNode = block.statements.nodes.head; 72 ExpressionStatement getNameFunctionNode = block.statements.nodes.head;
72 Send send = getNameFunctionNode.expression; 73 Send send = getNameFunctionNode.expression;
73 74
74 Expect.isFalse(renames.containsKey(send.selector)); 75 Expect.isFalse(renames.containsKey(send.selector));
75 Expect.isFalse(renames.containsKey(send.receiver)); 76 Expect.equals(1, imports.length);
76 Expect.equals(1, imports.keys.length);
77 })); 77 }));
78 } 78 }
79 79
80 const MEMORY_SOURCE_FILES = const <String, String> { 80 const MEMORY_SOURCE_FILES = const <String, String> {
81 'main.dart': """ 81 'main.dart': """
82 import 'dart:mirrors'; 82 import 'dart:mirrors';
83 83
84 class Foo { 84 class Foo {
85 noSuchMethod(Invocation invocation) { 85 noSuchMethod(Invocation invocation) {
86 MirrorSystem.getName(invocation.memberName); 86 MirrorSystem.getName(invocation.memberName);
87 } 87 }
88 } 88 }
89 89
90 void main() { 90 void main() {
91 new Foo().fisk(); 91 new Foo().fisk();
92 } 92 }
93 """}; 93 """};
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698