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

Side by Side Diff: pkg/analyzer/test/src/task/options_test.dart

Issue 1842363004: More strong mode fixes for analyzer (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Backout options changes Created 4 years, 8 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
OLDNEW
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 analyzer.test.src.task.options_test; 5 library analyzer.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/source/error_processor.dart'; 9 import 'package:analyzer/source/error_processor.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 test_configure_error_processors() { 108 test_configure_error_processors() {
109 configureContext(''' 109 configureContext('''
110 analyzer: 110 analyzer:
111 errors: 111 errors:
112 invalid_assignment: ignore 112 invalid_assignment: ignore
113 unused_local_variable: error 113 unused_local_variable: error
114 '''); 114 ''');
115 115
116 List<ErrorProcessor> processors = 116 List<ErrorProcessor> processors =
117 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); 117 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS)
118 as List<ErrorProcessor>;
118 expect(processors, hasLength(2)); 119 expect(processors, hasLength(2));
119 120
120 var unused_local = new AnalysisError( 121 var unused_local = new AnalysisError(
121 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [ 122 new TestSource(), 0, 1, HintCode.UNUSED_LOCAL_VARIABLE, [
122 ['x'] 123 ['x']
123 ]); 124 ]);
124 var invalid_assignment = 125 var invalid_assignment =
125 new AnalysisError(new TestSource(), 0, 1, HintCode.INVALID_ASSIGNMENT, [ 126 new AnalysisError(new TestSource(), 0, 1, HintCode.INVALID_ASSIGNMENT, [
126 ['x'], 127 ['x'],
127 ['y'] 128 ['y']
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 expect(descriptor, isNotNull); 216 expect(descriptor, isNotNull);
216 } 217 }
217 218
218 test_perform_bad_yaml() { 219 test_perform_bad_yaml() {
219 String code = r''' 220 String code = r'''
220 : 221 :
221 '''; 222 ''';
222 AnalysisTarget target = newSource(optionsFilePath, code); 223 AnalysisTarget target = newSource(optionsFilePath, code);
223 computeResult(target, ANALYSIS_OPTIONS_ERRORS); 224 computeResult(target, ANALYSIS_OPTIONS_ERRORS);
224 expect(task, isGenerateOptionsErrorsTask); 225 expect(task, isGenerateOptionsErrorsTask);
225 List<AnalysisError> errors = outputs[ANALYSIS_OPTIONS_ERRORS]; 226 List<AnalysisError> errors =
227 outputs[ANALYSIS_OPTIONS_ERRORS] as List<AnalysisError>;
226 expect(errors, hasLength(1)); 228 expect(errors, hasLength(1));
227 expect(errors[0].errorCode, AnalysisOptionsErrorCode.PARSE_ERROR); 229 expect(errors[0].errorCode, AnalysisOptionsErrorCode.PARSE_ERROR);
228 } 230 }
229 231
230 test_perform_OK() { 232 test_perform_OK() {
231 String code = r''' 233 String code = r'''
232 analyzer: 234 analyzer:
233 strong-mode: true 235 strong-mode: true
234 '''; 236 ''';
235 AnalysisTarget target = newSource(optionsFilePath, code); 237 AnalysisTarget target = newSource(optionsFilePath, code);
236 computeResult(target, ANALYSIS_OPTIONS_ERRORS); 238 computeResult(target, ANALYSIS_OPTIONS_ERRORS);
237 expect(task, isGenerateOptionsErrorsTask); 239 expect(task, isGenerateOptionsErrorsTask);
238 expect(outputs[ANALYSIS_OPTIONS_ERRORS], isEmpty); 240 expect(outputs[ANALYSIS_OPTIONS_ERRORS], isEmpty);
239 LineInfo lineInfo = outputs[LINE_INFO]; 241 LineInfo lineInfo = outputs[LINE_INFO];
240 expect(lineInfo, isNotNull); 242 expect(lineInfo, isNotNull);
241 expect(lineInfo.getLocation(1).lineNumber, 1); 243 expect(lineInfo.getLocation(1).lineNumber, 1);
242 expect(lineInfo.getLocation(10).lineNumber, 2); 244 expect(lineInfo.getLocation(10).lineNumber, 2);
243 } 245 }
244 246
245 test_perform_unsupported_analyzer_option() { 247 test_perform_unsupported_analyzer_option() {
246 String code = r''' 248 String code = r'''
247 analyzer: 249 analyzer:
248 not_supported: true 250 not_supported: true
249 '''; 251 ''';
250 AnalysisTarget target = newSource(optionsFilePath, code); 252 AnalysisTarget target = newSource(optionsFilePath, code);
251 computeResult(target, ANALYSIS_OPTIONS_ERRORS); 253 computeResult(target, ANALYSIS_OPTIONS_ERRORS);
252 expect(task, isGenerateOptionsErrorsTask); 254 expect(task, isGenerateOptionsErrorsTask);
253 List<AnalysisError> errors = outputs[ANALYSIS_OPTIONS_ERRORS]; 255 List<AnalysisError> errors =
256 outputs[ANALYSIS_OPTIONS_ERRORS] as List<AnalysisError>;
254 expect(errors, hasLength(1)); 257 expect(errors, hasLength(1));
255 expect(errors[0].errorCode, 258 expect(errors[0].errorCode,
256 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES); 259 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES);
257 expect( 260 expect(
258 errors[0].message, 261 errors[0].message,
259 "The option 'not_supported' is not supported by analyzer, supported " 262 "The option 'not_supported' is not supported by analyzer, supported "
260 "values are 'errors', 'exclude', 'language', 'plugins' and 'strong-mode' "); 263 "values are 'errors', 'exclude', 'language', 'plugins' and 'strong-mode' ");
261 } 264 }
262 } 265 }
263 266
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 392
390 test_linter_unsupported_option() { 393 test_linter_unsupported_option() {
391 validate( 394 validate(
392 ''' 395 '''
393 linter: 396 linter:
394 unsupported: true 397 unsupported: true
395 ''', 398 ''',
396 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]); 399 [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]);
397 } 400 }
398 401
399 void validate(String source, List<AnalysisOptionsErrorCode> expected) { 402 void validate(String source, List<ErrorCode> expected) {
400 var options = optionsProvider.getOptionsFromString(source); 403 var options = optionsProvider.getOptionsFromString(source);
401 var errors = validator.validate(options); 404 var errors = validator.validate(options);
402 expect(errors.map((AnalysisError e) => e.errorCode), 405 expect(errors.map((AnalysisError e) => e.errorCode),
403 unorderedEquals(expected)); 406 unorderedEquals(expected));
404 } 407 }
405 } 408 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/inputs_test.dart ('k') | pkg/analyzer/test/src/task/strong/strong_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698