| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Test that the compiler can handle imports when package root has not been set. | 5 // Test that the compiler can handle imports when package root has not been set. |
| 6 | 6 |
| 7 library dart2js.test.missing_file; | 7 library dart2js.test.missing_file; |
| 8 | 8 |
| 9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
| 10 import "package:async_helper/async_helper.dart"; | 10 import "package:async_helper/async_helper.dart"; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 void diagnosticHandler(Uri uri, int begin, int end, String message, | 41 void diagnosticHandler(Uri uri, int begin, int end, String message, |
| 42 Diagnostic kind) { | 42 Diagnostic kind) { |
| 43 if (kind == Diagnostic.ERROR) { | 43 if (kind == Diagnostic.ERROR) { |
| 44 errors.add(message); | 44 errors.add(message); |
| 45 } | 45 } |
| 46 handler(uri, begin, end, message, kind); | 46 handler(uri, begin, end, message, kind); |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 EventSink<String> outputProvider(String name, String extension) { | 50 EventSink<String> outputProvider(String name, String extension) { |
| 51 if (name != '') throw 'Attempt to output file "$name.$extension"'; | 51 if (name != '' && name != 'precompiled') { |
| 52 throw 'Attempt to output file "$name.$extension"'; |
| 53 } |
| 52 return new NullSink('$name.$extension'); | 54 return new NullSink('$name.$extension'); |
| 53 } | 55 } |
| 54 | 56 |
| 55 Compiler compiler = new Compiler(provider, | 57 Compiler compiler = new Compiler(provider, |
| 56 outputProvider, | 58 outputProvider, |
| 57 diagnosticHandler, | 59 diagnosticHandler, |
| 58 libraryRoot, | 60 libraryRoot, |
| 59 null, | 61 null, |
| 60 []); | 62 []); |
| 61 | 63 |
| 62 asyncTest(() => compiler.run(main).then((_) { | 64 asyncTest(() => compiler.run(main).then((_) { |
| 63 Expect.equals(1, errors.length); | 65 Expect.equals(1, errors.length); |
| 64 Expect.equals(expectedMessage, | 66 Expect.equals(expectedMessage, |
| 65 errors[0]); | 67 errors[0]); |
| 66 })); | 68 })); |
| 67 } | 69 } |
| 68 | 70 |
| 69 void main() { | 71 void main() { |
| 70 runCompiler(Uri.parse('memory:main.dart'), | 72 runCompiler(Uri.parse('memory:main.dart'), |
| 71 "Error: Can't read 'memory:foo.dart' " | 73 "Error: Can't read 'memory:foo.dart' " |
| 72 "(Exception: No such file memory:foo.dart)."); | 74 "(Exception: No such file memory:foo.dart)."); |
| 73 runCompiler(Uri.parse('memory:foo.dart'), | 75 runCompiler(Uri.parse('memory:foo.dart'), |
| 74 "Error: Can't read 'memory:foo.dart' " | 76 "Error: Can't read 'memory:foo.dart' " |
| 75 "(Exception: No such file memory:foo.dart)."); | 77 "(Exception: No such file memory:foo.dart)."); |
| 76 runCompiler(Uri.parse('dart:foo'), | 78 runCompiler(Uri.parse('dart:foo'), |
| 77 'Error: Library not found "dart:foo".'); | 79 'Error: Library not found "dart:foo".'); |
| 78 } | 80 } |
| OLD | NEW |