Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 } | |
| OLD | NEW |