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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library analyze_api;
6
7 import 'dart:uri';
8 import 'dart:io';
9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api;
10 import '../../../sdk/lib/_internal/compiler/implementation/apiimpl.dart';
11 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart'
12 hide Compiler;
13 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
14 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider. dart';
15 import '../../../sdk/lib/_internal/libraries.dart';
16
17 class CollectingDiagnosticHandler extends FormattingDiagnosticHandler {
18 bool hasWarnings = false;
19 bool hasErrors = false;
20
21 CollectingDiagnosticHandler(SourceFileProvider provider) : super(provider);
22
23 void diagnosticHandler(Uri uri, int begin, int end, String message,
24 api.Diagnostic kind) {
25 if (kind == api.Diagnostic.WARNING) {
26 hasWarnings = true;
27 }
28 if (kind == api.Diagnostic.ERROR) {
29 hasErrors = true;
30 }
31 super.diagnosticHandler(uri, begin, end, message, kind);
32 }
33 }
34
35 void main() {
36 Uri currentWorkingDirectory = getCurrentDirectory();
37 var libraryRoot = currentWorkingDirectory.resolve('sdk/');
38 var uriList = new List<Uri>();
39 LIBRARIES.forEach((String name, LibraryInfo info) {
40 if (info.documented) {
41 uriList.add(new Uri.fromComponents(scheme: 'dart', path: name));
42 }
43 });
44 var provider = new SourceFileProvider();
45 var handler = new CollectingDiagnosticHandler(provider);
46 var compiler = new Compiler(
47 provider.readStringFromUri,
48 handler.diagnosticHandler,
49 libraryRoot, libraryRoot,
50 <String>['--analyze-only']);
51 compiler.librariesToAnalyzeWhenRun = uriList;
52 compiler.run(null);
53 Expect.isFalse(handler.hasWarnings);
54 Expect.isFalse(handler.hasErrors);
55 }
OLDNEW
« 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