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

Side by Side Diff: pkg/analysis_server/test/operation/operation_analysis_test.dart

Issue 415263002: Drop 'errorToJson', use server's AnalysisError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 test.operation.analysis;
6
7 import 'package:analysis_server/src/operation/operation_analysis.dart';
8 import 'package:analysis_services/constants.dart';
9 import 'package:analysis_testing/mocks.dart';
10 import 'package:analysis_testing/reflective_tests.dart';
11 import 'package:analyzer/src/generated/error.dart';
12 import 'package:analyzer/src/generated/source.dart';
13 import 'package:typed_mock/typed_mock.dart';
14 import 'package:unittest/unittest.dart';
15
16
17 main() {
18 groupSep = ' | ';
19 runReflectiveTests(Test_errorToJson);
20 }
21
22
23 class AnalysisErrorMock extends TypedMock implements AnalysisError {
24 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
25 }
26
27
28 @ReflectiveTestCase()
29 class Test_errorToJson {
30 Source source = new MockSource();
31 LineInfo lineInfo;
32 AnalysisError analysisError = new AnalysisErrorMock();
33
34 void setUp() {
35 // prepare Source
36 when(source.fullName).thenReturn('foo.dart');
37 // prepare LineInfo
38 lineInfo = new LineInfo([0, 5, 9, 20]);
39 // prepare AnalysisError
40 when(analysisError.source).thenReturn(source);
41 when(analysisError.errorCode).thenReturn(
42 CompileTimeErrorCode.AMBIGUOUS_EXPORT);
43 when(analysisError.message).thenReturn('my message');
44 when(analysisError.offset).thenReturn(10);
45 when(analysisError.length).thenReturn(20);
46 }
47
48 void tearDown() {
49 source = null;
50 analysisError = null;
51 }
52
53 void test_noCorrection() {
54 Map<String, Object> json = errorToJson(lineInfo, analysisError);
55 expect(json, {
56 SEVERITY: 'ERROR',
57 TYPE: 'COMPILE_TIME_ERROR',
58 LOCATION: {
59 FILE: 'foo.dart',
60 OFFSET: 10,
61 LENGTH: 20,
62 START_LINE: 3,
63 START_COLUMN: 2
64 },
65 MESSAGE: 'my message'
66 });
67 }
68
69 void test_noLineInfo() {
70 Map<String, Object> json = errorToJson(null, analysisError);
71 expect(json, {
72 SEVERITY: 'ERROR',
73 TYPE: 'COMPILE_TIME_ERROR',
74 LOCATION: {
75 FILE: 'foo.dart',
76 OFFSET: 10,
77 LENGTH: 20
78 },
79 MESSAGE: 'my message'
80 });
81 }
82
83 void test_withCorrection() {
84 when(analysisError.correction).thenReturn('my correction');
85 Map<String, Object> json = errorToJson(lineInfo, analysisError);
86 expect(json, {
87 SEVERITY: 'ERROR',
88 TYPE: 'COMPILE_TIME_ERROR',
89 LOCATION: {
90 FILE: 'foo.dart',
91 OFFSET: 10,
92 LENGTH: 20,
93 START_LINE: 3,
94 START_COLUMN: 2
95 },
96 MESSAGE: 'my message',
97 CORRECTION: 'my correction'
98 });
99 }
100 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/computer/error_test.dart ('k') | pkg/analysis_server/test/operation/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698