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

Side by Side Diff: pkg/analyzer_experimental/test/generated/element_test.dart

Issue 17249003: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'dart:collection'; 4 import 'dart:collection';
5 import 'dart:io'; 5 import 'dart:io';
6 import 'package:analyzer_experimental/src/generated/java_core.dart'; 6 import 'package:analyzer_experimental/src/generated/java_core.dart';
7 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 7 import 'package:analyzer_experimental/src/generated/java_engine.dart';
8 import 'package:analyzer_experimental/src/generated/java_engine_io.dart'; 8 import 'package:analyzer_experimental/src/generated/java_engine_io.dart';
9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 9 import 'package:analyzer_experimental/src/generated/java_junit.dart';
10 import 'package:analyzer_experimental/src/generated/source_io.dart'; 10 import 'package:analyzer_experimental/src/generated/source_io.dart';
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 classA.accessors = <PropertyAccessorElement> [getterG]; 340 classA.accessors = <PropertyAccessorElement> [getterG];
341 InterfaceType typeA = classA.type; 341 InterfaceType typeA = classA.type;
342 JUnitTestCase.assertSame(getterG, typeA.getGetter(getterName)); 342 JUnitTestCase.assertSame(getterG, typeA.getGetter(getterName));
343 } 343 }
344 void test_getGetter_parameterized() { 344 void test_getGetter_parameterized() {
345 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 345 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
346 Type2 typeE = classA.type.typeArguments[0]; 346 Type2 typeE = classA.type.typeArguments[0];
347 String getterName = "g"; 347 String getterName = "g";
348 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, typeE); 348 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, typeE);
349 classA.accessors = <PropertyAccessorElement> [getterG]; 349 classA.accessors = <PropertyAccessorElement> [getterG];
350 ((getterG.type as FunctionTypeImpl)).typeArguments = classA.type.typeArgumen ts;
350 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 351 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
351 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); 352 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
352 typeAI.typeArguments = <Type2> [typeI]; 353 typeAI.typeArguments = <Type2> [typeI];
353 PropertyAccessorElement getter = typeAI.getGetter(getterName); 354 PropertyAccessorElement getter = typeAI.getGetter(getterName);
354 JUnitTestCase.assertNotNull(getter); 355 JUnitTestCase.assertNotNull(getter);
355 FunctionType getterType = getter.type; 356 FunctionType getterType = getter.type;
356 JUnitTestCase.assertSame(typeI, getterType.returnType); 357 JUnitTestCase.assertSame(typeI, getterType.returnType);
357 } 358 }
358 void test_getGetter_unimplemented() { 359 void test_getGetter_unimplemented() {
359 ClassElementImpl classA = ElementFactory.classElement2("A", []); 360 ClassElementImpl classA = ElementFactory.classElement2("A", []);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 classA.methods = <MethodElement> [methodM]; 582 classA.methods = <MethodElement> [methodM];
582 InterfaceType typeA = classA.type; 583 InterfaceType typeA = classA.type;
583 JUnitTestCase.assertSame(methodM, typeA.getMethod(methodName)); 584 JUnitTestCase.assertSame(methodM, typeA.getMethod(methodName));
584 } 585 }
585 void test_getMethod_parameterized() { 586 void test_getMethod_parameterized() {
586 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 587 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
587 Type2 typeE = classA.type.typeArguments[0]; 588 Type2 typeE = classA.type.typeArguments[0];
588 String methodName = "m"; 589 String methodName = "m";
589 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]); 590 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]);
590 classA.methods = <MethodElement> [methodM]; 591 classA.methods = <MethodElement> [methodM];
592 ((methodM.type as FunctionTypeImpl)).typeArguments = classA.type.typeArgumen ts;
591 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 593 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
592 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); 594 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
593 typeAI.typeArguments = <Type2> [typeI]; 595 typeAI.typeArguments = <Type2> [typeI];
594 MethodElement method = typeAI.getMethod(methodName); 596 MethodElement method = typeAI.getMethod(methodName);
595 JUnitTestCase.assertNotNull(method); 597 JUnitTestCase.assertNotNull(method);
596 FunctionType methodType = method.type; 598 FunctionType methodType = method.type;
597 JUnitTestCase.assertSame(typeI, methodType.returnType); 599 JUnitTestCase.assertSame(typeI, methodType.returnType);
598 List<Type2> parameterTypes = methodType.normalParameterTypes; 600 List<Type2> parameterTypes = methodType.normalParameterTypes;
599 EngineTestCase.assertLength(1, parameterTypes); 601 EngineTestCase.assertLength(1, parameterTypes);
600 JUnitTestCase.assertSame(typeI, parameterTypes[0]); 602 JUnitTestCase.assertSame(typeI, parameterTypes[0]);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 classA.accessors = <PropertyAccessorElement> [setterS]; 645 classA.accessors = <PropertyAccessorElement> [setterS];
644 InterfaceType typeA = classA.type; 646 InterfaceType typeA = classA.type;
645 JUnitTestCase.assertSame(setterS, typeA.getSetter(setterName)); 647 JUnitTestCase.assertSame(setterS, typeA.getSetter(setterName));
646 } 648 }
647 void test_getSetter_parameterized() { 649 void test_getSetter_parameterized() {
648 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 650 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
649 Type2 typeE = classA.type.typeArguments[0]; 651 Type2 typeE = classA.type.typeArguments[0];
650 String setterName = "s"; 652 String setterName = "s";
651 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, typeE); 653 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, typeE);
652 classA.accessors = <PropertyAccessorElement> [setterS]; 654 classA.accessors = <PropertyAccessorElement> [setterS];
655 ((setterS.type as FunctionTypeImpl)).typeArguments = classA.type.typeArgumen ts;
653 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 656 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
654 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA); 657 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
655 typeAI.typeArguments = <Type2> [typeI]; 658 typeAI.typeArguments = <Type2> [typeI];
656 PropertyAccessorElement setter = typeAI.getSetter(setterName); 659 PropertyAccessorElement setter = typeAI.getSetter(setterName);
657 JUnitTestCase.assertNotNull(setter); 660 JUnitTestCase.assertNotNull(setter);
658 FunctionType setterType = setter.type; 661 FunctionType setterType = setter.type;
659 List<Type2> parameterTypes = setterType.normalParameterTypes; 662 List<Type2> parameterTypes = setterType.normalParameterTypes;
660 EngineTestCase.assertLength(1, parameterTypes); 663 EngineTestCase.assertLength(1, parameterTypes);
661 JUnitTestCase.assertSame(typeI, parameterTypes[0]); 664 JUnitTestCase.assertSame(typeI, parameterTypes[0]);
662 } 665 }
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 CompilationUnitElement unit = library.definingCompilationUnit; 1019 CompilationUnitElement unit = library.definingCompilationUnit;
1017 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA, class B]; 1020 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA, class B];
1018 JUnitTestCase.assertSame(methodM, typeB.lookUpMethod(methodName, library)); 1021 JUnitTestCase.assertSame(methodM, typeB.lookUpMethod(methodName, library));
1019 } 1022 }
1020 void test_lookUpMethod_parameterized() { 1023 void test_lookUpMethod_parameterized() {
1021 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 1024 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
1022 Type2 typeE = classA.type.typeArguments[0]; 1025 Type2 typeE = classA.type.typeArguments[0];
1023 String methodName = "m"; 1026 String methodName = "m";
1024 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]); 1027 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]);
1025 classA.methods = <MethodElement> [methodM]; 1028 classA.methods = <MethodElement> [methodM];
1029 ((methodM.type as FunctionTypeImpl)).typeArguments = classA.type.typeArgumen ts;
1026 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]); 1030 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
1027 InterfaceType typeB = classB.type; 1031 InterfaceType typeB = classB.type;
1028 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); 1032 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
1029 typeAF.typeArguments = <Type2> [typeB.typeArguments[0]]; 1033 typeAF.typeArguments = <Type2> [typeB.typeArguments[0]];
1030 classB.supertype = typeAF; 1034 classB.supertype = typeAF;
1031 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1035 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1032 CompilationUnitElement unit = library.definingCompilationUnit; 1036 CompilationUnitElement unit = library.definingCompilationUnit;
1033 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA]; 1037 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1034 InterfaceType typeI = ElementFactory.classElement2("I", []).type; 1038 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
1035 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB); 1039 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 runJUnitTest(__test, __test.test_substitute_equal); 1552 runJUnitTest(__test, __test.test_substitute_equal);
1549 }); 1553 });
1550 _ut.test('test_substitute_notEqual', () { 1554 _ut.test('test_substitute_notEqual', () {
1551 final __test = new TypeVariableTypeImplTest(); 1555 final __test = new TypeVariableTypeImplTest();
1552 runJUnitTest(__test, __test.test_substitute_notEqual); 1556 runJUnitTest(__test, __test.test_substitute_notEqual);
1553 }); 1557 });
1554 }); 1558 });
1555 } 1559 }
1556 } 1560 }
1557 /** 1561 /**
1558 * The class {@code ElementFactory} defines utility methods used to create eleme nts for testing 1562 * The class `ElementFactory` defines utility methods used to create elements fo r testing
1559 * purposes. The elements that are created are complete in the sense that as muc h of the element 1563 * purposes. The elements that are created are complete in the sense that as muc h of the element
1560 * model as can be created, given the provided information, has been created. 1564 * model as can be created, given the provided information, has been created.
1561 */ 1565 */
1562 class ElementFactory { 1566 class ElementFactory {
1563 1567
1564 /** 1568 /**
1565 * The element representing the class 'Object'. 1569 * The element representing the class 'Object'.
1566 */ 1570 */
1567 static ClassElementImpl _objectElement; 1571 static ClassElementImpl _objectElement;
1568 static ClassElementImpl classElement(String typeName, InterfaceType superclass Type, List<String> parameterNames) { 1572 static ClassElementImpl classElement(String typeName, InterfaceType superclass Type, List<String> parameterNames) {
(...skipping 10 matching lines...) Expand all
1579 typeVariables[i] = variable; 1583 typeVariables[i] = variable;
1580 typeArguments[i] = new TypeVariableTypeImpl(variable); 1584 typeArguments[i] = new TypeVariableTypeImpl(variable);
1581 variable.type = typeArguments[i]; 1585 variable.type = typeArguments[i];
1582 } 1586 }
1583 element.typeVariables = typeVariables; 1587 element.typeVariables = typeVariables;
1584 type.typeArguments = typeArguments; 1588 type.typeArguments = typeArguments;
1585 } 1589 }
1586 return element; 1590 return element;
1587 } 1591 }
1588 static ClassElementImpl classElement2(String typeName, List<String> parameterN ames) => classElement(typeName, object.type, parameterNames); 1592 static ClassElementImpl classElement2(String typeName, List<String> parameterN ames) => classElement(typeName, object.type, parameterNames);
1589 static ConstructorElementImpl constructorElement(ClassElement clazz, String na me) { 1593 static ConstructorElementImpl constructorElement(ClassElement definingClass, S tring name) {
1590 Type2 type = clazz.type; 1594 Type2 type = definingClass.type;
1591 ConstructorElementImpl constructor = new ConstructorElementImpl(name == null ? null : ASTFactory.identifier3(name)); 1595 ConstructorElementImpl constructor = new ConstructorElementImpl(name == null ? null : ASTFactory.identifier3(name));
1596 constructor.returnType = type;
1592 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 1597 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
1593 constructorType.normalParameterTypes = <Type2> [type];
1594 constructorType.returnType = type;
1595 constructor.type = constructorType; 1598 constructor.type = constructorType;
1596 return constructor; 1599 return constructor;
1597 } 1600 }
1598 static ExportElementImpl exportFor(LibraryElement exportedLibrary2, List<Names paceCombinator> combinators2) { 1601 static ExportElementImpl exportFor(LibraryElement exportedLibrary2, List<Names paceCombinator> combinators2) {
1599 ExportElementImpl spec = new ExportElementImpl(); 1602 ExportElementImpl spec = new ExportElementImpl();
1600 spec.exportedLibrary = exportedLibrary2; 1603 spec.exportedLibrary = exportedLibrary2;
1601 spec.combinators = combinators2; 1604 spec.combinators = combinators2;
1602 return spec; 1605 return spec;
1603 } 1606 }
1604 static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, Type2 type2) { 1607 static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, Type2 type2) {
1605 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me)); 1608 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me));
1606 field.const3 = isConst; 1609 field.const3 = isConst;
1607 field.final2 = isFinal; 1610 field.final2 = isFinal;
1608 field.static = isStatic; 1611 field.static = isStatic;
1609 field.type = type2; 1612 field.type = type2;
1610 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 1613 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
1611 getter.getter = true; 1614 getter.getter = true;
1612 getter.static = isStatic; 1615 getter.static = isStatic;
1613 getter.synthetic = true; 1616 getter.synthetic = true;
1614 getter.variable = field; 1617 getter.variable = field;
1618 getter.returnType = type2;
1615 field.getter = getter; 1619 field.getter = getter;
1616 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1620 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1617 getterType.returnType = type2;
1618 getter.type = getterType; 1621 getter.type = getterType;
1619 if (!isConst && !isFinal) { 1622 if (!isConst && !isFinal) {
1620 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( field); 1623 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( field);
1621 setter.setter = true; 1624 setter.setter = true;
1622 setter.static = isStatic; 1625 setter.static = isStatic;
1623 setter.synthetic = true; 1626 setter.synthetic = true;
1624 setter.variable = field; 1627 setter.variable = field;
1628 setter.returnType = VoidTypeImpl.instance;
1625 field.setter = setter; 1629 field.setter = setter;
1626 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter); 1630 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter);
1627 setterType.normalParameterTypes = <Type2> [type2]; 1631 setterType.normalParameterTypes = <Type2> [type2];
1628 setterType.returnType = VoidTypeImpl.instance;
1629 setter.type = setterType; 1632 setter.type = setterType;
1630 } 1633 }
1631 return field; 1634 return field;
1632 } 1635 }
1633 static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) = > new FieldFormalParameterElementImpl(name); 1636 static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) = > new FieldFormalParameterElementImpl(name);
1634 static FunctionElementImpl functionElement(String functionName) => functionEle ment4(functionName, null, null, null, null); 1637 static FunctionElementImpl functionElement(String functionName) => functionEle ment4(functionName, null, null, null, null);
1635 static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null); 1638 static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null);
1636 static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalP arameters) { 1639 static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalP arameters) {
1637 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3(functionName)); 1640 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3(functionName));
1638 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 1641 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
1639 functionElement.type = functionType; 1642 functionElement.type = functionType;
1640 if (returnElement != null) { 1643 if (returnElement == null) {
1641 functionType.returnType = returnElement.type; 1644 functionElement.returnType = VoidTypeImpl.instance;
1645 } else {
1646 functionElement.returnType = returnElement.type;
1642 } 1647 }
1643 int normalCount = normalParameters == null ? 0 : normalParameters.length; 1648 int normalCount = normalParameters == null ? 0 : normalParameters.length;
1644 if (normalCount > 0) { 1649 if (normalCount > 0) {
1645 List<InterfaceType> normalParameterTypes = new List<InterfaceType>(normalC ount); 1650 List<InterfaceType> normalParameterTypes = new List<InterfaceType>(normalC ount);
1646 for (int i = 0; i < normalCount; i++) { 1651 for (int i = 0; i < normalCount; i++) {
1647 normalParameterTypes[i] = normalParameters[i].type; 1652 normalParameterTypes[i] = normalParameters[i].type;
1648 } 1653 }
1649 functionType.normalParameterTypes = normalParameterTypes; 1654 functionType.normalParameterTypes = normalParameterTypes;
1650 } 1655 }
1651 int optionalCount = optionalParameters == null ? 0 : optionalParameters.leng th; 1656 int optionalCount = optionalParameters == null ? 0 : optionalParameters.leng th;
(...skipping 17 matching lines...) Expand all
1669 } 1674 }
1670 parameters[i] = parameter; 1675 parameters[i] = parameter;
1671 } 1676 }
1672 functionElement.parameters = parameters; 1677 functionElement.parameters = parameters;
1673 return functionElement; 1678 return functionElement;
1674 } 1679 }
1675 static FunctionElementImpl functionElement4(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<String> names, List<Cla ssElement> namedParameters) { 1680 static FunctionElementImpl functionElement4(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<String> names, List<Cla ssElement> namedParameters) {
1676 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3(functionName)); 1681 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3(functionName));
1677 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 1682 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
1678 functionElement.type = functionType; 1683 functionElement.type = functionType;
1679 if (returnElement != null) { 1684 if (returnElement == null) {
1680 functionType.returnType = returnElement.type; 1685 functionElement.returnType = VoidTypeImpl.instance;
1686 } else {
1687 functionElement.returnType = returnElement.type;
1681 } 1688 }
1682 int count = normalParameters == null ? 0 : normalParameters.length; 1689 int count = normalParameters == null ? 0 : normalParameters.length;
1683 if (count > 0) { 1690 if (count > 0) {
1684 List<InterfaceType> normalParameterTypes = new List<InterfaceType>(count); 1691 List<InterfaceType> normalParameterTypes = new List<InterfaceType>(count);
1685 for (int i = 0; i < count; i++) { 1692 for (int i = 0; i < count; i++) {
1686 normalParameterTypes[i] = normalParameters[i].type; 1693 normalParameterTypes[i] = normalParameters[i].type;
1687 } 1694 }
1688 functionType.normalParameterTypes = normalParameterTypes; 1695 functionType.normalParameterTypes = normalParameterTypes;
1689 } 1696 }
1690 if (names != null && names.length > 0 && names.length == namedParameters.len gth) { 1697 if (names != null && names.length > 0 && names.length == namedParameters.len gth) {
(...skipping 18 matching lines...) Expand all
1709 } 1716 }
1710 static PropertyAccessorElementImpl getterElement(String name, bool isStatic, T ype2 type2) { 1717 static PropertyAccessorElementImpl getterElement(String name, bool isStatic, T ype2 type2) {
1711 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me)); 1718 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me));
1712 field.static = isStatic; 1719 field.static = isStatic;
1713 field.synthetic = true; 1720 field.synthetic = true;
1714 field.type = type2; 1721 field.type = type2;
1715 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 1722 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
1716 getter.getter = true; 1723 getter.getter = true;
1717 getter.static = isStatic; 1724 getter.static = isStatic;
1718 getter.variable = field; 1725 getter.variable = field;
1726 getter.returnType = type2;
1719 field.getter = getter; 1727 field.getter = getter;
1720 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1728 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1721 getterType.returnType = type2;
1722 getter.type = getterType; 1729 getter.type = getterType;
1723 return getter; 1730 return getter;
1724 } 1731 }
1725 static ImportElementImpl importFor(LibraryElement importedLibrary2, PrefixElem ent prefix2, List<NamespaceCombinator> combinators2) { 1732 static ImportElementImpl importFor(LibraryElement importedLibrary2, PrefixElem ent prefix2, List<NamespaceCombinator> combinators2) {
1726 ImportElementImpl spec = new ImportElementImpl(); 1733 ImportElementImpl spec = new ImportElementImpl();
1727 spec.importedLibrary = importedLibrary2; 1734 spec.importedLibrary = importedLibrary2;
1728 spec.prefix = prefix2; 1735 spec.prefix = prefix2;
1729 spec.combinators = combinators2; 1736 spec.combinators = combinators2;
1730 return spec; 1737 return spec;
1731 } 1738 }
(...skipping 12 matching lines...) Expand all
1744 MethodElementImpl method = new MethodElementImpl.con1(ASTFactory.identifier3 (methodName)); 1751 MethodElementImpl method = new MethodElementImpl.con1(ASTFactory.identifier3 (methodName));
1745 int count = argumentTypes.length; 1752 int count = argumentTypes.length;
1746 List<ParameterElement> parameters = new List<ParameterElement>(count); 1753 List<ParameterElement> parameters = new List<ParameterElement>(count);
1747 for (int i = 0; i < count; i++) { 1754 for (int i = 0; i < count; i++) {
1748 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.ident ifier3("a${i}")); 1755 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.ident ifier3("a${i}"));
1749 parameter.type = argumentTypes[i]; 1756 parameter.type = argumentTypes[i];
1750 parameter.parameterKind = ParameterKind.REQUIRED; 1757 parameter.parameterKind = ParameterKind.REQUIRED;
1751 parameters[i] = parameter; 1758 parameters[i] = parameter;
1752 } 1759 }
1753 method.parameters = parameters; 1760 method.parameters = parameters;
1761 method.returnType = returnType2;
1754 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method); 1762 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method);
1755 methodType.normalParameterTypes = argumentTypes; 1763 methodType.normalParameterTypes = argumentTypes;
1756 methodType.returnType = returnType2;
1757 method.type = methodType; 1764 method.type = methodType;
1758 return method; 1765 return method;
1759 } 1766 }
1760 static ParameterElementImpl namedParameter(String name) { 1767 static ParameterElementImpl namedParameter(String name) {
1761 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier3(name)); 1768 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier3(name));
1762 parameter.parameterKind = ParameterKind.NAMED; 1769 parameter.parameterKind = ParameterKind.NAMED;
1763 return parameter; 1770 return parameter;
1764 } 1771 }
1765 static ParameterElementImpl positionalParameter(String name) { 1772 static ParameterElementImpl positionalParameter(String name) {
1766 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier3(name)); 1773 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier3(name));
1767 parameter.parameterKind = ParameterKind.POSITIONAL; 1774 parameter.parameterKind = ParameterKind.POSITIONAL;
1768 return parameter; 1775 return parameter;
1769 } 1776 }
1770 static PrefixElementImpl prefix(String name) => new PrefixElementImpl(ASTFacto ry.identifier3(name)); 1777 static PrefixElementImpl prefix(String name) => new PrefixElementImpl(ASTFacto ry.identifier3(name));
1771 static ParameterElementImpl requiredParameter(String name) { 1778 static ParameterElementImpl requiredParameter(String name) {
1772 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier3(name)); 1779 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier3(name));
1773 parameter.parameterKind = ParameterKind.REQUIRED; 1780 parameter.parameterKind = ParameterKind.REQUIRED;
1774 return parameter; 1781 return parameter;
1775 } 1782 }
1776 static PropertyAccessorElementImpl setterElement(String name, bool isStatic, T ype2 type2) { 1783 static PropertyAccessorElementImpl setterElement(String name, bool isStatic, T ype2 type2) {
1777 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me)); 1784 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me));
1778 field.static = isStatic; 1785 field.static = isStatic;
1779 field.synthetic = true; 1786 field.synthetic = true;
1780 field.type = type2; 1787 field.type = type2;
1781 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 1788 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
1782 getter.getter = true; 1789 getter.getter = true;
1783 getter.static = isStatic; 1790 getter.static = isStatic;
1784 getter.variable = field; 1791 getter.variable = field;
1792 getter.returnType = type2;
1785 field.getter = getter; 1793 field.getter = getter;
1786 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1794 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1787 getterType.returnType = type2;
1788 getter.type = getterType; 1795 getter.type = getterType;
1789 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2(fi eld); 1796 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2(fi eld);
1790 setter.setter = true; 1797 setter.setter = true;
1791 setter.static = isStatic; 1798 setter.static = isStatic;
1792 setter.synthetic = true; 1799 setter.synthetic = true;
1793 setter.variable = field; 1800 setter.variable = field;
1801 setter.returnType = VoidTypeImpl.instance;
1794 field.setter = setter; 1802 field.setter = setter;
1795 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter); 1803 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(setter);
1796 setterType.normalParameterTypes = <Type2> [type2]; 1804 setterType.normalParameterTypes = <Type2> [type2];
1797 setterType.returnType = VoidTypeImpl.instance;
1798 setter.type = setterType; 1805 setter.type = setterType;
1799 return setter; 1806 return setter;
1800 } 1807 }
1801 static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.con1(name); 1808 static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.con1(name);
1802 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => ne w TopLevelVariableElementImpl.con2(name); 1809 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => ne w TopLevelVariableElementImpl.con2(name);
1803 static TopLevelVariableElementImpl topLevelVariableElement3(String name, bool isFinal, Type2 type2) { 1810 static TopLevelVariableElementImpl topLevelVariableElement3(String name, bool isFinal, Type2 type2) {
1804 TopLevelVariableElementImpl variable = new TopLevelVariableElementImpl.con2( name); 1811 TopLevelVariableElementImpl variable = new TopLevelVariableElementImpl.con2( name);
1805 variable.final2 = isFinal; 1812 variable.final2 = isFinal;
1806 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(va riable); 1813 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(va riable);
1807 getter.getter = true; 1814 getter.getter = true;
1808 getter.static = true; 1815 getter.static = true;
1809 getter.synthetic = true; 1816 getter.synthetic = true;
1810 getter.variable = variable; 1817 getter.variable = variable;
1818 getter.returnType = type2;
1811 variable.getter = getter; 1819 variable.getter = getter;
1812 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1820 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1813 getterType.returnType = type2;
1814 getter.type = getterType; 1821 getter.type = getterType;
1815 if (!isFinal) { 1822 if (!isFinal) {
1816 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( variable); 1823 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( variable);
1817 setter.setter = true; 1824 setter.setter = true;
1818 setter.static = true; 1825 setter.static = true;
1819 setter.synthetic = true; 1826 setter.synthetic = true;
1820 setter.variable = variable; 1827 setter.variable = variable;
1828 setter.returnType = VoidTypeImpl.instance;
1821 variable.setter = setter; 1829 variable.setter = setter;
1822 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter); 1830 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter);
1823 setterType.normalParameterTypes = <Type2> [type2]; 1831 setterType.normalParameterTypes = <Type2> [type2];
1824 setterType.returnType = VoidTypeImpl.instance;
1825 setter.type = setterType; 1832 setter.type = setterType;
1826 } 1833 }
1827 return variable; 1834 return variable;
1828 } 1835 }
1829 } 1836 }
1830 class ElementKindTest extends EngineTestCase { 1837 class ElementKindTest extends EngineTestCase {
1831 void test_of_nonNull() { 1838 void test_of_nonNull() {
1832 JUnitTestCase.assertSame(ElementKind.CLASS, ElementKind.of(ElementFactory.cl assElement2("A", []))); 1839 JUnitTestCase.assertSame(ElementKind.CLASS, ElementKind.of(ElementFactory.cl assElement2("A", [])));
1833 } 1840 }
1834 void test_of_null() { 1841 void test_of_null() {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f"))); 2207 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2201 Map<String, Type2> types = type.namedParameterTypes; 2208 Map<String, Type2> types = type.namedParameterTypes;
2202 EngineTestCase.assertSize2(0, types); 2209 EngineTestCase.assertSize2(0, types);
2203 } 2210 }
2204 void test_getNormalParameterTypes() { 2211 void test_getNormalParameterTypes() {
2205 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f"))); 2212 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2206 List<Type2> types = type.normalParameterTypes; 2213 List<Type2> types = type.normalParameterTypes;
2207 EngineTestCase.assertLength(0, types); 2214 EngineTestCase.assertLength(0, types);
2208 } 2215 }
2209 void test_getReturnType() { 2216 void test_getReturnType() {
2210 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f"))); 2217 Type2 expectedReturnType = VoidTypeImpl.instance;
2218 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3("f"));
2219 functionElement.returnType = expectedReturnType;
2220 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement);
2211 Type2 returnType = type.returnType; 2221 Type2 returnType = type.returnType;
2212 JUnitTestCase.assertEquals(VoidTypeImpl.instance, returnType); 2222 JUnitTestCase.assertEquals(expectedReturnType, returnType);
2213 } 2223 }
2214 void test_getTypeArguments() { 2224 void test_getTypeArguments() {
2215 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f"))); 2225 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2216 List<Type2> types = type.typeArguments; 2226 List<Type2> types = type.typeArguments;
2217 EngineTestCase.assertLength(0, types); 2227 EngineTestCase.assertLength(0, types);
2218 } 2228 }
2219 void test_hashCode_element() { 2229 void test_hashCode_element() {
2220 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f"))); 2230 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2221 type.hashCode; 2231 type.hashCode;
2222 } 2232 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 TestTypeProvider provider = new TestTypeProvider(); 2423 TestTypeProvider provider = new TestTypeProvider();
2414 InterfaceType boolType = provider.boolType; 2424 InterfaceType boolType = provider.boolType;
2415 InterfaceType stringType = provider.stringType; 2425 InterfaceType stringType = provider.stringType;
2416 TypeVariableElementImpl variableB = new TypeVariableElementImpl(ASTFactory.i dentifier3("B")); 2426 TypeVariableElementImpl variableB = new TypeVariableElementImpl(ASTFactory.i dentifier3("B"));
2417 variableB.bound = boolType; 2427 variableB.bound = boolType;
2418 TypeVariableTypeImpl typeB = new TypeVariableTypeImpl(variableB); 2428 TypeVariableTypeImpl typeB = new TypeVariableTypeImpl(variableB);
2419 TypeVariableElementImpl variableS = new TypeVariableElementImpl(ASTFactory.i dentifier3("S")); 2429 TypeVariableElementImpl variableS = new TypeVariableElementImpl(ASTFactory.i dentifier3("S"));
2420 variableS.bound = stringType; 2430 variableS.bound = stringType;
2421 TypeVariableTypeImpl typeS = new TypeVariableTypeImpl(variableS); 2431 TypeVariableTypeImpl typeS = new TypeVariableTypeImpl(variableS);
2422 FunctionElementImpl functionAliasElement = new FunctionElementImpl.con1(ASTF actory.identifier3("func")); 2432 FunctionElementImpl functionAliasElement = new FunctionElementImpl.con1(ASTF actory.identifier3("func"));
2433 functionAliasElement.returnType = stringType;
2423 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias Element); 2434 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias Element);
2424 functionAliasElement.type = functionAliasType; 2435 functionAliasElement.type = functionAliasType;
2425 functionAliasType.returnType = stringType;
2426 functionAliasType.normalParameterTypes = <Type2> [typeB]; 2436 functionAliasType.normalParameterTypes = <Type2> [typeB];
2427 functionAliasType.optionalParameterTypes = <Type2> [typeS]; 2437 functionAliasType.optionalParameterTypes = <Type2> [typeS];
2428 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3("f")); 2438 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3("f"));
2439 functionElement.returnType = provider.dynamicType;
2429 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 2440 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2430 functionElement.type = functionType; 2441 functionElement.type = functionType;
2431 functionType.returnType = provider.dynamicType;
2432 functionType.normalParameterTypes = <Type2> [boolType]; 2442 functionType.normalParameterTypes = <Type2> [boolType];
2433 functionType.optionalParameterTypes = <Type2> [stringType]; 2443 functionType.optionalParameterTypes = <Type2> [stringType];
2434 JUnitTestCase.assertTrue(functionType.isAssignableTo(functionAliasType)); 2444 JUnitTestCase.assertTrue(functionType.isAssignableTo(functionAliasType));
2435 } 2445 }
2436 void test_isSubtypeOf_wrongFunctionType_normal_named() { 2446 void test_isSubtypeOf_wrongFunctionType_normal_named() {
2437 ClassElement a = ElementFactory.classElement2("A", []); 2447 ClassElement a = ElementFactory.classElement2("A", []);
2438 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe; 2448 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
2439 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type; 2449 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
2440 JUnitTestCase.assertFalse(t.isSubtypeOf(s)); 2450 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2441 JUnitTestCase.assertFalse(s.isSubtypeOf(t)); 2451 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
(...skipping 14 matching lines...) Expand all
2456 JUnitTestCase.assertEquals(expectedTypes, types); 2466 JUnitTestCase.assertEquals(expectedTypes, types);
2457 } 2467 }
2458 void test_setNormalParameterTypes() { 2468 void test_setNormalParameterTypes() {
2459 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f"))); 2469 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2460 List<Type2> expectedTypes = <Type2> [new InterfaceTypeImpl.con1(new ClassEle mentImpl(ASTFactory.identifier3("C")))]; 2470 List<Type2> expectedTypes = <Type2> [new InterfaceTypeImpl.con1(new ClassEle mentImpl(ASTFactory.identifier3("C")))];
2461 type.normalParameterTypes = expectedTypes; 2471 type.normalParameterTypes = expectedTypes;
2462 List<Type2> types = type.normalParameterTypes; 2472 List<Type2> types = type.normalParameterTypes;
2463 JUnitTestCase.assertEquals(expectedTypes, types); 2473 JUnitTestCase.assertEquals(expectedTypes, types);
2464 } 2474 }
2465 void test_setReturnType() { 2475 void test_setReturnType() {
2466 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2467 Type2 expectedType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFact ory.identifier3("C"))); 2476 Type2 expectedType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFact ory.identifier3("C")));
2468 type.returnType = expectedType; 2477 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3("f"));
2469 Type2 returnType = type.returnType; 2478 functionElement.returnType = expectedType;
2470 JUnitTestCase.assertEquals(expectedType, returnType); 2479 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement);
2480 JUnitTestCase.assertEquals(expectedType, type.returnType);
2471 } 2481 }
2472 void test_setTypeArguments() { 2482 void test_setTypeArguments() {
2473 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f"))); 2483 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]);
2474 Type2 expectedType = new TypeVariableTypeImpl(new TypeVariableElementImpl(AS TFactory.identifier3("C"))); 2484 MethodElementImpl methodElement = new MethodElementImpl.con1(ASTFactory.iden tifier3("m"));
2485 enclosingClass.methods = <MethodElement> [methodElement];
2486 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement);
2487 Type2 expectedType = enclosingClass.typeVariables[0].type;
2475 type.typeArguments = <Type2> [expectedType]; 2488 type.typeArguments = <Type2> [expectedType];
2476 List<Type2> arguments = type.typeArguments; 2489 List<Type2> arguments = type.typeArguments;
2477 EngineTestCase.assertLength(1, arguments); 2490 EngineTestCase.assertLength(1, arguments);
2478 JUnitTestCase.assertEquals(expectedType, arguments[0]); 2491 JUnitTestCase.assertEquals(expectedType, arguments[0]);
2479 } 2492 }
2480 void test_substitute2_equal() { 2493 void test_substitute2_equal() {
2481 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier3("f"))); 2494 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]);
2482 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier3("E"))); 2495 TypeVariableType parameterType = definingClass.typeVariables[0].type;
2483 functionType.returnType = parameterType; 2496 MethodElementImpl functionElement = new MethodElementImpl.con1(ASTFactory.id entifier3("m"));
2497 functionElement.returnType = parameterType;
2498 definingClass.methods = <MethodElement> [functionElement];
2499 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2484 functionType.normalParameterTypes = <Type2> [parameterType]; 2500 functionType.normalParameterTypes = <Type2> [parameterType];
2485 functionType.optionalParameterTypes = <Type2> [parameterType]; 2501 functionType.optionalParameterTypes = <Type2> [parameterType];
2502 functionType.typeArguments = <Type2> [parameterType];
2486 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>(); 2503 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>();
2487 String namedParameterName = "c"; 2504 String namedParameterName = "c";
2488 namedParameterTypes[namedParameterName] = parameterType; 2505 namedParameterTypes[namedParameterName] = parameterType;
2489 functionType.namedParameterTypes = namedParameterTypes; 2506 functionType.namedParameterTypes = namedParameterTypes;
2490 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier3("D"))); 2507 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier3("D")));
2491 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]); 2508 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]);
2492 JUnitTestCase.assertEquals(argumentType, result.returnType); 2509 JUnitTestCase.assertEquals(argumentType, result.returnType);
2493 List<Type2> normalParameters = result.normalParameterTypes; 2510 List<Type2> normalParameters = result.normalParameterTypes;
2494 EngineTestCase.assertLength(1, normalParameters); 2511 EngineTestCase.assertLength(1, normalParameters);
2495 JUnitTestCase.assertEquals(argumentType, normalParameters[0]); 2512 JUnitTestCase.assertEquals(argumentType, normalParameters[0]);
2496 List<Type2> optionalParameters = result.optionalParameterTypes; 2513 List<Type2> optionalParameters = result.optionalParameterTypes;
2497 EngineTestCase.assertLength(1, optionalParameters); 2514 EngineTestCase.assertLength(1, optionalParameters);
2498 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]); 2515 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]);
2499 Map<String, Type2> namedParameters = result.namedParameterTypes; 2516 Map<String, Type2> namedParameters = result.namedParameterTypes;
2500 EngineTestCase.assertSize2(1, namedParameters); 2517 EngineTestCase.assertSize2(1, namedParameters);
2501 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] ); 2518 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] );
2502 } 2519 }
2503 void test_substitute2_notEqual() { 2520 void test_substitute2_notEqual() {
2504 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier3("f")));
2505 Type2 returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFactor y.identifier3("R"))); 2521 Type2 returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFactor y.identifier3("R")));
2506 Type2 normalParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl( ASTFactory.identifier3("A"))); 2522 Type2 normalParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl( ASTFactory.identifier3("A")));
2507 Type2 optionalParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(ASTFactory.identifier3("B"))); 2523 Type2 optionalParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(ASTFactory.identifier3("B")));
2508 Type2 namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl(A STFactory.identifier3("C"))); 2524 Type2 namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl(A STFactory.identifier3("C")));
2509 functionType.returnType = returnType; 2525 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3("f"));
2526 functionElement.returnType = returnType;
2527 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2510 functionType.normalParameterTypes = <Type2> [normalParameterType]; 2528 functionType.normalParameterTypes = <Type2> [normalParameterType];
2511 functionType.optionalParameterTypes = <Type2> [optionalParameterType]; 2529 functionType.optionalParameterTypes = <Type2> [optionalParameterType];
2512 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>(); 2530 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>();
2513 String namedParameterName = "c"; 2531 String namedParameterName = "c";
2514 namedParameterTypes[namedParameterName] = namedParameterType; 2532 namedParameterTypes[namedParameterName] = namedParameterType;
2515 functionType.namedParameterTypes = namedParameterTypes; 2533 functionType.namedParameterTypes = namedParameterTypes;
2516 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier3("D"))); 2534 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier3("D")));
2517 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier3("E"))); 2535 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier3("E")));
2518 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]); 2536 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]);
2519 JUnitTestCase.assertEquals(returnType, result.returnType); 2537 JUnitTestCase.assertEquals(returnType, result.returnType);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 main() { 2737 main() {
2720 ElementKindTest.dartSuite(); 2738 ElementKindTest.dartSuite();
2721 FunctionTypeImplTest.dartSuite(); 2739 FunctionTypeImplTest.dartSuite();
2722 InterfaceTypeImplTest.dartSuite(); 2740 InterfaceTypeImplTest.dartSuite();
2723 TypeVariableTypeImplTest.dartSuite(); 2741 TypeVariableTypeImplTest.dartSuite();
2724 ClassElementImplTest.dartSuite(); 2742 ClassElementImplTest.dartSuite();
2725 ElementLocationImplTest.dartSuite(); 2743 ElementLocationImplTest.dartSuite();
2726 ElementImplTest.dartSuite(); 2744 ElementImplTest.dartSuite();
2727 LibraryElementImplTest.dartSuite(); 2745 LibraryElementImplTest.dartSuite();
2728 } 2746 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/test/generated/ast_test.dart ('k') | pkg/analyzer_experimental/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698