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

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

Issue 1517723002: Server custom error severity support (#24452). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: lib_renames Created 5 years 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
« no previous file with comments | « pkg/analyzer/test/source/test_all.dart ('k') | pkg/analyzer/test/src/task/options_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 29 matching lines...) Expand all
40 runReflectiveTests(BuildPublicNamespaceTaskTest); 40 runReflectiveTests(BuildPublicNamespaceTaskTest);
41 runReflectiveTests(BuildSourceExportClosureTaskTest); 41 runReflectiveTests(BuildSourceExportClosureTaskTest);
42 runReflectiveTests(BuildTypeProviderTaskTest); 42 runReflectiveTests(BuildTypeProviderTaskTest);
43 runReflectiveTests(ComputeConstantDependenciesTaskTest); 43 runReflectiveTests(ComputeConstantDependenciesTaskTest);
44 runReflectiveTests(ComputeConstantValueTaskTest); 44 runReflectiveTests(ComputeConstantValueTaskTest);
45 runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest); 45 runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest);
46 runReflectiveTests(ComputeLibraryCycleTaskTest); 46 runReflectiveTests(ComputeLibraryCycleTaskTest);
47 runReflectiveTests(ComputePropagableVariableDependenciesTaskTest); 47 runReflectiveTests(ComputePropagableVariableDependenciesTaskTest);
48 runReflectiveTests(ContainingLibrariesTaskTest); 48 runReflectiveTests(ContainingLibrariesTaskTest);
49 runReflectiveTests(DartErrorsTaskTest); 49 runReflectiveTests(DartErrorsTaskTest);
50 runReflectiveTests(ErrorFilterTest);
51 runReflectiveTests(EvaluateUnitConstantsTaskTest); 50 runReflectiveTests(EvaluateUnitConstantsTaskTest);
52 runReflectiveTests(GatherUsedImportedElementsTaskTest); 51 runReflectiveTests(GatherUsedImportedElementsTaskTest);
53 runReflectiveTests(GatherUsedLocalElementsTaskTest); 52 runReflectiveTests(GatherUsedLocalElementsTaskTest);
54 runReflectiveTests(GenerateHintsTaskTest); 53 runReflectiveTests(GenerateHintsTaskTest);
55 runReflectiveTests(GenerateLintsTaskTest); 54 runReflectiveTests(GenerateLintsTaskTest);
56 runReflectiveTests(InferInstanceMembersInUnitTaskTest); 55 runReflectiveTests(InferInstanceMembersInUnitTaskTest);
57 runReflectiveTests(InferStaticVariableTypesInUnitTaskTest); 56 runReflectiveTests(InferStaticVariableTypesInUnitTaskTest);
58 runReflectiveTests(InferStaticVariableTypeTaskTest); 57 runReflectiveTests(InferStaticVariableTypeTaskTest);
59 runReflectiveTests(LibraryErrorsReadyTaskTest); 58 runReflectiveTests(LibraryErrorsReadyTaskTest);
60 runReflectiveTests(LibraryUnitErrorsTaskTest); 59 runReflectiveTests(LibraryUnitErrorsTaskTest);
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 for (CompilationUnitMember member in unit.declarations) { 1108 for (CompilationUnitMember member in unit.declarations) {
1110 if (member is ClassDeclaration && member.name.name == className) { 1109 if (member is ClassDeclaration && member.name.name == className) {
1111 expect(member.metadata, hasLength(1)); 1110 expect(member.metadata, hasLength(1));
1112 Annotation annotation = member.metadata[0]; 1111 Annotation annotation = member.metadata[0];
1113 ConstantEvaluationTarget_Annotation target = 1112 ConstantEvaluationTarget_Annotation target =
1114 new ConstantEvaluationTarget_Annotation( 1113 new ConstantEvaluationTarget_Annotation(
1115 context, source, source, annotation); 1114 context, source, source, annotation);
1116 computeResult(target, CONSTANT_VALUE, 1115 computeResult(target, CONSTANT_VALUE,
1117 matcher: isComputeConstantValueTask); 1116 matcher: isComputeConstantValueTask);
1118 expect(outputs[CONSTANT_VALUE], same(target)); 1117 expect(outputs[CONSTANT_VALUE], same(target));
1119 EvaluationResultImpl evaluationResult = (annotation.elementAnnotation 1118 EvaluationResultImpl evaluationResult =
1120 as ElementAnnotationImpl).evaluationResult; 1119 (annotation.elementAnnotation as ElementAnnotationImpl)
1120 .evaluationResult;
1121 return evaluationResult; 1121 return evaluationResult;
1122 } 1122 }
1123 } 1123 }
1124 fail('Annotation not found'); 1124 fail('Annotation not found');
1125 return null; 1125 return null;
1126 } 1126 }
1127 1127
1128 test_annotation_non_const_constructor() { 1128 test_annotation_non_const_constructor() {
1129 // Calling a non-const constructor from an annotation that is illegal, but 1129 // Calling a non-const constructor from an annotation that is illegal, but
1130 // shouldn't crash analysis. 1130 // shouldn't crash analysis.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 void _checkCircularities( 1278 void _checkCircularities(
1279 String variableName, List<String> otherVariables, String content) { 1279 String variableName, List<String> otherVariables, String content) {
1280 // Evaluating the first constant should produce an error. 1280 // Evaluating the first constant should produce an error.
1281 CompilationUnit unit = _resolveUnit(content); 1281 CompilationUnit unit = _resolveUnit(content);
1282 _expectCircularityError(_evaluateConstant(unit, variableName)); 1282 _expectCircularityError(_evaluateConstant(unit, variableName));
1283 // And all the other constants involved in the strongly connected component 1283 // And all the other constants involved in the strongly connected component
1284 // should be set to the same error state. 1284 // should be set to the same error state.
1285 for (String otherVariableName in otherVariables) { 1285 for (String otherVariableName in otherVariables) {
1286 PropertyInducingElement otherVariableElement = 1286 PropertyInducingElement otherVariableElement =
1287 AstFinder.getTopLevelVariableElement(unit, otherVariableName); 1287 AstFinder.getTopLevelVariableElement(unit, otherVariableName);
1288 _expectCircularityError((otherVariableElement 1288 _expectCircularityError(
1289 as TopLevelVariableElementImpl).evaluationResult); 1289 (otherVariableElement as TopLevelVariableElementImpl)
1290 .evaluationResult);
1290 } 1291 }
1291 } 1292 }
1292 1293
1293 EvaluationResultImpl _computeTopLevelVariableConstValue( 1294 EvaluationResultImpl _computeTopLevelVariableConstValue(
1294 String variableName, String content) { 1295 String variableName, String content) {
1295 return _evaluateConstant(_resolveUnit(content), variableName); 1296 return _evaluateConstant(_resolveUnit(content), variableName);
1296 } 1297 }
1297 1298
1298 EvaluationResultImpl _evaluateConstant( 1299 EvaluationResultImpl _evaluateConstant(
1299 CompilationUnit unit, String variableName) { 1300 CompilationUnit unit, String variableName) {
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 computeResult(part, DART_ERRORS, matcher: isDartErrorsTask); 1956 computeResult(part, DART_ERRORS, matcher: isDartErrorsTask);
1956 expect(outputs, hasLength(1)); 1957 expect(outputs, hasLength(1));
1957 List<AnalysisError> errors = outputs[DART_ERRORS]; 1958 List<AnalysisError> errors = outputs[DART_ERRORS];
1958 // This should contain only the errors in the part file, not the ones in the 1959 // This should contain only the errors in the part file, not the ones in the
1959 // library. 1960 // library.
1960 expect(errors, hasLength(1)); 1961 expect(errors, hasLength(1));
1961 } 1962 }
1962 } 1963 }
1963 1964
1964 @reflectiveTest 1965 @reflectiveTest
1965 class ErrorFilterTest extends _AbstractDartTaskTest {
1966 @override
1967 setUp() {
1968 super.setUp();
1969 context.setConfigurationData(CONFIGURED_ERROR_FILTERS, [
1970 (AnalysisError error) => error.errorCode.name == 'INVALID_ASSIGNMENT'
1971 ]);
1972 }
1973
1974 test_error_filters() {
1975 AnalysisTarget library = newSource(
1976 '/test.dart',
1977 '''
1978 main() {
1979 int x = ""; // INVALID_ASSIGNMENT (suppressed)
1980 // UNUSED_LOCAL_VARIABLE
1981 }''');
1982 computeResult(library, DART_ERRORS, matcher: isDartErrorsTask);
1983 expect(outputs, hasLength(1));
1984 List<AnalysisError> errors = outputs[DART_ERRORS];
1985 expect(errors, hasLength(1));
1986 expect(errors.first.errorCode, HintCode.UNUSED_LOCAL_VARIABLE);
1987 }
1988 }
1989
1990 @reflectiveTest
1991 class EvaluateUnitConstantsTaskTest extends _AbstractDartTaskTest { 1966 class EvaluateUnitConstantsTaskTest extends _AbstractDartTaskTest {
1992 test_perform() { 1967 test_perform() {
1993 Source source = newSource( 1968 Source source = newSource(
1994 '/test.dart', 1969 '/test.dart',
1995 ''' 1970 '''
1996 class C { 1971 class C {
1997 const C(); 1972 const C();
1998 } 1973 }
1999 1974
2000 @x 1975 @x
(...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after
3872 '''); 3847 ''');
3873 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT10); 3848 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT10);
3874 CompilationUnit unit = outputs[RESOLVED_UNIT10]; 3849 CompilationUnit unit = outputs[RESOLVED_UNIT10];
3875 VariableElement piFirst = 3850 VariableElement piFirst =
3876 AstFinder.getTopLevelVariable(unit, 'piFirst').name.staticElement; 3851 AstFinder.getTopLevelVariable(unit, 'piFirst').name.staticElement;
3877 VariableElement pi = 3852 VariableElement pi =
3878 AstFinder.getTopLevelVariable(unit, 'pi').name.staticElement; 3853 AstFinder.getTopLevelVariable(unit, 'pi').name.staticElement;
3879 VariableElement tau = 3854 VariableElement tau =
3880 AstFinder.getTopLevelVariable(unit, 'tau').name.staticElement; 3855 AstFinder.getTopLevelVariable(unit, 'tau').name.staticElement;
3881 Expression piFirstUse = (AstFinder 3856 Expression piFirstUse = (AstFinder
3882 .getTopLevelVariable(unit, 'tau') 3857 .getTopLevelVariable(unit, 'tau')
3883 .initializer as ConditionalExpression).condition; 3858 .initializer as ConditionalExpression)
3859 .condition;
3884 3860
3885 expect(piFirstUse.staticType, context.typeProvider.boolType); 3861 expect(piFirstUse.staticType, context.typeProvider.boolType);
3886 expect(piFirst.type, context.typeProvider.boolType); 3862 expect(piFirst.type, context.typeProvider.boolType);
3887 expect(pi.type.isDynamic, isTrue); 3863 expect(pi.type.isDynamic, isTrue);
3888 expect(tau.type.isDynamic, isTrue); 3864 expect(tau.type.isDynamic, isTrue);
3889 } 3865 }
3890 3866
3891 void test_perform_inference_cross_unit_cyclic() { 3867 void test_perform_inference_cross_unit_cyclic() {
3892 AnalysisTarget firstSource = newSource( 3868 AnalysisTarget firstSource = newSource(
3893 '/a.dart', 3869 '/a.dart',
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
4592 /** 4568 /**
4593 * Fill [errorListener] with [result] errors in the current [task]. 4569 * Fill [errorListener] with [result] errors in the current [task].
4594 */ 4570 */
4595 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 4571 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
4596 List<AnalysisError> errors = task.outputs[result]; 4572 List<AnalysisError> errors = task.outputs[result];
4597 expect(errors, isNotNull, reason: result.name); 4573 expect(errors, isNotNull, reason: result.name);
4598 errorListener = new GatheringErrorListener(); 4574 errorListener = new GatheringErrorListener();
4599 errorListener.addAll(errors); 4575 errorListener.addAll(errors);
4600 } 4576 }
4601 } 4577 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/source/test_all.dart ('k') | pkg/analyzer/test/src/task/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698