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 analyzer.test.src.task.dart_test; | 5 library analyzer.test.src.task.dart_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 4446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4457 FunctionElement main = mainDeclaration.element; | 4457 FunctionElement main = mainDeclaration.element; |
4458 expectMutated(body, main.parameters[0], false, false); | 4458 expectMutated(body, main.parameters[0], false, false); |
4459 expectMutated(body, main.parameters[1], false, true); | 4459 expectMutated(body, main.parameters[1], false, true); |
4460 expectMutated(body, main.parameters[2], true, true); | 4460 expectMutated(body, main.parameters[2], true, true); |
4461 expectMutated(body, main.parameters[3], true, true); | 4461 expectMutated(body, main.parameters[3], true, true); |
4462 } | 4462 } |
4463 } | 4463 } |
4464 | 4464 |
4465 @reflectiveTest | 4465 @reflectiveTest |
4466 class ScanDartTaskTest extends _AbstractDartTaskTest { | 4466 class ScanDartTaskTest extends _AbstractDartTaskTest { |
4467 test_ignore_info() { | |
4468 _performScanTask(''' | |
4469 //ignore: error_code | |
4470 var x = ''; | |
4471 foo(); // ignore: error_code_2 | |
4472 bar(); //ignore: error_code, error_code_2 | |
4473 '''); | |
4474 | |
4475 IgnoreInfo info = outputs[IGNORE_INFO]; | |
4476 expect(info.ignores.keys, hasLength(3)); | |
4477 expect(info.ignores[1].first, 'error_code'); | |
4478 expect(info.ignores[3].first, 'error_code_2'); | |
4479 expect(info.ignores[4], unorderedEquals(['error_code', 'error_code_2'])); | |
4480 } | |
4481 | |
4467 test_perform_errors() { | 4482 test_perform_errors() { |
4468 _performScanTask('import "'); | 4483 _performScanTask('import "'); |
4469 expect(outputs, hasLength(3)); | 4484 expect(outputs, hasLength(4)); |
4470 expect(outputs[LINE_INFO], isNotNull); | 4485 expect(outputs[LINE_INFO], isNotNull); |
4486 expect(outputs[IGNORE_INFO], isNotNull); | |
scheglov
2016/05/27 18:05:47
Would be nice to test the computed IgnoreInfo here
Brian Wilkerson
2016/05/27 18:21:18
If the method in the task gets moved to the class,
pquitslund
2016/05/27 21:50:53
Done.
| |
4471 expect(outputs[SCAN_ERRORS], hasLength(1)); | 4487 expect(outputs[SCAN_ERRORS], hasLength(1)); |
4472 expect(outputs[TOKEN_STREAM], isNotNull); | 4488 expect(outputs[TOKEN_STREAM], isNotNull); |
4473 } | 4489 } |
4474 | 4490 |
4475 test_perform_noErrors() { | 4491 test_perform_noErrors() { |
4476 _performScanTask('class A {}'); | 4492 _performScanTask('class A {}'); |
4477 expect(outputs, hasLength(3)); | 4493 expect(outputs, hasLength(4)); |
4478 expect(outputs[LINE_INFO], isNotNull); | 4494 expect(outputs[LINE_INFO], isNotNull); |
4495 expect(outputs[IGNORE_INFO], isNotNull); | |
4479 expect(outputs[SCAN_ERRORS], hasLength(0)); | 4496 expect(outputs[SCAN_ERRORS], hasLength(0)); |
4480 expect(outputs[TOKEN_STREAM], isNotNull); | 4497 expect(outputs[TOKEN_STREAM], isNotNull); |
4481 } | 4498 } |
4482 | 4499 |
4483 test_perform_script() { | 4500 test_perform_script() { |
4484 String scriptContent = ''' | 4501 String scriptContent = ''' |
4485 void buttonPressed() { | 4502 void buttonPressed() { |
4486 '''; | 4503 '''; |
4487 String htmlContent = ''' | 4504 String htmlContent = ''' |
4488 <!DOCTYPE html> | 4505 <!DOCTYPE html> |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5333 /** | 5350 /** |
5334 * Fill [errorListener] with [result] errors in the current [task]. | 5351 * Fill [errorListener] with [result] errors in the current [task]. |
5335 */ | 5352 */ |
5336 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 5353 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
5337 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; | 5354 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; |
5338 expect(errors, isNotNull, reason: result.name); | 5355 expect(errors, isNotNull, reason: result.name); |
5339 errorListener = new GatheringErrorListener(); | 5356 errorListener = new GatheringErrorListener(); |
5340 errorListener.addAll(errors); | 5357 errorListener.addAll(errors); |
5341 } | 5358 } |
5342 } | 5359 } |
OLD | NEW |