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

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

Issue 2971893002: Remove other usages of ExecutableElement.localVariables. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « pkg/analyzer/test/src/dart/element/element_test.dart ('k') | no next file » | 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/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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 '''); 178 ''');
179 CompilationUnit unit = outputs[RESOLVED_UNIT1]; 179 CompilationUnit unit = outputs[RESOLVED_UNIT1];
180 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; 180 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT];
181 Annotation annotation = unit.declarations 181 Annotation annotation = unit.declarations
182 .firstWhere((m) => m is FunctionDeclaration) 182 .firstWhere((m) => m is FunctionDeclaration)
183 .metadata[0]; 183 .metadata[0];
184 List<ConstantEvaluationTarget> expectedConstants = 184 List<ConstantEvaluationTarget> expectedConstants =
185 <ConstantEvaluationTarget>[ 185 <ConstantEvaluationTarget>[
186 unitElement.accessors.firstWhere((e) => e.isGetter).variable, 186 unitElement.accessors.firstWhere((e) => e.isGetter).variable,
187 unitElement.types[0].fields[0], 187 unitElement.types[0].fields[0],
188 unitElement.functions[0].localVariables[0], 188 findLocalVariable(unit, 'z'),
189 unitElement.types[0].constructors[0], 189 unitElement.types[0].constructors[0],
190 resolutionMap.elementAnnotationForAnnotation(annotation), 190 resolutionMap.elementAnnotationForAnnotation(annotation),
191 unitElement.types[0].constructors[0].parameters[0] 191 unitElement.types[0].constructors[0].parameters[0]
192 ]; 192 ];
193 expect( 193 expect(
194 outputs[COMPILATION_UNIT_CONSTANTS].toSet(), expectedConstants.toSet()); 194 outputs[COMPILATION_UNIT_CONSTANTS].toSet(), expectedConstants.toSet());
195 } 195 }
196 196
197 test_perform_library() { 197 test_perform_library() {
198 _performBuildTask(r''' 198 _performBuildTask(r'''
(...skipping 4120 matching lines...) Expand 10 before | Expand all | Expand 10 after
4319 } 4319 }
4320 } 4320 }
4321 '''); 4321 ''');
4322 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); 4322 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
4323 computeResult(target, RESOLVED_UNIT6, 4323 computeResult(target, RESOLVED_UNIT6,
4324 matcher: isResolveVariableReferencesTask); 4324 matcher: isResolveVariableReferencesTask);
4325 // validate 4325 // validate
4326 CompilationUnit unit = outputs[RESOLVED_UNIT6]; 4326 CompilationUnit unit = outputs[RESOLVED_UNIT6];
4327 FunctionDeclaration mainDeclaration = unit.declarations[0]; 4327 FunctionDeclaration mainDeclaration = unit.declarations[0];
4328 FunctionBody body = mainDeclaration.functionExpression.body; 4328 FunctionBody body = mainDeclaration.functionExpression.body;
4329 FunctionElement main = mainDeclaration.element; 4329 LocalVariableElement v1 = findLocalVariable(unit, 'v1');
4330 expectMutated(body, main.localVariables[0], false, false); 4330 LocalVariableElement v2 = findLocalVariable(unit, 'v2');
4331 expectMutated(body, main.localVariables[1], false, true); 4331 LocalVariableElement v3 = findLocalVariable(unit, 'v3');
4332 expectMutated(body, main.localVariables[2], true, true); 4332 LocalVariableElement v4 = findLocalVariable(unit, 'v4');
4333 expectMutated(body, main.localVariables[3], true, true); 4333 expectMutated(body, v1, false, false);
4334 expectMutated(body, v2, false, true);
4335 expectMutated(body, v3, true, true);
4336 expectMutated(body, v4, true, true);
4334 } 4337 }
4335 4338
4336 test_perform_parameter() { 4339 test_perform_parameter() {
4337 Source source = newSource( 4340 Source source = newSource(
4338 '/test.dart', 4341 '/test.dart',
4339 ''' 4342 '''
4340 main(p1, p2, p3, p4) { 4343 main(p1, p2, p3, p4) {
4341 p2 = 2; 4344 p2 = 2;
4342 p4 = 2; 4345 p4 = 2;
4343 localFunction() { 4346 localFunction() {
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
5307 /** 5310 /**
5308 * Fill [errorListener] with [result] errors in the current [task]. 5311 * Fill [errorListener] with [result] errors in the current [task].
5309 */ 5312 */
5310 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 5313 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
5311 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; 5314 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>;
5312 expect(errors, isNotNull, reason: result.name); 5315 expect(errors, isNotNull, reason: result.name);
5313 errorListener = new GatheringErrorListener(); 5316 errorListener = new GatheringErrorListener();
5314 errorListener.addAll(errors); 5317 errorListener.addAll(errors);
5315 } 5318 }
5316 } 5319 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/dart/element/element_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698