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

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

Issue 11887015: Add dart2js unittest to analyze the API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/analyze_api_test.dart
diff --git a/tests/compiler/dart2js/analyze_api_test.dart b/tests/compiler/dart2js/analyze_api_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..eaf8c4d8efff8cf4939e9e147b172bd32c1748c2
--- /dev/null
+++ b/tests/compiler/dart2js/analyze_api_test.dart
@@ -0,0 +1,55 @@
+// 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.
+
+library analyze_api;
+
+import 'dart:uri';
+import 'dart:io';
+import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
+import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart';
+import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
+ hide Compiler;
+import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
+import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider.dart';
+import '../../../sdk/lib/_internal/libraries.dart';
+
+class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
+ bool hasWarnings = false;
+ bool hasErrors = false;
+
+ CollectingDiagnosticHandler(SourceFileProvider provider) : super(provider);
+
+ void diagnosticHandler(Uri uri, int begin, int end, String message,
+ api.Diagnostic kind) {
+ if (kind == api.Diagnostic.WARNING) {
+ hasWarnings = true;
+ }
+ if (kind == api.Diagnostic.ERROR) {
+ hasErrors = true;
+ }
+ super.diagnosticHandler(uri, begin, end, message, kind);
+ }
+}
+
+void main() {
+ Uri currentWorkingDirectory = getCurrentDirectory();
+ var libraryRoot = currentWorkingDirectory.resolve('sdk/');
+ var uriList = new List<Uri>();
+ LIBRARIES.forEach((String name, LibraryInfo info) {
+ if (info.documented) {
+ uriList.add(new Uri.fromComponents(scheme: 'dart', path: name));
+ }
+ });
+ var provider = new SourceFileProvider();
+ var handler = new CollectingDiagnosticHandler(provider);
+ var compiler = new Compiler(
+ provider.readStringFromUri,
+ handler.diagnosticHandler,
+ libraryRoot, libraryRoot,
+ <String>['--analyze-only']);
+ compiler.librariesToAnalyzeWhenRun = uriList;
+ compiler.run(null);
+ Expect.isFalse(handler.hasWarnings);
+ Expect.isFalse(handler.hasErrors);
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698