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

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

Issue 838773002: Throw ArgumentError if packageRoot is null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 5 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 | Annotate | Revision Log
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 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
(...skipping 12 matching lines...) Expand all
23 23
24 import 'foo.dart'; 24 import 'foo.dart';
25 25
26 main() {} 26 main() {}
27 ''', 27 ''',
28 }; 28 };
29 29
30 void runCompiler(Uri main, String expectedMessage) { 30 void runCompiler(Uri main, String expectedMessage) {
31 Uri script = currentDirectory.resolveUri(Platform.script); 31 Uri script = currentDirectory.resolveUri(Platform.script);
32 Uri libraryRoot = script.resolve('../../../sdk/'); 32 Uri libraryRoot = script.resolve('../../../sdk/');
33 Uri packageRoot = script.resolve('./packages/');
33 34
34 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); 35 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
35 var handler = new FormattingDiagnosticHandler(provider); 36 var handler = new FormattingDiagnosticHandler(provider);
36 var errors = []; 37 var errors = [];
37 38
38 void diagnosticHandler(Uri uri, int begin, int end, String message, 39 void diagnosticHandler(Uri uri, int begin, int end, String message,
39 Diagnostic kind) { 40 Diagnostic kind) {
40 if (kind == Diagnostic.ERROR) { 41 if (kind == Diagnostic.ERROR) {
41 errors.add(message); 42 errors.add(message);
42 } 43 }
43 handler(uri, begin, end, message, kind); 44 handler(uri, begin, end, message, kind);
44 } 45 }
45 46
46 47
47 EventSink<String> outputProvider(String name, String extension) { 48 EventSink<String> outputProvider(String name, String extension) {
48 if (name != '') throw 'Attempt to output file "$name.$extension"'; 49 if (name != '') throw 'Attempt to output file "$name.$extension"';
49 return new NullSink('$name.$extension'); 50 return new NullSink('$name.$extension');
50 } 51 }
51 52
52 Compiler compiler = new Compiler(provider, 53 Compiler compiler = new Compiler(provider,
53 outputProvider, 54 outputProvider,
54 diagnosticHandler, 55 diagnosticHandler,
55 libraryRoot, 56 libraryRoot,
56 null, 57 packageRoot,
57 [], 58 [],
58 {}); 59 {});
59 60
60 asyncTest(() => compiler.run(main).then((_) { 61 asyncTest(() => compiler.run(main).then((_) {
61 Expect.equals(1, errors.length); 62 Expect.equals(1, errors.length);
62 Expect.equals(expectedMessage, 63 Expect.equals(expectedMessage,
63 errors[0]); 64 errors[0]);
64 })); 65 }));
65 } 66 }
66 67
67 void main() { 68 void main() {
68 runCompiler(Uri.parse('memory:main.dart'), 69 runCompiler(Uri.parse('memory:main.dart'),
69 "Can't read 'memory:foo.dart' " 70 "Can't read 'memory:foo.dart' "
70 "(Exception: No such file memory:foo.dart)."); 71 "(Exception: No such file memory:foo.dart).");
71 runCompiler(Uri.parse('memory:foo.dart'), 72 runCompiler(Uri.parse('memory:foo.dart'),
72 "Can't read 'memory:foo.dart' " 73 "Can't read 'memory:foo.dart' "
73 "(Exception: No such file memory:foo.dart)."); 74 "(Exception: No such file memory:foo.dart).");
74 runCompiler(Uri.parse('dart:foo'), 75 runCompiler(Uri.parse('dart:foo'),
75 "Library not found 'dart:foo'."); 76 "Library not found 'dart:foo'.");
76 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698