OLD | NEW |
(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:test/test.dart' hide ErrorFormatter; |
| 11 |
| 12 //import 'mocks.dart'; |
| 13 |
| 14 |
| 15 //TODO(pq): fix mocks and reimplement |
| 16 main() { |
| 17 // group('reporter', () { |
| 18 // var out = new StringBuffer(); |
| 19 // |
| 20 // tearDown(() => out.clear()); |
| 21 // |
| 22 // // Options |
| 23 // var options = new MockCommandLineOptions(); |
| 24 // when(options.disableHints).thenReturn(true); |
| 25 // when(options.enableTypeChecks).thenReturn(true); |
| 26 // when(options.machineFormat).thenReturn(false); |
| 27 // when(options.hintsAreFatal).thenReturn(false); |
| 28 // |
| 29 // var reporter = new ErrorFormatter(out, options); |
| 30 // |
| 31 // test('error', () { |
| 32 // var error = mockError(ErrorType.SYNTACTIC_ERROR, ErrorSeverity.ERROR); |
| 33 // reporter.formatErrors([error]); |
| 34 // |
| 35 // expect(out.toString(), |
| 36 // equals('''[error] MSG (/foo/bar/baz.dart, line 3, col 3) |
| 37 //1 error found. |
| 38 //''')); |
| 39 // }); |
| 40 // |
| 41 // test('hint', () { |
| 42 // var error = mockError(ErrorType.HINT, ErrorSeverity.INFO); |
| 43 // reporter.formatErrors([error]); |
| 44 // |
| 45 // expect(out.toString(), |
| 46 // equals('''[hint] MSG (/foo/bar/baz.dart, line 3, col 3) |
| 47 //1 hint found. |
| 48 //''')); |
| 49 // }); |
| 50 // }); |
| 51 } |
| 52 |
| 53 //MockAnalysisErrorInfo mockError(ErrorType type, ErrorSeverity severity) { |
| 54 // // ErrorInfo |
| 55 // var info = new MockAnalysisErrorInfo(); |
| 56 // var error = new MockAnalysisError(); |
| 57 // var lineInfo = new MockLineInfo(); |
| 58 // var location = new MockLineInfo_Location(); |
| 59 // when(location.columnNumber).thenReturn(3); |
| 60 // when(location.lineNumber).thenReturn(3); |
| 61 // when(lineInfo.getLocation(any)).thenReturn(location); |
| 62 // when(info.lineInfo).thenReturn(lineInfo); |
| 63 // |
| 64 // // Details |
| 65 // var code = new MockErrorCode(); |
| 66 // when(code.type).thenReturn(type); |
| 67 // when(code.errorSeverity).thenReturn(severity); |
| 68 // when(code.name).thenReturn('mock_code'); |
| 69 // when(error.errorCode).thenReturn(code); |
| 70 // when(error.message).thenReturn('MSG'); |
| 71 // var source = new MockSource(); |
| 72 // when(source.fullName).thenReturn('/foo/bar/baz.dart'); |
| 73 // when(error.source).thenReturn(source); |
| 74 // when(info.errors).thenReturn([error]); |
| 75 // |
| 76 // return info; |
| 77 //} |
OLD | NEW |