| 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.domain.analysis; | 5 library test.domain.analysis; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/computer/element.dart'; | 10 import 'package:analysis_server/src/computer/element.dart'; |
| 11 import 'package:analysis_server/src/constants.dart'; | 11 import 'package:analysis_server/src/constants.dart'; |
| 12 import 'package:analysis_server/src/domain_analysis.dart'; | 12 import 'package:analysis_server/src/domain_analysis.dart'; |
| 13 import 'package:analysis_server/src/protocol.dart'; | 13 import 'package:analysis_server/src/protocol.dart'; |
| 14 import 'package:analysis_testing/mock_sdk.dart'; | 14 import 'package:analysis_testing/mock_sdk.dart'; |
| 15 import 'package:analysis_testing/reflective_tests.dart'; | 15 import 'package:analysis_testing/reflective_tests.dart'; |
| 16 import 'package:analyzer/file_system/memory_file_system.dart'; | 16 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 17 import 'package:analyzer/src/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
| 18 import 'package:path/path.dart'; | 18 import 'package:path/path.dart'; |
| 19 import 'package:unittest/unittest.dart'; | 19 import 'package:unittest/unittest.dart'; |
| 20 | 20 |
| 21 import 'analysis_abstract.dart'; | 21 import 'analysis_abstract.dart'; |
| 22 import 'mocks.dart'; | 22 import 'mocks.dart'; |
| 23 | 23 |
| 24 | 24 |
| 25 AnalysisError jsonToAnalysisError(Map<String, Object> json) { | 25 AnalysisError jsonToAnalysisError(Map<String, Object> json) { |
| 26 Map<String, Object> jsonLocation = json[LOCATION]; | 26 Map<String, Object> jsonLocation = json[LOCATION]; |
| 27 Location location = new Location(jsonLocation[FILE], _getSafeInt(jsonLocation, | 27 Location location = new Location(jsonLocation[FILE], _getSafeInt(jsonLocation, |
| 28 OFFSET, -1), _getSafeInt(jsonLocation, LENGTH, -1), _getSafeInt(jsonLocati
on, | 28 OFFSET, -1), _getSafeInt(jsonLocation, LENGTH, -1), _getSafeInt(jsonLocati
on, |
| 29 START_LINE, -1), _getSafeInt(jsonLocation, START_COLUMN, -1)); | 29 START_LINE, -1), _getSafeInt(jsonLocation, START_COLUMN, -1)); |
| 30 return new AnalysisError(json[ERROR_CODE], json[SEVERITY], json[TYPE], locatio
n, | 30 return new AnalysisError('unknown error code', json[SEVERITY], json[TYPE], loc
ation, |
| 31 json['message'], json['correction']); | 31 json['message'], json['correction']); |
| 32 } | 32 } |
| 33 | 33 |
| 34 | 34 |
| 35 main() { | 35 main() { |
| 36 groupSep = ' | '; | 36 groupSep = ' | '; |
| 37 | 37 |
| 38 runReflectiveTests(AnalysisDomainTest); | 38 runReflectiveTests(AnalysisDomainTest); |
| 39 | 39 |
| 40 MockServerChannel serverChannel; | 40 MockServerChannel serverChannel; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 | 170 |
| 171 testNotificationErrors() { | 171 testNotificationErrors() { |
| 172 AnalysisTestHelper helper; | 172 AnalysisTestHelper helper; |
| 173 | 173 |
| 174 setUp(() { | 174 setUp(() { |
| 175 helper = new AnalysisTestHelper(); | 175 helper = new AnalysisTestHelper(); |
| 176 }); | 176 }); |
| 177 | 177 |
| 178 test('ParserErrorCode', () { | 178 test('ParserError', () { |
| 179 helper.createSingleFileProject('library lib'); | 179 helper.createSingleFileProject('library lib'); |
| 180 return helper.waitForOperationsFinished().then((_) { | 180 return helper.waitForOperationsFinished().then((_) { |
| 181 List<AnalysisError> errors = helper.getTestErrors(); | 181 List<AnalysisError> errors = helper.getTestErrors(); |
| 182 expect(errors, hasLength(1)); | 182 expect(errors, hasLength(1)); |
| 183 AnalysisError error = errors[0]; | 183 AnalysisError error = errors[0]; |
| 184 expect(error.location.file, '/project/bin/test.dart'); | 184 expect(error.location.file, '/project/bin/test.dart'); |
| 185 expect(error.location.offset, isPositive); | 185 expect(error.location.offset, isPositive); |
| 186 expect(error.location.length, isNonNegative); | 186 expect(error.location.length, isNonNegative); |
| 187 expect(error.errorCode, 'ParserErrorCode.EXPECTED_TOKEN'); | |
| 188 expect(error.severity, 'ERROR'); | 187 expect(error.severity, 'ERROR'); |
| 189 expect(error.type, 'SYNTACTIC_ERROR'); | 188 expect(error.type, 'SYNTACTIC_ERROR'); |
| 190 expect(error.message, isNotNull); | 189 expect(error.message, isNotNull); |
| 191 }); | 190 }); |
| 192 }); | 191 }); |
| 193 | 192 |
| 194 test('StaticWarningCode', () { | 193 test('StaticWarning', () { |
| 195 helper.createSingleFileProject(['main() {', ' print(unknown);', '}']); | 194 helper.createSingleFileProject(['main() {', ' print(unknown);', '}']); |
| 196 return helper.waitForOperationsFinished().then((_) { | 195 return helper.waitForOperationsFinished().then((_) { |
| 197 List<AnalysisError> errors = helper.getTestErrors(); | 196 List<AnalysisError> errors = helper.getTestErrors(); |
| 198 expect(errors, hasLength(1)); | 197 expect(errors, hasLength(1)); |
| 199 AnalysisError error = errors[0]; | 198 AnalysisError error = errors[0]; |
| 200 expect(error.errorCode, 'StaticWarningCode.UNDEFINED_IDENTIFIER'); | 199 expect(error.severity, 'WARNING'); |
| 200 expect(error.type, 'STATIC_WARNING'); |
| 201 }); | 201 }); |
| 202 }); | 202 }); |
| 203 } | 203 } |
| 204 | 204 |
| 205 | 205 |
| 206 testUpdateContent() { | 206 testUpdateContent() { |
| 207 test('full content', () { | 207 test('full content', () { |
| 208 AnalysisTestHelper helper = new AnalysisTestHelper(); | 208 AnalysisTestHelper helper = new AnalysisTestHelper(); |
| 209 helper.createSingleFileProject('// empty'); | 209 helper.createSingleFileProject('// empty'); |
| 210 return helper.waitForOperationsFinished().then((_) { | 210 return helper.waitForOperationsFinished().then((_) { |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 return waitForServerOperationsPerformed(server); | 643 return waitForServerOperationsPerformed(server); |
| 644 } | 644 } |
| 645 | 645 |
| 646 static String _getCodeString(code) { | 646 static String _getCodeString(code) { |
| 647 if (code is List<String>) { | 647 if (code is List<String>) { |
| 648 code = code.join('\n'); | 648 code = code.join('\n'); |
| 649 } | 649 } |
| 650 return code as String; | 650 return code as String; |
| 651 } | 651 } |
| 652 } | 652 } |
| OLD | NEW |