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

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: 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 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.
Bob Nystrom 2013/06/26 01:03:24 This is the new test. This fails with the current
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
12 const SOURCES = const {
13 "/main.dart": """
14 import "foo.dart";
15 main() => foo();
16 """,
17 "/foo.dart": """
18 library foo;
19 import "bar.dart";
20 foo() => bar();
21 """,
22 "/bar.dart": """
23 library bar;
24 bar() => print("bar");
25 """
26 };
27
28 Future<String> provideInput(Uri uri) {
29 var source = SOURCES[uri.path];
30 if (source == null) {
31 // Not one of our source files, so assume it's a built-in.
32 source = new File(uri.path).readAsStringSync();
33 }
34
35 // Deliver the input asynchronously.
36 return new Future(() => source);
Bob Nystrom 2013/06/26 01:03:24 If you do new Future.value(source) here, the test
37 }
38
39 main() {
40 var entrypoint = Uri.parse("file:///main.dart");
41
42 // Find the path to sdk/ in the repo relative to this script.
43 var scriptPath = new Path(new File(new Options().script).fullPathSync());
44 var libPath = scriptPath.join(new Path("../../../../sdk/")).canonicalize();
45 var libUri = new Uri(scheme: "file", path: libPath.toString());
46
47 compiler.compile(entrypoint, libUri, null,
48 provideInput, handleDiagnostic, []).then((code) {
49 Expect.isNotNull(code);
50 });
51 }
52
53 void handleDiagnostic(Uri uri, int begin, int end, String message,
54 compiler.Diagnostic kind) {
55 print(message);
56 // Do nothing.
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698