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

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

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

Powered by Google App Engine
This is Rietveld 408576698