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 linter.test.rule; | 5 library linter.test.rule; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 'foo_', | 181 'foo_', |
182 'foo.bar_baz.bang', | 182 'foo.bar_baz.bang', |
183 //See: https://github.com/flutter/flutter/pull/1996 | 183 //See: https://github.com/flutter/flutter/pull/1996 |
184 'pointycastle.impl.ec_domain_parameters.gostr3410_2001_cryptopro_a', | 184 'pointycastle.impl.ec_domain_parameters.gostr3410_2001_cryptopro_a', |
185 'a.b', | 185 'a.b', |
186 'a.b.c', | 186 'a.b.c', |
187 'p2.src.acme' | 187 'p2.src.acme' |
188 ]; | 188 ]; |
189 testEach(good, isLowerCaseUnderScoreWithDots, isTrue); | 189 testEach(good, isLowerCaseUnderScoreWithDots, isTrue); |
190 | 190 |
191 var bad = [ | 191 var bad = ['Foo', 'fooBar.', '.foo_Bar', '_f', 'F_B', 'JS', 'JSON']; |
192 'Foo', | |
193 'fooBar.', | |
194 '.foo_Bar', | |
195 '_f', | |
196 'F_B', | |
197 'JS', | |
198 'JSON' | |
199 ]; | |
200 testEach(bad, isLowerCaseUnderScoreWithDots, isFalse); | 192 testEach(bad, isLowerCaseUnderScoreWithDots, isFalse); |
201 }); | 193 }); |
202 group('lowerCamelCase', () { | 194 group('lowerCamelCase', () { |
203 var good = ['fooBar', 'foo', 'f', 'f1', '_f', '_foo', '_']; | 195 var good = ['fooBar', 'foo', 'f', 'f1', '_f', '_foo', '_']; |
204 testEach(good, isLowerCamelCase, isTrue); | 196 testEach(good, isLowerCamelCase, isTrue); |
205 | 197 |
206 var bad = ['Foo', 'foo_', 'foo_bar']; | 198 var bad = ['Foo', 'foo_', 'foo_bar']; |
207 testEach(bad, isLowerCamelCase, isFalse); | 199 testEach(bad, isLowerCamelCase, isFalse); |
208 }); | 200 }); |
209 group('libary_name_prefixes', () { | 201 group('libary_name_prefixes', () { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 expect( | 271 expect( |
280 () => expect(new Annotation('Message', ErrorType.LINT, 1), | 272 () => expect(new Annotation('Message', ErrorType.LINT, 1), |
281 matchesAnnotation('Message2', ErrorType.LINT, 1)), | 273 matchesAnnotation('Message2', ErrorType.LINT, 1)), |
282 throwsA(new isInstanceOf<TestFailure>())); | 274 throwsA(new isInstanceOf<TestFailure>())); |
283 expect( | 275 expect( |
284 () => expect(new Annotation('Message', ErrorType.LINT, 1), | 276 () => expect(new Annotation('Message', ErrorType.LINT, 1), |
285 matchesAnnotation('Message', ErrorType.LINT, 2)), | 277 matchesAnnotation('Message', ErrorType.LINT, 2)), |
286 throwsA(new isInstanceOf<TestFailure>())); | 278 throwsA(new isInstanceOf<TestFailure>())); |
287 }); | 279 }); |
288 }); | 280 }); |
| 281 |
| 282 group('reporting', () { |
| 283 //https://github.com/dart-lang/linter/issues/193 |
| 284 group('ignore synthetic nodes', () { |
| 285 String path = p.join('test', '_data', 'synthetic', 'synthetic.dart'); |
| 286 File file = new File(path); |
| 287 testRule('non_constant_identifier_names', file); |
| 288 }); |
| 289 }); |
289 } | 290 } |
290 | 291 |
291 /// Handy for debugging. | 292 /// Handy for debugging. |
292 defineSoloRuleTest(String ruleToTest) { | 293 defineSoloRuleTest(String ruleToTest) { |
293 for (var entry in new Directory(ruleDir).listSync()) { | 294 for (var entry in new Directory(ruleDir).listSync()) { |
294 if (entry is! File || !isDartFile(entry)) continue; | 295 if (entry is! File || !isDartFile(entry)) continue; |
295 var ruleName = p.basenameWithoutExtension(entry.path); | 296 var ruleName = p.basenameWithoutExtension(entry.path); |
296 if (ruleName == ruleToTest) { | 297 if (ruleName == ruleToTest) { |
297 testRule(ruleName, entry); | 298 testRule(ruleName, entry); |
298 } | 299 } |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 461 |
461 class NoFilter implements LintFilter { | 462 class NoFilter implements LintFilter { |
462 @override | 463 @override |
463 bool filter(AnalysisError lint) => false; | 464 bool filter(AnalysisError lint) => false; |
464 } | 465 } |
465 | 466 |
466 class ResultReporter extends DetailedReporter { | 467 class ResultReporter extends DetailedReporter { |
467 ResultReporter(Iterable<AnalysisErrorInfo> errors) | 468 ResultReporter(Iterable<AnalysisErrorInfo> errors) |
468 : super(errors, new NoFilter(), stdout); | 469 : super(errors, new NoFilter(), stdout); |
469 } | 470 } |
OLD | NEW |