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

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

Issue 839063002: Handle platform access through prefix in dart2dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Split fixed names into static and dynamic to avoid unneeded prefixes. Created 5 years, 11 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/src/apiimpl.dart' show 9 import 'package:compiler/src/apiimpl.dart' show
10 Compiler; 10 Compiler;
(...skipping 25 matching lines...) Expand all
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 MirrorRenamerImpl mirrorRenamer = backend.mirrorRenamer; 44 MirrorRenamerImpl mirrorRenamer = backend.mirrorRenamer;
45 Map<Node, String> renames = backend.placeholderRenamer.renames; 45 Map<Node, String> renames = backend.placeholderRenamer.renames;
46 Set<LibraryElement> imports = 46 Iterable<LibraryElement> imports =
47 backend.placeholderRenamer.platformImports; 47 backend.placeholderRenamer.platformImports.keys;
48 48
49 FunctionExpression node = backend.memberNodes.values.first.first; 49 FunctionExpression node = backend.memberNodes.values.first.first;
50 Block block = node.body; 50 Block block = node.body;
51 ExpressionStatement getNameFunctionNode = block.statements.nodes.head; 51 ExpressionStatement getNameFunctionNode = block.statements.nodes.head;
52 Send send = getNameFunctionNode.expression; 52 Send send = getNameFunctionNode.expression;
53 53
54 Expect.equals(renames[mirrorRenamer.getNameFunctionNode.name], 54 Expect.equals(renames[mirrorRenamer.getNameFunctionNode.name],
55 renames[send.selector]); 55 renames[send.selector]);
56 Expect.equals("", 56 Expect.equals("",
57 renames[send.receiver]); 57 renames[send.receiver]);
58 Expect.equals(1, imports.length); 58 Expect.equals(1, imports.length);
59 })); 59 }));
60 } 60 }
61 61
62 void testWithoutMirrorRenaming({bool minify}) { 62 void testWithoutMirrorRenaming({bool minify}) {
63 asyncTest(() => runCompiler(useMirrorHelperLibrary: false, minify: minify). 63 asyncTest(() => runCompiler(useMirrorHelperLibrary: false, minify: minify).
64 then((Compiler compiler) { 64 then((Compiler compiler) {
65 65
66 DartBackend backend = compiler.backend; 66 DartBackend backend = compiler.backend;
67 Map<Node, String> renames = backend.placeholderRenamer.renames; 67 Map<Node, String> renames = backend.placeholderRenamer.renames;
68 Set<LibraryElement> imports = 68 Iterable<LibraryElement> imports =
69 backend.placeholderRenamer.platformImports; 69 backend.placeholderRenamer.platformImports.keys;
70 FunctionExpression node = backend.memberNodes.values.first.first; 70 FunctionExpression node = backend.memberNodes.values.first.first;
71 Block block = node.body; 71 Block block = node.body;
72 ExpressionStatement getNameFunctionNode = block.statements.nodes.head; 72 ExpressionStatement getNameFunctionNode = block.statements.nodes.head;
73 Send send = getNameFunctionNode.expression; 73 Send send = getNameFunctionNode.expression;
74 74
75 Expect.isFalse(renames.containsKey(send.selector)); 75 Expect.isFalse(renames.containsKey(send.selector));
76 Expect.equals(1, imports.length); 76 Expect.equals(1, imports.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