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

Side by Side Diff: dart/tests/compiler/dart2js/package_root_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.package_root; 7 library dart2js.test.package_root;
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 'package:foo/foo.dart'; 24 import 'package:foo/foo.dart';
25 25
26 main() {} 26 main() {}
27 ''', 27 ''',
28 }; 28 };
29 29
30 void runCompiler(Uri main) { 30 void runCompiler(Uri main) {
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("Cannot resolve 'package:foo/foo.dart'. " 63 Expect.isTrue(
63 "Package root has not been set.", 64 errors[0].startsWith(
64 errors[0]); 65 "Can't read 'package:foo/foo.dart' (Error reading "));
65 })); 66 }));
66 } 67 }
67 68
68 void main() { 69 void main() {
69 runCompiler(Uri.parse('memory:main.dart')); 70 runCompiler(Uri.parse('memory:main.dart'));
70 runCompiler(Uri.parse('package:foo/foo.dart')); 71 runCompiler(Uri.parse('package:foo/foo.dart'));
71 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698