| 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/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
| 10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 expect( | 850 expect( |
| 851 (libraryUnit.directives[1] as PartDirective).element, same(firstPart)); | 851 (libraryUnit.directives[1] as PartDirective).element, same(firstPart)); |
| 852 | 852 |
| 853 expect(secondPart.uri, 'part2.dart'); | 853 expect(secondPart.uri, 'part2.dart'); |
| 854 expect(secondPart.uriOffset, 37); | 854 expect(secondPart.uriOffset, 37); |
| 855 expect(secondPart.uriEnd, 49); | 855 expect(secondPart.uriEnd, 49); |
| 856 expect( | 856 expect( |
| 857 (libraryUnit.directives[2] as PartDirective).element, same(secondPart)); | 857 (libraryUnit.directives[2] as PartDirective).element, same(secondPart)); |
| 858 } | 858 } |
| 859 | 859 |
| 860 test_perform_error_missingLibraryDirectiveWithPart_hasCommon() { | 860 test_perform_error_missingLibraryDirectiveWithPart() { |
| 861 _performBuildTask({ | 861 _performBuildTask({ |
| 862 '/lib.dart': ''' | 862 '/lib.dart': ''' |
| 863 part 'partA.dart'; | 863 part 'partA.dart'; |
| 864 part 'partB.dart'; | 864 part 'partB.dart'; |
| 865 ''', | 865 ''', |
| 866 '/partA.dart': ''' | 866 '/partA.dart': ''' |
| 867 part of my_lib; | 867 part of my_lib; |
| 868 ''', | 868 ''', |
| 869 '/partB.dart': ''' | 869 '/partB.dart': ''' |
| 870 part of my_lib; | 870 part of my_lib; |
| 871 ''' | 871 ''' |
| 872 }); | 872 }); |
| 873 _assertErrorsWithCodes( | 873 _assertErrorsWithCodes( |
| 874 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]); | 874 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]); |
| 875 AnalysisError error = errorListener.errors[0]; | |
| 876 expect(error.getProperty(ErrorProperty.PARTS_LIBRARY_NAME), 'my_lib'); | |
| 877 } | |
| 878 | |
| 879 test_perform_error_missingLibraryDirectiveWithPart_noCommon() { | |
| 880 _performBuildTask({ | |
| 881 '/lib.dart': ''' | |
| 882 part 'partA.dart'; | |
| 883 part 'partB.dart'; | |
| 884 ''', | |
| 885 '/partA.dart': ''' | |
| 886 part of libA; | |
| 887 ''', | |
| 888 '/partB.dart': ''' | |
| 889 part of libB; | |
| 890 ''' | |
| 891 }); | |
| 892 _assertErrorsWithCodes( | |
| 893 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]); | |
| 894 AnalysisError error = errorListener.errors[0]; | |
| 895 expect(error.getProperty(ErrorProperty.PARTS_LIBRARY_NAME), isNull); | |
| 896 } | 875 } |
| 897 | 876 |
| 898 test_perform_error_partDoesNotExist() { | 877 test_perform_error_partDoesNotExist() { |
| 899 _performBuildTask({ | 878 _performBuildTask({ |
| 900 '/lib.dart': ''' | 879 '/lib.dart': ''' |
| 901 library lib; | 880 library lib; |
| 902 part 'part.dart'; | 881 part 'part.dart'; |
| 903 ''' | 882 ''' |
| 904 }); | 883 }); |
| 905 // we already report URI_DOES_NOT_EXIST, no need to report other errors | 884 // we already report URI_DOES_NOT_EXIST, no need to report other errors |
| (...skipping 4823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5729 /** | 5708 /** |
| 5730 * Fill [errorListener] with [result] errors in the current [task]. | 5709 * Fill [errorListener] with [result] errors in the current [task]. |
| 5731 */ | 5710 */ |
| 5732 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 5711 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
| 5733 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; | 5712 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; |
| 5734 expect(errors, isNotNull, reason: result.name); | 5713 expect(errors, isNotNull, reason: result.name); |
| 5735 errorListener = new GatheringErrorListener(); | 5714 errorListener = new GatheringErrorListener(); |
| 5736 errorListener.addAll(errors); | 5715 errorListener.addAll(errors); |
| 5737 } | 5716 } |
| 5738 } | 5717 } |
| OLD | NEW |