| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 library engine.element_test; | 3 library engine.element_test; |
| 4 import 'package:analyzer_experimental/src/generated/java_core.dart'; | 4 import 'package:analyzer_experimental/src/generated/java_core.dart'; |
| 5 import 'package:analyzer_experimental/src/generated/java_engine_io.dart'; | 5 import 'package:analyzer_experimental/src/generated/java_engine_io.dart'; |
| 6 import 'package:analyzer_experimental/src/generated/java_junit.dart'; | 6 import 'package:analyzer_experimental/src/generated/java_junit.dart'; |
| 7 import 'package:analyzer_experimental/src/generated/source_io.dart'; | 7 import 'package:analyzer_experimental/src/generated/source_io.dart'; |
| 8 import 'package:analyzer_experimental/src/generated/utilities_dart.dart'; | 8 import 'package:analyzer_experimental/src/generated/utilities_dart.dart'; |
| 9 import 'package:analyzer_experimental/src/generated/ast.dart'; | 9 import 'package:analyzer_experimental/src/generated/ast.dart'; |
| 10 import 'package:analyzer_experimental/src/generated/element.dart'; | 10 import 'package:analyzer_experimental/src/generated/element.dart'; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 final __test = new LibraryElementImplTest(); | 197 final __test = new LibraryElementImplTest(); |
| 198 runJUnitTest(__test, __test.test_isUpToDate); | 198 runJUnitTest(__test, __test.test_isUpToDate); |
| 199 }); | 199 }); |
| 200 _ut.test('test_setImports', () { | 200 _ut.test('test_setImports', () { |
| 201 final __test = new LibraryElementImplTest(); | 201 final __test = new LibraryElementImplTest(); |
| 202 runJUnitTest(__test, __test.test_setImports); | 202 runJUnitTest(__test, __test.test_setImports); |
| 203 }); | 203 }); |
| 204 }); | 204 }); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 class TypeParameterTypeImplTest extends EngineTestCase { |
| 208 void fail_isMoreSpecificThan_typeArguments_object() { |
| 209 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i
dentifier3("E")); |
| 210 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 211 JUnitTestCase.assertTrue(type.isMoreSpecificThan(ElementFactory.object.type)
); |
| 212 } |
| 213 void fail_isMoreSpecificThan_typeArguments_self() { |
| 214 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i
dentifier3("E")); |
| 215 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 216 JUnitTestCase.assertTrue(type.isMoreSpecificThan(type)); |
| 217 } |
| 218 void test_creation() { |
| 219 JUnitTestCase.assertNotNull(new TypeParameterTypeImpl(new TypeParameterEleme
ntImpl(ASTFactory.identifier3("E")))); |
| 220 } |
| 221 void test_getElement() { |
| 222 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i
dentifier3("E")); |
| 223 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 224 JUnitTestCase.assertEquals(element, type.element); |
| 225 } |
| 226 void test_isMoreSpecificThan_typeArguments_upperBound() { |
| 227 ClassElementImpl classS = ElementFactory.classElement2("A", []); |
| 228 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(ASTFa
ctory.identifier3("T")); |
| 229 typeParameterT.bound = classS.type; |
| 230 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar
ameterT); |
| 231 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type))
; |
| 232 } |
| 233 void test_substitute_equal() { |
| 234 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i
dentifier3("E")); |
| 235 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 236 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl
(ASTFactory.identifier3("A"))); |
| 237 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element); |
| 238 JUnitTestCase.assertSame(argument, type.substitute2(<Type2> [argument], <Typ
e2> [parameter])); |
| 239 } |
| 240 void test_substitute_notEqual() { |
| 241 TypeParameterTypeImpl type = new TypeParameterTypeImpl(new TypeParameterElem
entImpl(ASTFactory.identifier3("E"))); |
| 242 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl
(ASTFactory.identifier3("A"))); |
| 243 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(new TypeParamete
rElementImpl(ASTFactory.identifier3("F"))); |
| 244 JUnitTestCase.assertSame(type, type.substitute2(<Type2> [argument], <Type2>
[parameter])); |
| 245 } |
| 246 static dartSuite() { |
| 247 _ut.group('TypeParameterTypeImplTest', () { |
| 248 _ut.test('test_creation', () { |
| 249 final __test = new TypeParameterTypeImplTest(); |
| 250 runJUnitTest(__test, __test.test_creation); |
| 251 }); |
| 252 _ut.test('test_getElement', () { |
| 253 final __test = new TypeParameterTypeImplTest(); |
| 254 runJUnitTest(__test, __test.test_getElement); |
| 255 }); |
| 256 _ut.test('test_isMoreSpecificThan_typeArguments_upperBound', () { |
| 257 final __test = new TypeParameterTypeImplTest(); |
| 258 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_upperB
ound); |
| 259 }); |
| 260 _ut.test('test_substitute_equal', () { |
| 261 final __test = new TypeParameterTypeImplTest(); |
| 262 runJUnitTest(__test, __test.test_substitute_equal); |
| 263 }); |
| 264 _ut.test('test_substitute_notEqual', () { |
| 265 final __test = new TypeParameterTypeImplTest(); |
| 266 runJUnitTest(__test, __test.test_substitute_notEqual); |
| 267 }); |
| 268 }); |
| 269 } |
| 270 } |
| 207 class InterfaceTypeImplTest extends EngineTestCase { | 271 class InterfaceTypeImplTest extends EngineTestCase { |
| 208 | 272 |
| 209 /** | 273 /** |
| 210 * The type provider used to access the types. | 274 * The type provider used to access the types. |
| 211 */ | 275 */ |
| 212 TestTypeProvider _typeProvider; | 276 TestTypeProvider _typeProvider; |
| 213 void setUp() { | 277 void setUp() { |
| 214 _typeProvider = new TestTypeProvider(); | 278 _typeProvider = new TestTypeProvider(); |
| 215 } | 279 } |
| 216 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() { | 280 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() { |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 void test_setTypeArguments() { | 1233 void test_setTypeArguments() { |
| 1170 InterfaceTypeImpl type = ElementFactory.classElement2("A", []).type as Inter
faceTypeImpl; | 1234 InterfaceTypeImpl type = ElementFactory.classElement2("A", []).type as Inter
faceTypeImpl; |
| 1171 List<Type2> typeArguments = <Type2> [ | 1235 List<Type2> typeArguments = <Type2> [ |
| 1172 ElementFactory.classElement2("B", []).type, | 1236 ElementFactory.classElement2("B", []).type, |
| 1173 ElementFactory.classElement2("C", []).type]; | 1237 ElementFactory.classElement2("C", []).type]; |
| 1174 type.typeArguments = typeArguments; | 1238 type.typeArguments = typeArguments; |
| 1175 JUnitTestCase.assertEquals(typeArguments, type.typeArguments); | 1239 JUnitTestCase.assertEquals(typeArguments, type.typeArguments); |
| 1176 } | 1240 } |
| 1177 void test_substitute_equal() { | 1241 void test_substitute_equal() { |
| 1178 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1242 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1179 TypeVariableElementImpl parameterElement = new TypeVariableElementImpl(ASTFa
ctory.identifier3("E")); | 1243 TypeParameterElementImpl parameterElement = new TypeParameterElementImpl(AST
Factory.identifier3("E")); |
| 1180 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); | 1244 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); |
| 1181 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(parameterElement); | 1245 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(parameterElement
); |
| 1182 type.typeArguments = <Type2> [parameter]; | 1246 type.typeArguments = <Type2> [parameter]; |
| 1183 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; | 1247 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; |
| 1184 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par
ameter]); | 1248 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par
ameter]); |
| 1185 JUnitTestCase.assertEquals(classA, result.element); | 1249 JUnitTestCase.assertEquals(classA, result.element); |
| 1186 List<Type2> resultArguments = result.typeArguments; | 1250 List<Type2> resultArguments = result.typeArguments; |
| 1187 EngineTestCase.assertLength(1, resultArguments); | 1251 EngineTestCase.assertLength(1, resultArguments); |
| 1188 JUnitTestCase.assertEquals(argumentType, resultArguments[0]); | 1252 JUnitTestCase.assertEquals(argumentType, resultArguments[0]); |
| 1189 } | 1253 } |
| 1190 void test_substitute_exception() { | 1254 void test_substitute_exception() { |
| 1191 try { | 1255 try { |
| 1192 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1256 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1193 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); | 1257 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); |
| 1194 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; | 1258 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; |
| 1195 type.substitute2(<Type2> [argumentType], <Type2> []); | 1259 type.substitute2(<Type2> [argumentType], <Type2> []); |
| 1196 JUnitTestCase.fail("Expected to encounter exception, argument and paramete
r type array lengths not equal."); | 1260 JUnitTestCase.fail("Expected to encounter exception, argument and paramete
r type array lengths not equal."); |
| 1197 } catch (e) { | 1261 } catch (e) { |
| 1198 } | 1262 } |
| 1199 } | 1263 } |
| 1200 void test_substitute_notEqual() { | 1264 void test_substitute_notEqual() { |
| 1201 ClassElementImpl classA = ElementFactory.classElement2("A", []); | 1265 ClassElementImpl classA = ElementFactory.classElement2("A", []); |
| 1202 TypeVariableElementImpl parameterElement = new TypeVariableElementImpl(ASTFa
ctory.identifier3("E")); | 1266 TypeParameterElementImpl parameterElement = new TypeParameterElementImpl(AST
Factory.identifier3("E")); |
| 1203 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); | 1267 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA); |
| 1204 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(parameterElement); | 1268 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(parameterElement
); |
| 1205 type.typeArguments = <Type2> [parameter]; | 1269 type.typeArguments = <Type2> [parameter]; |
| 1206 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; | 1270 InterfaceType argumentType = ElementFactory.classElement2("B", []).type; |
| 1207 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab
leElementImpl(ASTFactory.identifier3("F"))); | 1271 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara
meterElementImpl(ASTFactory.identifier3("F"))); |
| 1208 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par
ameterType]); | 1272 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par
ameterType]); |
| 1209 JUnitTestCase.assertEquals(classA, result.element); | 1273 JUnitTestCase.assertEquals(classA, result.element); |
| 1210 List<Type2> resultArguments = result.typeArguments; | 1274 List<Type2> resultArguments = result.typeArguments; |
| 1211 EngineTestCase.assertLength(1, resultArguments); | 1275 EngineTestCase.assertLength(1, resultArguments); |
| 1212 JUnitTestCase.assertEquals(parameter, resultArguments[0]); | 1276 JUnitTestCase.assertEquals(parameter, resultArguments[0]); |
| 1213 } | 1277 } |
| 1214 static dartSuite() { | 1278 static dartSuite() { |
| 1215 _ut.group('InterfaceTypeImplTest', () { | 1279 _ut.group('InterfaceTypeImplTest', () { |
| 1216 _ut.test('test_computeLongestInheritancePathToObject_multipleInterfacePath
s', () { | 1280 _ut.test('test_computeLongestInheritancePathToObject_multipleInterfacePath
s', () { |
| 1217 final __test = new InterfaceTypeImplTest(); | 1281 final __test = new InterfaceTypeImplTest(); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 final __test = new InterfaceTypeImplTest(); | 1669 final __test = new InterfaceTypeImplTest(); |
| 1606 runJUnitTest(__test, __test.test_substitute_exception); | 1670 runJUnitTest(__test, __test.test_substitute_exception); |
| 1607 }); | 1671 }); |
| 1608 _ut.test('test_substitute_notEqual', () { | 1672 _ut.test('test_substitute_notEqual', () { |
| 1609 final __test = new InterfaceTypeImplTest(); | 1673 final __test = new InterfaceTypeImplTest(); |
| 1610 runJUnitTest(__test, __test.test_substitute_notEqual); | 1674 runJUnitTest(__test, __test.test_substitute_notEqual); |
| 1611 }); | 1675 }); |
| 1612 }); | 1676 }); |
| 1613 } | 1677 } |
| 1614 } | 1678 } |
| 1615 class TypeVariableTypeImplTest extends EngineTestCase { | |
| 1616 void fail_isMoreSpecificThan_typeArguments_object() { | |
| 1617 TypeVariableElementImpl element = new TypeVariableElementImpl(ASTFactory.ide
ntifier3("E")); | |
| 1618 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); | |
| 1619 JUnitTestCase.assertTrue(type.isMoreSpecificThan(ElementFactory.object.type)
); | |
| 1620 } | |
| 1621 void fail_isMoreSpecificThan_typeArguments_self() { | |
| 1622 TypeVariableElementImpl element = new TypeVariableElementImpl(ASTFactory.ide
ntifier3("E")); | |
| 1623 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); | |
| 1624 JUnitTestCase.assertTrue(type.isMoreSpecificThan(type)); | |
| 1625 } | |
| 1626 void test_creation() { | |
| 1627 JUnitTestCase.assertNotNull(new TypeVariableTypeImpl(new TypeVariableElement
Impl(ASTFactory.identifier3("E")))); | |
| 1628 } | |
| 1629 void test_getElement() { | |
| 1630 TypeVariableElementImpl element = new TypeVariableElementImpl(ASTFactory.ide
ntifier3("E")); | |
| 1631 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); | |
| 1632 JUnitTestCase.assertEquals(element, type.element); | |
| 1633 } | |
| 1634 void test_isMoreSpecificThan_typeArguments_upperBound() { | |
| 1635 ClassElementImpl classS = ElementFactory.classElement2("A", []); | |
| 1636 TypeVariableElementImpl typeVarT = new TypeVariableElementImpl(ASTFactory.id
entifier3("T")); | |
| 1637 typeVarT.bound = classS.type; | |
| 1638 TypeVariableTypeImpl typeVarTypeT = new TypeVariableTypeImpl(typeVarT); | |
| 1639 JUnitTestCase.assertTrue(typeVarTypeT.isMoreSpecificThan(classS.type)); | |
| 1640 } | |
| 1641 void test_substitute_equal() { | |
| 1642 TypeVariableElementImpl element = new TypeVariableElementImpl(ASTFactory.ide
ntifier3("E")); | |
| 1643 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); | |
| 1644 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl
(ASTFactory.identifier3("A"))); | |
| 1645 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(element); | |
| 1646 JUnitTestCase.assertSame(argument, type.substitute2(<Type2> [argument], <Typ
e2> [parameter])); | |
| 1647 } | |
| 1648 void test_substitute_notEqual() { | |
| 1649 TypeVariableTypeImpl type = new TypeVariableTypeImpl(new TypeVariableElement
Impl(ASTFactory.identifier3("E"))); | |
| 1650 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl
(ASTFactory.identifier3("A"))); | |
| 1651 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(new TypeVariableEl
ementImpl(ASTFactory.identifier3("F"))); | |
| 1652 JUnitTestCase.assertSame(type, type.substitute2(<Type2> [argument], <Type2>
[parameter])); | |
| 1653 } | |
| 1654 static dartSuite() { | |
| 1655 _ut.group('TypeVariableTypeImplTest', () { | |
| 1656 _ut.test('test_creation', () { | |
| 1657 final __test = new TypeVariableTypeImplTest(); | |
| 1658 runJUnitTest(__test, __test.test_creation); | |
| 1659 }); | |
| 1660 _ut.test('test_getElement', () { | |
| 1661 final __test = new TypeVariableTypeImplTest(); | |
| 1662 runJUnitTest(__test, __test.test_getElement); | |
| 1663 }); | |
| 1664 _ut.test('test_isMoreSpecificThan_typeArguments_upperBound', () { | |
| 1665 final __test = new TypeVariableTypeImplTest(); | |
| 1666 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_upperB
ound); | |
| 1667 }); | |
| 1668 _ut.test('test_substitute_equal', () { | |
| 1669 final __test = new TypeVariableTypeImplTest(); | |
| 1670 runJUnitTest(__test, __test.test_substitute_equal); | |
| 1671 }); | |
| 1672 _ut.test('test_substitute_notEqual', () { | |
| 1673 final __test = new TypeVariableTypeImplTest(); | |
| 1674 runJUnitTest(__test, __test.test_substitute_notEqual); | |
| 1675 }); | |
| 1676 }); | |
| 1677 } | |
| 1678 } | |
| 1679 /** | 1679 /** |
| 1680 * The class `ElementFactory` defines utility methods used to create elements fo
r testing | 1680 * The class `ElementFactory` defines utility methods used to create elements fo
r testing |
| 1681 * purposes. The elements that are created are complete in the sense that as muc
h of the element | 1681 * purposes. The elements that are created are complete in the sense that as muc
h of the element |
| 1682 * model as can be created, given the provided information, has been created. | 1682 * model as can be created, given the provided information, has been created. |
| 1683 */ | 1683 */ |
| 1684 class ElementFactory { | 1684 class ElementFactory { |
| 1685 | 1685 |
| 1686 /** | 1686 /** |
| 1687 * The element representing the class 'Object'. | 1687 * The element representing the class 'Object'. |
| 1688 */ | 1688 */ |
| 1689 static ClassElementImpl _objectElement; | 1689 static ClassElementImpl _objectElement; |
| 1690 static ClassElementImpl classElement(String typeName, InterfaceType superclass
Type, List<String> parameterNames) { | 1690 static ClassElementImpl classElement(String typeName, InterfaceType superclass
Type, List<String> parameterNames) { |
| 1691 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN
ame)); | 1691 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN
ame)); |
| 1692 element.supertype = superclassType; | 1692 element.supertype = superclassType; |
| 1693 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); | 1693 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); |
| 1694 element.type = type; | 1694 element.type = type; |
| 1695 int count = parameterNames.length; | 1695 int count = parameterNames.length; |
| 1696 if (count > 0) { | 1696 if (count > 0) { |
| 1697 List<TypeVariableElementImpl> typeVariables = new List<TypeVariableElement
Impl>(count); | 1697 List<TypeParameterElementImpl> typeParameters = new List<TypeParameterElem
entImpl>(count); |
| 1698 List<TypeVariableTypeImpl> typeArguments = new List<TypeVariableTypeImpl>(
count); | 1698 List<TypeParameterTypeImpl> typeParameterTypes = new List<TypeParameterTyp
eImpl>(count); |
| 1699 for (int i = 0; i < count; i++) { | 1699 for (int i = 0; i < count; i++) { |
| 1700 TypeVariableElementImpl variable = new TypeVariableElementImpl(ASTFactor
y.identifier3(parameterNames[i])); | 1700 TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(AS
TFactory.identifier3(parameterNames[i])); |
| 1701 typeVariables[i] = variable; | 1701 typeParameters[i] = typeParameter; |
| 1702 typeArguments[i] = new TypeVariableTypeImpl(variable); | 1702 typeParameterTypes[i] = new TypeParameterTypeImpl(typeParameter); |
| 1703 variable.type = typeArguments[i]; | 1703 typeParameter.type = typeParameterTypes[i]; |
| 1704 } | 1704 } |
| 1705 element.typeVariables = typeVariables; | 1705 element.typeParameters = typeParameters; |
| 1706 type.typeArguments = typeArguments; | 1706 type.typeArguments = typeParameterTypes; |
| 1707 } | 1707 } |
| 1708 return element; | 1708 return element; |
| 1709 } | 1709 } |
| 1710 static ClassElementImpl classElement2(String typeName, List<String> parameterN
ames) => classElement(typeName, object.type, parameterNames); | 1710 static ClassElementImpl classElement2(String typeName, List<String> parameterN
ames) => classElement(typeName, object.type, parameterNames); |
| 1711 static ConstructorElementImpl constructorElement(ClassElement definingClass, S
tring name) { | 1711 static ConstructorElementImpl constructorElement(ClassElement definingClass, S
tring name) { |
| 1712 Type2 type = definingClass.type; | 1712 Type2 type = definingClass.type; |
| 1713 ConstructorElementImpl constructor = new ConstructorElementImpl(name == null
? null : ASTFactory.identifier3(name)); | 1713 ConstructorElementImpl constructor = new ConstructorElementImpl(name == null
? null : ASTFactory.identifier3(name)); |
| 1714 constructor.returnType = type; | 1714 constructor.returnType = type; |
| 1715 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 1715 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
| 1716 constructor.type = constructorType; | 1716 constructor.type = constructorType; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 return getter; | 1838 return getter; |
| 1839 } | 1839 } |
| 1840 static ImportElementImpl importFor(LibraryElement importedLibrary2, PrefixElem
ent prefix2, List<NamespaceCombinator> combinators2) { | 1840 static ImportElementImpl importFor(LibraryElement importedLibrary2, PrefixElem
ent prefix2, List<NamespaceCombinator> combinators2) { |
| 1841 ImportElementImpl spec = new ImportElementImpl(); | 1841 ImportElementImpl spec = new ImportElementImpl(); |
| 1842 spec.importedLibrary = importedLibrary2; | 1842 spec.importedLibrary = importedLibrary2; |
| 1843 spec.prefix = prefix2; | 1843 spec.prefix = prefix2; |
| 1844 spec.combinators = combinators2; | 1844 spec.combinators = combinators2; |
| 1845 return spec; | 1845 return spec; |
| 1846 } | 1846 } |
| 1847 static LibraryElementImpl library(AnalysisContext context, String libraryName)
{ | 1847 static LibraryElementImpl library(AnalysisContext context, String libraryName)
{ |
| 1848 String fileName = "${libraryName}.dart"; | 1848 String fileName = "/${libraryName}.dart"; |
| 1849 FileBasedSource source = new FileBasedSource.con1(context.sourceFactory.cont
entCache, FileUtilities2.createFile(fileName)); | 1849 FileBasedSource source = new FileBasedSource.con1(context.sourceFactory.cont
entCache, FileUtilities2.createFile(fileName)); |
| 1850 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName); | 1850 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName); |
| 1851 unit.source = source; | 1851 unit.source = source; |
| 1852 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr
aryIdentifier2([libraryName])); | 1852 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr
aryIdentifier2([libraryName])); |
| 1853 library.definingCompilationUnit = unit; | 1853 library.definingCompilationUnit = unit; |
| 1854 return library; | 1854 return library; |
| 1855 } | 1855 } |
| 1856 static LocalVariableElementImpl localVariableElement(Identifier name) => new L
ocalVariableElementImpl(name); | 1856 static LocalVariableElementImpl localVariableElement(Identifier name) => new L
ocalVariableElementImpl(name); |
| 1857 static LocalVariableElementImpl localVariableElement2(String name) => new Loca
lVariableElementImpl(ASTFactory.identifier3(name)); | 1857 static LocalVariableElementImpl localVariableElement2(String name) => new Loca
lVariableElementImpl(ASTFactory.identifier3(name)); |
| 1858 static MethodElementImpl methodElement(String methodName, Type2 returnType2, L
ist<Type2> argumentTypes) { | 1858 static MethodElementImpl methodElement(String methodName, Type2 returnType2, L
ist<Type2> argumentTypes) { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2375 ClassElement a = ElementFactory.classElement2("A", []); | 2375 ClassElement a = ElementFactory.classElement2("A", []); |
| 2376 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 2376 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 2377 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty
pe; | 2377 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty
pe; |
| 2378 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); | 2378 JUnitTestCase.assertTrue(t.isSubtypeOf(s)); |
| 2379 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 2379 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); |
| 2380 JUnitTestCase.assertTrue(t.isAssignableTo(s)); | 2380 JUnitTestCase.assertTrue(t.isAssignableTo(s)); |
| 2381 JUnitTestCase.assertFalse(s.isAssignableTo(t)); | 2381 JUnitTestCase.assertFalse(s.isAssignableTo(t)); |
| 2382 } | 2382 } |
| 2383 void test_isSubtypeOf_baseCase_classFunction() { | 2383 void test_isSubtypeOf_baseCase_classFunction() { |
| 2384 ClassElementImpl functionElement = ElementFactory.classElement2("Function",
[]); | 2384 ClassElementImpl functionElement = ElementFactory.classElement2("Function",
[]); |
| 2385 InterfaceTypeImpl functionType = new InterfaceTypeImpl_25(functionElement); | 2385 InterfaceTypeImpl functionType = new InterfaceTypeImpl_22(functionElement); |
| 2386 FunctionType f = ElementFactory.functionElement("f").type; | 2386 FunctionType f = ElementFactory.functionElement("f").type; |
| 2387 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType)); | 2387 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType)); |
| 2388 } | 2388 } |
| 2389 void test_isSubtypeOf_baseCase_notFunctionType() { | 2389 void test_isSubtypeOf_baseCase_notFunctionType() { |
| 2390 FunctionType f = ElementFactory.functionElement("f").type; | 2390 FunctionType f = ElementFactory.functionElement("f").type; |
| 2391 InterfaceType t = ElementFactory.classElement2("C", []).type; | 2391 InterfaceType t = ElementFactory.classElement2("C", []).type; |
| 2392 JUnitTestCase.assertFalse(f.isSubtypeOf(t)); | 2392 JUnitTestCase.assertFalse(f.isSubtypeOf(t)); |
| 2393 } | 2393 } |
| 2394 void test_isSubtypeOf_baseCase_null() { | 2394 void test_isSubtypeOf_baseCase_null() { |
| 2395 FunctionType f = ElementFactory.functionElement("f").type; | 2395 FunctionType f = ElementFactory.functionElement("f").type; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 } | 2562 } |
| 2563 void test_isSubtypeOf_returnType_tNotAssignableToS() { | 2563 void test_isSubtypeOf_returnType_tNotAssignableToS() { |
| 2564 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl
ement2("A", [])).type; | 2564 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl
ement2("A", [])).type; |
| 2565 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl
ement2("B", [])).type; | 2565 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl
ement2("B", [])).type; |
| 2566 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 2566 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); |
| 2567 } | 2567 } |
| 2568 void test_isSubtypeOf_typeParameters_matchesBounds() { | 2568 void test_isSubtypeOf_typeParameters_matchesBounds() { |
| 2569 TestTypeProvider provider = new TestTypeProvider(); | 2569 TestTypeProvider provider = new TestTypeProvider(); |
| 2570 InterfaceType boolType = provider.boolType; | 2570 InterfaceType boolType = provider.boolType; |
| 2571 InterfaceType stringType = provider.stringType; | 2571 InterfaceType stringType = provider.stringType; |
| 2572 TypeVariableElementImpl variableB = new TypeVariableElementImpl(ASTFactory.i
dentifier3("B")); | 2572 TypeParameterElementImpl parameterB = new TypeParameterElementImpl(ASTFactor
y.identifier3("B")); |
| 2573 variableB.bound = boolType; | 2573 parameterB.bound = boolType; |
| 2574 TypeVariableTypeImpl typeB = new TypeVariableTypeImpl(variableB); | 2574 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB); |
| 2575 TypeVariableElementImpl variableS = new TypeVariableElementImpl(ASTFactory.i
dentifier3("S")); | 2575 TypeParameterElementImpl parameterS = new TypeParameterElementImpl(ASTFactor
y.identifier3("S")); |
| 2576 variableS.bound = stringType; | 2576 parameterS.bound = stringType; |
| 2577 TypeVariableTypeImpl typeS = new TypeVariableTypeImpl(variableS); | 2577 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS); |
| 2578 FunctionElementImpl functionAliasElement = new FunctionElementImpl.con1(ASTF
actory.identifier3("func")); | 2578 FunctionElementImpl functionAliasElement = new FunctionElementImpl.con1(ASTF
actory.identifier3("func")); |
| 2579 functionAliasElement.parameters = <ParameterElement> [ | 2579 functionAliasElement.parameters = <ParameterElement> [ |
| 2580 ElementFactory.requiredParameter2("a", typeB), | 2580 ElementFactory.requiredParameter2("a", typeB), |
| 2581 ElementFactory.positionalParameter2("b", typeS)]; | 2581 ElementFactory.positionalParameter2("b", typeS)]; |
| 2582 functionAliasElement.returnType = stringType; | 2582 functionAliasElement.returnType = stringType; |
| 2583 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias
Element); | 2583 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias
Element); |
| 2584 functionAliasElement.type = functionAliasType; | 2584 functionAliasElement.type = functionAliasType; |
| 2585 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor
y.identifier3("f")); | 2585 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor
y.identifier3("f")); |
| 2586 functionElement.parameters = <ParameterElement> [ | 2586 functionElement.parameters = <ParameterElement> [ |
| 2587 ElementFactory.requiredParameter2("c", boolType), | 2587 ElementFactory.requiredParameter2("c", boolType), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2603 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; | 2603 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [
a]).type; |
| 2604 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name"
], <ClassElement> [a]).type; | 2604 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name"
], <ClassElement> [a]).type; |
| 2605 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); | 2605 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); |
| 2606 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); | 2606 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); |
| 2607 } | 2607 } |
| 2608 void test_setTypeArguments() { | 2608 void test_setTypeArguments() { |
| 2609 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); | 2609 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]); |
| 2610 MethodElementImpl methodElement = new MethodElementImpl.con1(ASTFactory.iden
tifier3("m")); | 2610 MethodElementImpl methodElement = new MethodElementImpl.con1(ASTFactory.iden
tifier3("m")); |
| 2611 enclosingClass.methods = <MethodElement> [methodElement]; | 2611 enclosingClass.methods = <MethodElement> [methodElement]; |
| 2612 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement); | 2612 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement); |
| 2613 Type2 expectedType = enclosingClass.typeVariables[0].type; | 2613 Type2 expectedType = enclosingClass.typeParameters[0].type; |
| 2614 type.typeArguments = <Type2> [expectedType]; | 2614 type.typeArguments = <Type2> [expectedType]; |
| 2615 List<Type2> arguments = type.typeArguments; | 2615 List<Type2> arguments = type.typeArguments; |
| 2616 EngineTestCase.assertLength(1, arguments); | 2616 EngineTestCase.assertLength(1, arguments); |
| 2617 JUnitTestCase.assertEquals(expectedType, arguments[0]); | 2617 JUnitTestCase.assertEquals(expectedType, arguments[0]); |
| 2618 } | 2618 } |
| 2619 void test_substitute2_equal() { | 2619 void test_substitute2_equal() { |
| 2620 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]); | 2620 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]); |
| 2621 TypeVariableType parameterType = definingClass.typeVariables[0].type; | 2621 TypeParameterType parameterType = definingClass.typeParameters[0].type; |
| 2622 MethodElementImpl functionElement = new MethodElementImpl.con1(ASTFactory.id
entifier3("m")); | 2622 MethodElementImpl functionElement = new MethodElementImpl.con1(ASTFactory.id
entifier3("m")); |
| 2623 String namedParameterName = "c"; | 2623 String namedParameterName = "c"; |
| 2624 functionElement.parameters = <ParameterElement> [ | 2624 functionElement.parameters = <ParameterElement> [ |
| 2625 ElementFactory.requiredParameter2("a", parameterType), | 2625 ElementFactory.requiredParameter2("a", parameterType), |
| 2626 ElementFactory.positionalParameter2("b", parameterType), | 2626 ElementFactory.positionalParameter2("b", parameterType), |
| 2627 ElementFactory.namedParameter2(namedParameterName, parameterType)]; | 2627 ElementFactory.namedParameter2(namedParameterName, parameterType)]; |
| 2628 functionElement.returnType = parameterType; | 2628 functionElement.returnType = parameterType; |
| 2629 definingClass.methods = <MethodElement> [functionElement]; | 2629 definingClass.methods = <MethodElement> [functionElement]; |
| 2630 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); | 2630 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
| 2631 functionType.typeArguments = <Type2> [parameterType]; | 2631 functionType.typeArguments = <Type2> [parameterType]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2649 Type2 namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl(A
STFactory.identifier3("C"))); | 2649 Type2 namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl(A
STFactory.identifier3("C"))); |
| 2650 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor
y.identifier3("f")); | 2650 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor
y.identifier3("f")); |
| 2651 String namedParameterName = "c"; | 2651 String namedParameterName = "c"; |
| 2652 functionElement.parameters = <ParameterElement> [ | 2652 functionElement.parameters = <ParameterElement> [ |
| 2653 ElementFactory.requiredParameter2("a", normalParameterType), | 2653 ElementFactory.requiredParameter2("a", normalParameterType), |
| 2654 ElementFactory.positionalParameter2("b", optionalParameterType), | 2654 ElementFactory.positionalParameter2("b", optionalParameterType), |
| 2655 ElementFactory.namedParameter2(namedParameterName, namedParameterType)]; | 2655 ElementFactory.namedParameter2(namedParameterName, namedParameterType)]; |
| 2656 functionElement.returnType = returnType; | 2656 functionElement.returnType = returnType; |
| 2657 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); | 2657 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
| 2658 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement
Impl(ASTFactory.identifier3("D"))); | 2658 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement
Impl(ASTFactory.identifier3("D"))); |
| 2659 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab
leElementImpl(ASTFactory.identifier3("E"))); | 2659 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara
meterElementImpl(ASTFactory.identifier3("E"))); |
| 2660 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type
2> [parameterType]); | 2660 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type
2> [parameterType]); |
| 2661 JUnitTestCase.assertEquals(returnType, result.returnType); | 2661 JUnitTestCase.assertEquals(returnType, result.returnType); |
| 2662 List<Type2> normalParameters = result.normalParameterTypes; | 2662 List<Type2> normalParameters = result.normalParameterTypes; |
| 2663 EngineTestCase.assertLength(1, normalParameters); | 2663 EngineTestCase.assertLength(1, normalParameters); |
| 2664 JUnitTestCase.assertEquals(normalParameterType, normalParameters[0]); | 2664 JUnitTestCase.assertEquals(normalParameterType, normalParameters[0]); |
| 2665 List<Type2> optionalParameters = result.optionalParameterTypes; | 2665 List<Type2> optionalParameters = result.optionalParameterTypes; |
| 2666 EngineTestCase.assertLength(1, optionalParameters); | 2666 EngineTestCase.assertLength(1, optionalParameters); |
| 2667 JUnitTestCase.assertEquals(optionalParameterType, optionalParameters[0]); | 2667 JUnitTestCase.assertEquals(optionalParameterType, optionalParameters[0]); |
| 2668 Map<String, Type2> namedParameters = result.namedParameterTypes; | 2668 Map<String, Type2> namedParameters = result.namedParameterTypes; |
| 2669 EngineTestCase.assertSize2(1, namedParameters); | 2669 EngineTestCase.assertSize2(1, namedParameters); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2839 final __test = new FunctionTypeImplTest(); | 2839 final __test = new FunctionTypeImplTest(); |
| 2840 runJUnitTest(__test, __test.test_substitute2_equal); | 2840 runJUnitTest(__test, __test.test_substitute2_equal); |
| 2841 }); | 2841 }); |
| 2842 _ut.test('test_substitute2_notEqual', () { | 2842 _ut.test('test_substitute2_notEqual', () { |
| 2843 final __test = new FunctionTypeImplTest(); | 2843 final __test = new FunctionTypeImplTest(); |
| 2844 runJUnitTest(__test, __test.test_substitute2_notEqual); | 2844 runJUnitTest(__test, __test.test_substitute2_notEqual); |
| 2845 }); | 2845 }); |
| 2846 }); | 2846 }); |
| 2847 } | 2847 } |
| 2848 } | 2848 } |
| 2849 class InterfaceTypeImpl_25 extends InterfaceTypeImpl { | 2849 class InterfaceTypeImpl_22 extends InterfaceTypeImpl { |
| 2850 InterfaceTypeImpl_25(ClassElement arg0) : super.con1(arg0); | 2850 InterfaceTypeImpl_22(ClassElement arg0) : super.con1(arg0); |
| 2851 bool get isDartCoreFunction => true; | 2851 bool get isDartCoreFunction => true; |
| 2852 } | 2852 } |
| 2853 main() { | 2853 main() { |
| 2854 ElementKindTest.dartSuite(); | 2854 ElementKindTest.dartSuite(); |
| 2855 FunctionTypeImplTest.dartSuite(); | 2855 FunctionTypeImplTest.dartSuite(); |
| 2856 InterfaceTypeImplTest.dartSuite(); | 2856 InterfaceTypeImplTest.dartSuite(); |
| 2857 TypeVariableTypeImplTest.dartSuite(); | 2857 TypeParameterTypeImplTest.dartSuite(); |
| 2858 ClassElementImplTest.dartSuite(); | 2858 ClassElementImplTest.dartSuite(); |
| 2859 ElementLocationImplTest.dartSuite(); | 2859 ElementLocationImplTest.dartSuite(); |
| 2860 ElementImplTest.dartSuite(); | 2860 ElementImplTest.dartSuite(); |
| 2861 LibraryElementImplTest.dartSuite(); | 2861 LibraryElementImplTest.dartSuite(); |
| 2862 } | 2862 } |
| OLD | NEW |