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

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

Issue 1417323005: Rename Compiler.runCompiler -> runInternal. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library compiler_helper; 5 library compiler_helper;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 9
10 import 'package:compiler/src/elements/elements.dart' 10 import 'package:compiler/src/elements/elements.dart'
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 int expectedWarnings}) { 139 int expectedWarnings}) {
140 Uri uri = new Uri(scheme: 'source'); 140 Uri uri = new Uri(scheme: 'source');
141 OutputCollector outputCollector = new OutputCollector(); 141 OutputCollector outputCollector = new OutputCollector();
142 MockCompiler compiler = compilerFor( 142 MockCompiler compiler = compilerFor(
143 code, uri, coreSource: coreSource, disableInlining: disableInlining, 143 code, uri, coreSource: coreSource, disableInlining: disableInlining,
144 minify: minify, expectedErrors: expectedErrors, 144 minify: minify, expectedErrors: expectedErrors,
145 trustTypeAnnotations: trustTypeAnnotations, 145 trustTypeAnnotations: trustTypeAnnotations,
146 expectedWarnings: expectedWarnings, 146 expectedWarnings: expectedWarnings,
147 outputProvider: outputCollector); 147 outputProvider: outputCollector);
148 compiler.diagnosticHandler = createHandler(compiler, code); 148 compiler.diagnosticHandler = createHandler(compiler, code);
149 return compiler.runCompiler(uri).then((_) { 149 return compiler.run(uri).then((compilationSucceded) {
150 Expect.isFalse(compiler.compilationFailed, 150 Expect.isTrue(compilationSucceded,
151 'Unexpected compilation error(s): ${compiler.errors}'); 151 'Unexpected compilation error(s): ${compiler.errors}');
152 return outputCollector.getOutput('', 'js'); 152 return outputCollector.getOutput('', 'js');
153 }); 153 });
154 } 154 }
155 155
156 Future compileAndCheck(String code, 156 Future compileAndCheck(String code,
157 String name, 157 String name,
158 check(MockCompiler compiler, lego.Element element), 158 check(MockCompiler compiler, lego.Element element),
159 {int expectedErrors, int expectedWarnings}) { 159 {int expectedErrors, int expectedWarnings}) {
160 Uri uri = new Uri(scheme: 'source'); 160 Uri uri = new Uri(scheme: 'source');
161 MockCompiler compiler = compilerFor(code, uri, 161 MockCompiler compiler = compilerFor(code, uri,
162 expectedErrors: expectedErrors, 162 expectedErrors: expectedErrors,
163 expectedWarnings: expectedWarnings); 163 expectedWarnings: expectedWarnings);
164 return compiler.runCompiler(uri).then((_) { 164 return compiler.run(uri).then((_) {
165 lego.Element element = findElement(compiler, name); 165 lego.Element element = findElement(compiler, name);
166 return check(compiler, element); 166 return check(compiler, element);
167 }); 167 });
168 } 168 }
169 169
170 Future compileSources(Map<String, String> sources, 170 Future compileSources(Map<String, String> sources,
171 check(MockCompiler compiler)) { 171 check(MockCompiler compiler)) {
172 Uri base = new Uri(scheme: 'source'); 172 Uri base = new Uri(scheme: 'source');
173 Uri mainUri = base.resolve('main.dart'); 173 Uri mainUri = base.resolve('main.dart');
174 String mainCode = sources['main.dart']; 174 String mainCode = sources['main.dart'];
175 Expect.isNotNull(mainCode, 'No source code found for "main.dart"'); 175 Expect.isNotNull(mainCode, 'No source code found for "main.dart"');
176 MockCompiler compiler = compilerFor(mainCode, mainUri); 176 MockCompiler compiler = compilerFor(mainCode, mainUri);
177 sources.forEach((String path, String code) { 177 sources.forEach((String path, String code) {
178 if (path == 'main.dart') return; 178 if (path == 'main.dart') return;
179 compiler.registerSource(base.resolve(path), code); 179 compiler.registerSource(base.resolve(path), code);
180 }); 180 });
181 181
182 return compiler.runCompiler(mainUri).then((_) { 182 return compiler.run(mainUri).then((_) {
183 return check(compiler); 183 return check(compiler);
184 }); 184 });
185 } 185 }
186 186
187 lego.Element findElement(compiler, String name, [Uri library]) { 187 lego.Element findElement(compiler, String name, [Uri library]) {
188 lego.LibraryElement lib = compiler.mainApp; 188 lego.LibraryElement lib = compiler.mainApp;
189 if (library != null) { 189 if (library != null) {
190 lib = compiler.libraryLoader.lookupLibrary(library); 190 lib = compiler.libraryLoader.lookupLibrary(library);
191 Expect.isNotNull(lib, 'Could not locate library $library.'); 191 Expect.isNotNull(lib, 'Could not locate library $library.');
192 } 192 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); 280 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)');
281 final spaceRe = new RegExp('\\s+'); 281 final spaceRe = new RegExp('\\s+');
282 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); 282 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)');
283 if (shouldMatch) { 283 if (shouldMatch) {
284 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); 284 Expect.isTrue(new RegExp(regexp).hasMatch(generated));
285 } else { 285 } else {
286 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); 286 Expect.isFalse(new RegExp(regexp).hasMatch(generated));
287 } 287 }
288 }); 288 });
289 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698