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 library part_of_test; | 5 library part_of_test; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
9 import 'package:compiler/src/diagnostics/messages.dart' show | 9 import 'package:compiler/src/diagnostics/messages.dart' show MessageKind; |
10 MessageKind; | |
11 import 'mock_compiler.dart'; | 10 import 'mock_compiler.dart'; |
12 | 11 |
13 final libraryUri = Uri.parse('test:library.dart'); | 12 final libraryUri = Uri.parse('test:library.dart'); |
14 const String LIBRARY_SOURCE = ''' | 13 const String LIBRARY_SOURCE = ''' |
15 library foo; | 14 library foo; |
16 part 'part.dart'; | 15 part 'part.dart'; |
17 '''; | 16 '''; |
18 | 17 |
19 final partUri = Uri.parse('test:part.dart'); | 18 final partUri = Uri.parse('test:part.dart'); |
20 const String PART_SOURCE = ''' | 19 const String PART_SOURCE = ''' |
21 part of bar; | 20 part of bar; |
22 '''; | 21 '''; |
23 | 22 |
24 void main() { | 23 void main() { |
25 MockCompiler compiler = new MockCompiler.internal(); | 24 MockCompiler compiler = new MockCompiler.internal(); |
26 compiler.registerSource(libraryUri, LIBRARY_SOURCE); | 25 compiler.registerSource(libraryUri, LIBRARY_SOURCE); |
27 compiler.registerSource(partUri, PART_SOURCE); | 26 compiler.registerSource(partUri, PART_SOURCE); |
28 | 27 |
29 asyncTest(() => compiler.libraryLoader.loadLibrary(libraryUri).then((_) { | 28 asyncTest(() => compiler.libraryLoader.loadLibrary(libraryUri).then((_) { |
30 DiagnosticCollector collector = compiler.diagnosticCollector; | 29 DiagnosticCollector collector = compiler.diagnosticCollector; |
31 print('errors: ${collector.errors}'); | 30 print('errors: ${collector.errors}'); |
32 print('warnings: ${collector.warnings}'); | 31 print('warnings: ${collector.warnings}'); |
33 Expect.isTrue(collector.errors.isEmpty); | 32 Expect.isTrue(collector.errors.isEmpty); |
34 Expect.equals(1, collector.warnings.length); | 33 Expect.equals(1, collector.warnings.length); |
35 Expect.equals(MessageKind.LIBRARY_NAME_MISMATCH, | 34 Expect.equals(MessageKind.LIBRARY_NAME_MISMATCH, |
36 collector.warnings.first.messageKind); | 35 collector.warnings.first.messageKind); |
37 Expect.equals('foo', | 36 Expect.equals( |
38 collector.warnings.first.message.arguments['libraryName'].toString()); | 37 'foo', |
39 })); | 38 collector.warnings.first.message.arguments['libraryName'] |
| 39 .toString()); |
| 40 })); |
40 } | 41 } |
OLD | NEW |