| 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 import 'package:analyzer/analyzer.dart'; | 5 import 'package:analyzer/analyzer.dart'; |
| 6 import 'package:analyzer/source/analysis_options_provider.dart'; | 6 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 import 'package:analyzer/src/lint/options_rule_validator.dart'; | 9 import 'package:analyzer/src/lint/options_rule_validator.dart'; |
| 10 import 'package:linter/src/rules.dart'; | 10 import 'package:linter/src/rules.dart'; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 List<AnalysisError> get errors => recorder.errors; | 28 List<AnalysisError> get errors => recorder.errors; |
| 29 | 29 |
| 30 setUp() { | 30 setUp() { |
| 31 registerLintRules(); | 31 registerLintRules(); |
| 32 recorder = new RecordingErrorListener(); | 32 recorder = new RecordingErrorListener(); |
| 33 reporter = new ErrorReporter(recorder, new _TestSource()); | 33 reporter = new ErrorReporter(recorder, new _TestSource()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 test_linter_defined_rules() { | 36 test_linter_defined_rules() { |
| 37 validate( | 37 validate(''' |
| 38 ''' | |
| 39 linter: | 38 linter: |
| 40 rules: | 39 rules: |
| 41 - camel_case_types | 40 - camel_case_types |
| 42 ''', | 41 ''', []); |
| 43 []); | |
| 44 } | 42 } |
| 45 | 43 |
| 46 test_linter_no_rules() { | 44 test_linter_no_rules() { |
| 47 validate( | 45 validate(''' |
| 48 ''' | |
| 49 linter: | 46 linter: |
| 50 rules: | 47 rules: |
| 51 ''', | 48 ''', []); |
| 52 []); | |
| 53 } | 49 } |
| 54 | 50 |
| 55 test_linter_null_rule() { | 51 test_linter_null_rule() { |
| 56 validate( | 52 validate(''' |
| 57 ''' | |
| 58 linter: | 53 linter: |
| 59 rules: | 54 rules: |
| 60 - | 55 - |
| 61 | 56 |
| 62 ''', | 57 ''', []); |
| 63 []); | |
| 64 } | 58 } |
| 65 | 59 |
| 66 test_linter_undefined_rule() { | 60 test_linter_undefined_rule() { |
| 67 validate( | 61 validate(''' |
| 68 ''' | |
| 69 linter: | 62 linter: |
| 70 rules: | 63 rules: |
| 71 - undefined | 64 - undefined |
| 72 ''', | 65 ''', [UNDEFINED_LINT_WARNING]); |
| 73 [UNDEFINED_LINT_WARNING]); | |
| 74 } | 66 } |
| 75 | 67 |
| 76 validate(String source, List<ErrorCode> expected) { | 68 validate(String source, List<ErrorCode> expected) { |
| 77 var options = optionsProvider.getOptionsFromString(source); | 69 var options = optionsProvider.getOptionsFromString(source); |
| 78 validator.validate(reporter, options); | 70 validator.validate(reporter, options); |
| 79 expect(errors.map((AnalysisError e) => e.errorCode), | 71 expect(errors.map((AnalysisError e) => e.errorCode), |
| 80 unorderedEquals(expected)); | 72 unorderedEquals(expected)); |
| 81 } | 73 } |
| 82 } | 74 } |
| 83 | 75 |
| 84 class _TestSource implements Source { | 76 class _TestSource implements Source { |
| 85 @override | 77 @override |
| 86 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 78 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 87 } | 79 } |
| OLD | NEW |