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

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 a number of tests, and remove unused typedef 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 =
69 backend.placeholderRenamer.platformImports;
68 70
69 FunctionExpression node = backend.memberNodes.values.first.first; 71 FunctionExpression node = backend.memberNodes.values.first.first;
70 Block block = node.body; 72 Block block = node.body;
71 ExpressionStatement getNameFunctionNode = block.statements.nodes.head; 73 ExpressionStatement getNameFunctionNode = block.statements.nodes.head;
72 Send send = getNameFunctionNode.expression; 74 Send send = getNameFunctionNode.expression;
73 75
74 Expect.isFalse(renames.containsKey(send.selector)); 76 Expect.isFalse(renames.containsKey(send.selector));
75 Expect.isFalse(renames.containsKey(send.receiver)); 77 Expect.isFalse(renames.containsKey(send.receiver));
76 Expect.equals(1, imports.keys.length); 78 Expect.equals(1, imports.length);
77 })); 79 }));
78 } 80 }
79 81
80 const MEMORY_SOURCE_FILES = const <String, String> { 82 const MEMORY_SOURCE_FILES = const <String, String> {
81 'main.dart': """ 83 'main.dart': """
82 import 'dart:mirrors'; 84 import 'dart:mirrors';
83 85
84 class Foo { 86 class Foo {
85 noSuchMethod(Invocation invocation) { 87 noSuchMethod(Invocation invocation) {
86 MirrorSystem.getName(invocation.memberName); 88 MirrorSystem.getName(invocation.memberName);
87 } 89 }
88 } 90 }
89 91
90 void main() { 92 void main() {
91 new Foo().fisk(); 93 new Foo().fisk();
92 } 94 }
93 """}; 95 """};
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698