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

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

Issue 1409803006: Rename apiimpl.Compiler to CompilerImpl. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix long lines Created 5 years, 1 month 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
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 runCompiler; 8 import 'memory_compiler.dart' show runCompiler;
9 import 'package:compiler/src/apiimpl.dart' show 9 import 'package:compiler/src/apiimpl.dart' show
10 Compiler; 10 CompilerImpl;
11 import 'package:compiler/src/dart_backend/dart_backend.dart' show 11 import 'package:compiler/src/dart_backend/dart_backend.dart' show
12 DartBackend; 12 DartBackend;
13 import 'package:compiler/src/tree/tree.dart' show 13 import 'package:compiler/src/tree/tree.dart' show
14 Identifier, Node, Send; 14 Identifier, Node, Send;
15 import 'package:compiler/src/mirror_renamer/mirror_renamer.dart' show 15 import 'package:compiler/src/mirror_renamer/mirror_renamer.dart' show
16 MirrorRenamerImpl; 16 MirrorRenamerImpl;
17 17
18 main() { 18 main() {
19 asyncTest(() async { 19 asyncTest(() async {
20 await testUniqueMinification(); 20 await testUniqueMinification();
21 await testNoUniqueMinification(); 21 await testNoUniqueMinification();
22 }); 22 });
23 } 23 }
24 24
25 Future<Compiler> run({useMirrorHelperLibrary: false, minify: false}) async { 25 Future<CompilerImpl> run({useMirrorHelperLibrary: false, minify: false}) async {
26 List<String> options = ['--output-type=dart']; 26 List<String> options = ['--output-type=dart'];
27 if (minify) { 27 if (minify) {
28 options.add('--minify'); 28 options.add('--minify');
29 } 29 }
30 var result = await runCompiler( 30 var result = await runCompiler(
31 memorySourceFiles: MEMORY_SOURCE_FILES, 31 memorySourceFiles: MEMORY_SOURCE_FILES,
32 options: options, 32 options: options,
33 beforeRun: (Compiler compiler) { 33 beforeRun: (CompilerImpl compiler) {
34 DartBackend backend = compiler.backend; 34 DartBackend backend = compiler.backend;
35 backend.useMirrorHelperLibrary = useMirrorHelperLibrary; 35 backend.useMirrorHelperLibrary = useMirrorHelperLibrary;
36 }); 36 });
37 return result.compiler; 37 return result.compiler;
38 } 38 }
39 39
40 Future testUniqueMinification() async { 40 Future testUniqueMinification() async {
41 Compiler compiler = await run(useMirrorHelperLibrary: true, minify: true); 41 CompilerImpl compiler = await run(useMirrorHelperLibrary: true, minify: true);
42 DartBackend backend = compiler.backend; 42 DartBackend backend = compiler.backend;
43 MirrorRenamerImpl mirrorRenamer = backend.mirrorRenamer; 43 MirrorRenamerImpl mirrorRenamer = backend.mirrorRenamer;
44 Map<Node, String> renames = backend.placeholderRenamer.renames; 44 Map<Node, String> renames = backend.placeholderRenamer.renames;
45 Map<String, String> symbols = mirrorRenamer.symbols; 45 Map<String, String> symbols = mirrorRenamer.symbols;
46 46
47 // Check that no two different source code names get the same mangled name, 47 // Check that no two different source code names get the same mangled name,
48 // with the exception of MirrorSystem.getName that gets renamed to the same 48 // with the exception of MirrorSystem.getName that gets renamed to the same
49 // mangled name as the getNameHelper from _mirror_helper.dart. 49 // mangled name as the getNameHelper from _mirror_helper.dart.
50 for (Node node in renames.keys) { 50 for (Node node in renames.keys) {
51 Identifier identifier = node.asIdentifier(); 51 Identifier identifier = node.asIdentifier();
52 if (identifier != null) { 52 if (identifier != null) {
53 String source = identifier.source; 53 String source = identifier.source;
54 Send send = mirrorRenamer.mirrorSystemGetNameNodes.first; 54 Send send = mirrorRenamer.mirrorSystemGetNameNodes.first;
55 if (send.selector == node) 55 if (send.selector == node)
56 continue; 56 continue;
57 if (symbols.containsKey(renames[node])) { 57 if (symbols.containsKey(renames[node])) {
58 print(node); 58 print(node);
59 Expect.equals(source, symbols[renames[node]]); 59 Expect.equals(source, symbols[renames[node]]);
60 } 60 }
61 } 61 }
62 } 62 }
63 } 63 }
64 64
65 Future testNoUniqueMinification() async { 65 Future testNoUniqueMinification() async {
66 Compiler compiler = await run(useMirrorHelperLibrary: false, minify: true); 66 CompilerImpl compiler =
67 await run(useMirrorHelperLibrary: false, minify: true);
67 DartBackend backend = compiler.backend; 68 DartBackend backend = compiler.backend;
68 Map<Node, String> renames = backend.placeholderRenamer.renames; 69 Map<Node, String> renames = backend.placeholderRenamer.renames;
69 70
70 // 'Foo' appears twice and 'invocation' and 'hest' get the same mangled 71 // 'Foo' appears twice and 'invocation' and 'hest' get the same mangled
71 // name. 72 // name.
72 Expect.equals(renames.values.toSet().length, renames.values.length - 2); 73 Expect.equals(renames.values.toSet().length, renames.values.length - 2);
73 } 74 }
74 75
75 const MEMORY_SOURCE_FILES = const <String, String> { 76 const MEMORY_SOURCE_FILES = const <String, String> {
76 'main.dart': """ 77 'main.dart': """
77 import 'dart:mirrors'; 78 import 'dart:mirrors';
78 79
79 class Foo { 80 class Foo {
80 noSuchMethod(invocation) { 81 noSuchMethod(invocation) {
81 MirrorSystem.getName(null); 82 MirrorSystem.getName(null);
82 } 83 }
83 } 84 }
84 85
85 main(hest) { 86 main(hest) {
86 new Foo().fisk(); 87 new Foo().fisk();
87 } 88 }
88 """}; 89 """};
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/mirror_helper_test.dart ('k') | tests/compiler/dart2js/mirrors_used_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698