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

Side by Side Diff: pkg/analyzer/test/src/dart/element/element_test.dart

Issue 2524903002: Rename AstFactory -> AstTestFactory. (Closed)
Patch Set: Created 4 years 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.dart.element.element_test; 5 library analyzer.test.src.dart.element.element_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/constant/value.dart'; 8 import 'package:analyzer/dart/constant/value.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';
11 import 'package:analyzer/src/dart/element/element.dart'; 11 import 'package:analyzer/src/dart/element/element.dart';
12 import 'package:analyzer/src/dart/element/handle.dart'; 12 import 'package:analyzer/src/dart/element/handle.dart';
13 import 'package:analyzer/src/dart/element/type.dart'; 13 import 'package:analyzer/src/dart/element/type.dart';
14 import 'package:analyzer/src/generated/engine.dart' 14 import 'package:analyzer/src/generated/engine.dart'
15 show AnalysisContext, AnalysisOptionsImpl; 15 show AnalysisContext, AnalysisOptionsImpl;
16 import 'package:analyzer/src/generated/source_io.dart'; 16 import 'package:analyzer/src/generated/source_io.dart';
17 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 17 import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
18 import 'package:analyzer/src/generated/testing/element_factory.dart'; 18 import 'package:analyzer/src/generated/testing/element_factory.dart';
19 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; 19 import 'package:analyzer/src/generated/testing/test_type_provider.dart';
20 import 'package:test/test.dart'; 20 import 'package:test/test.dart';
21 import 'package:test_reflective_loader/test_reflective_loader.dart'; 21 import 'package:test_reflective_loader/test_reflective_loader.dart';
22 22
23 import '../../../generated/analysis_context_factory.dart' 23 import '../../../generated/analysis_context_factory.dart'
24 show AnalysisContextHelper; 24 show AnalysisContextHelper;
25 import '../../../generated/resolver_test_case.dart'; 25 import '../../../generated/resolver_test_case.dart';
26 import '../../../generated/test_support.dart'; 26 import '../../../generated/test_support.dart';
27 27
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 expect(nodeB.element, same(elementB)); 1322 expect(nodeB.element, same(elementB));
1323 } 1323 }
1324 } 1324 }
1325 } 1325 }
1326 1326
1327 @reflectiveTest 1327 @reflectiveTest
1328 class FunctionTypeImplTest extends EngineTestCase { 1328 class FunctionTypeImplTest extends EngineTestCase {
1329 void test_creation() { 1329 void test_creation() {
1330 expect( 1330 expect(
1331 new FunctionTypeImpl( 1331 new FunctionTypeImpl(
1332 new FunctionElementImpl.forNode(AstFactory.identifier3("f"))), 1332 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f"))),
1333 isNotNull); 1333 isNotNull);
1334 } 1334 }
1335 1335
1336 void test_equality_recursive() { 1336 void test_equality_recursive() {
1337 FunctionTypeAliasElementImpl s = 1337 FunctionTypeAliasElementImpl s =
1338 ElementFactory.functionTypeAliasElement('s'); 1338 ElementFactory.functionTypeAliasElement('s');
1339 FunctionTypeAliasElementImpl t = 1339 FunctionTypeAliasElementImpl t =
1340 ElementFactory.functionTypeAliasElement('t'); 1340 ElementFactory.functionTypeAliasElement('t');
1341 FunctionTypeAliasElementImpl u = 1341 FunctionTypeAliasElementImpl u =
1342 ElementFactory.functionTypeAliasElement('u'); 1342 ElementFactory.functionTypeAliasElement('u');
1343 FunctionTypeAliasElementImpl v = 1343 FunctionTypeAliasElementImpl v =
1344 ElementFactory.functionTypeAliasElement('v'); 1344 ElementFactory.functionTypeAliasElement('v');
1345 s.returnType = t.type; 1345 s.returnType = t.type;
1346 t.returnType = s.type; 1346 t.returnType = s.type;
1347 u.returnType = v.type; 1347 u.returnType = v.type;
1348 v.returnType = u.type; 1348 v.returnType = u.type;
1349 // We don't care whether the types compare equal or not. We just need the 1349 // We don't care whether the types compare equal or not. We just need the
1350 // computation to terminate. 1350 // computation to terminate.
1351 expect(s.type == u.type, new isInstanceOf<bool>()); 1351 expect(s.type == u.type, new isInstanceOf<bool>());
1352 } 1352 }
1353 1353
1354 void test_getElement() { 1354 void test_getElement() {
1355 FunctionElementImpl typeElement = 1355 FunctionElementImpl typeElement =
1356 new FunctionElementImpl.forNode(AstFactory.identifier3("f")); 1356 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f"));
1357 FunctionTypeImpl type = new FunctionTypeImpl(typeElement); 1357 FunctionTypeImpl type = new FunctionTypeImpl(typeElement);
1358 expect(type.element, typeElement); 1358 expect(type.element, typeElement);
1359 } 1359 }
1360 1360
1361 void test_getNamedParameterTypes_namedParameters() { 1361 void test_getNamedParameterTypes_namedParameters() {
1362 TestTypeProvider typeProvider = new TestTypeProvider(); 1362 TestTypeProvider typeProvider = new TestTypeProvider();
1363 FunctionElement element = ElementFactory 1363 FunctionElement element = ElementFactory
1364 .functionElementWithParameters('f', VoidTypeImpl.instance, [ 1364 .functionElementWithParameters('f', VoidTypeImpl.instance, [
1365 ElementFactory.requiredParameter2('a', typeProvider.intType), 1365 ElementFactory.requiredParameter2('a', typeProvider.intType),
1366 ElementFactory.requiredParameter('b'), 1366 ElementFactory.requiredParameter('b'),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 FunctionTypeImpl type = element.type; 1458 FunctionTypeImpl type = element.type;
1459 List<DartType> types = type.optionalParameterTypes; 1459 List<DartType> types = type.optionalParameterTypes;
1460 expect(types, hasLength(2)); 1460 expect(types, hasLength(2));
1461 expect(types[0], typeProvider.stringType); 1461 expect(types[0], typeProvider.stringType);
1462 expect(types[1], DynamicTypeImpl.instance); 1462 expect(types[1], DynamicTypeImpl.instance);
1463 } 1463 }
1464 1464
1465 void test_getReturnType() { 1465 void test_getReturnType() {
1466 DartType expectedReturnType = VoidTypeImpl.instance; 1466 DartType expectedReturnType = VoidTypeImpl.instance;
1467 FunctionElementImpl functionElement = 1467 FunctionElementImpl functionElement =
1468 new FunctionElementImpl.forNode(AstFactory.identifier3("f")); 1468 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f"));
1469 functionElement.returnType = expectedReturnType; 1469 functionElement.returnType = expectedReturnType;
1470 FunctionTypeImpl type = new FunctionTypeImpl(functionElement); 1470 FunctionTypeImpl type = new FunctionTypeImpl(functionElement);
1471 DartType returnType = type.returnType; 1471 DartType returnType = type.returnType;
1472 expect(returnType, expectedReturnType); 1472 expect(returnType, expectedReturnType);
1473 } 1473 }
1474 1474
1475 void test_getTypeArguments() { 1475 void test_getTypeArguments() {
1476 FunctionTypeImpl type = new FunctionTypeImpl( 1476 FunctionTypeImpl type = new FunctionTypeImpl(
1477 new FunctionElementImpl.forNode(AstFactory.identifier3("f"))); 1477 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f")));
1478 List<DartType> types = type.typeArguments; 1478 List<DartType> types = type.typeArguments;
1479 expect(types, hasLength(0)); 1479 expect(types, hasLength(0));
1480 } 1480 }
1481 1481
1482 void test_hashCode_element() { 1482 void test_hashCode_element() {
1483 FunctionTypeImpl type = new FunctionTypeImpl( 1483 FunctionTypeImpl type = new FunctionTypeImpl(
1484 new FunctionElementImpl.forNode(AstFactory.identifier3("f"))); 1484 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f")));
1485 type.hashCode; 1485 type.hashCode;
1486 } 1486 }
1487 1487
1488 void test_hashCode_noElement() { 1488 void test_hashCode_noElement() {
1489 FunctionTypeImpl type = new FunctionTypeImpl(null); 1489 FunctionTypeImpl type = new FunctionTypeImpl(null);
1490 type.hashCode; 1490 type.hashCode;
1491 } 1491 }
1492 1492
1493 void test_hashCode_recursive() { 1493 void test_hashCode_recursive() {
1494 FunctionTypeAliasElementImpl s = 1494 FunctionTypeAliasElementImpl s =
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 .functionElement2("s", ElementFactory.classElement2("B")) 1834 .functionElement2("s", ElementFactory.classElement2("B"))
1835 .type; 1835 .type;
1836 expect(t.isSubtypeOf(s), isFalse); 1836 expect(t.isSubtypeOf(s), isFalse);
1837 } 1837 }
1838 1838
1839 void test_isSubtypeOf_typeParameters_matchesBounds() { 1839 void test_isSubtypeOf_typeParameters_matchesBounds() {
1840 TestTypeProvider provider = new TestTypeProvider(); 1840 TestTypeProvider provider = new TestTypeProvider();
1841 InterfaceType boolType = provider.boolType; 1841 InterfaceType boolType = provider.boolType;
1842 InterfaceType stringType = provider.stringType; 1842 InterfaceType stringType = provider.stringType;
1843 TypeParameterElementImpl parameterB = 1843 TypeParameterElementImpl parameterB =
1844 new TypeParameterElementImpl.forNode(AstFactory.identifier3("B")); 1844 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("B"));
1845 parameterB.bound = boolType; 1845 parameterB.bound = boolType;
1846 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB); 1846 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB);
1847 TypeParameterElementImpl parameterS = 1847 TypeParameterElementImpl parameterS =
1848 new TypeParameterElementImpl.forNode(AstFactory.identifier3("S")); 1848 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("S"));
1849 parameterS.bound = stringType; 1849 parameterS.bound = stringType;
1850 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS); 1850 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS);
1851 FunctionElementImpl functionAliasElement = 1851 FunctionElementImpl functionAliasElement =
1852 new FunctionElementImpl.forNode(AstFactory.identifier3("func")); 1852 new FunctionElementImpl.forNode(AstTestFactory.identifier3("func"));
1853 functionAliasElement.parameters = <ParameterElement>[ 1853 functionAliasElement.parameters = <ParameterElement>[
1854 ElementFactory.requiredParameter2("a", typeB), 1854 ElementFactory.requiredParameter2("a", typeB),
1855 ElementFactory.positionalParameter2("b", typeS) 1855 ElementFactory.positionalParameter2("b", typeS)
1856 ]; 1856 ];
1857 functionAliasElement.returnType = stringType; 1857 functionAliasElement.returnType = stringType;
1858 FunctionTypeImpl functionAliasType = 1858 FunctionTypeImpl functionAliasType =
1859 new FunctionTypeImpl(functionAliasElement); 1859 new FunctionTypeImpl(functionAliasElement);
1860 functionAliasElement.type = functionAliasType; 1860 functionAliasElement.type = functionAliasType;
1861 FunctionElementImpl functionElement = 1861 FunctionElementImpl functionElement =
1862 new FunctionElementImpl.forNode(AstFactory.identifier3("f")); 1862 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f"));
1863 functionElement.parameters = <ParameterElement>[ 1863 functionElement.parameters = <ParameterElement>[
1864 ElementFactory.requiredParameter2("c", boolType), 1864 ElementFactory.requiredParameter2("c", boolType),
1865 ElementFactory.positionalParameter2("d", stringType) 1865 ElementFactory.positionalParameter2("d", stringType)
1866 ]; 1866 ];
1867 functionElement.returnType = provider.dynamicType; 1867 functionElement.returnType = provider.dynamicType;
1868 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); 1868 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement);
1869 functionElement.type = functionType; 1869 functionElement.type = functionType;
1870 expect(functionType.isAssignableTo(functionAliasType), isTrue); 1870 expect(functionType.isAssignableTo(functionAliasType), isTrue);
1871 } 1871 }
1872 1872
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 f.returnType = g.type; 2034 f.returnType = g.type;
2035 FunctionTypeImpl paramType = f.type.returnType; 2035 FunctionTypeImpl paramType = f.type.returnType;
2036 expect(paramType.prunedTypedefs, hasLength(1)); 2036 expect(paramType.prunedTypedefs, hasLength(1));
2037 expect(paramType.prunedTypedefs[0], same(f)); 2037 expect(paramType.prunedTypedefs[0], same(f));
2038 } 2038 }
2039 2039
2040 void test_substitute2_equal() { 2040 void test_substitute2_equal() {
2041 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]); 2041 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]);
2042 TypeParameterType parameterType = definingClass.typeParameters[0].type; 2042 TypeParameterType parameterType = definingClass.typeParameters[0].type;
2043 MethodElementImpl functionElement = 2043 MethodElementImpl functionElement =
2044 new MethodElementImpl.forNode(AstFactory.identifier3("m")); 2044 new MethodElementImpl.forNode(AstTestFactory.identifier3("m"));
2045 String namedParameterName = "c"; 2045 String namedParameterName = "c";
2046 functionElement.parameters = <ParameterElement>[ 2046 functionElement.parameters = <ParameterElement>[
2047 ElementFactory.requiredParameter2("a", parameterType), 2047 ElementFactory.requiredParameter2("a", parameterType),
2048 ElementFactory.positionalParameter2("b", parameterType), 2048 ElementFactory.positionalParameter2("b", parameterType),
2049 ElementFactory.namedParameter2(namedParameterName, parameterType) 2049 ElementFactory.namedParameter2(namedParameterName, parameterType)
2050 ]; 2050 ];
2051 functionElement.returnType = parameterType; 2051 functionElement.returnType = parameterType;
2052 definingClass.methods = <MethodElement>[functionElement]; 2052 definingClass.methods = <MethodElement>[functionElement];
2053 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); 2053 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement);
2054 InterfaceTypeImpl argumentType = new InterfaceTypeImpl( 2054 InterfaceTypeImpl argumentType = new InterfaceTypeImpl(
2055 new ClassElementImpl.forNode(AstFactory.identifier3("D"))); 2055 new ClassElementImpl.forNode(AstTestFactory.identifier3("D")));
2056 FunctionType result = functionType 2056 FunctionType result = functionType
2057 .substitute2(<DartType>[argumentType], <DartType>[parameterType]); 2057 .substitute2(<DartType>[argumentType], <DartType>[parameterType]);
2058 expect(result.returnType, argumentType); 2058 expect(result.returnType, argumentType);
2059 List<DartType> normalParameters = result.normalParameterTypes; 2059 List<DartType> normalParameters = result.normalParameterTypes;
2060 expect(normalParameters, hasLength(1)); 2060 expect(normalParameters, hasLength(1));
2061 expect(normalParameters[0], argumentType); 2061 expect(normalParameters[0], argumentType);
2062 List<DartType> optionalParameters = result.optionalParameterTypes; 2062 List<DartType> optionalParameters = result.optionalParameterTypes;
2063 expect(optionalParameters, hasLength(1)); 2063 expect(optionalParameters, hasLength(1));
2064 expect(optionalParameters[0], argumentType); 2064 expect(optionalParameters[0], argumentType);
2065 Map<String, DartType> namedParameters = result.namedParameterTypes; 2065 Map<String, DartType> namedParameters = result.namedParameterTypes;
2066 expect(namedParameters, hasLength(1)); 2066 expect(namedParameters, hasLength(1));
2067 expect(namedParameters[namedParameterName], argumentType); 2067 expect(namedParameters[namedParameterName], argumentType);
2068 } 2068 }
2069 2069
2070 void test_substitute2_notEqual() { 2070 void test_substitute2_notEqual() {
2071 DartType returnType = new InterfaceTypeImpl( 2071 DartType returnType = new InterfaceTypeImpl(
2072 new ClassElementImpl.forNode(AstFactory.identifier3("R"))); 2072 new ClassElementImpl.forNode(AstTestFactory.identifier3("R")));
2073 DartType normalParameterType = new InterfaceTypeImpl( 2073 DartType normalParameterType = new InterfaceTypeImpl(
2074 new ClassElementImpl.forNode(AstFactory.identifier3("A"))); 2074 new ClassElementImpl.forNode(AstTestFactory.identifier3("A")));
2075 DartType optionalParameterType = new InterfaceTypeImpl( 2075 DartType optionalParameterType = new InterfaceTypeImpl(
2076 new ClassElementImpl.forNode(AstFactory.identifier3("B"))); 2076 new ClassElementImpl.forNode(AstTestFactory.identifier3("B")));
2077 DartType namedParameterType = new InterfaceTypeImpl( 2077 DartType namedParameterType = new InterfaceTypeImpl(
2078 new ClassElementImpl.forNode(AstFactory.identifier3("C"))); 2078 new ClassElementImpl.forNode(AstTestFactory.identifier3("C")));
2079 FunctionElementImpl functionElement = 2079 FunctionElementImpl functionElement =
2080 new FunctionElementImpl.forNode(AstFactory.identifier3("f")); 2080 new FunctionElementImpl.forNode(AstTestFactory.identifier3("f"));
2081 String namedParameterName = "c"; 2081 String namedParameterName = "c";
2082 functionElement.parameters = <ParameterElement>[ 2082 functionElement.parameters = <ParameterElement>[
2083 ElementFactory.requiredParameter2("a", normalParameterType), 2083 ElementFactory.requiredParameter2("a", normalParameterType),
2084 ElementFactory.positionalParameter2("b", optionalParameterType), 2084 ElementFactory.positionalParameter2("b", optionalParameterType),
2085 ElementFactory.namedParameter2(namedParameterName, namedParameterType) 2085 ElementFactory.namedParameter2(namedParameterName, namedParameterType)
2086 ]; 2086 ];
2087 functionElement.returnType = returnType; 2087 functionElement.returnType = returnType;
2088 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); 2088 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement);
2089 InterfaceTypeImpl argumentType = new InterfaceTypeImpl( 2089 InterfaceTypeImpl argumentType = new InterfaceTypeImpl(
2090 new ClassElementImpl.forNode(AstFactory.identifier3("D"))); 2090 new ClassElementImpl.forNode(AstTestFactory.identifier3("D")));
2091 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl( 2091 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(
2092 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))); 2092 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E")));
2093 FunctionType result = functionType 2093 FunctionType result = functionType
2094 .substitute2(<DartType>[argumentType], <DartType>[parameterType]); 2094 .substitute2(<DartType>[argumentType], <DartType>[parameterType]);
2095 expect(result.returnType, returnType); 2095 expect(result.returnType, returnType);
2096 List<DartType> normalParameters = result.normalParameterTypes; 2096 List<DartType> normalParameters = result.normalParameterTypes;
2097 expect(normalParameters, hasLength(1)); 2097 expect(normalParameters, hasLength(1));
2098 expect(normalParameters[0], normalParameterType); 2098 expect(normalParameters[0], normalParameterType);
2099 List<DartType> optionalParameters = result.optionalParameterTypes; 2099 List<DartType> optionalParameters = result.optionalParameterTypes;
2100 expect(optionalParameters, hasLength(1)); 2100 expect(optionalParameters, hasLength(1));
2101 expect(optionalParameters[0], optionalParameterType); 2101 expect(optionalParameters[0], optionalParameterType);
2102 Map<String, DartType> namedParameters = result.namedParameterTypes; 2102 Map<String, DartType> namedParameters = result.namedParameterTypes;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 expect(method.type.typeArguments, 2244 expect(method.type.typeArguments,
2245 unorderedEquals(_toTypes(classElement.typeParameters))); 2245 unorderedEquals(_toTypes(classElement.typeParameters)));
2246 expect(method.type.typeFormals, unorderedEquals(method.typeParameters)); 2246 expect(method.type.typeFormals, unorderedEquals(method.typeParameters));
2247 expect(method.type.typeParameters, 2247 expect(method.type.typeParameters,
2248 unorderedEquals(classElement.typeParameters)); 2248 unorderedEquals(classElement.typeParameters));
2249 } 2249 }
2250 2250
2251 void test_withTypeArguments() { 2251 void test_withTypeArguments() {
2252 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); 2252 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]);
2253 MethodElementImpl methodElement = 2253 MethodElementImpl methodElement =
2254 new MethodElementImpl.forNode(AstFactory.identifier3("m")); 2254 new MethodElementImpl.forNode(AstTestFactory.identifier3("m"));
2255 enclosingClass.methods = <MethodElement>[methodElement]; 2255 enclosingClass.methods = <MethodElement>[methodElement];
2256 FunctionTypeImpl type = new FunctionTypeImpl(methodElement); 2256 FunctionTypeImpl type = new FunctionTypeImpl(methodElement);
2257 DartType expectedType = enclosingClass.typeParameters[0].type; 2257 DartType expectedType = enclosingClass.typeParameters[0].type;
2258 List<DartType> arguments = type.typeArguments; 2258 List<DartType> arguments = type.typeArguments;
2259 expect(arguments, hasLength(1)); 2259 expect(arguments, hasLength(1));
2260 expect(arguments[0], expectedType); 2260 expect(arguments[0], expectedType);
2261 } 2261 }
2262 2262
2263 Iterable<DartType> _toTypes(List<TypeParameterElement> typeParameters) { 2263 Iterable<DartType> _toTypes(List<TypeParameterElement> typeParameters) {
2264 return typeParameters.map((TypeParameterElement element) => element.type); 2264 return typeParameters.map((TypeParameterElement element) => element.type);
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
3173 3173
3174 void test_isMoreSpecificThan_typeParameterType_withBound() { 3174 void test_isMoreSpecificThan_typeParameterType_withBound() {
3175 // 3175 //
3176 // class A {} 3176 // class A {}
3177 // class B<E extends A> {} 3177 // class B<E extends A> {}
3178 // 3178 //
3179 ClassElement classA = ElementFactory.classElement2("A"); 3179 ClassElement classA = ElementFactory.classElement2("A");
3180 InterfaceType typeA = classA.type; 3180 InterfaceType typeA = classA.type;
3181 ClassElementImpl classB = ElementFactory.classElement2("B"); 3181 ClassElementImpl classB = ElementFactory.classElement2("B");
3182 TypeParameterElementImpl parameterEA = 3182 TypeParameterElementImpl parameterEA =
3183 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 3183 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
3184 TypeParameterType parameterAEType = new TypeParameterTypeImpl(parameterEA); 3184 TypeParameterType parameterAEType = new TypeParameterTypeImpl(parameterEA);
3185 parameterEA.bound = typeA; 3185 parameterEA.bound = typeA;
3186 parameterEA.type = parameterAEType; 3186 parameterEA.type = parameterAEType;
3187 classB.typeParameters = <TypeParameterElementImpl>[parameterEA]; 3187 classB.typeParameters = <TypeParameterElementImpl>[parameterEA];
3188 expect(parameterAEType.isMoreSpecificThan(typeA), isTrue); 3188 expect(parameterAEType.isMoreSpecificThan(typeA), isTrue);
3189 } 3189 }
3190 3190
3191 void test_isSubtypeOf_directSubtype() { 3191 void test_isSubtypeOf_directSubtype() {
3192 ClassElement classA = ElementFactory.classElement2("A"); 3192 ClassElement classA = ElementFactory.classElement2("A");
3193 ClassElement classB = ElementFactory.classElement("B", classA.type); 3193 ClassElement classB = ElementFactory.classElement("B", classA.type);
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
3775 } catch (e) { 3775 } catch (e) {
3776 // Expected result 3776 // Expected result
3777 } 3777 }
3778 } 3778 }
3779 3779
3780 void test_substitute_notEqual() { 3780 void test_substitute_notEqual() {
3781 // The [test_substitute_equals] above has a slightly higher level 3781 // The [test_substitute_equals] above has a slightly higher level
3782 // implementation. 3782 // implementation.
3783 ClassElementImpl classA = ElementFactory.classElement2("A"); 3783 ClassElementImpl classA = ElementFactory.classElement2("A");
3784 TypeParameterElementImpl parameterElement = 3784 TypeParameterElementImpl parameterElement =
3785 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 3785 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
3786 InterfaceTypeImpl type = new InterfaceTypeImpl(classA); 3786 InterfaceTypeImpl type = new InterfaceTypeImpl(classA);
3787 TypeParameterTypeImpl parameter = 3787 TypeParameterTypeImpl parameter =
3788 new TypeParameterTypeImpl(parameterElement); 3788 new TypeParameterTypeImpl(parameterElement);
3789 type.typeArguments = <DartType>[parameter]; 3789 type.typeArguments = <DartType>[parameter];
3790 InterfaceType argumentType = ElementFactory.classElement2("B").type; 3790 InterfaceType argumentType = ElementFactory.classElement2("B").type;
3791 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl( 3791 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(
3792 new TypeParameterElementImpl.forNode(AstFactory.identifier3("F"))); 3792 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("F")));
3793 InterfaceType result = 3793 InterfaceType result =
3794 type.substitute2(<DartType>[argumentType], <DartType>[parameterType]); 3794 type.substitute2(<DartType>[argumentType], <DartType>[parameterType]);
3795 expect(result.element, classA); 3795 expect(result.element, classA);
3796 List<DartType> resultArguments = result.typeArguments; 3796 List<DartType> resultArguments = result.typeArguments;
3797 expect(resultArguments, hasLength(1)); 3797 expect(resultArguments, hasLength(1));
3798 expect(resultArguments[0], parameter); 3798 expect(resultArguments[0], parameter);
3799 } 3799 }
3800 } 3800 }
3801 3801
3802 @reflectiveTest 3802 @reflectiveTest
3803 class LibraryElementImplTest extends EngineTestCase { 3803 class LibraryElementImplTest extends EngineTestCase {
3804 void test_creation() { 3804 void test_creation() {
3805 expect( 3805 expect(
3806 new LibraryElementImpl.forNode( 3806 new LibraryElementImpl.forNode(
3807 createAnalysisContext(), AstFactory.libraryIdentifier2(["l"])), 3807 createAnalysisContext(), AstTestFactory.libraryIdentifier2(["l"])),
3808 isNotNull); 3808 isNotNull);
3809 } 3809 }
3810 3810
3811 void test_getImportedLibraries() { 3811 void test_getImportedLibraries() {
3812 AnalysisContext context = createAnalysisContext(); 3812 AnalysisContext context = createAnalysisContext();
3813 LibraryElementImpl library1 = ElementFactory.library(context, "l1"); 3813 LibraryElementImpl library1 = ElementFactory.library(context, "l1");
3814 LibraryElementImpl library2 = ElementFactory.library(context, "l2"); 3814 LibraryElementImpl library2 = ElementFactory.library(context, "l2");
3815 LibraryElementImpl library3 = ElementFactory.library(context, "l3"); 3815 LibraryElementImpl library3 = ElementFactory.library(context, "l3");
3816 LibraryElementImpl library4 = ElementFactory.library(context, "l4"); 3816 LibraryElementImpl library4 = ElementFactory.library(context, "l4");
3817 PrefixElement prefixA = 3817 PrefixElement prefixA =
3818 new PrefixElementImpl.forNode(AstFactory.identifier3("a")); 3818 new PrefixElementImpl.forNode(AstTestFactory.identifier3("a"));
3819 PrefixElement prefixB = 3819 PrefixElement prefixB =
3820 new PrefixElementImpl.forNode(AstFactory.identifier3("b")); 3820 new PrefixElementImpl.forNode(AstTestFactory.identifier3("b"));
3821 List<ImportElementImpl> imports = [ 3821 List<ImportElementImpl> imports = [
3822 ElementFactory.importFor(library2, null), 3822 ElementFactory.importFor(library2, null),
3823 ElementFactory.importFor(library2, prefixB), 3823 ElementFactory.importFor(library2, prefixB),
3824 ElementFactory.importFor(library3, null), 3824 ElementFactory.importFor(library3, null),
3825 ElementFactory.importFor(library3, prefixA), 3825 ElementFactory.importFor(library3, prefixA),
3826 ElementFactory.importFor(library3, prefixB), 3826 ElementFactory.importFor(library3, prefixB),
3827 ElementFactory.importFor(library4, prefixA) 3827 ElementFactory.importFor(library4, prefixA)
3828 ]; 3828 ];
3829 library1.imports = imports; 3829 library1.imports = imports;
3830 List<LibraryElement> libraries = library1.importedLibraries; 3830 List<LibraryElement> libraries = library1.importedLibraries;
3831 expect(libraries, 3831 expect(libraries,
3832 unorderedEquals(<LibraryElement>[library2, library3, library4])); 3832 unorderedEquals(<LibraryElement>[library2, library3, library4]));
3833 } 3833 }
3834 3834
3835 void test_getPrefixes() { 3835 void test_getPrefixes() {
3836 AnalysisContext context = createAnalysisContext(); 3836 AnalysisContext context = createAnalysisContext();
3837 LibraryElementImpl library = ElementFactory.library(context, "l1"); 3837 LibraryElementImpl library = ElementFactory.library(context, "l1");
3838 PrefixElement prefixA = 3838 PrefixElement prefixA =
3839 new PrefixElementImpl.forNode(AstFactory.identifier3("a")); 3839 new PrefixElementImpl.forNode(AstTestFactory.identifier3("a"));
3840 PrefixElement prefixB = 3840 PrefixElement prefixB =
3841 new PrefixElementImpl.forNode(AstFactory.identifier3("b")); 3841 new PrefixElementImpl.forNode(AstTestFactory.identifier3("b"));
3842 List<ImportElementImpl> imports = [ 3842 List<ImportElementImpl> imports = [
3843 ElementFactory.importFor(ElementFactory.library(context, "l2"), null), 3843 ElementFactory.importFor(ElementFactory.library(context, "l2"), null),
3844 ElementFactory.importFor(ElementFactory.library(context, "l3"), null), 3844 ElementFactory.importFor(ElementFactory.library(context, "l3"), null),
3845 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA), 3845 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA),
3846 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA), 3846 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA),
3847 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB) 3847 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB)
3848 ]; 3848 ];
3849 library.imports = imports; 3849 library.imports = imports;
3850 List<PrefixElement> prefixes = library.prefixes; 3850 List<PrefixElement> prefixes = library.prefixes;
3851 expect(prefixes, hasLength(2)); 3851 expect(prefixes, hasLength(2));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3884 ElementFactory.importFor(importedLibraryHandle, null); 3884 ElementFactory.importFor(importedLibraryHandle, null);
3885 library.imports = <ImportElement>[import]; 3885 library.imports = <ImportElement>[import];
3886 library.libraryCycle; // Force computation of the cycle. 3886 library.libraryCycle; // Force computation of the cycle.
3887 3887
3888 library.invalidateLibraryCycles(); 3888 library.invalidateLibraryCycles();
3889 } 3889 }
3890 3890
3891 void test_setImports() { 3891 void test_setImports() {
3892 AnalysisContext context = createAnalysisContext(); 3892 AnalysisContext context = createAnalysisContext();
3893 LibraryElementImpl library = new LibraryElementImpl.forNode( 3893 LibraryElementImpl library = new LibraryElementImpl.forNode(
3894 context, AstFactory.libraryIdentifier2(["l1"])); 3894 context, AstTestFactory.libraryIdentifier2(["l1"]));
3895 List<ImportElementImpl> expectedImports = [ 3895 List<ImportElementImpl> expectedImports = [
3896 ElementFactory.importFor(ElementFactory.library(context, "l2"), null), 3896 ElementFactory.importFor(ElementFactory.library(context, "l2"), null),
3897 ElementFactory.importFor(ElementFactory.library(context, "l3"), null) 3897 ElementFactory.importFor(ElementFactory.library(context, "l3"), null)
3898 ]; 3898 ];
3899 library.imports = expectedImports; 3899 library.imports = expectedImports;
3900 List<ImportElement> actualImports = library.imports; 3900 List<ImportElement> actualImports = library.imports;
3901 expect(actualImports, hasLength(expectedImports.length)); 3901 expect(actualImports, hasLength(expectedImports.length));
3902 for (int i = 0; i < actualImports.length; i++) { 3902 for (int i = 0; i < actualImports.length; i++) {
3903 expect(actualImports[i], same(expectedImports[i])); 3903 expect(actualImports[i], same(expectedImports[i]));
3904 } 3904 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
4240 expect(value, isNotNull); 4240 expect(value, isNotNull);
4241 expect(value.toIntValue(), 42); 4241 expect(value.toIntValue(), 42);
4242 expect(constant.constantValue, value); 4242 expect(constant.constantValue, value);
4243 } 4243 }
4244 } 4244 }
4245 4245
4246 @reflectiveTest 4246 @reflectiveTest
4247 class TypeParameterTypeImplTest extends EngineTestCase { 4247 class TypeParameterTypeImplTest extends EngineTestCase {
4248 void test_creation() { 4248 void test_creation() {
4249 expect( 4249 expect(
4250 new TypeParameterTypeImpl( 4250 new TypeParameterTypeImpl(new TypeParameterElementImpl.forNode(
4251 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))), 4251 AstTestFactory.identifier3("E"))),
4252 isNotNull); 4252 isNotNull);
4253 } 4253 }
4254 4254
4255 void test_getElement() { 4255 void test_getElement() {
4256 TypeParameterElementImpl element = 4256 TypeParameterElementImpl element =
4257 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 4257 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
4258 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); 4258 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4259 expect(type.element, element); 4259 expect(type.element, element);
4260 } 4260 }
4261 4261
4262 void test_isMoreSpecificThan_typeArguments_dynamic() { 4262 void test_isMoreSpecificThan_typeArguments_dynamic() {
4263 TypeParameterElementImpl element = 4263 TypeParameterElementImpl element =
4264 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 4264 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
4265 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); 4265 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4266 // E << dynamic 4266 // E << dynamic
4267 expect(type.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue); 4267 expect(type.isMoreSpecificThan(DynamicTypeImpl.instance), isTrue);
4268 } 4268 }
4269 4269
4270 void test_isMoreSpecificThan_typeArguments_object() { 4270 void test_isMoreSpecificThan_typeArguments_object() {
4271 TypeParameterElementImpl element = 4271 TypeParameterElementImpl element =
4272 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 4272 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
4273 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); 4273 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4274 // E << Object 4274 // E << Object
4275 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue); 4275 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue);
4276 } 4276 }
4277 4277
4278 void test_isMoreSpecificThan_typeArguments_recursive() { 4278 void test_isMoreSpecificThan_typeArguments_recursive() {
4279 ClassElementImpl classS = ElementFactory.classElement2("A"); 4279 ClassElementImpl classS = ElementFactory.classElement2("A");
4280 TypeParameterElementImpl typeParameterU = 4280 TypeParameterElementImpl typeParameterU =
4281 new TypeParameterElementImpl.forNode(AstFactory.identifier3("U")); 4281 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("U"));
4282 TypeParameterTypeImpl typeParameterTypeU = 4282 TypeParameterTypeImpl typeParameterTypeU =
4283 new TypeParameterTypeImpl(typeParameterU); 4283 new TypeParameterTypeImpl(typeParameterU);
4284 TypeParameterElementImpl typeParameterT = 4284 TypeParameterElementImpl typeParameterT =
4285 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); 4285 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("T"));
4286 TypeParameterTypeImpl typeParameterTypeT = 4286 TypeParameterTypeImpl typeParameterTypeT =
4287 new TypeParameterTypeImpl(typeParameterT); 4287 new TypeParameterTypeImpl(typeParameterT);
4288 typeParameterT.bound = typeParameterTypeU; 4288 typeParameterT.bound = typeParameterTypeU;
4289 typeParameterU.bound = typeParameterTypeU; 4289 typeParameterU.bound = typeParameterTypeU;
4290 // <T extends U> and <U extends T> 4290 // <T extends U> and <U extends T>
4291 // T << S 4291 // T << S
4292 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isFalse); 4292 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isFalse);
4293 } 4293 }
4294 4294
4295 void test_isMoreSpecificThan_typeArguments_self() { 4295 void test_isMoreSpecificThan_typeArguments_self() {
4296 TypeParameterElementImpl element = 4296 TypeParameterElementImpl element =
4297 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 4297 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
4298 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); 4298 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4299 // E << E 4299 // E << E
4300 expect(type.isMoreSpecificThan(type), isTrue); 4300 expect(type.isMoreSpecificThan(type), isTrue);
4301 } 4301 }
4302 4302
4303 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() { 4303 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() {
4304 // class A {} 4304 // class A {}
4305 // class B extends A {} 4305 // class B extends A {}
4306 // 4306 //
4307 ClassElement classA = ElementFactory.classElement2("A"); 4307 ClassElement classA = ElementFactory.classElement2("A");
4308 ClassElement classB = ElementFactory.classElement("B", classA.type); 4308 ClassElement classB = ElementFactory.classElement("B", classA.type);
4309 InterfaceType typeA = classA.type; 4309 InterfaceType typeA = classA.type;
4310 InterfaceType typeB = classB.type; 4310 InterfaceType typeB = classB.type;
4311 TypeParameterElementImpl typeParameterT = 4311 TypeParameterElementImpl typeParameterT =
4312 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); 4312 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("T"));
4313 typeParameterT.bound = typeB; 4313 typeParameterT.bound = typeB;
4314 TypeParameterTypeImpl typeParameterTypeT = 4314 TypeParameterTypeImpl typeParameterTypeT =
4315 new TypeParameterTypeImpl(typeParameterT); 4315 new TypeParameterTypeImpl(typeParameterT);
4316 // <T extends B> 4316 // <T extends B>
4317 // T << A 4317 // T << A
4318 expect(typeParameterTypeT.isMoreSpecificThan(typeA), isTrue); 4318 expect(typeParameterTypeT.isMoreSpecificThan(typeA), isTrue);
4319 } 4319 }
4320 4320
4321 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() { 4321 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() {
4322 ClassElementImpl classS = ElementFactory.classElement2("A"); 4322 ClassElementImpl classS = ElementFactory.classElement2("A");
4323 TypeParameterElementImpl typeParameterU = 4323 TypeParameterElementImpl typeParameterU =
4324 new TypeParameterElementImpl.forNode(AstFactory.identifier3("U")); 4324 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("U"));
4325 typeParameterU.bound = classS.type; 4325 typeParameterU.bound = classS.type;
4326 TypeParameterTypeImpl typeParameterTypeU = 4326 TypeParameterTypeImpl typeParameterTypeU =
4327 new TypeParameterTypeImpl(typeParameterU); 4327 new TypeParameterTypeImpl(typeParameterU);
4328 TypeParameterElementImpl typeParameterT = 4328 TypeParameterElementImpl typeParameterT =
4329 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); 4329 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("T"));
4330 typeParameterT.bound = typeParameterTypeU; 4330 typeParameterT.bound = typeParameterTypeU;
4331 TypeParameterTypeImpl typeParameterTypeT = 4331 TypeParameterTypeImpl typeParameterTypeT =
4332 new TypeParameterTypeImpl(typeParameterT); 4332 new TypeParameterTypeImpl(typeParameterT);
4333 // <T extends U> and <U extends S> 4333 // <T extends U> and <U extends S>
4334 // T << S 4334 // T << S
4335 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue); 4335 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue);
4336 } 4336 }
4337 4337
4338 void test_isMoreSpecificThan_typeArguments_upperBound() { 4338 void test_isMoreSpecificThan_typeArguments_upperBound() {
4339 ClassElementImpl classS = ElementFactory.classElement2("A"); 4339 ClassElementImpl classS = ElementFactory.classElement2("A");
4340 TypeParameterElementImpl typeParameterT = 4340 TypeParameterElementImpl typeParameterT =
4341 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); 4341 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("T"));
4342 typeParameterT.bound = classS.type; 4342 typeParameterT.bound = classS.type;
4343 TypeParameterTypeImpl typeParameterTypeT = 4343 TypeParameterTypeImpl typeParameterTypeT =
4344 new TypeParameterTypeImpl(typeParameterT); 4344 new TypeParameterTypeImpl(typeParameterT);
4345 // <T extends S> 4345 // <T extends S>
4346 // T << S 4346 // T << S
4347 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue); 4347 expect(typeParameterTypeT.isMoreSpecificThan(classS.type), isTrue);
4348 } 4348 }
4349 4349
4350 void test_resolveToBound_bound() { 4350 void test_resolveToBound_bound() {
4351 ClassElementImpl classS = ElementFactory.classElement2("A"); 4351 ClassElementImpl classS = ElementFactory.classElement2("A");
4352 TypeParameterElementImpl element = 4352 TypeParameterElementImpl element =
4353 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 4353 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
4354 element.bound = classS.type; 4354 element.bound = classS.type;
4355 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); 4355 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4356 expect(type.resolveToBound(null), same(classS.type)); 4356 expect(type.resolveToBound(null), same(classS.type));
4357 } 4357 }
4358 4358
4359 void test_resolveToBound_nestedBound() { 4359 void test_resolveToBound_nestedBound() {
4360 ClassElementImpl classS = ElementFactory.classElement2("A"); 4360 ClassElementImpl classS = ElementFactory.classElement2("A");
4361 TypeParameterElementImpl elementE = 4361 TypeParameterElementImpl elementE =
4362 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 4362 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
4363 elementE.bound = classS.type; 4363 elementE.bound = classS.type;
4364 TypeParameterTypeImpl typeE = new TypeParameterTypeImpl(elementE); 4364 TypeParameterTypeImpl typeE = new TypeParameterTypeImpl(elementE);
4365 TypeParameterElementImpl elementF = 4365 TypeParameterElementImpl elementF =
4366 new TypeParameterElementImpl.forNode(AstFactory.identifier3("F")); 4366 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("F"));
4367 elementF.bound = typeE; 4367 elementF.bound = typeE;
4368 TypeParameterTypeImpl typeF = new TypeParameterTypeImpl(elementE); 4368 TypeParameterTypeImpl typeF = new TypeParameterTypeImpl(elementE);
4369 expect(typeF.resolveToBound(null), same(classS.type)); 4369 expect(typeF.resolveToBound(null), same(classS.type));
4370 } 4370 }
4371 4371
4372 void test_resolveToBound_unbound() { 4372 void test_resolveToBound_unbound() {
4373 TypeParameterTypeImpl type = new TypeParameterTypeImpl( 4373 TypeParameterTypeImpl type = new TypeParameterTypeImpl(
4374 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))); 4374 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E")));
4375 // Returns whatever type is passed to resolveToBound(). 4375 // Returns whatever type is passed to resolveToBound().
4376 expect(type.resolveToBound(VoidTypeImpl.instance), 4376 expect(type.resolveToBound(VoidTypeImpl.instance),
4377 same(VoidTypeImpl.instance)); 4377 same(VoidTypeImpl.instance));
4378 } 4378 }
4379 4379
4380 void test_substitute_equal() { 4380 void test_substitute_equal() {
4381 TypeParameterElementImpl element = 4381 TypeParameterElementImpl element =
4382 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); 4382 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E"));
4383 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); 4383 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4384 InterfaceTypeImpl argument = new InterfaceTypeImpl( 4384 InterfaceTypeImpl argument = new InterfaceTypeImpl(
4385 new ClassElementImpl.forNode(AstFactory.identifier3("A"))); 4385 new ClassElementImpl.forNode(AstTestFactory.identifier3("A")));
4386 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element); 4386 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element);
4387 expect(type.substitute2(<DartType>[argument], <DartType>[parameter]), 4387 expect(type.substitute2(<DartType>[argument], <DartType>[parameter]),
4388 same(argument)); 4388 same(argument));
4389 } 4389 }
4390 4390
4391 void test_substitute_notEqual() { 4391 void test_substitute_notEqual() {
4392 TypeParameterTypeImpl type = new TypeParameterTypeImpl( 4392 TypeParameterTypeImpl type = new TypeParameterTypeImpl(
4393 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))); 4393 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("E")));
4394 InterfaceTypeImpl argument = new InterfaceTypeImpl( 4394 InterfaceTypeImpl argument = new InterfaceTypeImpl(
4395 new ClassElementImpl.forNode(AstFactory.identifier3("A"))); 4395 new ClassElementImpl.forNode(AstTestFactory.identifier3("A")));
4396 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl( 4396 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(
4397 new TypeParameterElementImpl.forNode(AstFactory.identifier3("F"))); 4397 new TypeParameterElementImpl.forNode(AstTestFactory.identifier3("F")));
4398 expect(type.substitute2(<DartType>[argument], <DartType>[parameter]), 4398 expect(type.substitute2(<DartType>[argument], <DartType>[parameter]),
4399 same(type)); 4399 same(type));
4400 } 4400 }
4401 } 4401 }
4402 4402
4403 @reflectiveTest 4403 @reflectiveTest
4404 class VoidTypeImplTest extends EngineTestCase { 4404 class VoidTypeImplTest extends EngineTestCase {
4405 /** 4405 /**
4406 * Reference {code VoidTypeImpl.getInstance()}. 4406 * Reference {code VoidTypeImpl.getInstance()}.
4407 */ 4407 */
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4444 } 4444 }
4445 4445
4446 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction 4446 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction
4447 extends InterfaceTypeImpl { 4447 extends InterfaceTypeImpl {
4448 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) 4448 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0)
4449 : super(arg0); 4449 : super(arg0);
4450 4450
4451 @override 4451 @override
4452 bool get isDartCoreFunction => true; 4452 bool get isDartCoreFunction => true;
4453 } 4453 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/dart/constant/utilities_test.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698