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

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

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
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 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 'dart:async'; 9 import 'dart:async';
10 import 'package:async_helper/async_helper.dart'; 10 import 'package:async_helper/async_helper.dart';
11 import "package:compiler/src/diagnostics/messages.dart"; 11 import "package:compiler/src/diagnostics/messages.dart";
12 import 'package:expect/expect.dart'; 12 import 'package:expect/expect.dart';
13 import 'memory_compiler.dart'; 13 import 'memory_compiler.dart';
14 14
15 const MEMORY_SOURCE_FILES = const { 15 const MEMORY_SOURCE_FILES = const {
16 'main.dart': ''' 16 'main.dart': '''
17 import 'foo.dart'; 17 import 'foo.dart';
18 main() {} 18 main() {}
19 ''', 19 ''',
20 20 'bar.dart': '''
21 'bar.dart': '''
22 import 'dart:foo'; 21 import 'dart:foo';
23 main() {} 22 main() {}
24 ''', 23 ''',
25 24 'baz.dart': '''
26 'baz.dart': '''
27 import 'dart:io'; 25 import 'dart:io';
28 main() {} 26 main() {}
29 ''', 27 ''',
30 }; 28 };
31 29
32 Future runTest(Uri main, 30 Future runTest(Uri main, {MessageKind error, MessageKind info}) async {
33 {MessageKind error,
34 MessageKind info}) async {
35 print("----\nentry-point: $main\n"); 31 print("----\nentry-point: $main\n");
36 32
37 DiagnosticCollector diagnostics = new DiagnosticCollector(); 33 DiagnosticCollector diagnostics = new DiagnosticCollector();
38 OutputCollector output = new OutputCollector(); 34 OutputCollector output = new OutputCollector();
39 await runCompiler( 35 await runCompiler(
40 entryPoint: main, 36 entryPoint: main,
41 memorySourceFiles: MEMORY_SOURCE_FILES, 37 memorySourceFiles: MEMORY_SOURCE_FILES,
42 diagnosticHandler: diagnostics, 38 diagnosticHandler: diagnostics,
43 outputProvider: output); 39 outputProvider: output);
44 40
45 Expect.isFalse(output.hasExtraOutput); 41 Expect.isFalse(output.hasExtraOutput);
46 Expect.equals(error != null ? 1 : 0, diagnostics.errors.length); 42 Expect.equals(error != null ? 1 : 0, diagnostics.errors.length);
47 if (error != null) { 43 if (error != null) {
48 Expect.equals(error, diagnostics.errors.first.message.kind); 44 Expect.equals(error, diagnostics.errors.first.message.kind);
49 } 45 }
50 Expect.equals(info != null ? 1 : 0, diagnostics.infos.length); 46 Expect.equals(info != null ? 1 : 0, diagnostics.infos.length);
51 if (info != null) { 47 if (info != null) {
52 Expect.equals(info, diagnostics.infos.first.message.kind); 48 Expect.equals(info, diagnostics.infos.first.message.kind);
53 } 49 }
54 Expect.equals(0, diagnostics.warnings.length); 50 Expect.equals(0, diagnostics.warnings.length);
55 Expect.equals(0, diagnostics.hints.length); 51 Expect.equals(0, diagnostics.hints.length);
56 } 52 }
57 53
58 void main() { 54 void main() {
59 asyncTest(() async { 55 asyncTest(() async {
60 await runTest( 56 await runTest(Uri.parse('memory:main.dart'),
61 Uri.parse('memory:main.dart'),
62 error: MessageKind.READ_SCRIPT_ERROR); 57 error: MessageKind.READ_SCRIPT_ERROR);
63 58
64 await runTest( 59 await runTest(Uri.parse('memory:foo.dart'),
65 Uri.parse('memory:foo.dart'),
66 error: MessageKind.READ_SELF_ERROR); 60 error: MessageKind.READ_SELF_ERROR);
67 61
68 await runTest( 62 await runTest(Uri.parse('dart:foo'), error: MessageKind.LIBRARY_NOT_FOUND);
69 Uri.parse('dart:foo'),
70 error: MessageKind.LIBRARY_NOT_FOUND);
71 63
72 await runTest( 64 await runTest(Uri.parse('dart:io'),
73 Uri.parse('dart:io'),
74 error: MessageKind.LIBRARY_NOT_SUPPORTED, 65 error: MessageKind.LIBRARY_NOT_SUPPORTED,
75 info: MessageKind.DISALLOWED_LIBRARY_IMPORT); 66 info: MessageKind.DISALLOWED_LIBRARY_IMPORT);
76 67
77 await runTest( 68 await runTest(Uri.parse('memory:bar.dart'),
78 Uri.parse('memory:bar.dart'),
79 error: MessageKind.LIBRARY_NOT_FOUND); 69 error: MessageKind.LIBRARY_NOT_FOUND);
80 70
81 await runTest( 71 await runTest(Uri.parse('memory:baz.dart'),
82 Uri.parse('memory:baz.dart'),
83 error: MessageKind.LIBRARY_NOT_SUPPORTED, 72 error: MessageKind.LIBRARY_NOT_SUPPORTED,
84 info: MessageKind.DISALLOWED_LIBRARY_IMPORT); 73 info: MessageKind.DISALLOWED_LIBRARY_IMPORT);
85 }); 74 });
86 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698