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

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

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/source_mapping_test.dart
diff --git a/tests/compiler/dart2js/source_mapping_test.dart b/tests/compiler/dart2js/source_mapping_test.dart
index 3cccbbdeef9d10292ee4d9f7b2aea9a64fe53edc..4b0f57e5ed96b8bacb113166df8331d640a2c467 100644
--- a/tests/compiler/dart2js/source_mapping_test.dart
+++ b/tests/compiler/dart2js/source_mapping_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:async';
import "package:expect/expect.dart";
import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart";
@@ -9,12 +10,13 @@ import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
import "mock_compiler.dart";
import 'parser_helper.dart';
-CodeBuffer compileAll(SourceFile sourceFile) {
+Future<CodeBuffer> compileAll(SourceFile sourceFile) {
MockCompiler compiler = new MockCompiler();
Uri uri = new Uri(path: sourceFile.filename);
compiler.sourceFiles[uri.toString()] = sourceFile;
- compiler.runCompiler(uri);
- return compiler.backend.emitter.mainBuffer;
+ return compiler.runCompiler(uri).then((_) {
+ return compiler.backend.emitter.mainBuffer;
+ });
}
void testSourceMapLocations(String codeWithMarkers) {
@@ -27,27 +29,27 @@ void testSourceMapLocations(String codeWithMarkers) {
String code = codeWithMarkers.replaceAll('@', '');
SourceFile sourceFile = new SourceFile('<test script>', code);
- CodeBuffer buffer = compileAll(sourceFile);
-
- Set<int> locations = new Set<int>();
- buffer.forEachSourceLocation((int offset, var sourcePosition) {
- if (sourcePosition != null && sourcePosition.sourceFile == sourceFile) {
- locations.add(sourcePosition.token.charOffset);
+ compileAll(sourceFile).then((CodeBuffer buffer) {
+ Set<int> locations = new Set<int>();
+ buffer.forEachSourceLocation((int offset, var sourcePosition) {
+ if (sourcePosition != null && sourcePosition.sourceFile == sourceFile) {
+ locations.add(sourcePosition.token.charOffset);
+ }
+ });
+
+ for (int i = 0; i < expectedLocations.length; ++i) {
+ int expectedLocation = expectedLocations[i];
+ if (!locations.contains(expectedLocation)) {
+ int originalLocation = expectedLocation + i;
+ SourceFile sourceFileWithMarkers = new SourceFile('<test script>',
+ codeWithMarkers);
+ String message = sourceFileWithMarkers.getLocationMessage(
+ 'Missing location', originalLocation, originalLocation + 1, true,
+ (s) => s);
+ Expect.fail(message);
+ }
}
});
-
- for (int i = 0; i < expectedLocations.length; ++i) {
- int expectedLocation = expectedLocations[i];
- if (!locations.contains(expectedLocation)) {
- int originalLocation = expectedLocation + i;
- SourceFile sourceFileWithMarkers = new SourceFile('<test script>',
- codeWithMarkers);
- String message = sourceFileWithMarkers.getLocationMessage(
- 'Missing location', originalLocation, originalLocation + 1, true,
- (s) => s);
- Expect.fail(message);
- }
- }
}
String FUNCTIONS_TEST = '''

Powered by Google App Engine
This is Rietveld 408576698