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

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

Issue 2782533002: Report errors for the new top-level inference rules. (Closed)
Patch Set: Update language_strong status for analyzer. Created 3 years, 8 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 2900 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 typeM); 2911 typeM);
2912 expect(variableC.initializer.staticType, typeM); 2912 expect(variableC.initializer.staticType, typeM);
2913 } 2913 }
2914 2914
2915 void test_perform_simple() { 2915 void test_perform_simple() {
2916 enableStrongMode(); 2916 enableStrongMode();
2917 AnalysisTarget source = newSource( 2917 AnalysisTarget source = newSource(
2918 '/test.dart', 2918 '/test.dart',
2919 ''' 2919 '''
2920 var X = 1; 2920 var X = 1;
2921 2921 var Y = () => 1 + X;
2922 var Y = () {
2923 return 1 + X;
2924 };
2925 '''); 2922 ''');
2926 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8, 2923 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT8,
2927 matcher: isInferStaticVariableTypesInUnitTask); 2924 matcher: isInferStaticVariableTypesInUnitTask);
2928 CompilationUnit unit = outputs[RESOLVED_UNIT8]; 2925 CompilationUnit unit = outputs[RESOLVED_UNIT8];
2929 TopLevelVariableDeclaration declaration = unit.declarations[1]; 2926 TopLevelVariableDeclaration declaration = unit.declarations[1];
2930 FunctionExpression function = 2927 FunctionExpression function =
2931 declaration.variables.variables[0].initializer; 2928 declaration.variables.variables[0].initializer;
2932 BlockFunctionBody body = function.body; 2929 ExpressionFunctionBody body = function.body;
2933 ReturnStatement statement = body.block.statements[0]; 2930 Expression expression = body.expression;
2934 Expression expression = statement.expression;
2935 InterfaceType intType = context.typeProvider.intType; 2931 InterfaceType intType = context.typeProvider.intType;
2936 expect(expression.staticType, intType); 2932 expect(expression.staticType, intType);
2937 } 2933 }
2938 2934
2939 test_staticModeHints_forStaticVariableInference() { 2935 test_staticModeHints_forStaticVariableInference() {
2940 context.analysisOptions = 2936 context.analysisOptions =
2941 new AnalysisOptionsImpl.from(context.analysisOptions) 2937 new AnalysisOptionsImpl.from(context.analysisOptions)
2942 ..strongModeHints = true; 2938 ..strongModeHints = true;
2943 Source source = newSource( 2939 Source source = newSource(
2944 '/test.dart', 2940 '/test.dart',
(...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after
5745 /** 5741 /**
5746 * Fill [errorListener] with [result] errors in the current [task]. 5742 * Fill [errorListener] with [result] errors in the current [task].
5747 */ 5743 */
5748 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 5744 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
5749 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; 5745 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>;
5750 expect(errors, isNotNull, reason: result.name); 5746 expect(errors, isNotNull, reason: result.name);
5751 errorListener = new GatheringErrorListener(); 5747 errorListener = new GatheringErrorListener();
5752 errorListener.addAll(errors); 5748 errorListener.addAll(errors);
5753 } 5749 }
5754 } 5750 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/summary/top_level_inference_test.dart ('k') | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698