| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.generated.resolver_test_case; | 5 library analyzer.test.generated.resolver_test_case; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 /** | 749 /** |
| 750 * Looks up the identifier with [name] and validates that its type type | 750 * Looks up the identifier with [name] and validates that its type type |
| 751 * stringifies to [type] and that its generics match the given stringified | 751 * stringifies to [type] and that its generics match the given stringified |
| 752 * output. | 752 * output. |
| 753 */ | 753 */ |
| 754 expectFunctionType(String name, String type, | 754 expectFunctionType(String name, String type, |
| 755 {String elementTypeParams: '[]', | 755 {String elementTypeParams: '[]', |
| 756 String typeParams: '[]', | 756 String typeParams: '[]', |
| 757 String typeArgs: '[]', | 757 String typeArgs: '[]', |
| 758 String typeFormals: '[]'}) { | 758 String typeFormals: '[]'}) { |
| 759 typeParameters(Element element) { |
| 760 if (element is ExecutableElement) { |
| 761 return element.typeParameters; |
| 762 } else if (element is ParameterElement) { |
| 763 return element.typeParameters; |
| 764 } |
| 765 fail('Wrong element type: ${element.runtimeType}'); |
| 766 } |
| 759 SimpleIdentifier identifier = findIdentifier(name); | 767 SimpleIdentifier identifier = findIdentifier(name); |
| 760 // Element is either ExecutableElement or ParameterElement. | 768 // Element is either ExecutableElement or ParameterElement. |
| 761 var element = identifier.staticElement; | 769 Element element = identifier.staticElement; |
| 762 FunctionTypeImpl functionType = identifier.staticType; | 770 FunctionTypeImpl functionType = identifier.staticType; |
| 763 expect(functionType.toString(), type); | 771 expect(functionType.toString(), type); |
| 764 expect(element.typeParameters.toString(), elementTypeParams); | 772 expect(typeParameters(element).toString(), elementTypeParams); |
| 765 expect(functionType.typeParameters.toString(), typeParams); | 773 expect(functionType.typeParameters.toString(), typeParams); |
| 766 expect(functionType.typeArguments.toString(), typeArgs); | 774 expect(functionType.typeArguments.toString(), typeArgs); |
| 767 expect(functionType.typeFormals.toString(), typeFormals); | 775 expect(functionType.typeFormals.toString(), typeFormals); |
| 768 } | 776 } |
| 769 | 777 |
| 770 /** | 778 /** |
| 771 * Looks up the identifier with [name] and validates its static [type]. | 779 * Looks up the identifier with [name] and validates its static [type]. |
| 772 * | 780 * |
| 773 * If [type] is a string, validates that the identifier's static type | 781 * If [type] is a string, validates that the identifier's static type |
| 774 * stringifies to that text. Otherwise, [type] is used directly a [Matcher] | 782 * stringifies to that text. Otherwise, [type] is used directly a [Matcher] |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 * text. Otherwise, [expected] is used directly a [Matcher] to match the type. | 837 * text. Otherwise, [expected] is used directly a [Matcher] to match the type. |
| 830 */ | 838 */ |
| 831 _expectType(DartType type, expected) { | 839 _expectType(DartType type, expected) { |
| 832 if (expected is String) { | 840 if (expected is String) { |
| 833 expect(type.toString(), expected); | 841 expect(type.toString(), expected); |
| 834 } else { | 842 } else { |
| 835 expect(type, expected); | 843 expect(type, expected); |
| 836 } | 844 } |
| 837 } | 845 } |
| 838 } | 846 } |
| OLD | NEW |