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

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

Issue 22849007: Enable unique global renaming in dart2dart minification. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 7 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6 import 'memory_compiler.dart' show compilerFor;
7 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart' show
8 Compiler;
9 import
10 '../../../sdk/lib/_internal/compiler/implementation/dart_backend/dart_backen d.dart'
11 show
12 DartBackend;
13
14 main() {
15 testUniqueMinification();
16 testNoUniqueMinification();
17 }
18
19 Compiler runCompiler({useMirrorHelperLibrary: false, minify: false}) {
20 List<String> options = ['--output-type=dart'];
21 if (minify) {
22 options.add('--minify');
23 }
24 Compiler compiler = compilerFor(MEMORY_SOURCE_FILES, options: options);
25 DartBackend backend = compiler.backend;
26 backend.useMirrorHelperLibrary = useMirrorHelperLibrary;
27 compiler.runCompiler(Uri.parse('memory:main.dart'));
28 return compiler;
29 }
30
31 void testUniqueMinification() {
32 Compiler compiler = runCompiler(useMirrorHelperLibrary: true, minify: true);
33 DartBackend backend = compiler.backend;
34 Map<Node, String> renames = backend.renames;
35
36 //'Foo' appears twice, so toSet() reduces the length by 1.
37 Expect.equals(renames.values.toSet().length, renames.values.length - 1);
38 }
39
40 void testNoUniqueMinification() {
41 Compiler compiler = runCompiler(useMirrorHelperLibrary: false, minify: true);
42 DartBackend backend = compiler.backend;
43 Map<Node, String> renames = backend.renames;
44
45 //'Foo' appears twice and now 'invocation' and 'hest' can get the same name.
46 Expect.equals(renames.values.toSet().length, renames.values.length - 2);
47 }
48
49 const MEMORY_SOURCE_FILES = const <String, String> {
50 'main.dart': """
51 import 'dart:mirrors';
52
53 class Foo {
54 noSuchMethod(invocation) {
55 MirrorSystem.getName(const Symbol('hest'));
56 }
57 }
58
59 main() {
60 new Foo().fisk();
61 var hest;
62 }
63 """};
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698