Chromium Code Reviews| 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..eb9c589db439dfa12bdb16b6e08f2251a23f982d |
| --- /dev/null |
| +++ b/tests/compiler/dart2js/async_compiler_input_provider_test.dart |
| @@ -0,0 +1,57 @@ |
| +// 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. |
|
Bob Nystrom
2013/06/26 01:03:24
This is the new test.
This fails with the current
|
| + |
| +import "dart:async"; |
| +import "dart:io"; |
| + |
| +import "package:expect/expect.dart"; |
| + |
| +import '../../../sdk/lib/_internal/compiler/compiler.dart' as compiler; |
| + |
| +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(uri.path).readAsStringSync(); |
| + } |
| + |
| + // Deliver the input asynchronously. |
| + return new Future(() => source); |
|
Bob Nystrom
2013/06/26 01:03:24
If you do new Future.value(source) here, the test
|
| +} |
| + |
| +main() { |
| + var entrypoint = Uri.parse("file:///main.dart"); |
| + |
| + // Find the path to sdk/ in the repo relative to this script. |
| + var scriptPath = new Path(new File(new Options().script).fullPathSync()); |
| + var libPath = scriptPath.join(new Path("../../../../sdk/")).canonicalize(); |
| + var libUri = new Uri(scheme: "file", path: libPath.toString()); |
| + |
| + compiler.compile(entrypoint, libUri, null, |
| + provideInput, handleDiagnostic, []).then((code) { |
| + Expect.isNotNull(code); |
| + }); |
| +} |
| + |
| +void handleDiagnostic(Uri uri, int begin, int end, String message, |
| + compiler.Diagnostic kind) { |
| + print(message); |
| + // Do nothing. |
| +} |