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'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 import 'dart:thisLibraryShouldNotExist'; | 21 import 'dart:thisLibraryShouldNotExist'; |
22 import 'package:thisPackageShouldNotExist/thisPackageShouldNotExist.dart'; | 22 import 'package:thisPackageShouldNotExist/thisPackageShouldNotExist.dart'; |
23 export 'foo.dart'; | 23 export 'foo.dart'; |
24 | 24 |
25 part 'bar.dart'; | 25 part 'bar.dart'; |
26 | 26 |
27 main() { | 27 main() { |
28 int i = ""; | 28 int i = ""; |
29 } | 29 } |
30 ''', | 30 ''', |
31 'part.dart': ''' | 31 'part.dart': ''' |
32 part of lib; | 32 part of lib; |
33 | 33 |
34 main() {} | 34 main() {} |
35 ''', | 35 ''', |
36 'lib.dart': ''' | 36 'lib.dart': ''' |
37 library lib; | 37 library lib; |
38 | 38 |
39 import 'part.dart'; | 39 import 'part.dart'; |
40 | 40 |
41 part 'part.dart'; | 41 part 'part.dart'; |
42 ''', | 42 ''', |
43 }; | 43 }; |
44 | 44 |
45 testEntryPointIsPart() async { | 45 testEntryPointIsPart() async { |
46 var collector = new DiagnosticCollector(); | 46 var collector = new DiagnosticCollector(); |
47 await runCompiler( | 47 await runCompiler( |
48 entryPoint: Uri.parse('memory:part.dart'), | 48 entryPoint: Uri.parse('memory:part.dart'), |
49 memorySourceFiles: MEMORY_SOURCE_FILES, | 49 memorySourceFiles: MEMORY_SOURCE_FILES, |
50 diagnosticHandler: collector); | 50 diagnosticHandler: collector); |
51 | 51 |
52 collector.checkMessages([ | 52 collector.checkMessages([const Expected.error(MessageKind.MAIN_HAS_PART_OF)]); |
53 const Expected.error(MessageKind.MAIN_HAS_PART_OF)]); | |
54 } | 53 } |
55 | 54 |
56 testImportPart() async { | 55 testImportPart() async { |
57 var collector = new DiagnosticCollector(); | 56 var collector = new DiagnosticCollector(); |
58 await runCompiler( | 57 await runCompiler( |
59 entryPoint: Uri.parse('memory:lib.dart'), | 58 entryPoint: Uri.parse('memory:lib.dart'), |
60 memorySourceFiles: MEMORY_SOURCE_FILES, | 59 memorySourceFiles: MEMORY_SOURCE_FILES, |
61 diagnosticHandler: collector); | 60 diagnosticHandler: collector); |
62 | 61 |
63 collector.checkMessages([ | 62 collector.checkMessages([ |
64 const Expected.error(MessageKind.IMPORT_PART_OF), | 63 const Expected.error(MessageKind.IMPORT_PART_OF), |
65 const Expected.info(MessageKind.IMPORT_PART_OF_HERE)]); | 64 const Expected.info(MessageKind.IMPORT_PART_OF_HERE) |
| 65 ]); |
66 } | 66 } |
67 | 67 |
68 testMissingImports() async { | 68 testMissingImports() async { |
69 var collector = new DiagnosticCollector(); | 69 var collector = new DiagnosticCollector(); |
70 await runCompiler( | 70 await runCompiler( |
71 memorySourceFiles: MEMORY_SOURCE_FILES, | 71 memorySourceFiles: MEMORY_SOURCE_FILES, diagnosticHandler: collector); |
72 diagnosticHandler: collector); | |
73 | 72 |
74 collector.checkMessages([ | 73 collector.checkMessages([ |
75 const Expected.error(MessageKind.READ_SCRIPT_ERROR), | 74 const Expected.error(MessageKind.READ_SCRIPT_ERROR), |
76 const Expected.error(MessageKind.LIBRARY_NOT_FOUND), | 75 const Expected.error(MessageKind.LIBRARY_NOT_FOUND), |
77 const Expected.error(MessageKind.LIBRARY_NOT_FOUND), | 76 const Expected.error(MessageKind.LIBRARY_NOT_FOUND), |
78 const Expected.error(MessageKind.READ_SCRIPT_ERROR), | 77 const Expected.error(MessageKind.READ_SCRIPT_ERROR), |
79 const Expected.warning(MessageKind.NOT_ASSIGNABLE)]); | 78 const Expected.warning(MessageKind.NOT_ASSIGNABLE) |
| 79 ]); |
80 } | 80 } |
81 | 81 |
82 testMissingMain() async { | 82 testMissingMain() async { |
83 var collector = new DiagnosticCollector(); | 83 var collector = new DiagnosticCollector(); |
84 await runCompiler( | 84 await runCompiler( |
85 entryPoint: Uri.parse('memory:missing.dart'), | 85 entryPoint: Uri.parse('memory:missing.dart'), |
86 diagnosticHandler: collector); | 86 diagnosticHandler: collector); |
87 collector.checkMessages([ | 87 collector.checkMessages([const Expected.error(MessageKind.READ_SELF_ERROR)]); |
88 const Expected.error(MessageKind.READ_SELF_ERROR)]); | |
89 } | 88 } |
90 | 89 |
91 void main() { | 90 void main() { |
92 asyncTest(() async { | 91 asyncTest(() async { |
93 await testEntryPointIsPart(); | 92 await testEntryPointIsPart(); |
94 await testImportPart(); | 93 await testImportPart(); |
95 await testMissingImports(); | 94 await testMissingImports(); |
96 await testMissingMain(); | 95 await testMissingMain(); |
97 }); | 96 }); |
98 } | 97 } |
OLD | NEW |