| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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.src.task.options_test; | 5 library test.src.task.options_test; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/source/analysis_options_provider.dart'; | 8 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 isInstanceOf isGenerateOptionsErrorsTask = | 27 isInstanceOf isGenerateOptionsErrorsTask = |
| 28 new isInstanceOf<GenerateOptionsErrorsTask>(); | 28 new isInstanceOf<GenerateOptionsErrorsTask>(); |
| 29 | 29 |
| 30 @reflectiveTest | 30 @reflectiveTest |
| 31 class GenerateOptionsErrorsTaskTest extends AbstractContextTest { | 31 class GenerateOptionsErrorsTaskTest extends AbstractContextTest { |
| 32 final optionsFilePath = '/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; | 32 final optionsFilePath = '/${AnalysisEngine.ANALYSIS_OPTIONS_FILE}'; |
| 33 | 33 |
| 34 Source source; | 34 Source source; |
| 35 LineInfo lineInfo(String source) => |
| 36 GenerateOptionsErrorsTask.computeLineInfo(source); |
| 37 |
| 35 @override | 38 @override |
| 36 setUp() { | 39 setUp() { |
| 37 super.setUp(); | 40 super.setUp(); |
| 38 source = newSource(optionsFilePath); | 41 source = newSource(optionsFilePath); |
| 39 } | 42 } |
| 40 | 43 |
| 41 test_buildInputs() { | 44 test_buildInputs() { |
| 42 Map<String, TaskInput> inputs = | 45 Map<String, TaskInput> inputs = |
| 43 GenerateOptionsErrorsTask.buildInputs(source); | 46 GenerateOptionsErrorsTask.buildInputs(source); |
| 44 expect(inputs, isNotNull); | 47 expect(inputs, isNotNull); |
| 45 expect(inputs.keys, | 48 expect(inputs.keys, |
| 46 unorderedEquals([GenerateOptionsErrorsTask.CONTENT_INPUT_NAME])); | 49 unorderedEquals([GenerateOptionsErrorsTask.CONTENT_INPUT_NAME])); |
| 47 } | 50 } |
| 48 | 51 |
| 52 test_compute_lineInfo() { |
| 53 expect(lineInfo('foo\nbar').getLocation(4).lineNumber, 2); |
| 54 expect(lineInfo('foo\nbar').getLocation(4).columnNumber, 1); |
| 55 expect(lineInfo('foo\r\nbar').getLocation(5).lineNumber, 2); |
| 56 expect(lineInfo('foo\r\nbar').getLocation(5).columnNumber, 1); |
| 57 expect(lineInfo('foo\rbar').getLocation(4).lineNumber, 2); |
| 58 expect(lineInfo('foo\rbar').getLocation(4).columnNumber, 1); |
| 59 expect(lineInfo('foo').getLocation(0).lineNumber, 1); |
| 60 expect(lineInfo('foo').getLocation(0).columnNumber, 1); |
| 61 expect(lineInfo('').getLocation(1).lineNumber, 1); |
| 62 } |
| 63 |
| 49 test_constructor() { | 64 test_constructor() { |
| 50 GenerateOptionsErrorsTask task = | 65 GenerateOptionsErrorsTask task = |
| 51 new GenerateOptionsErrorsTask(context, source); | 66 new GenerateOptionsErrorsTask(context, source); |
| 52 expect(task, isNotNull); | 67 expect(task, isNotNull); |
| 53 expect(task.context, context); | 68 expect(task.context, context); |
| 54 expect(task.target, source); | 69 expect(task.target, source); |
| 55 } | 70 } |
| 56 | 71 |
| 57 test_createTask() { | 72 test_createTask() { |
| 58 GenerateOptionsErrorsTask task = | 73 GenerateOptionsErrorsTask task = |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION]); | 184 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION]); |
| 170 } | 185 } |
| 171 | 186 |
| 172 void validate(String source, List<AnalysisOptionsErrorCode> expected) { | 187 void validate(String source, List<AnalysisOptionsErrorCode> expected) { |
| 173 var options = optionsProvider.getOptionsFromString(source); | 188 var options = optionsProvider.getOptionsFromString(source); |
| 174 var errors = validator.validate(options); | 189 var errors = validator.validate(options); |
| 175 expect(errors.map((AnalysisError e) => e.errorCode), | 190 expect(errors.map((AnalysisError e) => e.errorCode), |
| 176 unorderedEquals(expected)); | 191 unorderedEquals(expected)); |
| 177 } | 192 } |
| 178 } | 193 } |
| OLD | NEW |