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

Unified Diff: pkg/analyzer/test/src/dart/element/element_test.dart

Issue 1686893002: Consolidate the code that replaces a TypeParameter with its bound. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add unit tests. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/dart/element/element_test.dart
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 3f0aa8402837da0ec23b7e52bb31ef43c28d29be..f907ae3c6021abbbb38ca7b5b7887c5a90e5a7dd 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -1857,6 +1857,14 @@ class FunctionTypeImplTest extends EngineTestCase {
expect(paramType.prunedTypedefs[0], same(f));
}
+ void test_resolveToBound() {
+ FunctionElementImpl f = ElementFactory.functionElement('f');
+ FunctionTypeImpl type = f.type;
+
+ // Returns this.
+ expect(type.resolveToBound(null), same(type));
+ }
+
void test_returnType_pruned_no_type_arguments() {
FunctionTypeAliasElementImpl f =
ElementFactory.functionTypeAliasElement('f');
@@ -3392,6 +3400,14 @@ class InterfaceTypeImplTest extends EngineTestCase {
expect(typeA.lookUpSetter("s", library), isNull);
}
+ void test_resolveToBound() {
+ InterfaceTypeImpl type =
+ ElementFactory.classElement2("A").type as InterfaceTypeImpl;
+
+ // Returns this.
+ expect(type.resolveToBound(null), same(type));
+ }
+
void test_setTypeArguments() {
InterfaceTypeImpl type =
ElementFactory.classElement2("A").type as InterfaceTypeImpl;
@@ -3936,6 +3952,36 @@ class TypeParameterTypeImplTest extends EngineTestCase {
expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue);
}
+ void test_resolveToBound_unbound() {
+ TypeParameterTypeImpl type = new TypeParameterTypeImpl(
+ new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")));
+ // Returns whatever type is passed to resolveToBound().
+ expect(type.resolveToBound(VoidTypeImpl.instance),
+ same(VoidTypeImpl.instance));
+ }
+
+ void test_resolveToBound_bound() {
+ ClassElementImpl classS = ElementFactory.classElement2("A");
+ TypeParameterElementImpl element =
+ new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"));
+ element.bound = classS.type;
+ TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
+ expect(type.resolveToBound(null), same(classS.type));
+ }
+
+ void test_resolveToBound_nestedBound() {
+ ClassElementImpl classS = ElementFactory.classElement2("A");
+ TypeParameterElementImpl elementE =
+ new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"));
+ elementE.bound = classS.type;
+ TypeParameterTypeImpl typeE = new TypeParameterTypeImpl(elementE);
+ TypeParameterElementImpl elementF =
+ new TypeParameterElementImpl.forNode(AstFactory.identifier3("F"));
+ elementF.bound = typeE;
+ TypeParameterTypeImpl typeF = new TypeParameterTypeImpl(elementE);
+ expect(typeF.resolveToBound(null), same(classS.type));
+ }
+
void test_substitute_equal() {
TypeParameterElementImpl element =
new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"));
@@ -3995,6 +4041,11 @@ class VoidTypeImplTest extends EngineTestCase {
void test_isVoid() {
expect(_voidType.isVoid, isTrue);
}
+
+ void test_resolveToBound() {
+ // Returns this.
+ expect(_voidType.resolveToBound(null), same(_voidType));
+ }
}
class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698