| 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 missing files used in imports, exports, | 5 // Test that the compiler can handle missing files used in imports, exports, |
| 6 // part tags or as the main source file. | 6 // part tags or as the main source file. |
| 7 | 7 |
| 8 library dart2js.test.import; | 8 library dart2js.test.import; |
| 9 | 9 |
| 10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| 11 import "package:async_helper/async_helper.dart"; |
| 11 import 'memory_compiler.dart'; | 12 import 'memory_compiler.dart'; |
| 12 | 13 |
| 13 const MEMORY_SOURCE_FILES = const { | 14 const MEMORY_SOURCE_FILES = const { |
| 14 'main.dart': ''' | 15 'main.dart': ''' |
| 15 | 16 |
| 16 library main; | 17 library main; |
| 17 | 18 |
| 18 import 'dart:thisLibraryShouldNotExist'; | 19 import 'dart:thisLibraryShouldNotExist'; |
| 19 import 'package:thisPackageShouldNotExist/thisPackageShouldNotExist.dart'; | 20 import 'package:thisPackageShouldNotExist/thisPackageShouldNotExist.dart'; |
| 20 export 'foo.dart'; | 21 export 'foo.dart'; |
| 21 | 22 |
| 22 part 'bar.dart'; | 23 part 'bar.dart'; |
| 23 | 24 |
| 24 main() { | 25 main() { |
| 25 int i = ""; | 26 int i = ""; |
| 26 } | 27 } |
| 27 ''', | 28 ''', |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 testMissingImports() { | 31 testMissingImports() { |
| 31 var collector = new DiagnosticCollector(); | 32 var collector = new DiagnosticCollector(); |
| 32 var compiler = compilerFor(MEMORY_SOURCE_FILES, diagnosticHandler: collector); | 33 var compiler = compilerFor(MEMORY_SOURCE_FILES, diagnosticHandler: collector); |
| 33 compiler.run(Uri.parse('memory:main.dart')); | 34 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 34 Expect.equals(4, collector.errors.length); | 35 Expect.equals(4, collector.errors.length); |
| 35 Expect.equals(1, collector.warnings.length); | 36 Expect.equals(1, collector.warnings.length); |
| 37 })); |
| 36 } | 38 } |
| 37 | 39 |
| 38 testMissingMain() { | 40 testMissingMain() { |
| 39 var collector = new DiagnosticCollector(); | 41 var collector = new DiagnosticCollector(); |
| 40 var compiler = compilerFor({}, diagnosticHandler: collector); | 42 var compiler = compilerFor({}, diagnosticHandler: collector); |
| 41 compiler.run(Uri.parse('memory:missing.dart')); | 43 asyncTest(() => compiler.run(Uri.parse('memory:missing.dart')).then((_) { |
| 42 Expect.equals(1, collector.errors.length); | 44 Expect.equals(1, collector.errors.length); |
| 43 Expect.equals(0, collector.warnings.length); | 45 Expect.equals(0, collector.warnings.length); |
| 46 })); |
| 44 } | 47 } |
| 45 | 48 |
| 46 void main() { | 49 void main() { |
| 47 testMissingImports(); | 50 testMissingImports(); |
| 48 testMissingMain(); | 51 testMissingMain(); |
| 49 } | 52 } |
| OLD | NEW |