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

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

Issue 2613383003: Add support for generic function type syntax, part 1 (Closed)
Patch Set: 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 4523 matching lines...) Expand 10 before | Expand all | Expand 10 after
4534 // validate 4534 // validate
4535 CompilationUnit unit = outputs[RESOLVED_UNIT4]; 4535 CompilationUnit unit = outputs[RESOLVED_UNIT4];
4536 FunctionTypeAlias nodeF = unit.declarations[0]; 4536 FunctionTypeAlias nodeF = unit.declarations[0];
4537 // but 'T extends String' is resolved 4537 // but 'T extends String' is resolved
4538 _assertTypeParameterBound( 4538 _assertTypeParameterBound(
4539 nodeF.typeParameters.typeParameters[0], 'String', 'String'); 4539 nodeF.typeParameters.typeParameters[0], 'String', 'String');
4540 } 4540 }
4541 4541
4542 void _assertTypeParameterBound(TypeParameter typeParameter, 4542 void _assertTypeParameterBound(TypeParameter typeParameter,
4543 String expectedBoundTypeString, String expectedBoundElementName) { 4543 String expectedBoundTypeString, String expectedBoundElementName) {
4544 TypeName boundNode = typeParameter.bound; 4544 TypeAnnotation bound = typeParameter.bound;
4545 // TODO(brianwilkerson) Extend this to support function types as bounds.
4546 expect(bound, new isInstanceOf<TypeName>());
4547 TypeName boundNode = bound;
4545 Identifier boundName = boundNode.name; 4548 Identifier boundName = boundNode.name;
4546 expect(boundNode.type.toString(), expectedBoundTypeString); 4549 expect(boundNode.type.toString(), expectedBoundTypeString);
4547 expect(boundName.staticType.toString(), expectedBoundTypeString); 4550 expect(boundName.staticType.toString(), expectedBoundTypeString);
4548 expect(resolutionMap.staticElementForIdentifier(boundName).displayName, 4551 expect(resolutionMap.staticElementForIdentifier(boundName).displayName,
4549 expectedBoundElementName); 4552 expectedBoundElementName);
4550 } 4553 }
4551 } 4554 }
4552 4555
4553 @reflectiveTest 4556 @reflectiveTest
4554 class ResolveUnitTaskTest extends _AbstractDartTaskTest { 4557 class ResolveUnitTaskTest extends _AbstractDartTaskTest {
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
5726 /** 5729 /**
5727 * Fill [errorListener] with [result] errors in the current [task]. 5730 * Fill [errorListener] with [result] errors in the current [task].
5728 */ 5731 */
5729 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 5732 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
5730 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; 5733 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>;
5731 expect(errors, isNotNull, reason: result.name); 5734 expect(errors, isNotNull, reason: result.name);
5732 errorListener = new GatheringErrorListener(); 5735 errorListener = new GatheringErrorListener();
5733 errorListener.addAll(errors); 5736 errorListener.addAll(errors);
5734 } 5737 }
5735 } 5738 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/dart/ast/utilities_test.dart ('k') | pkg/analyzer/tool/summary/generate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698