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.services.linter; | 5 library test.services.linter; |
6 | 6 |
7 import 'package:analysis_server/src/services/linter/linter.dart'; | 7 import 'package:analysis_server/src/services/linter/linter.dart'; |
8 import 'package:analyzer/analyzer.dart'; | 8 import 'package:analyzer/analyzer.dart'; |
9 import 'package:analyzer/source/analysis_options_provider.dart'; | 9 import 'package:analyzer/source/analysis_options_provider.dart'; |
10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
12 import 'package:linter/src/rules.dart'; | |
13 import 'package:test/test.dart'; | 12 import 'package:test/test.dart'; |
14 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 13 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
15 | 14 |
16 main() { | 15 main() { |
17 defineReflectiveSuite(() { | 16 defineReflectiveSuite(() { |
18 defineReflectiveTests(LinterRuleOptionsValidatorTest); | 17 defineReflectiveTests(LinterRuleOptionsValidatorTest); |
19 }); | 18 }); |
20 } | 19 } |
21 | 20 |
22 @reflectiveTest | 21 @reflectiveTest |
23 class LinterRuleOptionsValidatorTest { | 22 class LinterRuleOptionsValidatorTest { |
24 final LinterRuleOptionsValidator validator = new LinterRuleOptionsValidator(); | 23 final LinterRuleOptionsValidator validator = new LinterRuleOptionsValidator(); |
25 final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider(); | 24 final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider(); |
26 | 25 |
27 RecordingErrorListener recorder; | 26 RecordingErrorListener recorder; |
28 ErrorReporter reporter; | 27 ErrorReporter reporter; |
29 | 28 |
30 List<AnalysisError> get errors => recorder.errors; | 29 List<AnalysisError> get errors => recorder.errors; |
31 | 30 |
32 setUp() { | 31 setUp() { |
33 registerLintRules(); | |
34 recorder = new RecordingErrorListener(); | 32 recorder = new RecordingErrorListener(); |
35 reporter = new ErrorReporter(recorder, new _TestSource()); | 33 reporter = new ErrorReporter(recorder, new _TestSource()); |
36 } | 34 } |
37 | 35 |
38 test_linter_defined_rules() { | 36 test_linter_defined_rules() { |
39 validate( | 37 validate( |
40 ''' | 38 ''' |
41 linter: | 39 linter: |
42 rules: | 40 rules: |
43 - camel_case_types | 41 - camel_case_types |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 validator.validate(reporter, options); | 78 validator.validate(reporter, options); |
81 expect(errors.map((AnalysisError e) => e.errorCode), | 79 expect(errors.map((AnalysisError e) => e.errorCode), |
82 unorderedEquals(expected)); | 80 unorderedEquals(expected)); |
83 } | 81 } |
84 } | 82 } |
85 | 83 |
86 class _TestSource implements Source { | 84 class _TestSource implements Source { |
87 @override | 85 @override |
88 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 86 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
89 } | 87 } |
OLD | NEW |