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

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

Issue 23593002: Only emit members in mirror helper symbolsmap. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed comment. Created 7 years, 3 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 'memory_compiler.dart' show compilerFor; 6 import 'memory_compiler.dart' show compilerFor;
7 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart' show 7 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart' show
8 Compiler; 8 Compiler;
9 import 9 import
10 '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart' 10 '../../../sdk/lib/_internal/compiler/implementation/tree/tree.dart'
(...skipping 30 matching lines...) Expand all
41 void testWithMirrorHelperLibrary({bool minify}) { 41 void testWithMirrorHelperLibrary({bool minify}) {
42 Compiler compiler = runCompiler(useMirrorHelperLibrary: true, minify: minify); 42 Compiler compiler = runCompiler(useMirrorHelperLibrary: true, minify: minify);
43 43
44 DartBackend backend = compiler.backend; 44 DartBackend backend = compiler.backend;
45 MirrorRenamer mirrorRenamer = backend.mirrorRenamer; 45 MirrorRenamer mirrorRenamer = backend.mirrorRenamer;
46 Map<Node, String> renames = backend.renames; 46 Map<Node, String> renames = backend.renames;
47 Map<String, SourceString> symbols = mirrorRenamer.symbols; 47 Map<String, SourceString> symbols = mirrorRenamer.symbols;
48 48
49 Expect.isFalse(null == backend.mirrorHelperLibrary); 49 Expect.isFalse(null == backend.mirrorHelperLibrary);
50 Expect.isFalse(null == backend.mirrorHelperGetNameFunction); 50 Expect.isFalse(null == backend.mirrorHelperGetNameFunction);
51 Expect.isTrue(symbols.containsValue(
52 const SourceString(MirrorRenamer.MIRROR_HELPER_GET_NAME_FUNCTION)));
53 51
54 for (Node n in renames.keys) { 52 for (Node n in renames.keys) {
55 if (symbols.containsKey(renames[n])) { 53 if (symbols.containsKey(renames[n])) {
56 if(n.toString() == 'getName') { 54 if(n.toString() == 'getName') {
57 Expect.equals( 55 Expect.equals(
58 const SourceString(MirrorRenamer.MIRROR_HELPER_GET_NAME_FUNCTION), 56 const SourceString(MirrorRenamer.MIRROR_HELPER_GET_NAME_FUNCTION),
59 symbols[renames[n]]); 57 symbols[renames[n]]);
60 } else { 58 } else {
61 Expect.equals(n.toString(), symbols[renames[n]].stringValue); 59 Expect.equals(n.toString(), symbols[renames[n]].stringValue);
62 } 60 }
63 } 61 }
64 } 62 }
65 63
66 String output = compiler.assembledCode; 64 String output = compiler.assembledCode;
67 String getNameMatch = MirrorRenamer.MIRROR_HELPER_GET_NAME_FUNCTION; 65 String getNameMatch = MirrorRenamer.MIRROR_HELPER_GET_NAME_FUNCTION;
68 Iterable i = getNameMatch.allMatches(output); 66 Iterable i = getNameMatch.allMatches(output);
69 67
70 68
71 if (minify) { 69 if (minify) {
72 Expect.equals(1, i.length); 70 Expect.equals(0, i.length);
73 } else { 71 } else {
74 // Appears twice in code (defined & called) and twice in renames map. 72 // Appears twice in code (defined & called).
75 Expect.equals(4, i.length); 73 Expect.equals(2, i.length);
76 } 74 }
77 75
78 String mapMatch = 'const<String,SourceString>'; 76 String mapMatch = 'const<String,SourceString>';
79 i = mapMatch.allMatches(output); 77 i = mapMatch.allMatches(output);
80 Expect.equals(1, i.length); 78 Expect.equals(1, i.length);
81 } 79 }
82 80
83 void testWithoutMirrorHelperLibrary({bool minify}) { 81 void testWithoutMirrorHelperLibrary({bool minify}) {
84 Compiler compiler = 82 Compiler compiler =
85 runCompiler(useMirrorHelperLibrary: false, minify: minify); 83 runCompiler(useMirrorHelperLibrary: false, minify: minify);
(...skipping 11 matching lines...) Expand all
97 class Foo { 95 class Foo {
98 noSuchMethod(Invocation invocation) { 96 noSuchMethod(Invocation invocation) {
99 MirrorSystem.getName(invocation.memberName); 97 MirrorSystem.getName(invocation.memberName);
100 } 98 }
101 } 99 }
102 100
103 void main() { 101 void main() {
104 new Foo().fisk(); 102 new Foo().fisk();
105 } 103 }
106 """}; 104 """};
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/mirror_helper.dart ('k') | tests/compiler/dart2js/mirror_helper_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698