Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1124)

Side by Side Diff: tests/compiler/dart2js/import_test.dart

Issue 1564803002: Specialize message for parts as entry point (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/compiler/dart2js/diagnostic_helper.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'package:async_helper/async_helper.dart';
12 import 'package:compiler/src/diagnostics/messages.dart';
13 import 'package:compiler/compiler.dart';
12 import 'memory_compiler.dart'; 14 import 'memory_compiler.dart';
13 15
14 const MEMORY_SOURCE_FILES = const { 16 const MEMORY_SOURCE_FILES = const {
15 'main.dart': ''' 17 'main.dart': '''
16 18
17 library main; 19 library main;
18 20
19 import 'dart:thisLibraryShouldNotExist'; 21 import 'dart:thisLibraryShouldNotExist';
20 import 'package:thisPackageShouldNotExist/thisPackageShouldNotExist.dart'; 22 import 'package:thisPackageShouldNotExist/thisPackageShouldNotExist.dart';
21 export 'foo.dart'; 23 export 'foo.dart';
22 24
23 part 'bar.dart'; 25 part 'bar.dart';
24 26
25 main() { 27 main() {
26 int i = ""; 28 int i = "";
27 } 29 }
28 ''', 30 ''',
31 'part.dart': '''
32 part of lib;
33
34 main() {}
35 ''',
36 'lib.dart': '''
37 library lib;
38
39 import 'part.dart';
40
41 part 'part.dart';
42 ''',
29 }; 43 };
30 44
45 testEntryPointIsPart() async {
46 var collector = new DiagnosticCollector();
47 await runCompiler(
48 entryPoint: Uri.parse('memory:part.dart'),
49 memorySourceFiles: MEMORY_SOURCE_FILES,
50 diagnosticHandler: collector);
51
52 collector.checkMessages([
53 const Expected.error(MessageKind.MAIN_HAS_PART_OF)]);
54 }
55
56 testImportPart() async {
57 var collector = new DiagnosticCollector();
58 await runCompiler(
59 entryPoint: Uri.parse('memory:lib.dart'),
60 memorySourceFiles: MEMORY_SOURCE_FILES,
61 diagnosticHandler: collector);
62
63 collector.checkMessages([
64 const Expected.error(MessageKind.IMPORT_PART_OF),
65 const Expected.info(MessageKind.IMPORT_PART_OF_HERE)]);
66 }
67
31 testMissingImports() async { 68 testMissingImports() async {
32 var collector = new DiagnosticCollector(); 69 var collector = new DiagnosticCollector();
33 await runCompiler( 70 await runCompiler(
34 memorySourceFiles: MEMORY_SOURCE_FILES, 71 memorySourceFiles: MEMORY_SOURCE_FILES,
35 diagnosticHandler: collector); 72 diagnosticHandler: collector);
36 Expect.equals(4, collector.errors.length); 73
37 Expect.equals(1, collector.warnings.length); 74 collector.checkMessages([
75 const Expected.error(MessageKind.READ_SCRIPT_ERROR),
76 const Expected.error(MessageKind.LIBRARY_NOT_FOUND),
77 const Expected.error(MessageKind.READ_SCRIPT_ERROR),
78 const Expected.error(MessageKind.READ_SCRIPT_ERROR),
79 const Expected.warning(MessageKind.NOT_ASSIGNABLE)]);
38 } 80 }
39 81
40 testMissingMain() async { 82 testMissingMain() async {
41 var collector = new DiagnosticCollector(); 83 var collector = new DiagnosticCollector();
42 await runCompiler( 84 await runCompiler(
43 entryPoint: Uri.parse('memory:missing.dart'), 85 entryPoint: Uri.parse('memory:missing.dart'),
44 diagnosticHandler: collector); 86 diagnosticHandler: collector);
45 Expect.equals(1, collector.errors.length); 87 collector.checkMessages([
46 Expect.equals(0, collector.warnings.length); 88 const Expected.error(MessageKind.READ_SELF_ERROR)]);
47 } 89 }
48 90
49 void main() { 91 void main() {
50 asyncTest(() async { 92 asyncTest(() async {
93 await testEntryPointIsPart();
94 await testImportPart();
51 await testMissingImports(); 95 await testMissingImports();
52 await testMissingMain(); 96 await testMissingMain();
53 }); 97 });
54 } 98 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/diagnostic_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698