Index: tests/compiler/dart2js/deferred_dont_inline_deferred_globals_test.dart |
diff --git a/tests/compiler/dart2js/deferred_dont_inline_deferred_globals_test.dart b/tests/compiler/dart2js/deferred_dont_inline_deferred_globals_test.dart |
index 2868661fe1ed70914a108876f567b1144993ee92..4f516e49acdb304e04572074ca3bfd7437ad21b9 100644 |
--- a/tests/compiler/dart2js/deferred_dont_inline_deferred_globals_test.dart |
+++ b/tests/compiler/dart2js/deferred_dont_inline_deferred_globals_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); |
@@ -65,8 +31,8 @@ void main() { |
var foo1 = lib1.find("finalVar"); |
var ou_lib1 = outputUnitForElement(foo1); |
- String mainOutput = outputs["main.js"].mem.toString(); |
- String lib1Output = outputs["out_${ou_lib1.name}.part.js"].mem.toString(); |
+ String mainOutput = collector.getOutput("", "js"); |
+ String lib1Output = collector.getOutput("out_${ou_lib1.name}", "part.js"); |
// Test that the deferred globals are not inlined into the main file. |
RegExp re1 = new RegExp(r"= .string1"); |
RegExp re2 = new RegExp(r"= .string2"); |