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

Unified Diff: pkg/analyzer_cli/test/reporter_test.dart

Issue 1462393002: Migrate `mockito` mocks to `typed_mock` (#24994). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: master merge 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/test/reporter_test.dart
diff --git a/pkg/analyzer_cli/test/reporter_test.dart b/pkg/analyzer_cli/test/reporter_test.dart
index 3adcda52e122ff5452aed9f9fde3fa761edc36fc..94b089649b32ebbefd2cdccec493afcfeefe0e1b 100644
--- a/pkg/analyzer_cli/test/reporter_test.dart
+++ b/pkg/analyzer_cli/test/reporter_test.dart
@@ -2,76 +2,75 @@
// 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.
-//@TestOn("vm")
library analyzer_cli.test.formatter;
-//import 'package:analyzer/analyzer.dart';
-//import 'package:analyzer_cli/src/error_formatter.dart';
-//import 'package:test/test.dart' hide ErrorFormatter;
+import 'package:analyzer/analyzer.dart';
+import 'package:analyzer_cli/src/error_formatter.dart';
+import 'package:typed_mock/typed_mock.dart';
+import 'package:unittest/unittest.dart' hide ErrorFormatter;
-//import 'mocks.dart';
+import 'mocks.dart';
-
-//TODO(pq): fix mocks and reimplement
main() {
-// group('reporter', () {
-// var out = new StringBuffer();
-//
-// tearDown(() => out.clear());
-//
-// // Options
-// var options = new MockCommandLineOptions();
-// when(options.disableHints).thenReturn(true);
-// when(options.enableTypeChecks).thenReturn(true);
-// when(options.machineFormat).thenReturn(false);
-// when(options.hintsAreFatal).thenReturn(false);
-//
-// var reporter = new ErrorFormatter(out, options);
-//
-// test('error', () {
-// var error = mockError(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR);
-// reporter.formatErrors([error]);
-//
-// expect(out.toString(),
-// equals('''[error] MSG (/foo/bar/baz.dart, line 3, col 3)
-//1 error found.
-//'''));
-// });
-//
-// test('hint', () {
-// var error = mockError(ErrorType.HINT, ErrorSeverity.INFO);
-// reporter.formatErrors([error]);
-//
-// expect(out.toString(),
-// equals('''[hint] MSG (/foo/bar/baz.dart, line 3, col 3)
-//1 hint found.
-//'''));
-// });
-// });
+ group('reporter', () {
+ var out = new StringBuffer();
+
+ tearDown(() => out.clear());
+
+ // Options
+ var options = new MockCommandLineOptions();
+ when(options.enableTypeChecks).thenReturn(false);
+ when(options.hintsAreFatal).thenReturn(false);
+ when(options.machineFormat).thenReturn(false);
+
+ var reporter = new ErrorFormatter(out, options);
+
+ test('error', () {
+ var error = mockError(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR);
+ reporter.formatErrors([error]);
+
+ expect(
+ out.toString(),
+ '''[error] MSG (/foo/bar/baz.dart, line 3, col 3)
+1 error found.
+''');
+ });
+
+ test('hint', () {
+ var error = mockError(ErrorType.HINT, ErrorSeverity.INFO);
+ reporter.formatErrors([error]);
+
+ expect(
+ out.toString(),
+ '''[hint] MSG (/foo/bar/baz.dart, line 3, col 3)
+1 hint found.
+''');
+ });
+ });
}
-//MockAnalysisErrorInfo mockError(ErrorType type, ErrorSeverity severity) {
-// // ErrorInfo
-// var info = new MockAnalysisErrorInfo();
-// var error = new MockAnalysisError();
-// var lineInfo = new MockLineInfo();
-// var location = new MockLineInfo_Location();
-// when(location.columnNumber).thenReturn(3);
-// when(location.lineNumber).thenReturn(3);
-// when(lineInfo.getLocation(any)).thenReturn(location);
-// when(info.lineInfo).thenReturn(lineInfo);
-//
-// // Details
-// var code = new MockErrorCode();
-// when(code.type).thenReturn(type);
-// when(code.errorSeverity).thenReturn(severity);
-// when(code.name).thenReturn('mock_code');
-// when(error.errorCode).thenReturn(code);
-// when(error.message).thenReturn('MSG');
-// var source = new MockSource();
-// when(source.fullName).thenReturn('/foo/bar/baz.dart');
-// when(error.source).thenReturn(source);
-// when(info.errors).thenReturn([error]);
-//
-// return info;
-//}
+MockAnalysisErrorInfo mockError(ErrorType type, ErrorSeverity severity) {
+ // ErrorInfo
+ var info = new MockAnalysisErrorInfo();
+ var error = new MockAnalysisError();
+ var lineInfo = new MockLineInfo();
+ var location = new MockLineInfo_Location();
+ when(location.columnNumber).thenReturn(3);
+ when(location.lineNumber).thenReturn(3);
+ when(lineInfo.getLocation(anyObject)).thenReturn(location);
+ when(info.lineInfo).thenReturn(lineInfo);
+
+ // Details
+ var code = new MockErrorCode();
+ when(code.type).thenReturn(type);
+ when(code.errorSeverity).thenReturn(severity);
+ when(code.name).thenReturn('mock_code');
+ when(error.errorCode).thenReturn(code);
+ when(error.message).thenReturn('MSG');
+ var source = new MockSource();
+ when(source.fullName).thenReturn('/foo/bar/baz.dart');
+ when(error.source).thenReturn(source);
+ when(info.errors).thenReturn([error]);
+
+ return info;
+}
« 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