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

Unified Diff: dart/tests/compiler/dart2js/missing_file_test.dart

Issue 24267004: Emit CSP code in separate file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make tests pass Created 7 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 side-by-side diff with in-line comments
Download patch
Index: dart/tests/compiler/dart2js/missing_file_test.dart
diff --git a/dart/tests/compiler/dart2js/missing_file_test.dart b/dart/tests/compiler/dart2js/missing_file_test.dart
index 06b75dd8798d450c0a91233ff7ebf282b90a8645..e190483abf7742437934f33914be661dddd107b6 100644
--- a/dart/tests/compiler/dart2js/missing_file_test.dart
+++ b/dart/tests/compiler/dart2js/missing_file_test.dart
@@ -1,78 +1,80 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// Test that the compiler can handle imports when package root has not been set.
-
-library dart2js.test.missing_file;
-
-import 'package:expect/expect.dart';
-import "package:async_helper/async_helper.dart";
-import 'memory_source_file_helper.dart';
-
-import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
- show NullSink;
-
-import '../../../sdk/lib/_internal/compiler/compiler.dart'
- show DiagnosticHandler, Diagnostic;
-
-import 'dart:async';
-
-import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart';
-import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart';
-
-const MEMORY_SOURCE_FILES = const {
- 'main.dart': '''
-
-import 'foo.dart';
-
-main() {}
-''',
-};
-
-void runCompiler(Uri main, String expectedMessage) {
- Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script));
- Uri libraryRoot = script.resolve('../../../sdk/');
-
- var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
- var handler = new FormattingDiagnosticHandler(provider);
- var errors = [];
-
- void diagnosticHandler(Uri uri, int begin, int end, String message,
- Diagnostic kind) {
- if (kind == Diagnostic.ERROR) {
- errors.add(message);
- }
- handler(uri, begin, end, message, kind);
- }
-
-
- EventSink<String> outputProvider(String name, String extension) {
- if (name != '') throw 'Attempt to output file "$name.$extension"';
- return new NullSink('$name.$extension');
- }
-
- Compiler compiler = new Compiler(provider,
- outputProvider,
- diagnosticHandler,
- libraryRoot,
- null,
- []);
-
- asyncTest(() => compiler.run(main).then((_) {
- Expect.equals(1, errors.length);
- Expect.equals(expectedMessage,
- errors[0]);
- }));
-}
-
-void main() {
- runCompiler(Uri.parse('memory:main.dart'),
- "Error: Can't read 'memory:foo.dart' "
- "(Exception: No such file memory:foo.dart).");
- runCompiler(Uri.parse('memory:foo.dart'),
- "Error: Can't read 'memory:foo.dart' "
- "(Exception: No such file memory:foo.dart).");
- runCompiler(Uri.parse('dart:foo'),
- 'Error: Library not found "dart:foo".');
-}
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that the compiler can handle imports when package root has not been set.
+
+library dart2js.test.missing_file;
+
+import 'package:expect/expect.dart';
+import "package:async_helper/async_helper.dart";
+import 'memory_source_file_helper.dart';
+
+import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
+ show NullSink;
+
+import '../../../sdk/lib/_internal/compiler/compiler.dart'
+ show DiagnosticHandler, Diagnostic;
+
+import 'dart:async';
+
+import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart';
+import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirror.dart';
+
+const MEMORY_SOURCE_FILES = const {
+ 'main.dart': '''
+
+import 'foo.dart';
+
+main() {}
+''',
+};
+
+void runCompiler(Uri main, String expectedMessage) {
+ Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script));
+ Uri libraryRoot = script.resolve('../../../sdk/');
+
+ var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
+ var handler = new FormattingDiagnosticHandler(provider);
+ var errors = [];
+
+ void diagnosticHandler(Uri uri, int begin, int end, String message,
+ Diagnostic kind) {
+ if (kind == Diagnostic.ERROR) {
+ errors.add(message);
+ }
+ handler(uri, begin, end, message, kind);
+ }
+
+
+ EventSink<String> outputProvider(String name, String extension) {
+ if (name != '' && name != 'precompiled') {
+ throw 'Attempt to output file "$name.$extension"';
+ }
+ return new NullSink('$name.$extension');
+ }
+
+ Compiler compiler = new Compiler(provider,
+ outputProvider,
+ diagnosticHandler,
+ libraryRoot,
+ null,
+ []);
+
+ asyncTest(() => compiler.run(main).then((_) {
+ Expect.equals(1, errors.length);
+ Expect.equals(expectedMessage,
+ errors[0]);
+ }));
+}
+
+void main() {
+ runCompiler(Uri.parse('memory:main.dart'),
+ "Error: Can't read 'memory:foo.dart' "
+ "(Exception: No such file memory:foo.dart).");
+ runCompiler(Uri.parse('memory:foo.dart'),
+ "Error: Can't read 'memory:foo.dart' "
+ "(Exception: No such file memory:foo.dart).");
+ runCompiler(Uri.parse('dart:foo'),
+ 'Error: Library not found "dart:foo".');
+}

Powered by Google App Engine
This is Rietveld 408576698