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

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

Issue 2781423003: Start preparing tests to accept binary compiler input. (Closed)
Patch Set: .. Created 3 years, 9 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
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/memory_source_file_helper.dart
diff --git a/tests/compiler/dart2js/memory_source_file_helper.dart b/tests/compiler/dart2js/memory_source_file_helper.dart
index a198aefdbd1e556177b006c65d58b02f760d7b47..53521cdda4fda7ced7d9b842f121380416b3a72e 100644
--- a/tests/compiler/dart2js/memory_source_file_helper.dart
+++ b/tests/compiler/dart2js/memory_source_file_helper.dart
@@ -12,7 +12,7 @@ export 'package:compiler/src/apiimpl.dart' show CompilerImpl;
export 'package:compiler/src/filenames.dart' show currentDirectory;
import 'package:compiler/src/io/source_file.dart'
- show StringSourceFile, SourceFile;
+ show StringSourceFile, SourceFile, Utf8BytesSourceFile;
import 'package:compiler/src/source_file_provider.dart' show SourceFileProvider;
@@ -20,38 +20,48 @@ export 'package:compiler/src/source_file_provider.dart'
show SourceFileProvider, FormattingDiagnosticHandler;
class MemorySourceFileProvider extends SourceFileProvider {
- Map<String, String> memorySourceFiles;
+ Map<String, dynamic> memorySourceFiles;
- MemorySourceFileProvider(Map<String, String> this.memorySourceFiles);
+ /// MemorySourceFiles can contain maps of file names to string contents or
+ /// file names to binary contents.
+ MemorySourceFileProvider(Map<String, dynamic> this.memorySourceFiles);
- Future<String> readStringFromUri(Uri resourceUri) {
+ Future<List<int>> readUtf8BytesFromUri(Uri resourceUri) {
if (resourceUri.scheme != 'memory') {
- return super.readStringFromUri(resourceUri);
+ return super.readUtf8BytesFromUri(resourceUri);
}
- String source = memorySourceFiles[resourceUri.path];
+ var source = memorySourceFiles[resourceUri.path];
if (source == null) {
return new Future.error(new Exception(
'No such memory file $resourceUri in ${memorySourceFiles.keys}'));
}
- this.sourceFiles[resourceUri] =
- new StringSourceFile.fromUri(resourceUri, source);
+ var sourceFile;
+ if (source is String) {
+ sourceFile = new StringSourceFile.fromUri(resourceUri, source);
+ } else {
+ sourceFile = new Utf8BytesSourceFile(resourceUri, source);
+ }
+ this.sourceFiles[resourceUri] = sourceFile;
return new Future.value(source);
}
- Future<String> call(Uri resourceUri) => readStringFromUri(resourceUri);
+ Future<List<int>> call(Uri resourceUri) => readUtf8BytesFromUri(resourceUri);
SourceFile getSourceFile(Uri resourceUri) {
if (resourceUri.scheme != 'memory') {
return super.getSourceFile(resourceUri);
}
- String source = memorySourceFiles[resourceUri.path];
+ var source = memorySourceFiles[resourceUri.path];
if (source == null) {
throw new Exception(
'No such memory file $resourceUri in ${memorySourceFiles.keys}');
}
- return new StringSourceFile.fromUri(resourceUri, source);
+ if (source is String) {
+ return new StringSourceFile.fromUri(resourceUri, source);
+ }
+ return new Utf8BytesSourceFile(resourceUri, source);
}
@override
- Future readFromUri(Uri resourceUri) => readStringFromUri(resourceUri);
+ Future readFromUri(Uri resourceUri) => readUtf8BytesFromUri(resourceUri);
}
« no previous file with comments | « tests/compiler/dart2js/memory_compiler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698