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

Side by Side 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: Remove withCurrentElementAsync Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:async";
6 import "dart:io";
7
8 import "package:expect/expect.dart";
9
10 import '../../../sdk/lib/_internal/compiler/compiler.dart' as compiler;
11 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
12
13 const SOURCES = const {
14 "/main.dart": """
15 import "foo.dart";
16 main() => foo();
17 """,
18 "/foo.dart": """
19 library foo;
20 import "bar.dart";
21 foo() => bar();
22 """,
23 "/bar.dart": """
24 library bar;
25 bar() => print("bar");
26 """
27 };
28
29 Future<String> provideInput(Uri uri) {
30 var source = SOURCES[uri.path];
31 if (source == null) {
32 // Not one of our source files, so assume it's a built-in.
33 source = new File(uriPathToNative(uri.path)).readAsStringSync();
34 }
35
36 // Deliver the input asynchronously.
37 return new Future(() => source);
38 }
39
40 main() {
41 var entrypoint = Uri.parse("file:///main.dart");
42
43 // Find the path to sdk/ in the repo relative to this script.
44 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script));
45 Uri libraryRoot = script.resolve('../../../sdk/');
46 Uri packageRoot = script.resolve('./packages/');
47
48 compiler.compile(entrypoint, libraryRoot, packageRoot,
49 provideInput, handleDiagnostic, []).then((code) {
ahe 2013/08/06 16:29:17 Needs dart/tests/async_helper.dart.
Johnni Winther 2013/08/27 11:05:00 Done.
50 Expect.isNotNull(code);
51 });
52 }
53
54 void handleDiagnostic(Uri uri, int begin, int end, String message,
55 compiler.Diagnostic kind) {
56 print(message);
57 // Do nothing.
58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698