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

Unified Diff: tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart
diff --git a/tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart b/tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart
index e0f93e57cf8ad3dc3289c4316435178b8f3997b3..0cbcc0b90ef9738aa8b3d00d44515423680ea818 100644
--- a/tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart
+++ b/tests/compiler/dart2js/deferred_dont_inline_deferred_constants_test.dart
@@ -5,57 +5,23 @@
// Test that the additional runtime type support is output to the right
// Files when using deferred loading.
+import 'package:async_helper/async_helper.dart';
+import 'package:compiler/src/dart2jslib.dart';
import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import 'memory_source_file_helper.dart';
-import "dart:async";
-
-import 'package:compiler/src/dart2jslib.dart'
- as dart2js;
-
-class MemoryOutputSink extends EventSink<String> {
- StringBuffer mem = new StringBuffer();
- void add(String event) {
- mem.write(event);
- }
- void addError(String event, [StackTrace stackTrace]) {
- Expect.isTrue(false);
- }
- void close() {}
-}
+import 'memory_compiler.dart';
+import 'output_collector.dart';
void main() {
- Uri script = currentDirectory.resolveUri(Platform.script);
- Uri libraryRoot = script.resolve('../../../sdk/');
- Uri packageRoot = script.resolve('./packages/');
-
- var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
- var handler = new FormattingDiagnosticHandler(provider);
-
- Map<String, MemoryOutputSink> outputs = new Map<String, MemoryOutputSink>();
-
- MemoryOutputSink outputSaver(name, extension) {
- if (name == '') {
- name = 'main';
- }
- return outputs.putIfAbsent("$name.$extension", () {
- return new MemoryOutputSink();
- });
- }
-
- Compiler compiler = new Compiler(provider.readStringFromUri,
- outputSaver,
- handler.diagnosticHandler,
- libraryRoot,
- packageRoot,
- [],
- {});
+ OutputCollector collector = new OutputCollector();
+ Compiler compiler = compilerFor(
+ MEMORY_SOURCE_FILES,
+ outputProvider: collector);
asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) {
lookupLibrary(name) {
return compiler.libraryLoader.lookupLibrary(Uri.parse(name));
}
- var main = compiler.mainApp.find(dart2js.Compiler.MAIN);
+ var main = compiler.mainApp.find(Compiler.MAIN);
Expect.isNotNull(main, "Could not find 'main'");
compiler.deferredLoadTask.onResolutionComplete(main);
@@ -72,11 +38,11 @@ void main() {
var fooMain = compiler.mainApp.find("foo");
var ou_lib1_lib2 = outputUnitForElement(fooMain);
- String mainOutput = outputs["main.js"].mem.toString();
- String lib1Output = outputs["out_${ou_lib1.name}.part.js"].mem.toString();
- String lib2Output = outputs["out_${ou_lib2.name}.part.js"].mem.toString();
+ String mainOutput = collector.getOutput("","js");
+ String lib1Output = collector.getOutput("out_${ou_lib1.name}", "part.js");
+ String lib2Output = collector.getOutput("out_${ou_lib2.name}", "part.js");
String lib12Output =
- outputs["out_${ou_lib1_lib2.name}.part.js"].mem.toString();
+ collector.getOutput("out_${ou_lib1_lib2.name}", "part.js");
// Test that the deferred constants are not inlined into the main file.
RegExp re1 = new RegExp(r"= .string1");
RegExp re2 = new RegExp(r"= .string2");

Powered by Google App Engine
This is Rietveld 408576698