Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 2640853005: Make Analyzer, VM and dart2js accept URI strings as part-of library identifier. (Closed)
Patch Set: Add tests, enable flag by default in analyzer. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (context.analysisOptions.enableUriInPartOf) {
874 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]); 874 // Should report that names are wrong.
Lasse Reichstein Nielsen 2017/01/26 10:39:13 TODO added here.
875 AnalysisError error = errorListener.errors[0]; 875 } else {
876 expect(error.getProperty(ErrorProperty.PARTS_LIBRARY_NAME), 'my_lib'); 876 _assertErrorsWithCodes(
877 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]);
878 AnalysisError error = errorListener.errors[0];
879 expect(error.getProperty(ErrorProperty.PARTS_LIBRARY_NAME), 'my_lib');
880 }
877 } 881 }
878 882
879 test_perform_error_missingLibraryDirectiveWithPart_noCommon() { 883 test_perform_error_missingLibraryDirectiveWithPart_noCommon() {
880 _performBuildTask({ 884 _performBuildTask({
881 '/lib.dart': ''' 885 '/lib.dart': '''
882 part 'partA.dart'; 886 part 'partA.dart';
883 part 'partB.dart'; 887 part 'partB.dart';
884 ''', 888 ''',
885 '/partA.dart': ''' 889 '/partA.dart': '''
886 part of libA; 890 part of libA;
887 ''', 891 ''',
888 '/partB.dart': ''' 892 '/partB.dart': '''
889 part of libB; 893 part of libB;
890 ''' 894 '''
891 }); 895 });
892 _assertErrorsWithCodes( 896 if (context.analysisOptions.enableUriInPartOf) {
893 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]); 897 // Should report that names are wrong.
Lasse Reichstein Nielsen 2017/01/26 10:39:13 TODO added here.
894 AnalysisError error = errorListener.errors[0]; 898 } else {
895 expect(error.getProperty(ErrorProperty.PARTS_LIBRARY_NAME), isNull); 899 _assertErrorsWithCodes(
900 [ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART]);
901 AnalysisError error = errorListener.errors[0];
902 expect(error.getProperty(ErrorProperty.PARTS_LIBRARY_NAME), isNull);
903 }
896 } 904 }
897 905
898 test_perform_error_partDoesNotExist() { 906 test_perform_error_partDoesNotExist() {
899 _performBuildTask({ 907 _performBuildTask({
900 '/lib.dart': ''' 908 '/lib.dart': '''
901 library lib; 909 library lib;
902 part 'part.dart'; 910 part 'part.dart';
903 ''' 911 '''
904 }); 912 });
905 // we already report URI_DOES_NOT_EXIST, no need to report other errors 913 // 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
5729 /** 5737 /**
5730 * Fill [errorListener] with [result] errors in the current [task]. 5738 * Fill [errorListener] with [result] errors in the current [task].
5731 */ 5739 */
5732 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 5740 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
5733 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; 5741 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>;
5734 expect(errors, isNotNull, reason: result.name); 5742 expect(errors, isNotNull, reason: result.name);
5735 errorListener = new GatheringErrorListener(); 5743 errorListener = new GatheringErrorListener();
5736 errorListener.addAll(errors); 5744 errorListener.addAll(errors);
5737 } 5745 }
5738 } 5746 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698