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

Side by Side Diff: pkg/analyzer-experimental/test/generated/element_test.dart

Issue 12671003: Push new analyzer-experimental with Resolver and ResolverTest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 3
4 library engine.element_test; 4 library engine.element_test;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:io'; 7 import 'dart:io';
8 import 'package:analyzer-experimental/src/generated/java_core.dart'; 8 import 'package:analyzer-experimental/src/generated/java_core.dart';
9 import 'package:analyzer-experimental/src/generated/java_engine.dart'; 9 import 'package:analyzer-experimental/src/generated/java_engine.dart';
10 import 'package:analyzer-experimental/src/generated/java_engine_io.dart'; 10 import 'package:analyzer-experimental/src/generated/java_engine_io.dart';
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 library18.imports = imports; 120 library18.imports = imports;
121 List<PrefixElement> prefixes2 = library18.prefixes; 121 List<PrefixElement> prefixes2 = library18.prefixes;
122 EngineTestCase.assertLength(2, prefixes2); 122 EngineTestCase.assertLength(2, prefixes2);
123 if (identical(prefixA, prefixes2[0])) { 123 if (identical(prefixA, prefixes2[0])) {
124 JUnitTestCase.assertSame(prefixB, prefixes2[1]); 124 JUnitTestCase.assertSame(prefixB, prefixes2[1]);
125 } else { 125 } else {
126 JUnitTestCase.assertSame(prefixB, prefixes2[0]); 126 JUnitTestCase.assertSame(prefixB, prefixes2[0]);
127 JUnitTestCase.assertSame(prefixA, prefixes2[1]); 127 JUnitTestCase.assertSame(prefixA, prefixes2[1]);
128 } 128 }
129 } 129 }
130 void test_isUpToDate() {
131 AnalysisContext context = new AnalysisContextImpl();
132 context.sourceFactory = new SourceFactory.con2([]);
133 LibraryElement library19 = ElementFactory.library(context, "foo");
134 context.sourceFactory.setContents(library19.definingCompilationUnit.source, "sdfsdff");
135 JUnitTestCase.assertFalse(library19.isUpToDate2(0));
136 JUnitTestCase.assertTrue(library19.isUpToDate2(JavaSystem.currentTimeMillis( ) + 1000));
137 }
130 void test_setImports() { 138 void test_setImports() {
131 AnalysisContext context = new AnalysisContextImpl(); 139 AnalysisContext context = new AnalysisContextImpl();
132 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["l1"])); 140 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["l1"]));
133 List<ImportElementImpl> expectedImports = [ElementFactory.importFor(ElementF actory.library(context, "l2"), null, []), ElementFactory.importFor(ElementFactor y.library(context, "l3"), null, [])]; 141 List<ImportElementImpl> expectedImports = [ElementFactory.importFor(ElementF actory.library(context, "l2"), null, []), ElementFactory.importFor(ElementFactor y.library(context, "l3"), null, [])];
134 library.imports = expectedImports; 142 library.imports = expectedImports;
135 List<ImportElement> actualImports = library.imports; 143 List<ImportElement> actualImports = library.imports;
136 EngineTestCase.assertLength(expectedImports.length, actualImports); 144 EngineTestCase.assertLength(expectedImports.length, actualImports);
137 for (int i = 0; i < actualImports.length; i++) { 145 for (int i = 0; i < actualImports.length; i++) {
138 JUnitTestCase.assertSame(expectedImports[i], actualImports[i]); 146 JUnitTestCase.assertSame(expectedImports[i], actualImports[i]);
139 } 147 }
140 } 148 }
141 static dartSuite() { 149 static dartSuite() {
142 _ut.group('LibraryElementImplTest', () { 150 _ut.group('LibraryElementImplTest', () {
143 _ut.test('test_creation', () { 151 _ut.test('test_creation', () {
144 final __test = new LibraryElementImplTest(); 152 final __test = new LibraryElementImplTest();
145 runJUnitTest(__test, __test.test_creation); 153 runJUnitTest(__test, __test.test_creation);
146 }); 154 });
147 _ut.test('test_getImportedLibraries', () { 155 _ut.test('test_getImportedLibraries', () {
148 final __test = new LibraryElementImplTest(); 156 final __test = new LibraryElementImplTest();
149 runJUnitTest(__test, __test.test_getImportedLibraries); 157 runJUnitTest(__test, __test.test_getImportedLibraries);
150 }); 158 });
151 _ut.test('test_getPrefixes', () { 159 _ut.test('test_getPrefixes', () {
152 final __test = new LibraryElementImplTest(); 160 final __test = new LibraryElementImplTest();
153 runJUnitTest(__test, __test.test_getPrefixes); 161 runJUnitTest(__test, __test.test_getPrefixes);
154 }); 162 });
163 _ut.test('test_isUpToDate', () {
164 final __test = new LibraryElementImplTest();
165 runJUnitTest(__test, __test.test_isUpToDate);
166 });
155 _ut.test('test_setImports', () { 167 _ut.test('test_setImports', () {
156 final __test = new LibraryElementImplTest(); 168 final __test = new LibraryElementImplTest();
157 runJUnitTest(__test, __test.test_setImports); 169 runJUnitTest(__test, __test.test_setImports);
158 }); 170 });
159 }); 171 });
160 } 172 }
161 } 173 }
162 class InterfaceTypeImplTest extends EngineTestCase { 174 class InterfaceTypeImplTest extends EngineTestCase {
163 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() { 175 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() {
164 ClassElementImpl elementA = ElementFactory.classElement2("A", []); 176 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 507 }
496 void test_isDirectSupertypeOf_with() { 508 void test_isDirectSupertypeOf_with() {
497 ClassElementImpl elementA = ElementFactory.classElement2("A", []); 509 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
498 ClassElementImpl elementB = ElementFactory.classElement2("B", []); 510 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
499 elementB.mixins = <InterfaceType> [elementA.type]; 511 elementB.mixins = <InterfaceType> [elementA.type];
500 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA); 512 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
501 InterfaceTypeImpl typeB = new InterfaceTypeImpl.con1(elementB); 513 InterfaceTypeImpl typeB = new InterfaceTypeImpl.con1(elementB);
502 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB)); 514 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
503 } 515 }
504 void test_isMoreSpecificThan_bottom() { 516 void test_isMoreSpecificThan_bottom() {
505 Type2 type24 = ElementFactory.classElement2("A", []).type; 517 Type2 type25 = ElementFactory.classElement2("A", []).type;
506 JUnitTestCase.assertTrue(BottomTypeImpl.instance.isMoreSpecificThan(type24)) ; 518 JUnitTestCase.assertTrue(BottomTypeImpl.instance.isMoreSpecificThan(type25)) ;
507 } 519 }
508 void test_isMoreSpecificThan_covariance() { 520 void test_isMoreSpecificThan_covariance() {
509 ClassElement elementA = ElementFactory.classElement2("A", ["E"]); 521 ClassElement elementA = ElementFactory.classElement2("A", ["E"]);
510 ClassElement elementI = ElementFactory.classElement2("I", []); 522 ClassElement elementI = ElementFactory.classElement2("I", []);
511 ClassElement elementJ = ElementFactory.classElement("J", elementI.type, []); 523 ClassElement elementJ = ElementFactory.classElement("J", elementI.type, []);
512 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(elementA); 524 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(elementA);
513 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(elementA); 525 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(elementA);
514 typeAI.typeArguments = <Type2> [elementI.type]; 526 typeAI.typeArguments = <Type2> [elementI.type];
515 typeAJ.typeArguments = <Type2> [elementJ.type]; 527 typeAJ.typeArguments = <Type2> [elementJ.type];
516 JUnitTestCase.assertTrue(typeAJ.isMoreSpecificThan(typeAI)); 528 JUnitTestCase.assertTrue(typeAJ.isMoreSpecificThan(typeAI));
517 JUnitTestCase.assertFalse(typeAI.isMoreSpecificThan(typeAJ)); 529 JUnitTestCase.assertFalse(typeAI.isMoreSpecificThan(typeAJ));
518 } 530 }
519 void test_isMoreSpecificThan_directSupertype() { 531 void test_isMoreSpecificThan_directSupertype() {
520 ClassElement elementA = ElementFactory.classElement2("A", []); 532 ClassElement elementA = ElementFactory.classElement2("A", []);
521 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []); 533 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
522 InterfaceType typeA = elementA.type; 534 InterfaceType typeA = elementA.type;
523 InterfaceType typeB = elementB.type; 535 InterfaceType typeB = elementB.type;
524 JUnitTestCase.assertTrue(typeB.isMoreSpecificThan(typeA)); 536 JUnitTestCase.assertTrue(typeB.isMoreSpecificThan(typeA));
525 JUnitTestCase.assertFalse(typeA.isMoreSpecificThan(typeB)); 537 JUnitTestCase.assertFalse(typeA.isMoreSpecificThan(typeB));
526 } 538 }
527 void test_isMoreSpecificThan_dynamic() { 539 void test_isMoreSpecificThan_dynamic() {
528 InterfaceType type25 = ElementFactory.classElement2("A", []).type; 540 InterfaceType type26 = ElementFactory.classElement2("A", []).type;
529 JUnitTestCase.assertTrue(type25.isMoreSpecificThan(DynamicTypeImpl.instance) ); 541 JUnitTestCase.assertTrue(type26.isMoreSpecificThan(DynamicTypeImpl.instance) );
530 } 542 }
531 void test_isMoreSpecificThan_indirectSupertype() { 543 void test_isMoreSpecificThan_indirectSupertype() {
532 ClassElement elementA = ElementFactory.classElement2("A", []); 544 ClassElement elementA = ElementFactory.classElement2("A", []);
533 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []); 545 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
534 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []); 546 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
535 InterfaceType typeA = elementA.type; 547 InterfaceType typeA = elementA.type;
536 InterfaceType typeC = elementC.type; 548 InterfaceType typeC = elementC.type;
537 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA)); 549 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA));
538 } 550 }
539 void test_isMoreSpecificThan_self() { 551 void test_isMoreSpecificThan_self() {
540 InterfaceType type26 = ElementFactory.classElement2("A", []).type; 552 InterfaceType type27 = ElementFactory.classElement2("A", []).type;
541 JUnitTestCase.assertTrue(type26.isMoreSpecificThan(type26)); 553 JUnitTestCase.assertTrue(type27.isMoreSpecificThan(type27));
542 } 554 }
543 void test_isSubtypeOf_directSubtype() { 555 void test_isSubtypeOf_directSubtype() {
544 ClassElement elementA = ElementFactory.classElement2("A", []); 556 ClassElement elementA = ElementFactory.classElement2("A", []);
545 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []); 557 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
546 InterfaceType typeA = elementA.type; 558 InterfaceType typeA = elementA.type;
547 InterfaceType typeB = elementB.type; 559 InterfaceType typeB = elementB.type;
548 JUnitTestCase.assertTrue(typeB.isSubtypeOf(typeA)); 560 JUnitTestCase.assertTrue(typeB.isSubtypeOf(typeA));
549 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeB)); 561 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeB));
550 } 562 }
551 void test_isSubtypeOf_dynamic() { 563 void test_isSubtypeOf_dynamic() {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 InterfaceType typeObject = elementA.supertype; 696 InterfaceType typeObject = elementA.supertype;
685 JUnitTestCase.assertFalse(typeA.isSupertypeOf(typeObject)); 697 JUnitTestCase.assertFalse(typeA.isSupertypeOf(typeObject));
686 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeA)); 698 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeA));
687 } 699 }
688 void test_isSupertypeOf_self() { 700 void test_isSupertypeOf_self() {
689 ClassElement elementA = ElementFactory.classElement2("A", []); 701 ClassElement elementA = ElementFactory.classElement2("A", []);
690 InterfaceType typeA = elementA.type; 702 InterfaceType typeA = elementA.type;
691 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeA)); 703 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeA));
692 } 704 }
693 void test_setTypeArguments() { 705 void test_setTypeArguments() {
694 InterfaceTypeImpl type27 = ElementFactory.classElement2("A", []).type as Int erfaceTypeImpl; 706 InterfaceTypeImpl type28 = ElementFactory.classElement2("A", []).type as Int erfaceTypeImpl;
695 List<Type2> typeArguments = <Type2> [new InterfaceTypeImpl.con1(ElementFacto ry.classElement2("B", [])), new InterfaceTypeImpl.con1(ElementFactory.classEleme nt2("C", []))]; 707 List<Type2> typeArguments = <Type2> [new InterfaceTypeImpl.con1(ElementFacto ry.classElement2("B", [])), new InterfaceTypeImpl.con1(ElementFactory.classEleme nt2("C", []))];
696 type27.typeArguments = typeArguments; 708 type28.typeArguments = typeArguments;
697 JUnitTestCase.assertEquals(typeArguments, type27.typeArguments); 709 JUnitTestCase.assertEquals(typeArguments, type28.typeArguments);
698 } 710 }
699 void test_substitute_equal() { 711 void test_substitute_equal() {
700 ClassElementImpl classElement = new ClassElementImpl(ASTFactory.identifier2( "A")); 712 ClassElementImpl classElement = new ClassElementImpl(ASTFactory.identifier2( "A"));
701 TypeVariableElementImpl parameterElement = new TypeVariableElementImpl(ASTFa ctory.identifier2("E")); 713 TypeVariableElementImpl parameterElement = new TypeVariableElementImpl(ASTFa ctory.identifier2("E"));
702 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classElement); 714 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classElement);
703 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(parameterElement); 715 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(parameterElement);
704 type.typeArguments = <Type2> [parameter]; 716 type.typeArguments = <Type2> [parameter];
705 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("B"))); 717 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("B")));
706 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par ameter]); 718 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par ameter]);
707 JUnitTestCase.assertEquals(classElement, result.element); 719 JUnitTestCase.assertEquals(classElement, result.element);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 return element; 1034 return element;
1023 } 1035 }
1024 static ClassElementImpl classElement2(String typeName, List<String> parameterN ames) => classElement(typeName, object.type, parameterNames); 1036 static ClassElementImpl classElement2(String typeName, List<String> parameterN ames) => classElement(typeName, object.type, parameterNames);
1025 static ConstructorElementImpl constructorElement(String name) => new Construct orElementImpl(name == null ? null : ASTFactory.identifier2(name)); 1037 static ConstructorElementImpl constructorElement(String name) => new Construct orElementImpl(name == null ? null : ASTFactory.identifier2(name));
1026 static ExportElementImpl exportFor(LibraryElement exportedLibrary4, List<Names paceCombinator> combinators4) { 1038 static ExportElementImpl exportFor(LibraryElement exportedLibrary4, List<Names paceCombinator> combinators4) {
1027 ExportElementImpl spec = new ExportElementImpl(); 1039 ExportElementImpl spec = new ExportElementImpl();
1028 spec.exportedLibrary = exportedLibrary4; 1040 spec.exportedLibrary = exportedLibrary4;
1029 spec.combinators = combinators4; 1041 spec.combinators = combinators4;
1030 return spec; 1042 return spec;
1031 } 1043 }
1032 static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, Type2 type32) { 1044 static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, Type2 type33) {
1033 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me)); 1045 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me));
1034 field.const2 = isConst; 1046 field.const2 = isConst;
1035 field.final2 = isFinal; 1047 field.final2 = isFinal;
1036 field.static = isStatic; 1048 field.static = isStatic;
1037 field.type = type32; 1049 field.type = type33;
1038 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 1050 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
1039 getter.getter = true; 1051 getter.getter = true;
1040 getter.synthetic = true; 1052 getter.synthetic = true;
1041 field.getter = getter; 1053 field.getter = getter;
1042 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1054 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1043 getterType.returnType = type32; 1055 getterType.returnType = type33;
1044 getter.type = getterType; 1056 getter.type = getterType;
1045 if (!isConst && !isFinal) { 1057 if (!isConst && !isFinal) {
1046 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( field); 1058 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( field);
1047 setter.setter = true; 1059 setter.setter = true;
1048 setter.synthetic = true; 1060 setter.synthetic = true;
1049 field.setter = setter; 1061 field.setter = setter;
1050 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter); 1062 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter);
1051 setterType.normalParameterTypes = <Type2> [type32]; 1063 setterType.normalParameterTypes = <Type2> [type33];
1052 setterType.returnType = VoidTypeImpl.instance; 1064 setterType.returnType = VoidTypeImpl.instance;
1053 setter.type = setterType; 1065 setter.type = setterType;
1054 } 1066 }
1055 return field; 1067 return field;
1056 } 1068 }
1057 static FunctionElementImpl functionElement(String functionName) => functionEle ment4(functionName, null, null, null, null); 1069 static FunctionElementImpl functionElement(String functionName) => functionEle ment4(functionName, null, null, null, null);
1058 static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null); 1070 static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null);
1059 static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalP arameters) { 1071 static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalP arameters) {
1060 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier2(functionName)); 1072 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier2(functionName));
1061 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 1073 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 } 1121 }
1110 static FunctionElementImpl functionElement5(String functionName, List<ClassEle ment> normalParameters) => functionElement3(functionName, null, normalParameters , null); 1122 static FunctionElementImpl functionElement5(String functionName, List<ClassEle ment> normalParameters) => functionElement3(functionName, null, normalParameters , null);
1111 static FunctionElementImpl functionElement6(String functionName, List<ClassEle ment> normalParameters, List<ClassElement> optionalParameters) => functionElemen t3(functionName, null, normalParameters, optionalParameters); 1123 static FunctionElementImpl functionElement6(String functionName, List<ClassEle ment> normalParameters, List<ClassElement> optionalParameters) => functionElemen t3(functionName, null, normalParameters, optionalParameters);
1112 static FunctionElementImpl functionElement7(String functionName, List<ClassEle ment> normalParameters, List<String> names, List<ClassElement> namedParameters) => functionElement4(functionName, null, normalParameters, names, namedParameters ); 1124 static FunctionElementImpl functionElement7(String functionName, List<ClassEle ment> normalParameters, List<String> names, List<ClassElement> namedParameters) => functionElement4(functionName, null, normalParameters, names, namedParameters );
1113 static ClassElementImpl get object { 1125 static ClassElementImpl get object {
1114 if (_objectElement == null) { 1126 if (_objectElement == null) {
1115 _objectElement = classElement("Object", (null as InterfaceType), []); 1127 _objectElement = classElement("Object", (null as InterfaceType), []);
1116 } 1128 }
1117 return _objectElement; 1129 return _objectElement;
1118 } 1130 }
1119 static PropertyAccessorElementImpl getterElement(String name, bool isStatic, T ype2 type33) { 1131 static PropertyAccessorElementImpl getterElement(String name, bool isStatic, T ype2 type34) {
1120 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me)); 1132 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me));
1121 field.static = isStatic; 1133 field.static = isStatic;
1122 field.synthetic = true; 1134 field.synthetic = true;
1123 field.type = type33; 1135 field.type = type34;
1124 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 1136 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
1125 getter.getter = true; 1137 getter.getter = true;
1126 field.getter = getter; 1138 field.getter = getter;
1127 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1139 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1128 getterType.returnType = type33; 1140 getterType.returnType = type34;
1129 getter.type = getterType; 1141 getter.type = getterType;
1130 return getter; 1142 return getter;
1131 } 1143 }
1132 static ImportElementImpl importFor(LibraryElement importedLibrary5, PrefixElem ent prefix13, List<NamespaceCombinator> combinators5) { 1144 static ImportElementImpl importFor(LibraryElement importedLibrary5, PrefixElem ent prefix13, List<NamespaceCombinator> combinators5) {
1133 ImportElementImpl spec = new ImportElementImpl(); 1145 ImportElementImpl spec = new ImportElementImpl();
1134 spec.importedLibrary = importedLibrary5; 1146 spec.importedLibrary = importedLibrary5;
1135 spec.prefix = prefix13; 1147 spec.prefix = prefix13;
1136 spec.combinators = combinators5; 1148 spec.combinators = combinators5;
1137 return spec; 1149 return spec;
1138 } 1150 }
1139 static LibraryElementImpl library(AnalysisContext context, String libraryName) { 1151 static LibraryElementImpl library(AnalysisContext context, String libraryName) {
1140 String fileName = "${libraryName}.dart"; 1152 String fileName = "${libraryName}.dart";
1141 FileBasedSource source = new FileBasedSource.con1(null, FileUtilities2.creat eFile(fileName)); 1153 FileBasedSource source = new FileBasedSource.con1(context.sourceFactory, Fil eUtilities2.createFile(fileName));
1142 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName); 1154 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName);
1143 unit.source = source; 1155 unit.source = source;
1144 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName])); 1156 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName]));
1145 library.definingCompilationUnit = unit; 1157 library.definingCompilationUnit = unit;
1146 return library; 1158 return library;
1147 } 1159 }
1148 static LocalVariableElementImpl localVariableElement(Identifier name) => new L ocalVariableElementImpl(name); 1160 static LocalVariableElementImpl localVariableElement(Identifier name) => new L ocalVariableElementImpl(name);
1149 static LocalVariableElementImpl localVariableElement2(String name) => new Loca lVariableElementImpl(ASTFactory.identifier2(name)); 1161 static LocalVariableElementImpl localVariableElement2(String name) => new Loca lVariableElementImpl(ASTFactory.identifier2(name));
1150 static MethodElementImpl methodElement(String methodName, Type2 returnType13, List<Type2> argumentTypes) { 1162 static MethodElementImpl methodElement(String methodName, Type2 returnType13, List<Type2> argumentTypes) {
1151 MethodElementImpl method = new MethodElementImpl.con1(ASTFactory.identifier2 (methodName)); 1163 MethodElementImpl method = new MethodElementImpl.con1(ASTFactory.identifier2 (methodName));
(...skipping 21 matching lines...) Expand all
1173 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier2(name)); 1185 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier2(name));
1174 parameter.parameterKind = ParameterKind.POSITIONAL; 1186 parameter.parameterKind = ParameterKind.POSITIONAL;
1175 return parameter; 1187 return parameter;
1176 } 1188 }
1177 static PrefixElementImpl prefix(String name) => new PrefixElementImpl(ASTFacto ry.identifier2(name)); 1189 static PrefixElementImpl prefix(String name) => new PrefixElementImpl(ASTFacto ry.identifier2(name));
1178 static ParameterElementImpl requiredParameter(String name) { 1190 static ParameterElementImpl requiredParameter(String name) {
1179 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier2(name)); 1191 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier2(name));
1180 parameter.parameterKind = ParameterKind.REQUIRED; 1192 parameter.parameterKind = ParameterKind.REQUIRED;
1181 return parameter; 1193 return parameter;
1182 } 1194 }
1183 static PropertyAccessorElementImpl setterElement(String name, bool isStatic, T ype2 type34) { 1195 static PropertyAccessorElementImpl setterElement(String name, bool isStatic, T ype2 type35) {
1184 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me)); 1196 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me));
1185 field.static = isStatic; 1197 field.static = isStatic;
1186 field.synthetic = true; 1198 field.synthetic = true;
1187 field.type = type34; 1199 field.type = type35;
1188 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld); 1200 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
1189 getter.getter = true; 1201 getter.getter = true;
1190 field.getter = getter; 1202 field.getter = getter;
1191 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1203 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1192 getterType.returnType = type34; 1204 getterType.returnType = type35;
1193 getter.type = getterType; 1205 getter.type = getterType;
1194 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2(fi eld); 1206 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2(fi eld);
1195 setter.setter = true; 1207 setter.setter = true;
1196 setter.synthetic = true; 1208 setter.synthetic = true;
1197 field.setter = setter; 1209 field.setter = setter;
1198 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter); 1210 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter);
1199 setterType.normalParameterTypes = <Type2> [type34]; 1211 setterType.normalParameterTypes = <Type2> [type35];
1200 setterType.returnType = VoidTypeImpl.instance; 1212 setterType.returnType = VoidTypeImpl.instance;
1201 setter.type = setterType; 1213 setter.type = setterType;
1202 return setter; 1214 return setter;
1203 } 1215 }
1204 static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.con1(name); 1216 static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.con1(name);
1205 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => ne w TopLevelVariableElementImpl.con2(name); 1217 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => ne w TopLevelVariableElementImpl.con2(name);
1206 /** 1218 /**
1207 * Prevent the creation of instances of this class. 1219 * Prevent the creation of instances of this class.
1208 */ 1220 */
1209 ElementFactory() { 1221 ElementFactory() {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 void test_hashCode_element() { 1477 void test_hashCode_element() {
1466 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f"))); 1478 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
1467 type.hashCode; 1479 type.hashCode;
1468 } 1480 }
1469 void test_hashCode_noElement() { 1481 void test_hashCode_noElement() {
1470 FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement )); 1482 FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement ));
1471 type.hashCode; 1483 type.hashCode;
1472 } 1484 }
1473 void test_isSubtypeOf_baseCase_classFunction() { 1485 void test_isSubtypeOf_baseCase_classFunction() {
1474 ClassElementImpl functionElement = ElementFactory.classElement2("Function", []); 1486 ClassElementImpl functionElement = ElementFactory.classElement2("Function", []);
1475 InterfaceTypeImpl functionType = new InterfaceTypeImpl_11(functionElement); 1487 InterfaceTypeImpl functionType = new InterfaceTypeImpl_12(functionElement);
1476 FunctionType f = ElementFactory.functionElement("f").type; 1488 FunctionType f = ElementFactory.functionElement("f").type;
1477 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType)); 1489 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType));
1478 } 1490 }
1479 void test_isSubtypeOf_baseCase_notFunctionType() { 1491 void test_isSubtypeOf_baseCase_notFunctionType() {
1480 FunctionType f = ElementFactory.functionElement("f").type; 1492 FunctionType f = ElementFactory.functionElement("f").type;
1481 InterfaceType t = ElementFactory.classElement2("C", []).type; 1493 InterfaceType t = ElementFactory.classElement2("C", []).type;
1482 JUnitTestCase.assertFalse(f.isSubtypeOf(t)); 1494 JUnitTestCase.assertFalse(f.isSubtypeOf(t));
1483 } 1495 }
1484 void test_isSubtypeOf_baseCase_null() { 1496 void test_isSubtypeOf_baseCase_null() {
1485 FunctionType f = ElementFactory.functionElement("f").type; 1497 FunctionType f = ElementFactory.functionElement("f").type;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 final __test = new FunctionTypeImplTest(); 1889 final __test = new FunctionTypeImplTest();
1878 runJUnitTest(__test, __test.test_substitute2_equal); 1890 runJUnitTest(__test, __test.test_substitute2_equal);
1879 }); 1891 });
1880 _ut.test('test_substitute2_notEqual', () { 1892 _ut.test('test_substitute2_notEqual', () {
1881 final __test = new FunctionTypeImplTest(); 1893 final __test = new FunctionTypeImplTest();
1882 runJUnitTest(__test, __test.test_substitute2_notEqual); 1894 runJUnitTest(__test, __test.test_substitute2_notEqual);
1883 }); 1895 });
1884 }); 1896 });
1885 } 1897 }
1886 } 1898 }
1887 class InterfaceTypeImpl_11 extends InterfaceTypeImpl { 1899 class InterfaceTypeImpl_12 extends InterfaceTypeImpl {
1888 InterfaceTypeImpl_11(ClassElement arg0) : super.con1(arg0); 1900 InterfaceTypeImpl_12(ClassElement arg0) : super.con1(arg0);
1889 bool isDartCoreFunction() => true; 1901 bool isDartCoreFunction() => true;
1890 } 1902 }
1891 main() { 1903 main() {
1892 FunctionTypeImplTest.dartSuite(); 1904 FunctionTypeImplTest.dartSuite();
1893 InterfaceTypeImplTest.dartSuite(); 1905 InterfaceTypeImplTest.dartSuite();
1894 TypeVariableTypeImplTest.dartSuite(); 1906 TypeVariableTypeImplTest.dartSuite();
1895 ClassElementImplTest.dartSuite(); 1907 ClassElementImplTest.dartSuite();
1896 ElementLocationImplTest.dartSuite(); 1908 ElementLocationImplTest.dartSuite();
1897 ElementImplTest.dartSuite(); 1909 ElementImplTest.dartSuite();
1898 LibraryElementImplTest.dartSuite(); 1910 LibraryElementImplTest.dartSuite();
1899 } 1911 }
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