| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.computer.error; | 5 library test.computer.error; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/computer/error.dart'; | 7 import 'package:analysis_server/src/computer/error.dart'; |
| 8 import 'package:analysis_server/src/protocol2.dart'; | 8 import 'package:analysis_server/src/protocol2.dart'; |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_testing/mocks.dart'; | 10 import 'package:analysis_testing/mocks.dart'; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 when(engineError.length).thenReturn(20); | 47 when(engineError.length).thenReturn(20); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void tearDown() { | 50 void tearDown() { |
| 51 source = null; | 51 source = null; |
| 52 engineError = null; | 52 engineError = null; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void test_fromEngine_hasCorrection() { | 55 void test_fromEngine_hasCorrection() { |
| 56 when(engineError.correction).thenReturn('my correction'); | 56 when(engineError.correction).thenReturn('my correction'); |
| 57 AnalysisError error = analysisErrorFromEngine(lineInfo, engineError); | 57 AnalysisError error = new AnalysisError.fromEngine(lineInfo, engineError); |
| 58 expect(error.toJson(), { | 58 expect(error.toJson(), { |
| 59 SEVERITY: 'ERROR', | 59 SEVERITY: 'ERROR', |
| 60 TYPE: 'COMPILE_TIME_ERROR', | 60 TYPE: 'COMPILE_TIME_ERROR', |
| 61 LOCATION: { | 61 LOCATION: { |
| 62 FILE: 'foo.dart', | 62 FILE: 'foo.dart', |
| 63 OFFSET: 10, | 63 OFFSET: 10, |
| 64 LENGTH: 20, | 64 LENGTH: 20, |
| 65 START_LINE: 3, | 65 START_LINE: 3, |
| 66 START_COLUMN: 2 | 66 START_COLUMN: 2 |
| 67 }, | 67 }, |
| 68 MESSAGE: 'my message', | 68 MESSAGE: 'my message', |
| 69 CORRECTION: 'my correction' | 69 CORRECTION: 'my correction' |
| 70 }); | 70 }); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void test_fromEngine_noCorrection() { | 73 void test_fromEngine_noCorrection() { |
| 74 when(engineError.correction).thenReturn(null); | 74 when(engineError.correction).thenReturn(null); |
| 75 AnalysisError error = analysisErrorFromEngine(lineInfo, engineError); | 75 AnalysisError error = new AnalysisError.fromEngine(lineInfo, engineError); |
| 76 expect(error.toJson(), { | 76 expect(error.toJson(), { |
| 77 SEVERITY: 'ERROR', | 77 SEVERITY: 'ERROR', |
| 78 TYPE: 'COMPILE_TIME_ERROR', | 78 TYPE: 'COMPILE_TIME_ERROR', |
| 79 LOCATION: { | 79 LOCATION: { |
| 80 FILE: 'foo.dart', | 80 FILE: 'foo.dart', |
| 81 OFFSET: 10, | 81 OFFSET: 10, |
| 82 LENGTH: 20, | 82 LENGTH: 20, |
| 83 START_LINE: 3, | 83 START_LINE: 3, |
| 84 START_COLUMN: 2 | 84 START_COLUMN: 2 |
| 85 }, | 85 }, |
| 86 MESSAGE: 'my message' | 86 MESSAGE: 'my message' |
| 87 }); | 87 }); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void test_fromEngine_noLineInfo() { | 90 void test_fromEngine_noLineInfo() { |
| 91 when(engineError.correction).thenReturn(null); | 91 when(engineError.correction).thenReturn(null); |
| 92 AnalysisError error = analysisErrorFromEngine(null, engineError); | 92 AnalysisError error = new AnalysisError.fromEngine(null, engineError); |
| 93 expect(error.toJson(), { | 93 expect(error.toJson(), { |
| 94 SEVERITY: 'ERROR', | 94 SEVERITY: 'ERROR', |
| 95 TYPE: 'COMPILE_TIME_ERROR', | 95 TYPE: 'COMPILE_TIME_ERROR', |
| 96 LOCATION: { | 96 LOCATION: { |
| 97 FILE: 'foo.dart', | 97 FILE: 'foo.dart', |
| 98 OFFSET: 10, | 98 OFFSET: 10, |
| 99 LENGTH: 20, | 99 LENGTH: 20, |
| 100 START_LINE: -1, | 100 START_LINE: -1, |
| 101 START_COLUMN: -1 | 101 START_COLUMN: -1 |
| 102 }, | 102 }, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 'file': 'foo.dart', | 143 'file': 'foo.dart', |
| 144 'offset': 10, | 144 'offset': 10, |
| 145 'length': 20, | 145 'length': 20, |
| 146 'startLine': 3, | 146 'startLine': 3, |
| 147 'startColumn': 2 | 147 'startColumn': 2 |
| 148 }, | 148 }, |
| 149 'message': 'my message' | 149 'message': 'my message' |
| 150 }])); | 150 }])); |
| 151 } | 151 } |
| 152 } | 152 } |
| OLD | NEW |