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

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

Issue 824103005: Revert "Remove Compiler.assembledCode." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, OutputCollector; 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;
11 import 'package:compiler/src/tree/tree.dart' show 11 import 'package:compiler/src/tree/tree.dart' show
12 Node; 12 Node;
13 import 'package:compiler/src/dart_backend/dart_backend.dart'; 13 import 'package:compiler/src/dart_backend/dart_backend.dart';
14 import 'package:compiler/src/mirror_renamer/mirror_renamer.dart'; 14 import 'package:compiler/src/mirror_renamer/mirror_renamer.dart';
15 15
16 main() { 16 main() {
17 testWithMirrorHelperLibrary(minify: true); 17 testWithMirrorHelperLibrary(minify: true);
18 testWithMirrorHelperLibrary(minify: false); 18 testWithMirrorHelperLibrary(minify: false);
19 testWithoutMirrorHelperLibrary(minify: true); 19 testWithoutMirrorHelperLibrary(minify: true);
20 testWithoutMirrorHelperLibrary(minify: false); 20 testWithoutMirrorHelperLibrary(minify: false);
21 } 21 }
22 22
23 Future<Compiler> runCompiler({OutputCollector outputCollector, 23 Future<Compiler> runCompiler({useMirrorHelperLibrary: false, minify: false}) {
24 bool useMirrorHelperLibrary: false,
25 bool minify: false}) {
26 List<String> options = ['--output-type=dart']; 24 List<String> options = ['--output-type=dart'];
27 if (minify) { 25 if (minify) {
28 options.add('--minify'); 26 options.add('--minify');
29 } 27 }
30 Compiler compiler = compilerFor( 28 Compiler compiler = compilerFor(MEMORY_SOURCE_FILES, options: options);
31 MEMORY_SOURCE_FILES, outputProvider: outputCollector, options: options);
32 DartBackend backend = compiler.backend; 29 DartBackend backend = compiler.backend;
33 backend.useMirrorHelperLibrary = useMirrorHelperLibrary; 30 backend.useMirrorHelperLibrary = useMirrorHelperLibrary;
34 return 31 return
35 compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) => compiler); 32 compiler.runCompiler(Uri.parse('memory:main.dart')).then((_) => compiler);
36 } 33 }
37 34
38 void testWithMirrorHelperLibrary({bool minify}) { 35 void testWithMirrorHelperLibrary({bool minify}) {
39 OutputCollector outputCollector = new OutputCollector(); 36 asyncTest(() => runCompiler(useMirrorHelperLibrary: true, minify: minify).
40 asyncTest(() => 37 then((Compiler compiler) {
41 runCompiler(outputCollector: outputCollector,
42 useMirrorHelperLibrary: true,
43 minify: minify)
44 .then((Compiler compiler) {
45 DartBackend backend = compiler.backend; 38 DartBackend backend = compiler.backend;
46 MirrorRenamerImpl mirrorRenamer = backend.mirrorRenamer; 39 MirrorRenamerImpl mirrorRenamer = backend.mirrorRenamer;
47 Map<Node, String> renames = backend.placeholderRenamer.renames; 40 Map<Node, String> renames = backend.placeholderRenamer.renames;
48 Map<String, String> symbols = mirrorRenamer.symbols; 41 Map<String, String> symbols = mirrorRenamer.symbols;
49 42
50 Expect.isFalse(null == mirrorRenamer.helperLibrary); 43 Expect.isFalse(null == mirrorRenamer.helperLibrary);
51 Expect.isFalse(null == mirrorRenamer.getNameFunction); 44 Expect.isFalse(null == mirrorRenamer.getNameFunction);
52 45
53 for (Node n in renames.keys) { 46 for (Node n in renames.keys) {
54 if (symbols.containsKey(renames[n])) { 47 if (symbols.containsKey(renames[n])) {
55 if(n.toString() == 'getName') { 48 if(n.toString() == 'getName') {
56 Expect.equals( 49 Expect.equals(
57 MirrorRenamerImpl.MIRROR_HELPER_GET_NAME_FUNCTION, 50 MirrorRenamerImpl.MIRROR_HELPER_GET_NAME_FUNCTION,
58 symbols[renames[n]]); 51 symbols[renames[n]]);
59 } else { 52 } else {
60 Expect.equals(n.toString(), symbols[renames[n]]); 53 Expect.equals(n.toString(), symbols[renames[n]]);
61 } 54 }
62 } 55 }
63 } 56 }
64 57
65 String output = outputCollector.getOutput('', 'dart'); 58 String output = compiler.assembledCode;
66 String getNameMatch = MirrorRenamerImpl.MIRROR_HELPER_GET_NAME_FUNCTION; 59 String getNameMatch = MirrorRenamerImpl.MIRROR_HELPER_GET_NAME_FUNCTION;
67 Iterable i = getNameMatch.allMatches(output); 60 Iterable i = getNameMatch.allMatches(output);
68 print(output); 61 print(output);
69 if (minify) { 62 if (minify) {
70 Expect.equals(0, i.length); 63 Expect.equals(0, i.length);
71 } else { 64 } else {
72 // Appears twice in code (defined & called). 65 // Appears twice in code (defined & called).
73 Expect.equals(2, i.length); 66 Expect.equals(2, i.length);
74 } 67 }
75 68
(...skipping 21 matching lines...) Expand all
97 class Foo { 90 class Foo {
98 noSuchMethod(Invocation invocation) { 91 noSuchMethod(Invocation invocation) {
99 MirrorSystem.getName(invocation.memberName); 92 MirrorSystem.getName(invocation.memberName);
100 } 93 }
101 } 94 }
102 95
103 void main() { 96 void main() {
104 new Foo().fisk(); 97 new Foo().fisk();
105 } 98 }
106 """}; 99 """};
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698