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

Side by Side Diff: pkg/analyzer_cli/test/reporter_test.dart

Issue 1462143002: Revert "Move `analyzer_cli` into the SDK." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « pkg/analyzer_cli/test/plugin_manager_test.dart ('k') | pkg/analyzer_cli/test/sdk_ext_test.dart » ('j') | 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) 2015, 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 @TestOn("vm")
6 library analyzer_cli.test.formatter;
7
8 import 'package:analyzer/analyzer.dart';
9 import 'package:analyzer_cli/src/error_formatter.dart';
10 import 'package:mockito/mockito.dart';
11 import 'package:test/test.dart' hide ErrorFormatter;
12
13 import 'mocks.dart';
14
15 main() {
16 group('reporter', () {
17 var out = new StringBuffer();
18
19 tearDown(() => out.clear());
20
21 // Options
22 var options = new MockCommandLineOptions();
23 when(options.disableHints).thenReturn(true);
24 when(options.enableTypeChecks).thenReturn(true);
25 when(options.machineFormat).thenReturn(false);
26 when(options.hintsAreFatal).thenReturn(false);
27
28 var reporter = new ErrorFormatter(out, options);
29
30 test('error', () {
31 var error = mockError(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR);
32 reporter.formatErrors([error]);
33
34 expect(out.toString(),
35 equals('''[error] MSG (/foo/bar/baz.dart, line 3, col 3)
36 1 error found.
37 '''));
38 });
39
40 test('hint', () {
41 var error = mockError(ErrorType.HINT, ErrorSeverity.INFO);
42 reporter.formatErrors([error]);
43
44 expect(out.toString(),
45 equals('''[hint] MSG (/foo/bar/baz.dart, line 3, col 3)
46 1 hint found.
47 '''));
48 });
49 });
50 }
51
52 MockAnalysisErrorInfo mockError(ErrorType type, ErrorSeverity severity) {
53 // ErrorInfo
54 var info = new MockAnalysisErrorInfo();
55 var error = new MockAnalysisError();
56 var lineInfo = new MockLineInfo();
57 var location = new MockLineInfo_Location();
58 when(location.columnNumber).thenReturn(3);
59 when(location.lineNumber).thenReturn(3);
60 when(lineInfo.getLocation(any)).thenReturn(location);
61 when(info.lineInfo).thenReturn(lineInfo);
62
63 // Details
64 var code = new MockErrorCode();
65 when(code.type).thenReturn(type);
66 when(code.errorSeverity).thenReturn(severity);
67 when(code.name).thenReturn('mock_code');
68 when(error.errorCode).thenReturn(code);
69 when(error.message).thenReturn('MSG');
70 var source = new MockSource();
71 when(source.fullName).thenReturn('/foo/bar/baz.dart');
72 when(error.source).thenReturn(source);
73 when(info.errors).thenReturn([error]);
74
75 return info;
76 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/test/plugin_manager_test.dart ('k') | pkg/analyzer_cli/test/sdk_ext_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698