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

Unified Diff: tests/compiler/dart2js/async_compiler_input_provider_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: Updated cf. comments Created 7 years, 3 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/analyze_only_test.dart ('k') | tests/compiler/dart2js/bad_loop_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/async_compiler_input_provider_test.dart
diff --git a/tests/compiler/dart2js/async_compiler_input_provider_test.dart b/tests/compiler/dart2js/async_compiler_input_provider_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9b8a8264039f30e7b5e712c6bd04b5118e08129c
--- /dev/null
+++ b/tests/compiler/dart2js/async_compiler_input_provider_test.dart
@@ -0,0 +1,62 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// 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 "dart:io";
+
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+
+import '../../../sdk/lib/_internal/compiler/compiler.dart' as compiler;
+import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
+
+const SOURCES = const {
+ "/main.dart": """
+ import "foo.dart";
+ main() => foo();
+ """,
+ "/foo.dart": """
+ library foo;
+ import "bar.dart";
+ foo() => bar();
+ """,
+ "/bar.dart": """
+ library bar;
+ bar() => print("bar");
+ """
+};
+
+Future<String> provideInput(Uri uri) {
+ var source = SOURCES[uri.path];
+ if (source == null) {
+ // Not one of our source files, so assume it's a built-in.
+ source = new File(uriPathToNative(uri.path)).readAsStringSync();
+ }
+
+ // Deliver the input asynchronously.
+ return new Future(() => source);
+}
+
+main() {
+ var entrypoint = Uri.parse("file:///main.dart");
+
+ // Find the path to sdk/ in the repo relative to this script.
+ Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script));
+ Uri libraryRoot = script.resolve('../../../sdk/');
+ Uri packageRoot = script.resolve('./packages/');
+
+ asyncStart();
+ compiler.compile(entrypoint, libraryRoot, packageRoot,
+ provideInput, handleDiagnostic, []).then((code) {
+ Expect.isNotNull(code);
+ }).whenComplete(() => asyncEnd());
+}
+
+void handleDiagnostic(Uri uri, int begin, int end, String message,
+ compiler.Diagnostic kind) {
+ print(message);
+ if (kind != compiler.Diagnostic.VERBOSE_INFO) {
+ throw 'Unexpected diagnostic kind $kind';
+ }
+}
« no previous file with comments | « tests/compiler/dart2js/analyze_only_test.dart ('k') | tests/compiler/dart2js/bad_loop_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698