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

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

Issue 45573002: Rename analyzer_experimental to analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks before publishing. Created 7 years, 1 month 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
(Empty)
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.
3 library engine.element_test;
4 import 'package:analyzer_experimental/src/generated/java_core.dart';
5 import 'package:analyzer_experimental/src/generated/java_engine_io.dart';
6 import 'package:analyzer_experimental/src/generated/java_junit.dart';
7 import 'package:analyzer_experimental/src/generated/source_io.dart';
8 import 'package:analyzer_experimental/src/generated/utilities_dart.dart';
9 import 'package:analyzer_experimental/src/generated/ast.dart';
10 import 'package:analyzer_experimental/src/generated/element.dart';
11 import 'package:analyzer_experimental/src/generated/engine.dart' show AnalysisCo ntext, AnalysisContextImpl;
12 import 'package:unittest/unittest.dart' as _ut;
13 import 'test_support.dart';
14 import 'ast_test.dart' show ASTFactory;
15 import 'resolver_test.dart' show TestTypeProvider;
16 class ElementLocationImplTest extends EngineTestCase {
17 void test_create_encoding() {
18 String encoding = "a;b;c";
19 ElementLocationImpl location = new ElementLocationImpl.con2(encoding);
20 JUnitTestCase.assertEquals(encoding, location.encoding);
21 }
22 void test_equals_equal() {
23 String encoding = "a;b;c";
24 ElementLocationImpl first = new ElementLocationImpl.con2(encoding);
25 ElementLocationImpl second = new ElementLocationImpl.con2(encoding);
26 JUnitTestCase.assertTrue(first == second);
27 }
28 void test_equals_equalWithDifferentUriKind() {
29 ElementLocationImpl first = new ElementLocationImpl.con2("fa;fb;c");
30 ElementLocationImpl second = new ElementLocationImpl.con2("pa;pb;c");
31 JUnitTestCase.assertTrue(first == second);
32 }
33 void test_equals_notEqual_differentLengths() {
34 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c");
35 ElementLocationImpl second = new ElementLocationImpl.con2("a;b;c;d");
36 JUnitTestCase.assertFalse(first == second);
37 }
38 void test_equals_notEqual_notLocation() {
39 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c");
40 JUnitTestCase.assertFalse(first == "a;b;d");
41 }
42 void test_equals_notEqual_sameLengths() {
43 ElementLocationImpl first = new ElementLocationImpl.con2("a;b;c");
44 ElementLocationImpl second = new ElementLocationImpl.con2("a;b;d");
45 JUnitTestCase.assertFalse(first == second);
46 }
47 void test_getComponents() {
48 String encoding = "a;b;c";
49 ElementLocationImpl location = new ElementLocationImpl.con2(encoding);
50 List<String> components = location.components;
51 EngineTestCase.assertLength(3, components);
52 JUnitTestCase.assertEquals("a", components[0]);
53 JUnitTestCase.assertEquals("b", components[1]);
54 JUnitTestCase.assertEquals("c", components[2]);
55 }
56 void test_getEncoding() {
57 String encoding = "a;b;c;;d";
58 ElementLocationImpl location = new ElementLocationImpl.con2(encoding);
59 JUnitTestCase.assertEquals(encoding, location.encoding);
60 }
61 void test_hashCode_equal() {
62 String encoding = "a;b;c";
63 ElementLocationImpl first = new ElementLocationImpl.con2(encoding);
64 ElementLocationImpl second = new ElementLocationImpl.con2(encoding);
65 JUnitTestCase.assertTrue(first.hashCode == second.hashCode);
66 }
67 void test_hashCode_equalWithDifferentUriKind() {
68 ElementLocationImpl first = new ElementLocationImpl.con2("fa;fb;c");
69 ElementLocationImpl second = new ElementLocationImpl.con2("pa;pb;c");
70 JUnitTestCase.assertTrue(first.hashCode == second.hashCode);
71 }
72 static dartSuite() {
73 _ut.group('ElementLocationImplTest', () {
74 _ut.test('test_create_encoding', () {
75 final __test = new ElementLocationImplTest();
76 runJUnitTest(__test, __test.test_create_encoding);
77 });
78 _ut.test('test_equals_equal', () {
79 final __test = new ElementLocationImplTest();
80 runJUnitTest(__test, __test.test_equals_equal);
81 });
82 _ut.test('test_equals_equalWithDifferentUriKind', () {
83 final __test = new ElementLocationImplTest();
84 runJUnitTest(__test, __test.test_equals_equalWithDifferentUriKind);
85 });
86 _ut.test('test_equals_notEqual_differentLengths', () {
87 final __test = new ElementLocationImplTest();
88 runJUnitTest(__test, __test.test_equals_notEqual_differentLengths);
89 });
90 _ut.test('test_equals_notEqual_notLocation', () {
91 final __test = new ElementLocationImplTest();
92 runJUnitTest(__test, __test.test_equals_notEqual_notLocation);
93 });
94 _ut.test('test_equals_notEqual_sameLengths', () {
95 final __test = new ElementLocationImplTest();
96 runJUnitTest(__test, __test.test_equals_notEqual_sameLengths);
97 });
98 _ut.test('test_getComponents', () {
99 final __test = new ElementLocationImplTest();
100 runJUnitTest(__test, __test.test_getComponents);
101 });
102 _ut.test('test_getEncoding', () {
103 final __test = new ElementLocationImplTest();
104 runJUnitTest(__test, __test.test_getEncoding);
105 });
106 _ut.test('test_hashCode_equal', () {
107 final __test = new ElementLocationImplTest();
108 runJUnitTest(__test, __test.test_hashCode_equal);
109 });
110 _ut.test('test_hashCode_equalWithDifferentUriKind', () {
111 final __test = new ElementLocationImplTest();
112 runJUnitTest(__test, __test.test_hashCode_equalWithDifferentUriKind);
113 });
114 });
115 }
116 }
117 class MultiplyDefinedElementImplTest extends EngineTestCase {
118 void test_fromElements_conflicting() {
119 Element firstElement = ElementFactory.localVariableElement2("xx");
120 Element secondElement = ElementFactory.localVariableElement2("yy");
121 Element result = MultiplyDefinedElementImpl.fromElements(null, firstElement, secondElement);
122 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, result);
123 List<Element> elements = ((result as MultiplyDefinedElement)).conflictingEle ments;
124 EngineTestCase.assertLength(2, elements);
125 for (int i = 0; i < elements.length; i++) {
126 EngineTestCase.assertInstanceOf(LocalVariableElement, elements[i]);
127 }
128 }
129 void test_fromElements_multiple() {
130 Element firstElement = ElementFactory.localVariableElement2("xx");
131 Element secondElement = ElementFactory.localVariableElement2("yy");
132 Element thirdElement = ElementFactory.localVariableElement2("zz");
133 Element result = MultiplyDefinedElementImpl.fromElements(null, MultiplyDefin edElementImpl.fromElements(null, firstElement, secondElement), thirdElement);
134 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, result);
135 List<Element> elements = ((result as MultiplyDefinedElement)).conflictingEle ments;
136 EngineTestCase.assertLength(3, elements);
137 for (int i = 0; i < elements.length; i++) {
138 EngineTestCase.assertInstanceOf(LocalVariableElement, elements[i]);
139 }
140 }
141 void test_fromElements_nonConflicting() {
142 Element element = ElementFactory.localVariableElement2("xx");
143 JUnitTestCase.assertSame(element, MultiplyDefinedElementImpl.fromElements(nu ll, element, element));
144 }
145 static dartSuite() {
146 _ut.group('MultiplyDefinedElementImplTest', () {
147 _ut.test('test_fromElements_conflicting', () {
148 final __test = new MultiplyDefinedElementImplTest();
149 runJUnitTest(__test, __test.test_fromElements_conflicting);
150 });
151 _ut.test('test_fromElements_multiple', () {
152 final __test = new MultiplyDefinedElementImplTest();
153 runJUnitTest(__test, __test.test_fromElements_multiple);
154 });
155 _ut.test('test_fromElements_nonConflicting', () {
156 final __test = new MultiplyDefinedElementImplTest();
157 runJUnitTest(__test, __test.test_fromElements_nonConflicting);
158 });
159 });
160 }
161 }
162 class LibraryElementImplTest extends EngineTestCase {
163 void test_creation() {
164 JUnitTestCase.assertNotNull(new LibraryElementImpl(createAnalysisContext(), ASTFactory.libraryIdentifier2(["l"])));
165 }
166 void test_getImportedLibraries() {
167 AnalysisContext context = createAnalysisContext();
168 LibraryElementImpl library1 = ElementFactory.library(context, "l1");
169 LibraryElementImpl library2 = ElementFactory.library(context, "l2");
170 LibraryElementImpl library3 = ElementFactory.library(context, "l3");
171 LibraryElementImpl library4 = ElementFactory.library(context, "l4");
172 PrefixElement prefixA = new PrefixElementImpl(ASTFactory.identifier3("a"));
173 PrefixElement prefixB = new PrefixElementImpl(ASTFactory.identifier3("b"));
174 List<ImportElementImpl> imports = [
175 ElementFactory.importFor(library2, null, []),
176 ElementFactory.importFor(library2, prefixB, []),
177 ElementFactory.importFor(library3, null, []),
178 ElementFactory.importFor(library3, prefixA, []),
179 ElementFactory.importFor(library3, prefixB, []),
180 ElementFactory.importFor(library4, prefixA, [])];
181 library1.imports = imports;
182 List<LibraryElement> libraries = library1.importedLibraries;
183 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library2, library3, library4], libraries);
184 }
185 void test_getPrefixes() {
186 AnalysisContext context = createAnalysisContext();
187 LibraryElementImpl library = ElementFactory.library(context, "l1");
188 PrefixElement prefixA = new PrefixElementImpl(ASTFactory.identifier3("a"));
189 PrefixElement prefixB = new PrefixElementImpl(ASTFactory.identifier3("b"));
190 List<ImportElementImpl> imports = [
191 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, [] ),
192 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, [] ),
193 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA, []),
194 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA, []),
195 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB, [])];
196 library.imports = imports;
197 List<PrefixElement> prefixes = library.prefixes;
198 EngineTestCase.assertLength(2, prefixes);
199 if (identical(prefixA, prefixes[0])) {
200 JUnitTestCase.assertSame(prefixB, prefixes[1]);
201 } else {
202 JUnitTestCase.assertSame(prefixB, prefixes[0]);
203 JUnitTestCase.assertSame(prefixA, prefixes[1]);
204 }
205 }
206 void test_isUpToDate() {
207 AnalysisContext context = createAnalysisContext();
208 context.sourceFactory = new SourceFactory.con2([]);
209 LibraryElement library = ElementFactory.library(context, "foo");
210 context.sourceFactory.setContents(library.definingCompilationUnit.source, "s dfsdff");
211 JUnitTestCase.assertFalse(library.isUpToDate2(0));
212 JUnitTestCase.assertTrue(library.isUpToDate2(JavaSystem.currentTimeMillis() + 1000));
213 }
214 void test_setImports() {
215 AnalysisContext context = createAnalysisContext();
216 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["l1"]));
217 List<ImportElementImpl> expectedImports = [
218 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, [] ),
219 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, [] )];
220 library.imports = expectedImports;
221 List<ImportElement> actualImports = library.imports;
222 EngineTestCase.assertLength(expectedImports.length, actualImports);
223 for (int i = 0; i < actualImports.length; i++) {
224 JUnitTestCase.assertSame(expectedImports[i], actualImports[i]);
225 }
226 }
227 static dartSuite() {
228 _ut.group('LibraryElementImplTest', () {
229 _ut.test('test_creation', () {
230 final __test = new LibraryElementImplTest();
231 runJUnitTest(__test, __test.test_creation);
232 });
233 _ut.test('test_getImportedLibraries', () {
234 final __test = new LibraryElementImplTest();
235 runJUnitTest(__test, __test.test_getImportedLibraries);
236 });
237 _ut.test('test_getPrefixes', () {
238 final __test = new LibraryElementImplTest();
239 runJUnitTest(__test, __test.test_getPrefixes);
240 });
241 _ut.test('test_isUpToDate', () {
242 final __test = new LibraryElementImplTest();
243 runJUnitTest(__test, __test.test_isUpToDate);
244 });
245 _ut.test('test_setImports', () {
246 final __test = new LibraryElementImplTest();
247 runJUnitTest(__test, __test.test_setImports);
248 });
249 });
250 }
251 }
252 class TypeParameterTypeImplTest extends EngineTestCase {
253 void test_creation() {
254 JUnitTestCase.assertNotNull(new TypeParameterTypeImpl(new TypeParameterEleme ntImpl(ASTFactory.identifier3("E"))));
255 }
256 void test_getElement() {
257 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i dentifier3("E"));
258 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
259 JUnitTestCase.assertEquals(element, type.element);
260 }
261 void test_isMoreSpecificThan_typeArguments_bottom() {
262 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i dentifier3("E"));
263 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
264 JUnitTestCase.assertTrue(type.isMoreSpecificThan(BottomTypeImpl.instance));
265 }
266 void test_isMoreSpecificThan_typeArguments_dynamic() {
267 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i dentifier3("E"));
268 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
269 JUnitTestCase.assertTrue(type.isMoreSpecificThan(DynamicTypeImpl.instance));
270 }
271 void test_isMoreSpecificThan_typeArguments_object() {
272 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i dentifier3("E"));
273 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
274 JUnitTestCase.assertTrue(type.isMoreSpecificThan(ElementFactory.object.type) );
275 }
276 void test_isMoreSpecificThan_typeArguments_resursive() {
277 ClassElementImpl classS = ElementFactory.classElement2("A", []);
278 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl(ASTFa ctory.identifier3("U"));
279 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU);
280 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(ASTFa ctory.identifier3("T"));
281 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
282 typeParameterT.bound = typeParameterTypeU;
283 typeParameterU.bound = typeParameterTypeU;
284 JUnitTestCase.assertFalse(typeParameterTypeT.isMoreSpecificThan(classS.type) );
285 }
286 void test_isMoreSpecificThan_typeArguments_self() {
287 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i dentifier3("E"));
288 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
289 JUnitTestCase.assertTrue(type.isMoreSpecificThan(type));
290 }
291 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() {
292 ClassElement classA = ElementFactory.classElement2("A", []);
293 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
294 InterfaceType typeA = classA.type;
295 InterfaceType typeB = classB.type;
296 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(ASTFa ctory.identifier3("T"));
297 typeParameterT.bound = typeB;
298 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
299 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(typeA));
300 }
301 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() {
302 ClassElementImpl classS = ElementFactory.classElement2("A", []);
303 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl(ASTFa ctory.identifier3("U"));
304 typeParameterU.bound = classS.type;
305 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU);
306 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(ASTFa ctory.identifier3("T"));
307 typeParameterT.bound = typeParameterTypeU;
308 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
309 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type)) ;
310 }
311 void test_isMoreSpecificThan_typeArguments_upperBound() {
312 ClassElementImpl classS = ElementFactory.classElement2("A", []);
313 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(ASTFa ctory.identifier3("T"));
314 typeParameterT.bound = classS.type;
315 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
316 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type)) ;
317 }
318 void test_substitute_equal() {
319 TypeParameterElementImpl element = new TypeParameterElementImpl(ASTFactory.i dentifier3("E"));
320 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
321 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (ASTFactory.identifier3("A")));
322 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element);
323 JUnitTestCase.assertSame(argument, type.substitute2(<Type2> [argument], <Typ e2> [parameter]));
324 }
325 void test_substitute_notEqual() {
326 TypeParameterTypeImpl type = new TypeParameterTypeImpl(new TypeParameterElem entImpl(ASTFactory.identifier3("E")));
327 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (ASTFactory.identifier3("A")));
328 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(new TypeParamete rElementImpl(ASTFactory.identifier3("F")));
329 JUnitTestCase.assertSame(type, type.substitute2(<Type2> [argument], <Type2> [parameter]));
330 }
331 static dartSuite() {
332 _ut.group('TypeParameterTypeImplTest', () {
333 _ut.test('test_creation', () {
334 final __test = new TypeParameterTypeImplTest();
335 runJUnitTest(__test, __test.test_creation);
336 });
337 _ut.test('test_getElement', () {
338 final __test = new TypeParameterTypeImplTest();
339 runJUnitTest(__test, __test.test_getElement);
340 });
341 _ut.test('test_isMoreSpecificThan_typeArguments_bottom', () {
342 final __test = new TypeParameterTypeImplTest();
343 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_bottom );
344 });
345 _ut.test('test_isMoreSpecificThan_typeArguments_dynamic', () {
346 final __test = new TypeParameterTypeImplTest();
347 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_dynami c);
348 });
349 _ut.test('test_isMoreSpecificThan_typeArguments_object', () {
350 final __test = new TypeParameterTypeImplTest();
351 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_object );
352 });
353 _ut.test('test_isMoreSpecificThan_typeArguments_resursive', () {
354 final __test = new TypeParameterTypeImplTest();
355 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_resurs ive);
356 });
357 _ut.test('test_isMoreSpecificThan_typeArguments_self', () {
358 final __test = new TypeParameterTypeImplTest();
359 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_self);
360 });
361 _ut.test('test_isMoreSpecificThan_typeArguments_transitivity_interfaceType s', () {
362 final __test = new TypeParameterTypeImplTest();
363 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_transi tivity_interfaceTypes);
364 });
365 _ut.test('test_isMoreSpecificThan_typeArguments_transitivity_typeParameter s', () {
366 final __test = new TypeParameterTypeImplTest();
367 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_transi tivity_typeParameters);
368 });
369 _ut.test('test_isMoreSpecificThan_typeArguments_upperBound', () {
370 final __test = new TypeParameterTypeImplTest();
371 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_upperB ound);
372 });
373 _ut.test('test_substitute_equal', () {
374 final __test = new TypeParameterTypeImplTest();
375 runJUnitTest(__test, __test.test_substitute_equal);
376 });
377 _ut.test('test_substitute_notEqual', () {
378 final __test = new TypeParameterTypeImplTest();
379 runJUnitTest(__test, __test.test_substitute_notEqual);
380 });
381 });
382 }
383 }
384 class InterfaceTypeImplTest extends EngineTestCase {
385
386 /**
387 * The type provider used to access the types.
388 */
389 TestTypeProvider _typeProvider;
390 void setUp() {
391 _typeProvider = new TestTypeProvider();
392 }
393 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() {
394 ClassElementImpl classA = ElementFactory.classElement2("A", []);
395 ClassElementImpl classB = ElementFactory.classElement2("B", []);
396 ClassElementImpl classC = ElementFactory.classElement2("C", []);
397 ClassElementImpl classD = ElementFactory.classElement2("D", []);
398 ClassElementImpl classE = ElementFactory.classElement2("E", []);
399 classB.interfaces = <InterfaceType> [classA.type];
400 classC.interfaces = <InterfaceType> [classA.type];
401 classD.interfaces = <InterfaceType> [classC.type];
402 classE.interfaces = <InterfaceType> [classB.type, classD.type];
403 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classB.type));
404 JUnitTestCase.assertEquals(4, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classE.type));
405 }
406 void test_computeLongestInheritancePathToObject_multipleSuperclassPaths() {
407 ClassElement classA = ElementFactory.classElement2("A", []);
408 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
409 ClassElement classC = ElementFactory.classElement("C", classA.type, []);
410 ClassElement classD = ElementFactory.classElement("D", classC.type, []);
411 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []);
412 classE.interfaces = <InterfaceType> [classD.type];
413 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classB.type));
414 JUnitTestCase.assertEquals(4, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classE.type));
415 }
416 void test_computeLongestInheritancePathToObject_object() {
417 ClassElement classA = ElementFactory.classElement2("A", []);
418 InterfaceType object = classA.supertype;
419 JUnitTestCase.assertEquals(0, InterfaceTypeImpl.computeLongestInheritancePat hToObject(object));
420 }
421 void test_computeLongestInheritancePathToObject_recursion() {
422 ClassElementImpl classA = ElementFactory.classElement2("A", []);
423 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
424 classA.supertype = classB.type;
425 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classA.type));
426 }
427 void test_computeLongestInheritancePathToObject_singleInterfacePath() {
428 ClassElementImpl classA = ElementFactory.classElement2("A", []);
429 ClassElementImpl classB = ElementFactory.classElement2("B", []);
430 ClassElementImpl classC = ElementFactory.classElement2("C", []);
431 classB.interfaces = <InterfaceType> [classA.type];
432 classC.interfaces = <InterfaceType> [classB.type];
433 JUnitTestCase.assertEquals(1, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classA.type));
434 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classB.type));
435 JUnitTestCase.assertEquals(3, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classC.type));
436 }
437 void test_computeLongestInheritancePathToObject_singleSuperclassPath() {
438 ClassElement classA = ElementFactory.classElement2("A", []);
439 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
440 ClassElement classC = ElementFactory.classElement("C", classB.type, []);
441 JUnitTestCase.assertEquals(1, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classA.type));
442 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classB.type));
443 JUnitTestCase.assertEquals(3, InterfaceTypeImpl.computeLongestInheritancePat hToObject(classC.type));
444 }
445 void test_computeSuperinterfaceSet_multipleInterfacePaths() {
446 ClassElementImpl classA = ElementFactory.classElement2("A", []);
447 ClassElementImpl classB = ElementFactory.classElement2("B", []);
448 ClassElementImpl classC = ElementFactory.classElement2("C", []);
449 ClassElementImpl classD = ElementFactory.classElement2("D", []);
450 ClassElementImpl classE = ElementFactory.classElement2("E", []);
451 classB.interfaces = <InterfaceType> [classA.type];
452 classC.interfaces = <InterfaceType> [classA.type];
453 classD.interfaces = <InterfaceType> [classC.type];
454 classE.interfaces = <InterfaceType> [classB.type, classD.type];
455 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(classD.type);
456 EngineTestCase.assertSize3(3, superinterfacesOfD);
457 JUnitTestCase.assertTrue(superinterfacesOfD.contains(ElementFactory.object.t ype));
458 JUnitTestCase.assertTrue(superinterfacesOfD.contains(classA.type));
459 JUnitTestCase.assertTrue(superinterfacesOfD.contains(classC.type));
460 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(classE.type);
461 EngineTestCase.assertSize3(5, superinterfacesOfE);
462 JUnitTestCase.assertTrue(superinterfacesOfE.contains(ElementFactory.object.t ype));
463 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classA.type));
464 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classB.type));
465 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classC.type));
466 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classD.type));
467 }
468 void test_computeSuperinterfaceSet_multipleSuperclassPaths() {
469 ClassElement classA = ElementFactory.classElement2("A", []);
470 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
471 ClassElement classC = ElementFactory.classElement("C", classA.type, []);
472 ClassElement classD = ElementFactory.classElement("D", classC.type, []);
473 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []);
474 classE.interfaces = <InterfaceType> [classD.type];
475 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(classD.type);
476 EngineTestCase.assertSize3(3, superinterfacesOfD);
477 JUnitTestCase.assertTrue(superinterfacesOfD.contains(ElementFactory.object.t ype));
478 JUnitTestCase.assertTrue(superinterfacesOfD.contains(classA.type));
479 JUnitTestCase.assertTrue(superinterfacesOfD.contains(classC.type));
480 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(classE.type);
481 EngineTestCase.assertSize3(5, superinterfacesOfE);
482 JUnitTestCase.assertTrue(superinterfacesOfE.contains(ElementFactory.object.t ype));
483 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classA.type));
484 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classB.type));
485 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classC.type));
486 JUnitTestCase.assertTrue(superinterfacesOfE.contains(classD.type));
487 }
488 void test_computeSuperinterfaceSet_recursion() {
489 ClassElementImpl classA = ElementFactory.classElement2("A", []);
490 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
491 classA.supertype = classB.type;
492 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type);
493 EngineTestCase.assertSize3(2, superinterfacesOfB);
494 }
495 void test_computeSuperinterfaceSet_singleInterfacePath() {
496 ClassElementImpl classA = ElementFactory.classElement2("A", []);
497 ClassElementImpl classB = ElementFactory.classElement2("B", []);
498 ClassElementImpl classC = ElementFactory.classElement2("C", []);
499 classB.interfaces = <InterfaceType> [classA.type];
500 classC.interfaces = <InterfaceType> [classB.type];
501 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(classA.type);
502 EngineTestCase.assertSize3(1, superinterfacesOfA);
503 JUnitTestCase.assertTrue(superinterfacesOfA.contains(ElementFactory.object.t ype));
504 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type);
505 EngineTestCase.assertSize3(2, superinterfacesOfB);
506 JUnitTestCase.assertTrue(superinterfacesOfB.contains(ElementFactory.object.t ype));
507 JUnitTestCase.assertTrue(superinterfacesOfB.contains(classA.type));
508 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(classC.type);
509 EngineTestCase.assertSize3(3, superinterfacesOfC);
510 JUnitTestCase.assertTrue(superinterfacesOfC.contains(ElementFactory.object.t ype));
511 JUnitTestCase.assertTrue(superinterfacesOfC.contains(classA.type));
512 JUnitTestCase.assertTrue(superinterfacesOfC.contains(classB.type));
513 }
514 void test_computeSuperinterfaceSet_singleSuperclassPath() {
515 ClassElement classA = ElementFactory.classElement2("A", []);
516 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
517 ClassElement classC = ElementFactory.classElement("C", classB.type, []);
518 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(classA.type);
519 EngineTestCase.assertSize3(1, superinterfacesOfA);
520 JUnitTestCase.assertTrue(superinterfacesOfA.contains(ElementFactory.object.t ype));
521 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(classB.type);
522 EngineTestCase.assertSize3(2, superinterfacesOfB);
523 JUnitTestCase.assertTrue(superinterfacesOfB.contains(ElementFactory.object.t ype));
524 JUnitTestCase.assertTrue(superinterfacesOfB.contains(classA.type));
525 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(classC.type);
526 EngineTestCase.assertSize3(3, superinterfacesOfC);
527 JUnitTestCase.assertTrue(superinterfacesOfC.contains(ElementFactory.object.t ype));
528 JUnitTestCase.assertTrue(superinterfacesOfC.contains(classA.type));
529 JUnitTestCase.assertTrue(superinterfacesOfC.contains(classB.type));
530 }
531 void test_creation() {
532 JUnitTestCase.assertNotNull(new InterfaceTypeImpl.con1(ElementFactory.classE lement2("A", [])));
533 }
534 void test_getAccessors() {
535 ClassElementImpl typeElement = ElementFactory.classElement2("A", []);
536 PropertyAccessorElement getterG = ElementFactory.getterElement("g", false, n ull);
537 PropertyAccessorElement getterH = ElementFactory.getterElement("h", false, n ull);
538 typeElement.accessors = <PropertyAccessorElement> [getterG, getterH];
539 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
540 JUnitTestCase.assertEquals(2, type.accessors.length);
541 }
542 void test_getAccessors_empty() {
543 ClassElementImpl typeElement = ElementFactory.classElement2("A", []);
544 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
545 JUnitTestCase.assertEquals(0, type.accessors.length);
546 }
547 void test_getElement() {
548 ClassElementImpl typeElement = ElementFactory.classElement2("A", []);
549 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
550 JUnitTestCase.assertEquals(typeElement, type.element);
551 }
552 void test_getGetter_implemented() {
553 ClassElementImpl classA = ElementFactory.classElement2("A", []);
554 String getterName = "g";
555 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null);
556 classA.accessors = <PropertyAccessorElement> [getterG];
557 InterfaceType typeA = classA.type;
558 JUnitTestCase.assertSame(getterG, typeA.getGetter(getterName));
559 }
560 void test_getGetter_parameterized() {
561 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
562 Type2 typeE = classA.type.typeArguments[0];
563 String getterName = "g";
564 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, typeE);
565 classA.accessors = <PropertyAccessorElement> [getterG];
566 ((getterG.type as FunctionTypeImpl)).typeArguments = classA.type.typeArgumen ts;
567 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
568 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
569 typeAI.typeArguments = <Type2> [typeI];
570 PropertyAccessorElement getter = typeAI.getGetter(getterName);
571 JUnitTestCase.assertNotNull(getter);
572 FunctionType getterType = getter.type;
573 JUnitTestCase.assertSame(typeI, getterType.returnType);
574 }
575 void test_getGetter_unimplemented() {
576 ClassElementImpl classA = ElementFactory.classElement2("A", []);
577 InterfaceType typeA = classA.type;
578 JUnitTestCase.assertNull(typeA.getGetter("g"));
579 }
580 void test_getInterfaces_nonParameterized() {
581 ClassElementImpl classA = ElementFactory.classElement2("A", []);
582 InterfaceType typeA = classA.type;
583 ClassElementImpl classB = ElementFactory.classElement2("B", []);
584 InterfaceType typeB = classB.type;
585 ClassElementImpl classC = ElementFactory.classElement2("C", []);
586 classC.interfaces = <InterfaceType> [typeA, typeB];
587 List<InterfaceType> interfaces = classC.type.interfaces;
588 EngineTestCase.assertLength(2, interfaces);
589 if (identical(interfaces[0], typeA)) {
590 JUnitTestCase.assertSame(typeB, interfaces[1]);
591 } else {
592 JUnitTestCase.assertSame(typeB, interfaces[0]);
593 JUnitTestCase.assertSame(typeA, interfaces[1]);
594 }
595 }
596 void test_getInterfaces_parameterized() {
597 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
598 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
599 InterfaceType typeB = classB.type;
600 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
601 typeAF.typeArguments = <Type2> [typeB.typeArguments[0]];
602 classB.interfaces = <InterfaceType> [typeAF];
603 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
604 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
605 typeBI.typeArguments = <Type2> [typeI];
606 List<InterfaceType> interfaces = typeBI.interfaces;
607 EngineTestCase.assertLength(1, interfaces);
608 InterfaceType result = interfaces[0];
609 JUnitTestCase.assertSame(classA, result.element);
610 JUnitTestCase.assertSame(typeI, result.typeArguments[0]);
611 }
612 void test_getLeastUpperBound_directInterfaceCase() {
613 ClassElementImpl classA = ElementFactory.classElement2("A", []);
614 ClassElementImpl classB = ElementFactory.classElement2("B", []);
615 ClassElementImpl classC = ElementFactory.classElement2("C", []);
616 InterfaceType typeA = classA.type;
617 InterfaceType typeB = classB.type;
618 InterfaceType typeC = classC.type;
619 classB.interfaces = <InterfaceType> [typeA];
620 classC.interfaces = <InterfaceType> [typeB];
621 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC));
622 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB));
623 }
624 void test_getLeastUpperBound_directSubclassCase() {
625 ClassElementImpl classA = ElementFactory.classElement2("A", []);
626 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
627 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []);
628 InterfaceType typeB = classB.type;
629 InterfaceType typeC = classC.type;
630 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC));
631 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB));
632 }
633 void test_getLeastUpperBound_functionType() {
634 Type2 interfaceType = ElementFactory.classElement2("A", []).type;
635 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier3("f")));
636 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(functionType));
637 }
638 void test_getLeastUpperBound_mixinCase() {
639 ClassElement classA = ElementFactory.classElement2("A", []);
640 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
641 ClassElement classC = ElementFactory.classElement("C", classA.type, []);
642 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []);
643 InterfaceType typeA = classA.type;
644 InterfaceType typeC = classC.type;
645 InterfaceType typeD = classD.type;
646 classD.mixins = <InterfaceType> [
647 ElementFactory.classElement2("M", []).type,
648 ElementFactory.classElement2("N", []).type,
649 ElementFactory.classElement2("O", []).type,
650 ElementFactory.classElement2("P", []).type];
651 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeC));
652 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeD));
653 }
654 void test_getLeastUpperBound_null() {
655 Type2 interfaceType = ElementFactory.classElement2("A", []).type;
656 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(null));
657 }
658 void test_getLeastUpperBound_object() {
659 ClassElementImpl classA = ElementFactory.classElement2("A", []);
660 ClassElementImpl classB = ElementFactory.classElement2("B", []);
661 InterfaceType typeA = classA.type;
662 InterfaceType typeB = classB.type;
663 Type2 typeObject = typeA.element.supertype;
664 JUnitTestCase.assertNull(((typeObject.element as ClassElement)).supertype);
665 JUnitTestCase.assertEquals(typeObject, typeB.element.supertype);
666 JUnitTestCase.assertEquals(typeObject, typeA.getLeastUpperBound(typeB));
667 }
668 void test_getLeastUpperBound_self() {
669 ClassElement classA = ElementFactory.classElement2("A", []);
670 InterfaceType typeA = classA.type;
671 JUnitTestCase.assertEquals(typeA, typeA.getLeastUpperBound(typeA));
672 }
673 void test_getLeastUpperBound_sharedSuperclass1() {
674 ClassElementImpl classA = ElementFactory.classElement2("A", []);
675 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
676 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []);
677 InterfaceType typeA = classA.type;
678 InterfaceType typeB = classB.type;
679 InterfaceType typeC = classC.type;
680 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
681 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
682 }
683 void test_getLeastUpperBound_sharedSuperclass2() {
684 ClassElementImpl classA = ElementFactory.classElement2("A", []);
685 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
686 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []);
687 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []);
688 InterfaceType typeA = classA.type;
689 InterfaceType typeB = classB.type;
690 InterfaceType typeD = classD.type;
691 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeD));
692 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeB));
693 }
694 void test_getLeastUpperBound_sharedSuperclass3() {
695 ClassElementImpl classA = ElementFactory.classElement2("A", []);
696 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
697 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []);
698 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []);
699 InterfaceType typeB = classB.type;
700 InterfaceType typeC = classC.type;
701 InterfaceType typeD = classD.type;
702 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeD));
703 JUnitTestCase.assertEquals(typeB, typeD.getLeastUpperBound(typeC));
704 }
705 void test_getLeastUpperBound_sharedSuperclass4() {
706 ClassElement classA = ElementFactory.classElement2("A", []);
707 ClassElement classA2 = ElementFactory.classElement2("A2", []);
708 ClassElement classA3 = ElementFactory.classElement2("A3", []);
709 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
710 ClassElementImpl classC = ElementFactory.classElement("C", classA.type, []);
711 InterfaceType typeA = classA.type;
712 InterfaceType typeA2 = classA2.type;
713 InterfaceType typeA3 = classA3.type;
714 InterfaceType typeB = classB.type;
715 InterfaceType typeC = classC.type;
716 classB.interfaces = <InterfaceType> [typeA2];
717 classC.interfaces = <InterfaceType> [typeA3];
718 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
719 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
720 }
721 void test_getLeastUpperBound_sharedSuperinterface1() {
722 ClassElementImpl classA = ElementFactory.classElement2("A", []);
723 ClassElementImpl classB = ElementFactory.classElement2("B", []);
724 ClassElementImpl classC = ElementFactory.classElement2("C", []);
725 InterfaceType typeA = classA.type;
726 InterfaceType typeB = classB.type;
727 InterfaceType typeC = classC.type;
728 classB.interfaces = <InterfaceType> [typeA];
729 classC.interfaces = <InterfaceType> [typeA];
730 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
731 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
732 }
733 void test_getLeastUpperBound_sharedSuperinterface2() {
734 ClassElementImpl classA = ElementFactory.classElement2("A", []);
735 ClassElementImpl classB = ElementFactory.classElement2("B", []);
736 ClassElementImpl classC = ElementFactory.classElement2("C", []);
737 ClassElementImpl classD = ElementFactory.classElement2("D", []);
738 InterfaceType typeA = classA.type;
739 InterfaceType typeB = classB.type;
740 InterfaceType typeC = classC.type;
741 InterfaceType typeD = classD.type;
742 classB.interfaces = <InterfaceType> [typeA];
743 classC.interfaces = <InterfaceType> [typeA];
744 classD.interfaces = <InterfaceType> [typeC];
745 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeD));
746 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeB));
747 }
748 void test_getLeastUpperBound_sharedSuperinterface3() {
749 ClassElementImpl classA = ElementFactory.classElement2("A", []);
750 ClassElementImpl classB = ElementFactory.classElement2("B", []);
751 ClassElementImpl classC = ElementFactory.classElement2("C", []);
752 ClassElementImpl classD = ElementFactory.classElement2("D", []);
753 InterfaceType typeA = classA.type;
754 InterfaceType typeB = classB.type;
755 InterfaceType typeC = classC.type;
756 InterfaceType typeD = classD.type;
757 classB.interfaces = <InterfaceType> [typeA];
758 classC.interfaces = <InterfaceType> [typeB];
759 classD.interfaces = <InterfaceType> [typeB];
760 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeD));
761 JUnitTestCase.assertEquals(typeB, typeD.getLeastUpperBound(typeC));
762 }
763 void test_getLeastUpperBound_sharedSuperinterface4() {
764 ClassElement classA = ElementFactory.classElement2("A", []);
765 ClassElement classA2 = ElementFactory.classElement2("A2", []);
766 ClassElement classA3 = ElementFactory.classElement2("A3", []);
767 ClassElementImpl classB = ElementFactory.classElement2("B", []);
768 ClassElementImpl classC = ElementFactory.classElement2("C", []);
769 InterfaceType typeA = classA.type;
770 InterfaceType typeA2 = classA2.type;
771 InterfaceType typeA3 = classA3.type;
772 InterfaceType typeB = classB.type;
773 InterfaceType typeC = classC.type;
774 classB.interfaces = <InterfaceType> [typeA, typeA2];
775 classC.interfaces = <InterfaceType> [typeA, typeA3];
776 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
777 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
778 }
779 void test_getLeastUpperBound_twoComparables() {
780 InterfaceType string = _typeProvider.stringType;
781 InterfaceType num = _typeProvider.numType;
782 JUnitTestCase.assertEquals(_typeProvider.objectType, string.getLeastUpperBou nd(num));
783 }
784 void test_getLeastUpperBound_typeParameters_different() {
785 InterfaceType listType = _typeProvider.listType;
786 InterfaceType intType = _typeProvider.intType;
787 InterfaceType doubleType = _typeProvider.doubleType;
788 InterfaceType listOfIntType = listType.substitute4(<Type2> [intType]);
789 InterfaceType listOfDoubleType = listType.substitute4(<Type2> [doubleType]);
790 JUnitTestCase.assertEquals(listType.substitute4(<Type2> [_typeProvider.dynam icType]), listOfIntType.getLeastUpperBound(listOfDoubleType));
791 }
792 void test_getLeastUpperBound_typeParameters_same() {
793 InterfaceType listType = _typeProvider.listType;
794 InterfaceType intType = _typeProvider.intType;
795 InterfaceType listOfIntType = listType.substitute4(<Type2> [intType]);
796 JUnitTestCase.assertEquals(listOfIntType, listOfIntType.getLeastUpperBound(l istOfIntType));
797 }
798 void test_getMethod_implemented() {
799 ClassElementImpl classA = ElementFactory.classElement2("A", []);
800 String methodName = "m";
801 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [ ]);
802 classA.methods = <MethodElement> [methodM];
803 InterfaceType typeA = classA.type;
804 JUnitTestCase.assertSame(methodM, typeA.getMethod(methodName));
805 }
806 void test_getMethod_parameterized() {
807 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
808 Type2 typeE = classA.type.typeArguments[0];
809 String methodName = "m";
810 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]);
811 classA.methods = <MethodElement> [methodM];
812 ((methodM.type as FunctionTypeImpl)).typeArguments = classA.type.typeArgumen ts;
813 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
814 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
815 typeAI.typeArguments = <Type2> [typeI];
816 MethodElement method = typeAI.getMethod(methodName);
817 JUnitTestCase.assertNotNull(method);
818 FunctionType methodType = method.type;
819 JUnitTestCase.assertSame(typeI, methodType.returnType);
820 List<Type2> parameterTypes = methodType.normalParameterTypes;
821 EngineTestCase.assertLength(1, parameterTypes);
822 JUnitTestCase.assertSame(typeI, parameterTypes[0]);
823 }
824 void test_getMethod_unimplemented() {
825 ClassElementImpl classA = ElementFactory.classElement2("A", []);
826 InterfaceType typeA = classA.type;
827 JUnitTestCase.assertNull(typeA.getMethod("m"));
828 }
829 void test_getMethods() {
830 ClassElementImpl typeElement = ElementFactory.classElement2("A", []);
831 MethodElementImpl methodOne = ElementFactory.methodElement("one", null, []);
832 MethodElementImpl methodTwo = ElementFactory.methodElement("two", null, []);
833 typeElement.methods = <MethodElement> [methodOne, methodTwo];
834 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
835 JUnitTestCase.assertEquals(2, type.methods.length);
836 }
837 void test_getMethods_empty() {
838 ClassElementImpl typeElement = ElementFactory.classElement2("A", []);
839 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
840 JUnitTestCase.assertEquals(0, type.methods.length);
841 }
842 void test_getMixins_nonParameterized() {
843 ClassElementImpl classA = ElementFactory.classElement2("A", []);
844 InterfaceType typeA = classA.type;
845 ClassElementImpl classB = ElementFactory.classElement2("B", []);
846 InterfaceType typeB = classB.type;
847 ClassElementImpl classC = ElementFactory.classElement2("C", []);
848 classC.mixins = <InterfaceType> [typeA, typeB];
849 List<InterfaceType> interfaces = classC.type.mixins;
850 EngineTestCase.assertLength(2, interfaces);
851 if (identical(interfaces[0], typeA)) {
852 JUnitTestCase.assertSame(typeB, interfaces[1]);
853 } else {
854 JUnitTestCase.assertSame(typeB, interfaces[0]);
855 JUnitTestCase.assertSame(typeA, interfaces[1]);
856 }
857 }
858 void test_getMixins_parameterized() {
859 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
860 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
861 InterfaceType typeB = classB.type;
862 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
863 typeAF.typeArguments = <Type2> [typeB.typeArguments[0]];
864 classB.mixins = <InterfaceType> [typeAF];
865 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
866 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
867 typeBI.typeArguments = <Type2> [typeI];
868 List<InterfaceType> interfaces = typeBI.mixins;
869 EngineTestCase.assertLength(1, interfaces);
870 InterfaceType result = interfaces[0];
871 JUnitTestCase.assertSame(classA, result.element);
872 JUnitTestCase.assertSame(typeI, result.typeArguments[0]);
873 }
874 void test_getSetter_implemented() {
875 ClassElementImpl classA = ElementFactory.classElement2("A", []);
876 String setterName = "s";
877 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null);
878 classA.accessors = <PropertyAccessorElement> [setterS];
879 InterfaceType typeA = classA.type;
880 JUnitTestCase.assertSame(setterS, typeA.getSetter(setterName));
881 }
882 void test_getSetter_parameterized() {
883 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
884 Type2 typeE = classA.type.typeArguments[0];
885 String setterName = "s";
886 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, typeE);
887 classA.accessors = <PropertyAccessorElement> [setterS];
888 ((setterS.type as FunctionTypeImpl)).typeArguments = classA.type.typeArgumen ts;
889 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
890 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
891 typeAI.typeArguments = <Type2> [typeI];
892 PropertyAccessorElement setter = typeAI.getSetter(setterName);
893 JUnitTestCase.assertNotNull(setter);
894 FunctionType setterType = setter.type;
895 List<Type2> parameterTypes = setterType.normalParameterTypes;
896 EngineTestCase.assertLength(1, parameterTypes);
897 JUnitTestCase.assertSame(typeI, parameterTypes[0]);
898 }
899 void test_getSetter_unimplemented() {
900 ClassElementImpl classA = ElementFactory.classElement2("A", []);
901 InterfaceType typeA = classA.type;
902 JUnitTestCase.assertNull(typeA.getSetter("s"));
903 }
904 void test_getSuperclass_nonParameterized() {
905 ClassElementImpl classA = ElementFactory.classElement2("A", []);
906 InterfaceType typeA = classA.type;
907 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []);
908 InterfaceType typeB = classB.type;
909 JUnitTestCase.assertSame(typeA, typeB.superclass);
910 }
911 void test_getSuperclass_parameterized() {
912 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
913 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
914 InterfaceType typeB = classB.type;
915 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
916 typeAF.typeArguments = <Type2> [typeB.typeArguments[0]];
917 classB.supertype = typeAF;
918 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
919 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
920 typeBI.typeArguments = <Type2> [typeI];
921 InterfaceType superclass = typeBI.superclass;
922 JUnitTestCase.assertSame(classA, superclass.element);
923 JUnitTestCase.assertSame(typeI, superclass.typeArguments[0]);
924 }
925 void test_getTypeArguments_empty() {
926 InterfaceType type = ElementFactory.classElement2("A", []).type;
927 EngineTestCase.assertLength(0, type.typeArguments);
928 }
929 void test_hashCode() {
930 ClassElement classA = ElementFactory.classElement2("A", []);
931 InterfaceType typeA = classA.type;
932 JUnitTestCase.assertFalse(0 == typeA.hashCode);
933 }
934 void test_isDirectSupertypeOf_extends() {
935 ClassElement classA = ElementFactory.classElement2("A", []);
936 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
937 InterfaceType typeA = classA.type;
938 InterfaceType typeB = classB.type;
939 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
940 }
941 void test_isDirectSupertypeOf_false() {
942 ClassElement classA = ElementFactory.classElement2("A", []);
943 ClassElement classB = ElementFactory.classElement2("B", []);
944 ClassElement classC = ElementFactory.classElement("C", classB.type, []);
945 InterfaceType typeA = classA.type;
946 InterfaceType typeC = classC.type;
947 JUnitTestCase.assertFalse(typeA.isDirectSupertypeOf(typeC));
948 }
949 void test_isDirectSupertypeOf_implements() {
950 ClassElementImpl classA = ElementFactory.classElement2("A", []);
951 ClassElementImpl classB = ElementFactory.classElement2("B", []);
952 InterfaceType typeA = classA.type;
953 InterfaceType typeB = classB.type;
954 classB.interfaces = <InterfaceType> [typeA];
955 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
956 }
957 void test_isDirectSupertypeOf_with() {
958 ClassElementImpl classA = ElementFactory.classElement2("A", []);
959 ClassElementImpl classB = ElementFactory.classElement2("B", []);
960 InterfaceType typeA = classA.type;
961 InterfaceType typeB = classB.type;
962 classB.mixins = <InterfaceType> [typeA];
963 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
964 }
965 void test_isMoreSpecificThan_bottom() {
966 Type2 type = ElementFactory.classElement2("A", []).type;
967 JUnitTestCase.assertTrue(BottomTypeImpl.instance.isMoreSpecificThan(type));
968 }
969 void test_isMoreSpecificThan_covariance() {
970 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
971 ClassElement classI = ElementFactory.classElement2("I", []);
972 ClassElement classJ = ElementFactory.classElement("J", classI.type, []);
973 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
974 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA);
975 typeAI.typeArguments = <Type2> [classI.type];
976 typeAJ.typeArguments = <Type2> [classJ.type];
977 JUnitTestCase.assertTrue(typeAJ.isMoreSpecificThan(typeAI));
978 JUnitTestCase.assertFalse(typeAI.isMoreSpecificThan(typeAJ));
979 }
980 void test_isMoreSpecificThan_directSupertype() {
981 ClassElement classA = ElementFactory.classElement2("A", []);
982 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
983 InterfaceType typeA = classA.type;
984 InterfaceType typeB = classB.type;
985 JUnitTestCase.assertTrue(typeB.isMoreSpecificThan(typeA));
986 JUnitTestCase.assertFalse(typeA.isMoreSpecificThan(typeB));
987 }
988 void test_isMoreSpecificThan_dynamic() {
989 InterfaceType type = ElementFactory.classElement2("A", []).type;
990 JUnitTestCase.assertTrue(type.isMoreSpecificThan(DynamicTypeImpl.instance));
991 }
992 void test_isMoreSpecificThan_self() {
993 InterfaceType type = ElementFactory.classElement2("A", []).type;
994 JUnitTestCase.assertTrue(type.isMoreSpecificThan(type));
995 }
996 void test_isMoreSpecificThan_transitive_interface() {
997 ClassElementImpl classA = ElementFactory.classElement2("A", []);
998 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
999 ClassElementImpl classC = ElementFactory.classElement2("C", []);
1000 classC.interfaces = <InterfaceType> [classB.type];
1001 InterfaceType typeA = classA.type;
1002 InterfaceType typeC = classC.type;
1003 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA));
1004 }
1005 void test_isMoreSpecificThan_transitive_mixin() {
1006 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1007 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1008 ClassElementImpl classC = ElementFactory.classElement2("C", []);
1009 classC.mixins = <InterfaceType> [classB.type];
1010 InterfaceType typeA = classA.type;
1011 InterfaceType typeC = classC.type;
1012 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA));
1013 }
1014 void test_isMoreSpecificThan_transitive_recursive() {
1015 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1016 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1017 ClassElementImpl classC = ElementFactory.classElement2("C", []);
1018 InterfaceType typeA = classA.type;
1019 InterfaceType typeC = classC.type;
1020 classA.supertype = classB.type;
1021 JUnitTestCase.assertFalse(typeA.isMoreSpecificThan(typeC));
1022 }
1023 void test_isMoreSpecificThan_transitive_superclass() {
1024 ClassElement classA = ElementFactory.classElement2("A", []);
1025 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1026 ClassElement classC = ElementFactory.classElement("C", classB.type, []);
1027 InterfaceType typeA = classA.type;
1028 InterfaceType typeC = classC.type;
1029 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA));
1030 }
1031 void test_isSubtypeOf_directSubtype() {
1032 ClassElement classA = ElementFactory.classElement2("A", []);
1033 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1034 InterfaceType typeA = classA.type;
1035 InterfaceType typeB = classB.type;
1036 JUnitTestCase.assertTrue(typeB.isSubtypeOf(typeA));
1037 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeB));
1038 }
1039 void test_isSubtypeOf_dynamic() {
1040 ClassElement classA = ElementFactory.classElement2("A", []);
1041 InterfaceType typeA = classA.type;
1042 Type2 dynamicType = DynamicTypeImpl.instance;
1043 JUnitTestCase.assertTrue(dynamicType.isSubtypeOf(typeA));
1044 JUnitTestCase.assertTrue(typeA.isSubtypeOf(dynamicType));
1045 }
1046 void test_isSubtypeOf_function() {
1047 InterfaceType stringType = _typeProvider.stringType;
1048 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1049 classA.methods = <MethodElement> [ElementFactory.methodElement("call", VoidT ypeImpl.instance, [stringType])];
1050 FunctionType functionType = ElementFactory.functionElement5("f", <ClassEleme nt> [stringType.element]).type;
1051 JUnitTestCase.assertTrue(classA.type.isSubtypeOf(functionType));
1052 }
1053 void test_isSubtypeOf_interface() {
1054 ClassElement classA = ElementFactory.classElement2("A", []);
1055 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1056 ClassElementImpl classC = ElementFactory.classElement2("C", []);
1057 InterfaceType typeObject = classA.supertype;
1058 InterfaceType typeA = classA.type;
1059 InterfaceType typeB = classB.type;
1060 InterfaceType typeC = classC.type;
1061 classC.interfaces = <InterfaceType> [typeB];
1062 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeB));
1063 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeObject));
1064 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA));
1065 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
1066 }
1067 void test_isSubtypeOf_mixins() {
1068 ClassElement classA = ElementFactory.classElement2("A", []);
1069 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1070 ClassElementImpl classC = ElementFactory.classElement2("C", []);
1071 InterfaceType typeObject = classA.supertype;
1072 InterfaceType typeA = classA.type;
1073 InterfaceType typeB = classB.type;
1074 InterfaceType typeC = classC.type;
1075 classC.mixins = <InterfaceType> [typeB];
1076 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeB));
1077 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeObject));
1078 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA));
1079 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
1080 }
1081 void test_isSubtypeOf_object() {
1082 ClassElement classA = ElementFactory.classElement2("A", []);
1083 InterfaceType typeA = classA.type;
1084 InterfaceType typeObject = classA.supertype;
1085 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeObject));
1086 JUnitTestCase.assertFalse(typeObject.isSubtypeOf(typeA));
1087 }
1088 void test_isSubtypeOf_self() {
1089 ClassElement classA = ElementFactory.classElement2("A", []);
1090 InterfaceType typeA = classA.type;
1091 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeA));
1092 }
1093 void test_isSubtypeOf_transitive_recursive() {
1094 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1095 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1096 ClassElementImpl classC = ElementFactory.classElement2("C", []);
1097 InterfaceType typeA = classA.type;
1098 InterfaceType typeC = classC.type;
1099 classA.supertype = classB.type;
1100 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
1101 }
1102 void test_isSubtypeOf_transitive_superclass() {
1103 ClassElement classA = ElementFactory.classElement2("A", []);
1104 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1105 ClassElement classC = ElementFactory.classElement("C", classB.type, []);
1106 InterfaceType typeA = classA.type;
1107 InterfaceType typeC = classC.type;
1108 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA));
1109 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
1110 }
1111 void test_isSubtypeOf_typeArguments() {
1112 Type2 dynamicType = DynamicTypeImpl.instance;
1113 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
1114 ClassElement classI = ElementFactory.classElement2("I", []);
1115 ClassElement classJ = ElementFactory.classElement("J", classI.type, []);
1116 ClassElement classK = ElementFactory.classElement2("K", []);
1117 InterfaceType typeA = classA.type;
1118 InterfaceType typeA_dynamic = typeA.substitute4(<Type2> [dynamicType]);
1119 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(classA);
1120 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(classA);
1121 InterfaceTypeImpl typeAK = new InterfaceTypeImpl.con1(classA);
1122 typeAI.typeArguments = <Type2> [classI.type];
1123 typeAJ.typeArguments = <Type2> [classJ.type];
1124 typeAK.typeArguments = <Type2> [classK.type];
1125 JUnitTestCase.assertTrue(typeAJ.isSubtypeOf(typeAI));
1126 JUnitTestCase.assertFalse(typeAI.isSubtypeOf(typeAJ));
1127 JUnitTestCase.assertTrue(typeAI.isSubtypeOf(typeAI));
1128 JUnitTestCase.assertTrue(typeA_dynamic.isSubtypeOf(typeAI));
1129 JUnitTestCase.assertTrue(typeA_dynamic.isSubtypeOf(typeAJ));
1130 JUnitTestCase.assertTrue(typeAI.isSubtypeOf(typeA_dynamic));
1131 JUnitTestCase.assertTrue(typeAJ.isSubtypeOf(typeA_dynamic));
1132 JUnitTestCase.assertFalse(typeAI.isSubtypeOf(typeAK));
1133 JUnitTestCase.assertFalse(typeAK.isSubtypeOf(typeAI));
1134 }
1135 void test_isSupertypeOf_directSupertype() {
1136 ClassElement classA = ElementFactory.classElement2("A", []);
1137 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1138 InterfaceType typeA = classA.type;
1139 InterfaceType typeB = classB.type;
1140 JUnitTestCase.assertFalse(typeB.isSupertypeOf(typeA));
1141 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeB));
1142 }
1143 void test_isSupertypeOf_dynamic() {
1144 ClassElement classA = ElementFactory.classElement2("A", []);
1145 InterfaceType typeA = classA.type;
1146 Type2 dynamicType = DynamicTypeImpl.instance;
1147 JUnitTestCase.assertTrue(dynamicType.isSupertypeOf(typeA));
1148 JUnitTestCase.assertTrue(typeA.isSupertypeOf(dynamicType));
1149 }
1150 void test_isSupertypeOf_indirectSupertype() {
1151 ClassElement classA = ElementFactory.classElement2("A", []);
1152 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1153 ClassElement classC = ElementFactory.classElement("C", classB.type, []);
1154 InterfaceType typeA = classA.type;
1155 InterfaceType typeC = classC.type;
1156 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
1157 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC));
1158 }
1159 void test_isSupertypeOf_interface() {
1160 ClassElement classA = ElementFactory.classElement2("A", []);
1161 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1162 ClassElementImpl classC = ElementFactory.classElement2("C", []);
1163 InterfaceType typeObject = classA.supertype;
1164 InterfaceType typeA = classA.type;
1165 InterfaceType typeB = classB.type;
1166 InterfaceType typeC = classC.type;
1167 classC.interfaces = <InterfaceType> [typeB];
1168 JUnitTestCase.assertTrue(typeB.isSupertypeOf(typeC));
1169 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeC));
1170 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC));
1171 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
1172 }
1173 void test_isSupertypeOf_mixins() {
1174 ClassElement classA = ElementFactory.classElement2("A", []);
1175 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1176 ClassElementImpl classC = ElementFactory.classElement2("C", []);
1177 InterfaceType typeObject = classA.supertype;
1178 InterfaceType typeA = classA.type;
1179 InterfaceType typeB = classB.type;
1180 InterfaceType typeC = classC.type;
1181 classC.mixins = <InterfaceType> [typeB];
1182 JUnitTestCase.assertTrue(typeB.isSupertypeOf(typeC));
1183 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeC));
1184 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC));
1185 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
1186 }
1187 void test_isSupertypeOf_object() {
1188 ClassElement classA = ElementFactory.classElement2("A", []);
1189 InterfaceType typeA = classA.type;
1190 InterfaceType typeObject = classA.supertype;
1191 JUnitTestCase.assertFalse(typeA.isSupertypeOf(typeObject));
1192 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeA));
1193 }
1194 void test_isSupertypeOf_self() {
1195 ClassElement classA = ElementFactory.classElement2("A", []);
1196 InterfaceType typeA = classA.type;
1197 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeA));
1198 }
1199 void test_lookUpGetter_implemented() {
1200 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1201 String getterName = "g";
1202 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null);
1203 classA.accessors = <PropertyAccessorElement> [getterG];
1204 InterfaceType typeA = classA.type;
1205 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1206 CompilationUnitElement unit = library.definingCompilationUnit;
1207 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1208 JUnitTestCase.assertSame(getterG, typeA.lookUpGetter(getterName, library));
1209 }
1210 void test_lookUpGetter_inherited() {
1211 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1212 String getterName = "g";
1213 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, null);
1214 classA.accessors = <PropertyAccessorElement> [getterG];
1215 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1216 InterfaceType typeB = classB.type;
1217 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1218 CompilationUnitElement unit = library.definingCompilationUnit;
1219 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA, class B];
1220 JUnitTestCase.assertSame(getterG, typeB.lookUpGetter(getterName, library));
1221 }
1222 void test_lookUpGetter_recursive() {
1223 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1224 InterfaceType typeA = classA.type;
1225 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []);
1226 classA.supertype = classB.type;
1227 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1228 CompilationUnitElement unit = library.definingCompilationUnit;
1229 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA, class B];
1230 JUnitTestCase.assertNull(typeA.lookUpGetter("g", library));
1231 }
1232 void test_lookUpGetter_unimplemented() {
1233 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1234 InterfaceType typeA = classA.type;
1235 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1236 CompilationUnitElement unit = library.definingCompilationUnit;
1237 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1238 JUnitTestCase.assertNull(typeA.lookUpGetter("g", library));
1239 }
1240 void test_lookUpMethod_implemented() {
1241 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1242 String methodName = "m";
1243 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [ ]);
1244 classA.methods = <MethodElement> [methodM];
1245 InterfaceType typeA = classA.type;
1246 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1247 CompilationUnitElement unit = library.definingCompilationUnit;
1248 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1249 JUnitTestCase.assertSame(methodM, typeA.lookUpMethod(methodName, library));
1250 }
1251 void test_lookUpMethod_inherited() {
1252 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1253 String methodName = "m";
1254 MethodElementImpl methodM = ElementFactory.methodElement(methodName, null, [ ]);
1255 classA.methods = <MethodElement> [methodM];
1256 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1257 InterfaceType typeB = classB.type;
1258 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1259 CompilationUnitElement unit = library.definingCompilationUnit;
1260 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA, class B];
1261 JUnitTestCase.assertSame(methodM, typeB.lookUpMethod(methodName, library));
1262 }
1263 void test_lookUpMethod_parameterized() {
1264 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
1265 Type2 typeE = classA.type.typeArguments[0];
1266 String methodName = "m";
1267 MethodElementImpl methodM = ElementFactory.methodElement(methodName, typeE, [typeE]);
1268 classA.methods = <MethodElement> [methodM];
1269 ((methodM.type as FunctionTypeImpl)).typeArguments = classA.type.typeArgumen ts;
1270 ClassElementImpl classB = ElementFactory.classElement2("B", ["F"]);
1271 InterfaceType typeB = classB.type;
1272 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA);
1273 typeAF.typeArguments = <Type2> [typeB.typeArguments[0]];
1274 classB.supertype = typeAF;
1275 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1276 CompilationUnitElement unit = library.definingCompilationUnit;
1277 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1278 InterfaceType typeI = ElementFactory.classElement2("I", []).type;
1279 InterfaceTypeImpl typeBI = new InterfaceTypeImpl.con1(classB);
1280 typeBI.typeArguments = <Type2> [typeI];
1281 MethodElement method = typeBI.lookUpMethod(methodName, library);
1282 JUnitTestCase.assertNotNull(method);
1283 FunctionType methodType = method.type;
1284 JUnitTestCase.assertSame(typeI, methodType.returnType);
1285 List<Type2> parameterTypes = methodType.normalParameterTypes;
1286 EngineTestCase.assertLength(1, parameterTypes);
1287 JUnitTestCase.assertSame(typeI, parameterTypes[0]);
1288 }
1289 void test_lookUpMethod_recursive() {
1290 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1291 InterfaceType typeA = classA.type;
1292 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []);
1293 classA.supertype = classB.type;
1294 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1295 CompilationUnitElement unit = library.definingCompilationUnit;
1296 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA, class B];
1297 JUnitTestCase.assertNull(typeA.lookUpMethod("m", library));
1298 }
1299 void test_lookUpMethod_unimplemented() {
1300 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1301 InterfaceType typeA = classA.type;
1302 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1303 CompilationUnitElement unit = library.definingCompilationUnit;
1304 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1305 JUnitTestCase.assertNull(typeA.lookUpMethod("m", library));
1306 }
1307 void test_lookUpSetter_implemented() {
1308 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1309 String setterName = "s";
1310 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null);
1311 classA.accessors = <PropertyAccessorElement> [setterS];
1312 InterfaceType typeA = classA.type;
1313 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1314 CompilationUnitElement unit = library.definingCompilationUnit;
1315 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1316 JUnitTestCase.assertSame(setterS, typeA.lookUpSetter(setterName, library));
1317 }
1318 void test_lookUpSetter_inherited() {
1319 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1320 String setterName = "g";
1321 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, null);
1322 classA.accessors = <PropertyAccessorElement> [setterS];
1323 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1324 InterfaceType typeB = classB.type;
1325 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1326 CompilationUnitElement unit = library.definingCompilationUnit;
1327 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA, class B];
1328 JUnitTestCase.assertSame(setterS, typeB.lookUpSetter(setterName, library));
1329 }
1330 void test_lookUpSetter_recursive() {
1331 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1332 InterfaceType typeA = classA.type;
1333 ClassElementImpl classB = ElementFactory.classElement("B", typeA, []);
1334 classA.supertype = classB.type;
1335 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1336 CompilationUnitElement unit = library.definingCompilationUnit;
1337 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA, class B];
1338 JUnitTestCase.assertNull(typeA.lookUpSetter("s", library));
1339 }
1340 void test_lookUpSetter_unimplemented() {
1341 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1342 InterfaceType typeA = classA.type;
1343 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
1344 CompilationUnitElement unit = library.definingCompilationUnit;
1345 ((unit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1346 JUnitTestCase.assertNull(typeA.lookUpSetter("s", library));
1347 }
1348 void test_setTypeArguments() {
1349 InterfaceTypeImpl type = ElementFactory.classElement2("A", []).type as Inter faceTypeImpl;
1350 List<Type2> typeArguments = <Type2> [
1351 ElementFactory.classElement2("B", []).type,
1352 ElementFactory.classElement2("C", []).type];
1353 type.typeArguments = typeArguments;
1354 JUnitTestCase.assertEquals(typeArguments, type.typeArguments);
1355 }
1356 void test_substitute_equal() {
1357 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1358 TypeParameterElementImpl parameterElement = new TypeParameterElementImpl(AST Factory.identifier3("E"));
1359 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA);
1360 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(parameterElement );
1361 type.typeArguments = <Type2> [parameter];
1362 InterfaceType argumentType = ElementFactory.classElement2("B", []).type;
1363 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par ameter]);
1364 JUnitTestCase.assertEquals(classA, result.element);
1365 List<Type2> resultArguments = result.typeArguments;
1366 EngineTestCase.assertLength(1, resultArguments);
1367 JUnitTestCase.assertEquals(argumentType, resultArguments[0]);
1368 }
1369 void test_substitute_exception() {
1370 try {
1371 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1372 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA);
1373 InterfaceType argumentType = ElementFactory.classElement2("B", []).type;
1374 type.substitute2(<Type2> [argumentType], <Type2> []);
1375 JUnitTestCase.fail("Expected to encounter exception, argument and paramete r type array lengths not equal.");
1376 } on JavaException catch (e) {
1377 }
1378 }
1379 void test_substitute_notEqual() {
1380 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1381 TypeParameterElementImpl parameterElement = new TypeParameterElementImpl(AST Factory.identifier3("E"));
1382 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classA);
1383 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(parameterElement );
1384 type.typeArguments = <Type2> [parameter];
1385 InterfaceType argumentType = ElementFactory.classElement2("B", []).type;
1386 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara meterElementImpl(ASTFactory.identifier3("F")));
1387 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par ameterType]);
1388 JUnitTestCase.assertEquals(classA, result.element);
1389 List<Type2> resultArguments = result.typeArguments;
1390 EngineTestCase.assertLength(1, resultArguments);
1391 JUnitTestCase.assertEquals(parameter, resultArguments[0]);
1392 }
1393 static dartSuite() {
1394 _ut.group('InterfaceTypeImplTest', () {
1395 _ut.test('test_computeLongestInheritancePathToObject_multipleInterfacePath s', () {
1396 final __test = new InterfaceTypeImplTest();
1397 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_m ultipleInterfacePaths);
1398 });
1399 _ut.test('test_computeLongestInheritancePathToObject_multipleSuperclassPat hs', () {
1400 final __test = new InterfaceTypeImplTest();
1401 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_m ultipleSuperclassPaths);
1402 });
1403 _ut.test('test_computeLongestInheritancePathToObject_object', () {
1404 final __test = new InterfaceTypeImplTest();
1405 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_o bject);
1406 });
1407 _ut.test('test_computeLongestInheritancePathToObject_recursion', () {
1408 final __test = new InterfaceTypeImplTest();
1409 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_r ecursion);
1410 });
1411 _ut.test('test_computeLongestInheritancePathToObject_singleInterfacePath', () {
1412 final __test = new InterfaceTypeImplTest();
1413 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_s ingleInterfacePath);
1414 });
1415 _ut.test('test_computeLongestInheritancePathToObject_singleSuperclassPath' , () {
1416 final __test = new InterfaceTypeImplTest();
1417 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_s ingleSuperclassPath);
1418 });
1419 _ut.test('test_computeSuperinterfaceSet_multipleInterfacePaths', () {
1420 final __test = new InterfaceTypeImplTest();
1421 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_multipleInterf acePaths);
1422 });
1423 _ut.test('test_computeSuperinterfaceSet_multipleSuperclassPaths', () {
1424 final __test = new InterfaceTypeImplTest();
1425 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_multipleSuperc lassPaths);
1426 });
1427 _ut.test('test_computeSuperinterfaceSet_recursion', () {
1428 final __test = new InterfaceTypeImplTest();
1429 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_recursion);
1430 });
1431 _ut.test('test_computeSuperinterfaceSet_singleInterfacePath', () {
1432 final __test = new InterfaceTypeImplTest();
1433 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_singleInterfac ePath);
1434 });
1435 _ut.test('test_computeSuperinterfaceSet_singleSuperclassPath', () {
1436 final __test = new InterfaceTypeImplTest();
1437 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_singleSupercla ssPath);
1438 });
1439 _ut.test('test_creation', () {
1440 final __test = new InterfaceTypeImplTest();
1441 runJUnitTest(__test, __test.test_creation);
1442 });
1443 _ut.test('test_getAccessors', () {
1444 final __test = new InterfaceTypeImplTest();
1445 runJUnitTest(__test, __test.test_getAccessors);
1446 });
1447 _ut.test('test_getAccessors_empty', () {
1448 final __test = new InterfaceTypeImplTest();
1449 runJUnitTest(__test, __test.test_getAccessors_empty);
1450 });
1451 _ut.test('test_getElement', () {
1452 final __test = new InterfaceTypeImplTest();
1453 runJUnitTest(__test, __test.test_getElement);
1454 });
1455 _ut.test('test_getGetter_implemented', () {
1456 final __test = new InterfaceTypeImplTest();
1457 runJUnitTest(__test, __test.test_getGetter_implemented);
1458 });
1459 _ut.test('test_getGetter_parameterized', () {
1460 final __test = new InterfaceTypeImplTest();
1461 runJUnitTest(__test, __test.test_getGetter_parameterized);
1462 });
1463 _ut.test('test_getGetter_unimplemented', () {
1464 final __test = new InterfaceTypeImplTest();
1465 runJUnitTest(__test, __test.test_getGetter_unimplemented);
1466 });
1467 _ut.test('test_getInterfaces_nonParameterized', () {
1468 final __test = new InterfaceTypeImplTest();
1469 runJUnitTest(__test, __test.test_getInterfaces_nonParameterized);
1470 });
1471 _ut.test('test_getInterfaces_parameterized', () {
1472 final __test = new InterfaceTypeImplTest();
1473 runJUnitTest(__test, __test.test_getInterfaces_parameterized);
1474 });
1475 _ut.test('test_getLeastUpperBound_directInterfaceCase', () {
1476 final __test = new InterfaceTypeImplTest();
1477 runJUnitTest(__test, __test.test_getLeastUpperBound_directInterfaceCase) ;
1478 });
1479 _ut.test('test_getLeastUpperBound_directSubclassCase', () {
1480 final __test = new InterfaceTypeImplTest();
1481 runJUnitTest(__test, __test.test_getLeastUpperBound_directSubclassCase);
1482 });
1483 _ut.test('test_getLeastUpperBound_functionType', () {
1484 final __test = new InterfaceTypeImplTest();
1485 runJUnitTest(__test, __test.test_getLeastUpperBound_functionType);
1486 });
1487 _ut.test('test_getLeastUpperBound_mixinCase', () {
1488 final __test = new InterfaceTypeImplTest();
1489 runJUnitTest(__test, __test.test_getLeastUpperBound_mixinCase);
1490 });
1491 _ut.test('test_getLeastUpperBound_null', () {
1492 final __test = new InterfaceTypeImplTest();
1493 runJUnitTest(__test, __test.test_getLeastUpperBound_null);
1494 });
1495 _ut.test('test_getLeastUpperBound_object', () {
1496 final __test = new InterfaceTypeImplTest();
1497 runJUnitTest(__test, __test.test_getLeastUpperBound_object);
1498 });
1499 _ut.test('test_getLeastUpperBound_self', () {
1500 final __test = new InterfaceTypeImplTest();
1501 runJUnitTest(__test, __test.test_getLeastUpperBound_self);
1502 });
1503 _ut.test('test_getLeastUpperBound_sharedSuperclass1', () {
1504 final __test = new InterfaceTypeImplTest();
1505 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass1);
1506 });
1507 _ut.test('test_getLeastUpperBound_sharedSuperclass2', () {
1508 final __test = new InterfaceTypeImplTest();
1509 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass2);
1510 });
1511 _ut.test('test_getLeastUpperBound_sharedSuperclass3', () {
1512 final __test = new InterfaceTypeImplTest();
1513 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass3);
1514 });
1515 _ut.test('test_getLeastUpperBound_sharedSuperclass4', () {
1516 final __test = new InterfaceTypeImplTest();
1517 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass4);
1518 });
1519 _ut.test('test_getLeastUpperBound_sharedSuperinterface1', () {
1520 final __test = new InterfaceTypeImplTest();
1521 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 1);
1522 });
1523 _ut.test('test_getLeastUpperBound_sharedSuperinterface2', () {
1524 final __test = new InterfaceTypeImplTest();
1525 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 2);
1526 });
1527 _ut.test('test_getLeastUpperBound_sharedSuperinterface3', () {
1528 final __test = new InterfaceTypeImplTest();
1529 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 3);
1530 });
1531 _ut.test('test_getLeastUpperBound_sharedSuperinterface4', () {
1532 final __test = new InterfaceTypeImplTest();
1533 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 4);
1534 });
1535 _ut.test('test_getLeastUpperBound_twoComparables', () {
1536 final __test = new InterfaceTypeImplTest();
1537 runJUnitTest(__test, __test.test_getLeastUpperBound_twoComparables);
1538 });
1539 _ut.test('test_getLeastUpperBound_typeParameters_different', () {
1540 final __test = new InterfaceTypeImplTest();
1541 runJUnitTest(__test, __test.test_getLeastUpperBound_typeParameters_diffe rent);
1542 });
1543 _ut.test('test_getLeastUpperBound_typeParameters_same', () {
1544 final __test = new InterfaceTypeImplTest();
1545 runJUnitTest(__test, __test.test_getLeastUpperBound_typeParameters_same) ;
1546 });
1547 _ut.test('test_getMethod_implemented', () {
1548 final __test = new InterfaceTypeImplTest();
1549 runJUnitTest(__test, __test.test_getMethod_implemented);
1550 });
1551 _ut.test('test_getMethod_parameterized', () {
1552 final __test = new InterfaceTypeImplTest();
1553 runJUnitTest(__test, __test.test_getMethod_parameterized);
1554 });
1555 _ut.test('test_getMethod_unimplemented', () {
1556 final __test = new InterfaceTypeImplTest();
1557 runJUnitTest(__test, __test.test_getMethod_unimplemented);
1558 });
1559 _ut.test('test_getMethods', () {
1560 final __test = new InterfaceTypeImplTest();
1561 runJUnitTest(__test, __test.test_getMethods);
1562 });
1563 _ut.test('test_getMethods_empty', () {
1564 final __test = new InterfaceTypeImplTest();
1565 runJUnitTest(__test, __test.test_getMethods_empty);
1566 });
1567 _ut.test('test_getMixins_nonParameterized', () {
1568 final __test = new InterfaceTypeImplTest();
1569 runJUnitTest(__test, __test.test_getMixins_nonParameterized);
1570 });
1571 _ut.test('test_getMixins_parameterized', () {
1572 final __test = new InterfaceTypeImplTest();
1573 runJUnitTest(__test, __test.test_getMixins_parameterized);
1574 });
1575 _ut.test('test_getSetter_implemented', () {
1576 final __test = new InterfaceTypeImplTest();
1577 runJUnitTest(__test, __test.test_getSetter_implemented);
1578 });
1579 _ut.test('test_getSetter_parameterized', () {
1580 final __test = new InterfaceTypeImplTest();
1581 runJUnitTest(__test, __test.test_getSetter_parameterized);
1582 });
1583 _ut.test('test_getSetter_unimplemented', () {
1584 final __test = new InterfaceTypeImplTest();
1585 runJUnitTest(__test, __test.test_getSetter_unimplemented);
1586 });
1587 _ut.test('test_getSuperclass_nonParameterized', () {
1588 final __test = new InterfaceTypeImplTest();
1589 runJUnitTest(__test, __test.test_getSuperclass_nonParameterized);
1590 });
1591 _ut.test('test_getSuperclass_parameterized', () {
1592 final __test = new InterfaceTypeImplTest();
1593 runJUnitTest(__test, __test.test_getSuperclass_parameterized);
1594 });
1595 _ut.test('test_getTypeArguments_empty', () {
1596 final __test = new InterfaceTypeImplTest();
1597 runJUnitTest(__test, __test.test_getTypeArguments_empty);
1598 });
1599 _ut.test('test_hashCode', () {
1600 final __test = new InterfaceTypeImplTest();
1601 runJUnitTest(__test, __test.test_hashCode);
1602 });
1603 _ut.test('test_isDirectSupertypeOf_extends', () {
1604 final __test = new InterfaceTypeImplTest();
1605 runJUnitTest(__test, __test.test_isDirectSupertypeOf_extends);
1606 });
1607 _ut.test('test_isDirectSupertypeOf_false', () {
1608 final __test = new InterfaceTypeImplTest();
1609 runJUnitTest(__test, __test.test_isDirectSupertypeOf_false);
1610 });
1611 _ut.test('test_isDirectSupertypeOf_implements', () {
1612 final __test = new InterfaceTypeImplTest();
1613 runJUnitTest(__test, __test.test_isDirectSupertypeOf_implements);
1614 });
1615 _ut.test('test_isDirectSupertypeOf_with', () {
1616 final __test = new InterfaceTypeImplTest();
1617 runJUnitTest(__test, __test.test_isDirectSupertypeOf_with);
1618 });
1619 _ut.test('test_isMoreSpecificThan_bottom', () {
1620 final __test = new InterfaceTypeImplTest();
1621 runJUnitTest(__test, __test.test_isMoreSpecificThan_bottom);
1622 });
1623 _ut.test('test_isMoreSpecificThan_covariance', () {
1624 final __test = new InterfaceTypeImplTest();
1625 runJUnitTest(__test, __test.test_isMoreSpecificThan_covariance);
1626 });
1627 _ut.test('test_isMoreSpecificThan_directSupertype', () {
1628 final __test = new InterfaceTypeImplTest();
1629 runJUnitTest(__test, __test.test_isMoreSpecificThan_directSupertype);
1630 });
1631 _ut.test('test_isMoreSpecificThan_dynamic', () {
1632 final __test = new InterfaceTypeImplTest();
1633 runJUnitTest(__test, __test.test_isMoreSpecificThan_dynamic);
1634 });
1635 _ut.test('test_isMoreSpecificThan_self', () {
1636 final __test = new InterfaceTypeImplTest();
1637 runJUnitTest(__test, __test.test_isMoreSpecificThan_self);
1638 });
1639 _ut.test('test_isMoreSpecificThan_transitive_interface', () {
1640 final __test = new InterfaceTypeImplTest();
1641 runJUnitTest(__test, __test.test_isMoreSpecificThan_transitive_interface );
1642 });
1643 _ut.test('test_isMoreSpecificThan_transitive_mixin', () {
1644 final __test = new InterfaceTypeImplTest();
1645 runJUnitTest(__test, __test.test_isMoreSpecificThan_transitive_mixin);
1646 });
1647 _ut.test('test_isMoreSpecificThan_transitive_recursive', () {
1648 final __test = new InterfaceTypeImplTest();
1649 runJUnitTest(__test, __test.test_isMoreSpecificThan_transitive_recursive );
1650 });
1651 _ut.test('test_isMoreSpecificThan_transitive_superclass', () {
1652 final __test = new InterfaceTypeImplTest();
1653 runJUnitTest(__test, __test.test_isMoreSpecificThan_transitive_superclas s);
1654 });
1655 _ut.test('test_isSubtypeOf_directSubtype', () {
1656 final __test = new InterfaceTypeImplTest();
1657 runJUnitTest(__test, __test.test_isSubtypeOf_directSubtype);
1658 });
1659 _ut.test('test_isSubtypeOf_dynamic', () {
1660 final __test = new InterfaceTypeImplTest();
1661 runJUnitTest(__test, __test.test_isSubtypeOf_dynamic);
1662 });
1663 _ut.test('test_isSubtypeOf_function', () {
1664 final __test = new InterfaceTypeImplTest();
1665 runJUnitTest(__test, __test.test_isSubtypeOf_function);
1666 });
1667 _ut.test('test_isSubtypeOf_interface', () {
1668 final __test = new InterfaceTypeImplTest();
1669 runJUnitTest(__test, __test.test_isSubtypeOf_interface);
1670 });
1671 _ut.test('test_isSubtypeOf_mixins', () {
1672 final __test = new InterfaceTypeImplTest();
1673 runJUnitTest(__test, __test.test_isSubtypeOf_mixins);
1674 });
1675 _ut.test('test_isSubtypeOf_object', () {
1676 final __test = new InterfaceTypeImplTest();
1677 runJUnitTest(__test, __test.test_isSubtypeOf_object);
1678 });
1679 _ut.test('test_isSubtypeOf_self', () {
1680 final __test = new InterfaceTypeImplTest();
1681 runJUnitTest(__test, __test.test_isSubtypeOf_self);
1682 });
1683 _ut.test('test_isSubtypeOf_transitive_recursive', () {
1684 final __test = new InterfaceTypeImplTest();
1685 runJUnitTest(__test, __test.test_isSubtypeOf_transitive_recursive);
1686 });
1687 _ut.test('test_isSubtypeOf_transitive_superclass', () {
1688 final __test = new InterfaceTypeImplTest();
1689 runJUnitTest(__test, __test.test_isSubtypeOf_transitive_superclass);
1690 });
1691 _ut.test('test_isSubtypeOf_typeArguments', () {
1692 final __test = new InterfaceTypeImplTest();
1693 runJUnitTest(__test, __test.test_isSubtypeOf_typeArguments);
1694 });
1695 _ut.test('test_isSupertypeOf_directSupertype', () {
1696 final __test = new InterfaceTypeImplTest();
1697 runJUnitTest(__test, __test.test_isSupertypeOf_directSupertype);
1698 });
1699 _ut.test('test_isSupertypeOf_dynamic', () {
1700 final __test = new InterfaceTypeImplTest();
1701 runJUnitTest(__test, __test.test_isSupertypeOf_dynamic);
1702 });
1703 _ut.test('test_isSupertypeOf_indirectSupertype', () {
1704 final __test = new InterfaceTypeImplTest();
1705 runJUnitTest(__test, __test.test_isSupertypeOf_indirectSupertype);
1706 });
1707 _ut.test('test_isSupertypeOf_interface', () {
1708 final __test = new InterfaceTypeImplTest();
1709 runJUnitTest(__test, __test.test_isSupertypeOf_interface);
1710 });
1711 _ut.test('test_isSupertypeOf_mixins', () {
1712 final __test = new InterfaceTypeImplTest();
1713 runJUnitTest(__test, __test.test_isSupertypeOf_mixins);
1714 });
1715 _ut.test('test_isSupertypeOf_object', () {
1716 final __test = new InterfaceTypeImplTest();
1717 runJUnitTest(__test, __test.test_isSupertypeOf_object);
1718 });
1719 _ut.test('test_isSupertypeOf_self', () {
1720 final __test = new InterfaceTypeImplTest();
1721 runJUnitTest(__test, __test.test_isSupertypeOf_self);
1722 });
1723 _ut.test('test_lookUpGetter_implemented', () {
1724 final __test = new InterfaceTypeImplTest();
1725 runJUnitTest(__test, __test.test_lookUpGetter_implemented);
1726 });
1727 _ut.test('test_lookUpGetter_inherited', () {
1728 final __test = new InterfaceTypeImplTest();
1729 runJUnitTest(__test, __test.test_lookUpGetter_inherited);
1730 });
1731 _ut.test('test_lookUpGetter_recursive', () {
1732 final __test = new InterfaceTypeImplTest();
1733 runJUnitTest(__test, __test.test_lookUpGetter_recursive);
1734 });
1735 _ut.test('test_lookUpGetter_unimplemented', () {
1736 final __test = new InterfaceTypeImplTest();
1737 runJUnitTest(__test, __test.test_lookUpGetter_unimplemented);
1738 });
1739 _ut.test('test_lookUpMethod_implemented', () {
1740 final __test = new InterfaceTypeImplTest();
1741 runJUnitTest(__test, __test.test_lookUpMethod_implemented);
1742 });
1743 _ut.test('test_lookUpMethod_inherited', () {
1744 final __test = new InterfaceTypeImplTest();
1745 runJUnitTest(__test, __test.test_lookUpMethod_inherited);
1746 });
1747 _ut.test('test_lookUpMethod_parameterized', () {
1748 final __test = new InterfaceTypeImplTest();
1749 runJUnitTest(__test, __test.test_lookUpMethod_parameterized);
1750 });
1751 _ut.test('test_lookUpMethod_recursive', () {
1752 final __test = new InterfaceTypeImplTest();
1753 runJUnitTest(__test, __test.test_lookUpMethod_recursive);
1754 });
1755 _ut.test('test_lookUpMethod_unimplemented', () {
1756 final __test = new InterfaceTypeImplTest();
1757 runJUnitTest(__test, __test.test_lookUpMethod_unimplemented);
1758 });
1759 _ut.test('test_lookUpSetter_implemented', () {
1760 final __test = new InterfaceTypeImplTest();
1761 runJUnitTest(__test, __test.test_lookUpSetter_implemented);
1762 });
1763 _ut.test('test_lookUpSetter_inherited', () {
1764 final __test = new InterfaceTypeImplTest();
1765 runJUnitTest(__test, __test.test_lookUpSetter_inherited);
1766 });
1767 _ut.test('test_lookUpSetter_recursive', () {
1768 final __test = new InterfaceTypeImplTest();
1769 runJUnitTest(__test, __test.test_lookUpSetter_recursive);
1770 });
1771 _ut.test('test_lookUpSetter_unimplemented', () {
1772 final __test = new InterfaceTypeImplTest();
1773 runJUnitTest(__test, __test.test_lookUpSetter_unimplemented);
1774 });
1775 _ut.test('test_setTypeArguments', () {
1776 final __test = new InterfaceTypeImplTest();
1777 runJUnitTest(__test, __test.test_setTypeArguments);
1778 });
1779 _ut.test('test_substitute_equal', () {
1780 final __test = new InterfaceTypeImplTest();
1781 runJUnitTest(__test, __test.test_substitute_equal);
1782 });
1783 _ut.test('test_substitute_exception', () {
1784 final __test = new InterfaceTypeImplTest();
1785 runJUnitTest(__test, __test.test_substitute_exception);
1786 });
1787 _ut.test('test_substitute_notEqual', () {
1788 final __test = new InterfaceTypeImplTest();
1789 runJUnitTest(__test, __test.test_substitute_notEqual);
1790 });
1791 });
1792 }
1793 }
1794 /**
1795 * The class `ElementFactory` defines utility methods used to create elements fo r testing
1796 * purposes. The elements that are created are complete in the sense that as muc h of the element
1797 * model as can be created, given the provided information, has been created.
1798 */
1799 class ElementFactory {
1800
1801 /**
1802 * The element representing the class 'Object'.
1803 */
1804 static ClassElementImpl _objectElement;
1805 static ClassElementImpl classElement(String typeName, InterfaceType superclass Type, List<String> parameterNames) {
1806 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN ame));
1807 element.supertype = superclassType;
1808 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element);
1809 element.type = type;
1810 int count = parameterNames.length;
1811 if (count > 0) {
1812 List<TypeParameterElementImpl> typeParameters = new List<TypeParameterElem entImpl>(count);
1813 List<TypeParameterTypeImpl> typeParameterTypes = new List<TypeParameterTyp eImpl>(count);
1814 for (int i = 0; i < count; i++) {
1815 TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(AS TFactory.identifier3(parameterNames[i]));
1816 typeParameters[i] = typeParameter;
1817 typeParameterTypes[i] = new TypeParameterTypeImpl(typeParameter);
1818 typeParameter.type = typeParameterTypes[i];
1819 }
1820 element.typeParameters = typeParameters;
1821 type.typeArguments = typeParameterTypes;
1822 }
1823 return element;
1824 }
1825 static ClassElementImpl classElement2(String typeName, List<String> parameterN ames) => classElement(typeName, object.type, parameterNames);
1826 static ConstructorElementImpl constructorElement(ClassElement definingClass, S tring name) {
1827 Type2 type = definingClass.type;
1828 ConstructorElementImpl constructor = new ConstructorElementImpl(name == null ? null : ASTFactory.identifier3(name));
1829 constructor.returnType = type;
1830 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
1831 constructor.type = constructorType;
1832 return constructor;
1833 }
1834 static ExportElementImpl exportFor(LibraryElement exportedLibrary, List<Namesp aceCombinator> combinators) {
1835 ExportElementImpl spec = new ExportElementImpl();
1836 spec.exportedLibrary = exportedLibrary;
1837 spec.combinators = combinators;
1838 return spec;
1839 }
1840 static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, Type2 type) {
1841 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me));
1842 field.const3 = isConst;
1843 field.final2 = isFinal;
1844 field.static = isStatic;
1845 field.type = type;
1846 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
1847 getter.getter = true;
1848 getter.static = isStatic;
1849 getter.synthetic = true;
1850 getter.variable = field;
1851 getter.returnType = type;
1852 field.getter = getter;
1853 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1854 getter.type = getterType;
1855 if (!isConst && !isFinal) {
1856 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( field);
1857 setter.setter = true;
1858 setter.static = isStatic;
1859 setter.synthetic = true;
1860 setter.variable = field;
1861 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ e)];
1862 setter.returnType = VoidTypeImpl.instance;
1863 setter.type = new FunctionTypeImpl.con1(setter);
1864 field.setter = setter;
1865 }
1866 return field;
1867 }
1868 static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) = > new FieldFormalParameterElementImpl(name);
1869 static FunctionElementImpl functionElement(String functionName) => functionEle ment4(functionName, null, null, null, null);
1870 static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null);
1871 static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalP arameters) {
1872 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3(functionName));
1873 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
1874 functionElement.type = functionType;
1875 if (returnElement == null) {
1876 functionElement.returnType = VoidTypeImpl.instance;
1877 } else {
1878 functionElement.returnType = returnElement.type;
1879 }
1880 int normalCount = normalParameters == null ? 0 : normalParameters.length;
1881 int optionalCount = optionalParameters == null ? 0 : optionalParameters.leng th;
1882 int totalCount = normalCount + optionalCount;
1883 List<ParameterElement> parameters = new List<ParameterElement>(totalCount);
1884 for (int i = 0; i < totalCount; i++) {
1885 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory. identifier3("a${i}"));
1886 if (i < normalCount) {
1887 parameter.type = normalParameters[i].type;
1888 parameter.parameterKind = ParameterKind.REQUIRED;
1889 } else {
1890 parameter.type = optionalParameters[i - normalCount].type;
1891 parameter.parameterKind = ParameterKind.POSITIONAL;
1892 }
1893 parameters[i] = parameter;
1894 }
1895 functionElement.parameters = parameters;
1896 return functionElement;
1897 }
1898 static FunctionElementImpl functionElement4(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<String> names, List<Cla ssElement> namedParameters) {
1899 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3(functionName));
1900 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
1901 functionElement.type = functionType;
1902 int normalCount = normalParameters == null ? 0 : normalParameters.length;
1903 int nameCount = names == null ? 0 : names.length;
1904 int typeCount = namedParameters == null ? 0 : namedParameters.length;
1905 if (names != null && nameCount != typeCount) {
1906 throw new IllegalStateException("The passed String[] and ClassElement[] ar rays had different lengths.");
1907 }
1908 int totalCount = normalCount + nameCount;
1909 List<ParameterElement> parameters = new List<ParameterElement>(totalCount);
1910 for (int i = 0; i < totalCount; i++) {
1911 if (i < normalCount) {
1912 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactor y.identifier3("a${i}"));
1913 parameter.type = normalParameters[i].type;
1914 parameter.parameterKind = ParameterKind.REQUIRED;
1915 parameters[i] = parameter;
1916 } else {
1917 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactor y.identifier3(names[i - normalCount]));
1918 parameter.type = namedParameters[i - normalCount].type;
1919 parameter.parameterKind = ParameterKind.NAMED;
1920 parameters[i] = parameter;
1921 }
1922 }
1923 functionElement.parameters = parameters;
1924 if (returnElement == null) {
1925 functionElement.returnType = VoidTypeImpl.instance;
1926 } else {
1927 functionElement.returnType = returnElement.type;
1928 }
1929 return functionElement;
1930 }
1931 static FunctionElementImpl functionElement5(String functionName, List<ClassEle ment> normalParameters) => functionElement3(functionName, null, normalParameters , null);
1932 static FunctionElementImpl functionElement6(String functionName, List<ClassEle ment> normalParameters, List<ClassElement> optionalParameters) => functionElemen t3(functionName, null, normalParameters, optionalParameters);
1933 static FunctionElementImpl functionElement7(String functionName, List<ClassEle ment> normalParameters, List<String> names, List<ClassElement> namedParameters) => functionElement4(functionName, null, normalParameters, names, namedParameters );
1934 static ClassElementImpl get object {
1935 if (_objectElement == null) {
1936 _objectElement = classElement("Object", null as InterfaceType, []);
1937 }
1938 return _objectElement;
1939 }
1940 static PropertyAccessorElementImpl getterElement(String name, bool isStatic, T ype2 type) {
1941 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me));
1942 field.static = isStatic;
1943 field.synthetic = true;
1944 field.type = type;
1945 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
1946 getter.getter = true;
1947 getter.static = isStatic;
1948 getter.variable = field;
1949 getter.returnType = type;
1950 field.getter = getter;
1951 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
1952 getter.type = getterType;
1953 return getter;
1954 }
1955 static ImportElementImpl importFor(LibraryElement importedLibrary, PrefixEleme nt prefix, List<NamespaceCombinator> combinators) {
1956 ImportElementImpl spec = new ImportElementImpl();
1957 spec.importedLibrary = importedLibrary;
1958 spec.prefix = prefix;
1959 spec.combinators = combinators;
1960 return spec;
1961 }
1962 static LibraryElementImpl library(AnalysisContext context, String libraryName) {
1963 String fileName = "/${libraryName}.dart";
1964 FileBasedSource source = new FileBasedSource.con1(context.sourceFactory.cont entCache, FileUtilities2.createFile(fileName));
1965 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName);
1966 unit.source = source;
1967 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName]));
1968 library.definingCompilationUnit = unit;
1969 return library;
1970 }
1971 static LocalVariableElementImpl localVariableElement(Identifier name) => new L ocalVariableElementImpl(name);
1972 static LocalVariableElementImpl localVariableElement2(String name) => new Loca lVariableElementImpl(ASTFactory.identifier3(name));
1973 static MethodElementImpl methodElement(String methodName, Type2 returnType, Li st<Type2> argumentTypes) {
1974 MethodElementImpl method = new MethodElementImpl.con1(ASTFactory.identifier3 (methodName));
1975 int count = argumentTypes.length;
1976 List<ParameterElement> parameters = new List<ParameterElement>(count);
1977 for (int i = 0; i < count; i++) {
1978 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory. identifier3("a${i}"));
1979 parameter.type = argumentTypes[i];
1980 parameter.parameterKind = ParameterKind.REQUIRED;
1981 parameters[i] = parameter;
1982 }
1983 method.parameters = parameters;
1984 method.returnType = returnType;
1985 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method);
1986 method.type = methodType;
1987 return method;
1988 }
1989 static ParameterElementImpl namedParameter(String name) {
1990 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory.id entifier3(name));
1991 parameter.parameterKind = ParameterKind.NAMED;
1992 return parameter;
1993 }
1994 static ParameterElementImpl namedParameter2(String name, Type2 type) {
1995 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory.id entifier3(name));
1996 parameter.parameterKind = ParameterKind.NAMED;
1997 parameter.type = type;
1998 return parameter;
1999 }
2000 static ParameterElementImpl positionalParameter(String name) {
2001 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory.id entifier3(name));
2002 parameter.parameterKind = ParameterKind.POSITIONAL;
2003 return parameter;
2004 }
2005 static ParameterElementImpl positionalParameter2(String name, Type2 type) {
2006 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory.id entifier3(name));
2007 parameter.parameterKind = ParameterKind.POSITIONAL;
2008 parameter.type = type;
2009 return parameter;
2010 }
2011 static PrefixElementImpl prefix(String name) => new PrefixElementImpl(ASTFacto ry.identifier3(name));
2012 static ParameterElementImpl requiredParameter(String name) {
2013 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory.id entifier3(name));
2014 parameter.parameterKind = ParameterKind.REQUIRED;
2015 return parameter;
2016 }
2017 static ParameterElementImpl requiredParameter2(String name, Type2 type) {
2018 ParameterElementImpl parameter = new ParameterElementImpl.con1(ASTFactory.id entifier3(name));
2019 parameter.parameterKind = ParameterKind.REQUIRED;
2020 parameter.type = type;
2021 return parameter;
2022 }
2023 static PropertyAccessorElementImpl setterElement(String name, bool isStatic, T ype2 type) {
2024 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier3(na me));
2025 field.static = isStatic;
2026 field.synthetic = true;
2027 field.type = type;
2028 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
2029 getter.getter = true;
2030 getter.static = isStatic;
2031 getter.variable = field;
2032 getter.returnType = type;
2033 field.getter = getter;
2034 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
2035 getter.type = getterType;
2036 ParameterElementImpl parameter = requiredParameter2("a", type);
2037 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2(fi eld);
2038 setter.setter = true;
2039 setter.static = isStatic;
2040 setter.synthetic = true;
2041 setter.variable = field;
2042 setter.parameters = <ParameterElement> [parameter];
2043 setter.returnType = VoidTypeImpl.instance;
2044 setter.type = new FunctionTypeImpl.con1(setter);
2045 field.setter = setter;
2046 return setter;
2047 }
2048 static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.con1(name);
2049 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => ne w TopLevelVariableElementImpl.con2(name);
2050 static TopLevelVariableElementImpl topLevelVariableElement3(String name, bool isFinal, Type2 type) {
2051 TopLevelVariableElementImpl variable = new TopLevelVariableElementImpl.con2( name);
2052 variable.final2 = isFinal;
2053 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(va riable);
2054 getter.getter = true;
2055 getter.static = true;
2056 getter.synthetic = true;
2057 getter.variable = variable;
2058 getter.returnType = type;
2059 variable.getter = getter;
2060 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
2061 getter.type = getterType;
2062 if (!isFinal) {
2063 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( variable);
2064 setter.setter = true;
2065 setter.static = true;
2066 setter.synthetic = true;
2067 setter.variable = variable;
2068 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ e)];
2069 setter.returnType = VoidTypeImpl.instance;
2070 setter.type = new FunctionTypeImpl.con1(setter);
2071 variable.setter = setter;
2072 }
2073 return variable;
2074 }
2075 }
2076 class ElementKindTest extends EngineTestCase {
2077 void test_of_nonNull() {
2078 JUnitTestCase.assertSame(ElementKind.CLASS, ElementKind.of(ElementFactory.cl assElement2("A", [])));
2079 }
2080 void test_of_null() {
2081 JUnitTestCase.assertSame(ElementKind.ERROR, ElementKind.of(null));
2082 }
2083 static dartSuite() {
2084 _ut.group('ElementKindTest', () {
2085 _ut.test('test_of_nonNull', () {
2086 final __test = new ElementKindTest();
2087 runJUnitTest(__test, __test.test_of_nonNull);
2088 });
2089 _ut.test('test_of_null', () {
2090 final __test = new ElementKindTest();
2091 runJUnitTest(__test, __test.test_of_null);
2092 });
2093 });
2094 }
2095 }
2096 class ClassElementImplTest extends EngineTestCase {
2097 void test_getAllSupertypes_interface() {
2098 ClassElement classA = ElementFactory.classElement2("A", []);
2099 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
2100 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
2101 InterfaceType typeObject = classA.supertype;
2102 InterfaceType typeA = classA.type;
2103 InterfaceType typeB = classB.type;
2104 InterfaceType typeC = elementC.type;
2105 elementC.interfaces = <InterfaceType> [typeB];
2106 List<InterfaceType> supers = elementC.allSupertypes;
2107 List<InterfaceType> types = new List<InterfaceType>();
2108 types.addAll(supers);
2109 JUnitTestCase.assertTrue(types.contains(typeA));
2110 JUnitTestCase.assertTrue(types.contains(typeB));
2111 JUnitTestCase.assertTrue(types.contains(typeObject));
2112 JUnitTestCase.assertFalse(types.contains(typeC));
2113 }
2114 void test_getAllSupertypes_mixins() {
2115 ClassElement classA = ElementFactory.classElement2("A", []);
2116 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
2117 ClassElementImpl classC = ElementFactory.classElement2("C", []);
2118 InterfaceType typeObject = classA.supertype;
2119 InterfaceType typeA = classA.type;
2120 InterfaceType typeB = classB.type;
2121 InterfaceType typeC = classC.type;
2122 classC.mixins = <InterfaceType> [typeB];
2123 List<InterfaceType> supers = classC.allSupertypes;
2124 List<InterfaceType> types = new List<InterfaceType>();
2125 types.addAll(supers);
2126 JUnitTestCase.assertFalse(types.contains(typeA));
2127 JUnitTestCase.assertTrue(types.contains(typeB));
2128 JUnitTestCase.assertTrue(types.contains(typeObject));
2129 JUnitTestCase.assertFalse(types.contains(typeC));
2130 }
2131 void test_getAllSupertypes_recursive() {
2132 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2133 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2134 classA.supertype = classB.type;
2135 List<InterfaceType> supers = classB.allSupertypes;
2136 EngineTestCase.assertLength(1, supers);
2137 }
2138 void test_getMethod_declared() {
2139 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2140 String methodName = "m";
2141 MethodElement method = ElementFactory.methodElement(methodName, null, []);
2142 classA.methods = <MethodElement> [method];
2143 JUnitTestCase.assertSame(method, classA.getMethod(methodName));
2144 }
2145 void test_getMethod_undeclared() {
2146 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2147 String methodName = "m";
2148 MethodElement method = ElementFactory.methodElement(methodName, null, []);
2149 classA.methods = <MethodElement> [method];
2150 JUnitTestCase.assertNull(classA.getMethod("${methodName}x"));
2151 }
2152 void test_hasNonFinalField_false_const() {
2153 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2154 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, true, classA.type)];
2155 JUnitTestCase.assertFalse(classA.hasNonFinalField());
2156 }
2157 void test_hasNonFinalField_false_final() {
2158 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2159 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, true , false, classA.type)];
2160 JUnitTestCase.assertFalse(classA.hasNonFinalField());
2161 }
2162 void test_hasNonFinalField_false_recursive() {
2163 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2164 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2165 classA.supertype = classB.type;
2166 JUnitTestCase.assertFalse(classA.hasNonFinalField());
2167 }
2168 void test_hasNonFinalField_true_immediate() {
2169 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2170 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)];
2171 JUnitTestCase.assertTrue(classA.hasNonFinalField());
2172 }
2173 void test_hasNonFinalField_true_inherited() {
2174 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2175 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2176 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)];
2177 JUnitTestCase.assertTrue(classB.hasNonFinalField());
2178 }
2179 void test_lookUpGetter_declared() {
2180 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2181 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2182 String getterName = "g";
2183 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
2184 classA.accessors = <PropertyAccessorElement> [getter];
2185 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA];
2186 JUnitTestCase.assertSame(getter, classA.lookUpGetter(getterName, library));
2187 }
2188 void test_lookUpGetter_inherited() {
2189 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2190 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2191 String getterName = "g";
2192 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
2193 classA.accessors = <PropertyAccessorElement> [getter];
2194 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2195 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA, classB];
2196 JUnitTestCase.assertSame(getter, classB.lookUpGetter(getterName, library));
2197 }
2198 void test_lookUpGetter_undeclared() {
2199 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2200 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2201 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA];
2202 JUnitTestCase.assertNull(classA.lookUpGetter("g", library));
2203 }
2204 void test_lookUpGetter_undeclared_recursive() {
2205 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2206 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2207 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2208 classA.supertype = classB.type;
2209 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA, classB];
2210 JUnitTestCase.assertNull(classA.lookUpGetter("g", library));
2211 }
2212 void test_lookUpMethod_declared() {
2213 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2214 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2215 String methodName = "m";
2216 MethodElement method = ElementFactory.methodElement(methodName, null, []);
2217 classA.methods = <MethodElement> [method];
2218 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA];
2219 JUnitTestCase.assertSame(method, classA.lookUpMethod(methodName, library));
2220 }
2221 void test_lookUpMethod_inherited() {
2222 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2223 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2224 String methodName = "m";
2225 MethodElement method = ElementFactory.methodElement(methodName, null, []);
2226 classA.methods = <MethodElement> [method];
2227 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2228 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA, classB];
2229 JUnitTestCase.assertSame(method, classB.lookUpMethod(methodName, library));
2230 }
2231 void test_lookUpMethod_undeclared() {
2232 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2233 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2234 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA];
2235 JUnitTestCase.assertNull(classA.lookUpMethod("m", library));
2236 }
2237 void test_lookUpMethod_undeclared_recursive() {
2238 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2239 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2240 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2241 classA.supertype = classB.type;
2242 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA, classB];
2243 JUnitTestCase.assertNull(classA.lookUpMethod("m", library));
2244 }
2245 void test_lookUpSetter_declared() {
2246 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2247 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2248 String setterName = "s";
2249 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
2250 classA.accessors = <PropertyAccessorElement> [setter];
2251 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA];
2252 JUnitTestCase.assertSame(setter, classA.lookUpSetter(setterName, library));
2253 }
2254 void test_lookUpSetter_inherited() {
2255 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2256 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2257 String setterName = "s";
2258 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
2259 classA.accessors = <PropertyAccessorElement> [setter];
2260 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2261 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA, classB];
2262 JUnitTestCase.assertSame(setter, classB.lookUpSetter(setterName, library));
2263 }
2264 void test_lookUpSetter_undeclared() {
2265 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2266 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2267 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA];
2268 JUnitTestCase.assertNull(classA.lookUpSetter("s", library));
2269 }
2270 void test_lookUpSetter_undeclared_recursive() {
2271 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2272 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2273 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
2274 classA.supertype = classB.type;
2275 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classA, classB];
2276 JUnitTestCase.assertNull(classA.lookUpSetter("s", library));
2277 }
2278 static dartSuite() {
2279 _ut.group('ClassElementImplTest', () {
2280 _ut.test('test_getAllSupertypes_interface', () {
2281 final __test = new ClassElementImplTest();
2282 runJUnitTest(__test, __test.test_getAllSupertypes_interface);
2283 });
2284 _ut.test('test_getAllSupertypes_mixins', () {
2285 final __test = new ClassElementImplTest();
2286 runJUnitTest(__test, __test.test_getAllSupertypes_mixins);
2287 });
2288 _ut.test('test_getAllSupertypes_recursive', () {
2289 final __test = new ClassElementImplTest();
2290 runJUnitTest(__test, __test.test_getAllSupertypes_recursive);
2291 });
2292 _ut.test('test_getMethod_declared', () {
2293 final __test = new ClassElementImplTest();
2294 runJUnitTest(__test, __test.test_getMethod_declared);
2295 });
2296 _ut.test('test_getMethod_undeclared', () {
2297 final __test = new ClassElementImplTest();
2298 runJUnitTest(__test, __test.test_getMethod_undeclared);
2299 });
2300 _ut.test('test_hasNonFinalField_false_const', () {
2301 final __test = new ClassElementImplTest();
2302 runJUnitTest(__test, __test.test_hasNonFinalField_false_const);
2303 });
2304 _ut.test('test_hasNonFinalField_false_final', () {
2305 final __test = new ClassElementImplTest();
2306 runJUnitTest(__test, __test.test_hasNonFinalField_false_final);
2307 });
2308 _ut.test('test_hasNonFinalField_false_recursive', () {
2309 final __test = new ClassElementImplTest();
2310 runJUnitTest(__test, __test.test_hasNonFinalField_false_recursive);
2311 });
2312 _ut.test('test_hasNonFinalField_true_immediate', () {
2313 final __test = new ClassElementImplTest();
2314 runJUnitTest(__test, __test.test_hasNonFinalField_true_immediate);
2315 });
2316 _ut.test('test_hasNonFinalField_true_inherited', () {
2317 final __test = new ClassElementImplTest();
2318 runJUnitTest(__test, __test.test_hasNonFinalField_true_inherited);
2319 });
2320 _ut.test('test_lookUpGetter_declared', () {
2321 final __test = new ClassElementImplTest();
2322 runJUnitTest(__test, __test.test_lookUpGetter_declared);
2323 });
2324 _ut.test('test_lookUpGetter_inherited', () {
2325 final __test = new ClassElementImplTest();
2326 runJUnitTest(__test, __test.test_lookUpGetter_inherited);
2327 });
2328 _ut.test('test_lookUpGetter_undeclared', () {
2329 final __test = new ClassElementImplTest();
2330 runJUnitTest(__test, __test.test_lookUpGetter_undeclared);
2331 });
2332 _ut.test('test_lookUpGetter_undeclared_recursive', () {
2333 final __test = new ClassElementImplTest();
2334 runJUnitTest(__test, __test.test_lookUpGetter_undeclared_recursive);
2335 });
2336 _ut.test('test_lookUpMethod_declared', () {
2337 final __test = new ClassElementImplTest();
2338 runJUnitTest(__test, __test.test_lookUpMethod_declared);
2339 });
2340 _ut.test('test_lookUpMethod_inherited', () {
2341 final __test = new ClassElementImplTest();
2342 runJUnitTest(__test, __test.test_lookUpMethod_inherited);
2343 });
2344 _ut.test('test_lookUpMethod_undeclared', () {
2345 final __test = new ClassElementImplTest();
2346 runJUnitTest(__test, __test.test_lookUpMethod_undeclared);
2347 });
2348 _ut.test('test_lookUpMethod_undeclared_recursive', () {
2349 final __test = new ClassElementImplTest();
2350 runJUnitTest(__test, __test.test_lookUpMethod_undeclared_recursive);
2351 });
2352 _ut.test('test_lookUpSetter_declared', () {
2353 final __test = new ClassElementImplTest();
2354 runJUnitTest(__test, __test.test_lookUpSetter_declared);
2355 });
2356 _ut.test('test_lookUpSetter_inherited', () {
2357 final __test = new ClassElementImplTest();
2358 runJUnitTest(__test, __test.test_lookUpSetter_inherited);
2359 });
2360 _ut.test('test_lookUpSetter_undeclared', () {
2361 final __test = new ClassElementImplTest();
2362 runJUnitTest(__test, __test.test_lookUpSetter_undeclared);
2363 });
2364 _ut.test('test_lookUpSetter_undeclared_recursive', () {
2365 final __test = new ClassElementImplTest();
2366 runJUnitTest(__test, __test.test_lookUpSetter_undeclared_recursive);
2367 });
2368 });
2369 }
2370 }
2371 class ElementImplTest extends EngineTestCase {
2372 void test_equals() {
2373 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2374 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
2375 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classElement];
2376 FieldElement field = ElementFactory.fieldElement("next", false, false, false , classElement.type);
2377 classElement.fields = <FieldElement> [field];
2378 JUnitTestCase.assertTrue(field == field);
2379 JUnitTestCase.assertFalse(field == field.getter);
2380 JUnitTestCase.assertFalse(field == field.setter);
2381 JUnitTestCase.assertFalse(field.getter == field.setter);
2382 }
2383 void test_isAccessibleIn_private_differentLibrary() {
2384 AnalysisContextImpl context = createAnalysisContext();
2385 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
2386 ClassElement classElement = ElementFactory.classElement2("_C", []);
2387 ((library1.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classElement];
2388 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
2389 JUnitTestCase.assertFalse(classElement.isAccessibleIn(library2));
2390 }
2391 void test_isAccessibleIn_private_sameLibrary() {
2392 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2393 ClassElement classElement = ElementFactory.classElement2("_C", []);
2394 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classElement];
2395 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library));
2396 }
2397 void test_isAccessibleIn_public_differentLibrary() {
2398 AnalysisContextImpl context = createAnalysisContext();
2399 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
2400 ClassElement classElement = ElementFactory.classElement2("C", []);
2401 ((library1.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classElement];
2402 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
2403 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library2));
2404 }
2405 void test_isAccessibleIn_public_sameLibrary() {
2406 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2407 ClassElement classElement = ElementFactory.classElement2("C", []);
2408 ((library.definingCompilationUnit as CompilationUnitElementImpl)).types = <C lassElement> [classElement];
2409 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library));
2410 }
2411 void test_SORT_BY_OFFSET() {
2412 ClassElementImpl classElementA = ElementFactory.classElement2("A", []);
2413 classElementA.nameOffset = 1;
2414 ClassElementImpl classElementB = ElementFactory.classElement2("B", []);
2415 classElementB.nameOffset = 2;
2416 JUnitTestCase.assertEquals(0, Element.SORT_BY_OFFSET(classElementA, classEle mentA));
2417 JUnitTestCase.assertTrue(Element.SORT_BY_OFFSET(classElementA, classElementB ) < 0);
2418 JUnitTestCase.assertTrue(Element.SORT_BY_OFFSET(classElementB, classElementA ) > 0);
2419 }
2420 static dartSuite() {
2421 _ut.group('ElementImplTest', () {
2422 _ut.test('test_SORT_BY_OFFSET', () {
2423 final __test = new ElementImplTest();
2424 runJUnitTest(__test, __test.test_SORT_BY_OFFSET);
2425 });
2426 _ut.test('test_equals', () {
2427 final __test = new ElementImplTest();
2428 runJUnitTest(__test, __test.test_equals);
2429 });
2430 _ut.test('test_isAccessibleIn_private_differentLibrary', () {
2431 final __test = new ElementImplTest();
2432 runJUnitTest(__test, __test.test_isAccessibleIn_private_differentLibrary );
2433 });
2434 _ut.test('test_isAccessibleIn_private_sameLibrary', () {
2435 final __test = new ElementImplTest();
2436 runJUnitTest(__test, __test.test_isAccessibleIn_private_sameLibrary);
2437 });
2438 _ut.test('test_isAccessibleIn_public_differentLibrary', () {
2439 final __test = new ElementImplTest();
2440 runJUnitTest(__test, __test.test_isAccessibleIn_public_differentLibrary) ;
2441 });
2442 _ut.test('test_isAccessibleIn_public_sameLibrary', () {
2443 final __test = new ElementImplTest();
2444 runJUnitTest(__test, __test.test_isAccessibleIn_public_sameLibrary);
2445 });
2446 });
2447 }
2448 }
2449 class FunctionTypeImplTest extends EngineTestCase {
2450 void test_creation() {
2451 JUnitTestCase.assertNotNull(new FunctionTypeImpl.con1(new FunctionElementImp l.con1(ASTFactory.identifier3("f"))));
2452 }
2453 void test_getElement() {
2454 FunctionElementImpl typeElement = new FunctionElementImpl.con1(ASTFactory.id entifier3("f"));
2455 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement);
2456 JUnitTestCase.assertEquals(typeElement, type.element);
2457 }
2458 void test_getNamedParameterTypes() {
2459 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2460 Map<String, Type2> types = type.namedParameterTypes;
2461 EngineTestCase.assertSize2(0, types);
2462 }
2463 void test_getNormalParameterTypes() {
2464 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2465 List<Type2> types = type.normalParameterTypes;
2466 EngineTestCase.assertLength(0, types);
2467 }
2468 void test_getReturnType() {
2469 Type2 expectedReturnType = VoidTypeImpl.instance;
2470 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3("f"));
2471 functionElement.returnType = expectedReturnType;
2472 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement);
2473 Type2 returnType = type.returnType;
2474 JUnitTestCase.assertEquals(expectedReturnType, returnType);
2475 }
2476 void test_getTypeArguments() {
2477 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2478 List<Type2> types = type.typeArguments;
2479 EngineTestCase.assertLength(0, types);
2480 }
2481 void test_hashCode_element() {
2482 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier3("f")));
2483 type.hashCode;
2484 }
2485 void test_hashCode_noElement() {
2486 FunctionTypeImpl type = new FunctionTypeImpl.con1(null as ExecutableElement) ;
2487 type.hashCode;
2488 }
2489 void test_isAssignableTo_normalAndPositionalArgs() {
2490 ClassElement a = ElementFactory.classElement2("A", []);
2491 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
2492 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
2493 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2494 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
2495 JUnitTestCase.assertTrue(t.isAssignableTo(s));
2496 JUnitTestCase.assertFalse(s.isAssignableTo(t));
2497 }
2498 void test_isSubtypeOf_baseCase_classFunction() {
2499 ClassElementImpl functionElement = ElementFactory.classElement2("Function", []);
2500 InterfaceTypeImpl functionType = new InterfaceTypeImpl_23(functionElement);
2501 FunctionType f = ElementFactory.functionElement("f").type;
2502 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType));
2503 }
2504 void test_isSubtypeOf_baseCase_notFunctionType() {
2505 FunctionType f = ElementFactory.functionElement("f").type;
2506 InterfaceType t = ElementFactory.classElement2("C", []).type;
2507 JUnitTestCase.assertFalse(f.isSubtypeOf(t));
2508 }
2509 void test_isSubtypeOf_baseCase_null() {
2510 FunctionType f = ElementFactory.functionElement("f").type;
2511 JUnitTestCase.assertFalse(f.isSubtypeOf(null));
2512 }
2513 void test_isSubtypeOf_baseCase_self() {
2514 FunctionType f = ElementFactory.functionElement("f").type;
2515 JUnitTestCase.assertTrue(f.isSubtypeOf(f));
2516 }
2517 void test_isSubtypeOf_namedParameters_isAssignable() {
2518 ClassElement a = ElementFactory.classElement2("A", []);
2519 ClassElement b = ElementFactory.classElement("B", a.type, []);
2520 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
2521 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
2522 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2523 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
2524 }
2525 void test_isSubtypeOf_namedParameters_isNotAssignable() {
2526 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("A", [])]).type;
2527 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("B", [])]).type;
2528 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2529 }
2530 void test_isSubtypeOf_namedParameters_namesDifferent() {
2531 ClassElement a = ElementFactory.classElement2("A", []);
2532 ClassElement b = ElementFactory.classElement("B", a.type, []);
2533 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
2534 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "diff"], <ClassElement> [b]).type;
2535 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2536 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
2537 }
2538 void test_isSubtypeOf_namedParameters_orderOfParams() {
2539 ClassElement a = ElementFactory.classElement2("A", []);
2540 ClassElement b = ElementFactory.classElement("B", a.type, []);
2541 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
2542 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
2543 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2544 }
2545 void test_isSubtypeOf_namedParameters_orderOfParams2() {
2546 ClassElement a = ElementFactory.classElement2("A", []);
2547 ClassElement b = ElementFactory.classElement("B", a.type, []);
2548 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "B"], <ClassElement> [b]).type;
2549 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
2550 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2551 }
2552 void test_isSubtypeOf_namedParameters_orderOfParams3() {
2553 ClassElement a = ElementFactory.classElement2("A", []);
2554 ClassElement b = ElementFactory.classElement("B", a.type, []);
2555 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
2556 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B"], <ClassElement> [b]).type;
2557 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2558 }
2559 void test_isSubtypeOf_namedParameters_sHasMoreParams() {
2560 ClassElement a = ElementFactory.classElement2("A", []);
2561 ClassElement b = ElementFactory.classElement("B", a.type, []);
2562 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
2563 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name", "name2"], <ClassElement> [b, b]).type;
2564 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2565 }
2566 void test_isSubtypeOf_namedParameters_tHasMoreParams() {
2567 ClassElement a = ElementFactory.classElement2("A", []);
2568 ClassElement b = ElementFactory.classElement("B", a.type, []);
2569 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name", "name2"], <ClassElement> [a, a]).type;
2570 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
2571 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2572 }
2573 void test_isSubtypeOf_normalAndPositionalArgs_1() {
2574 ClassElement a = ElementFactory.classElement2("A", []);
2575 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
2576 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
2577 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2578 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
2579 }
2580 void test_isSubtypeOf_normalAndPositionalArgs_2() {
2581 ClassElement a = ElementFactory.classElement2("A", []);
2582 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a], <C lassElement> [a]).type;
2583 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
2584 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2585 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
2586 }
2587 void test_isSubtypeOf_normalAndPositionalArgs_3() {
2588 ClassElement a = ElementFactory.classElement2("A", []);
2589 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
2590 FunctionType s = ElementFactory.functionElement("s").type;
2591 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2592 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
2593 }
2594 void test_isSubtypeOf_normalAndPositionalArgs_4() {
2595 ClassElement a = ElementFactory.classElement2("A", []);
2596 ClassElement b = ElementFactory.classElement2("B", []);
2597 ClassElement c = ElementFactory.classElement2("C", []);
2598 ClassElement d = ElementFactory.classElement2("D", []);
2599 ClassElement e = ElementFactory.classElement2("E", []);
2600 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a, b], <ClassElement> [c, d, e]).type;
2601 FunctionType s = ElementFactory.functionElement6("s", <ClassElement> [a, b, c], <ClassElement> [d]).type;
2602 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2603 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
2604 }
2605 void test_isSubtypeOf_normalParameters_isAssignable() {
2606 ClassElement a = ElementFactory.classElement2("A", []);
2607 ClassElement b = ElementFactory.classElement("B", a.type, []);
2608 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
2609 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
2610 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2611 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
2612 }
2613 void test_isSubtypeOf_normalParameters_isNotAssignable() {
2614 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen tFactory.classElement2("A", [])]).type;
2615 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen tFactory.classElement2("B", [])]).type;
2616 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2617 }
2618 void test_isSubtypeOf_normalParameters_sHasMoreParams() {
2619 ClassElement a = ElementFactory.classElement2("A", []);
2620 ClassElement b = ElementFactory.classElement("B", a.type, []);
2621 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
2622 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b]) .type;
2623 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2624 }
2625 void test_isSubtypeOf_normalParameters_tHasMoreParams() {
2626 ClassElement a = ElementFactory.classElement2("A", []);
2627 ClassElement b = ElementFactory.classElement("B", a.type, []);
2628 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a]) .type;
2629 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
2630 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2631 }
2632 void test_isSubtypeOf_Object() {
2633 FunctionType f = ElementFactory.functionElement("f").type;
2634 InterfaceType t = ElementFactory.object.type;
2635 JUnitTestCase.assertTrue(f.isSubtypeOf(t));
2636 }
2637 void test_isSubtypeOf_positionalParameters_isAssignable() {
2638 ClassElement a = ElementFactory.classElement2("A", []);
2639 ClassElement b = ElementFactory.classElement("B", a.type, []);
2640 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
2641 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
2642 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2643 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
2644 }
2645 void test_isSubtypeOf_positionalParameters_isNotAssignable() {
2646 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ ElementFactory.classElement2("A", [])]).type;
2647 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ ElementFactory.classElement2("B", [])]).type;
2648 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2649 }
2650 void test_isSubtypeOf_positionalParameters_sHasMoreParams() {
2651 ClassElement a = ElementFactory.classElement2("A", []);
2652 ClassElement b = ElementFactory.classElement("B", a.type, []);
2653 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
2654 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b, b]).type;
2655 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2656 }
2657 void test_isSubtypeOf_positionalParameters_tHasMoreParams() {
2658 ClassElement a = ElementFactory.classElement2("A", []);
2659 ClassElement b = ElementFactory.classElement("B", a.type, []);
2660 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a, a]).type;
2661 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
2662 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2663 }
2664 void test_isSubtypeOf_returnType_sIsVoid() {
2665 FunctionType t = ElementFactory.functionElement("t").type;
2666 FunctionType s = ElementFactory.functionElement("s").type;
2667 JUnitTestCase.assertTrue(VoidTypeImpl.instance == s.returnType);
2668 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2669 }
2670 void test_isSubtypeOf_returnType_tAssignableToS() {
2671 ClassElement a = ElementFactory.classElement2("A", []);
2672 ClassElement b = ElementFactory.classElement("B", a.type, []);
2673 FunctionType t = ElementFactory.functionElement2("t", a).type;
2674 FunctionType s = ElementFactory.functionElement2("s", b).type;
2675 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
2676 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
2677 }
2678 void test_isSubtypeOf_returnType_tNotAssignableToS() {
2679 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A", [])).type;
2680 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl ement2("B", [])).type;
2681 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2682 }
2683 void test_isSubtypeOf_typeParameters_matchesBounds() {
2684 TestTypeProvider provider = new TestTypeProvider();
2685 InterfaceType boolType = provider.boolType;
2686 InterfaceType stringType = provider.stringType;
2687 TypeParameterElementImpl parameterB = new TypeParameterElementImpl(ASTFactor y.identifier3("B"));
2688 parameterB.bound = boolType;
2689 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB);
2690 TypeParameterElementImpl parameterS = new TypeParameterElementImpl(ASTFactor y.identifier3("S"));
2691 parameterS.bound = stringType;
2692 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS);
2693 FunctionElementImpl functionAliasElement = new FunctionElementImpl.con1(ASTF actory.identifier3("func"));
2694 functionAliasElement.parameters = <ParameterElement> [
2695 ElementFactory.requiredParameter2("a", typeB),
2696 ElementFactory.positionalParameter2("b", typeS)];
2697 functionAliasElement.returnType = stringType;
2698 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias Element);
2699 functionAliasElement.type = functionAliasType;
2700 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3("f"));
2701 functionElement.parameters = <ParameterElement> [
2702 ElementFactory.requiredParameter2("c", boolType),
2703 ElementFactory.positionalParameter2("d", stringType)];
2704 functionElement.returnType = provider.dynamicType;
2705 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2706 functionElement.type = functionType;
2707 JUnitTestCase.assertTrue(functionType.isAssignableTo(functionAliasType));
2708 }
2709 void test_isSubtypeOf_wrongFunctionType_normal_named() {
2710 ClassElement a = ElementFactory.classElement2("A", []);
2711 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
2712 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
2713 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2714 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
2715 }
2716 void test_isSubtypeOf_wrongFunctionType_optional_named() {
2717 ClassElement a = ElementFactory.classElement2("A", []);
2718 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
2719 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
2720 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
2721 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
2722 }
2723 void test_setTypeArguments() {
2724 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]);
2725 MethodElementImpl methodElement = new MethodElementImpl.con1(ASTFactory.iden tifier3("m"));
2726 enclosingClass.methods = <MethodElement> [methodElement];
2727 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement);
2728 Type2 expectedType = enclosingClass.typeParameters[0].type;
2729 type.typeArguments = <Type2> [expectedType];
2730 List<Type2> arguments = type.typeArguments;
2731 EngineTestCase.assertLength(1, arguments);
2732 JUnitTestCase.assertEquals(expectedType, arguments[0]);
2733 }
2734 void test_substitute2_equal() {
2735 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]);
2736 TypeParameterType parameterType = definingClass.typeParameters[0].type;
2737 MethodElementImpl functionElement = new MethodElementImpl.con1(ASTFactory.id entifier3("m"));
2738 String namedParameterName = "c";
2739 functionElement.parameters = <ParameterElement> [
2740 ElementFactory.requiredParameter2("a", parameterType),
2741 ElementFactory.positionalParameter2("b", parameterType),
2742 ElementFactory.namedParameter2(namedParameterName, parameterType)];
2743 functionElement.returnType = parameterType;
2744 definingClass.methods = <MethodElement> [functionElement];
2745 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2746 functionType.typeArguments = <Type2> [parameterType];
2747 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier3("D")));
2748 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]);
2749 JUnitTestCase.assertEquals(argumentType, result.returnType);
2750 List<Type2> normalParameters = result.normalParameterTypes;
2751 EngineTestCase.assertLength(1, normalParameters);
2752 JUnitTestCase.assertEquals(argumentType, normalParameters[0]);
2753 List<Type2> optionalParameters = result.optionalParameterTypes;
2754 EngineTestCase.assertLength(1, optionalParameters);
2755 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]);
2756 Map<String, Type2> namedParameters = result.namedParameterTypes;
2757 EngineTestCase.assertSize2(1, namedParameters);
2758 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] );
2759 }
2760 void test_substitute2_notEqual() {
2761 Type2 returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFactor y.identifier3("R")));
2762 Type2 normalParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl( ASTFactory.identifier3("A")));
2763 Type2 optionalParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(ASTFactory.identifier3("B")));
2764 Type2 namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl(A STFactory.identifier3("C")));
2765 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier3("f"));
2766 String namedParameterName = "c";
2767 functionElement.parameters = <ParameterElement> [
2768 ElementFactory.requiredParameter2("a", normalParameterType),
2769 ElementFactory.positionalParameter2("b", optionalParameterType),
2770 ElementFactory.namedParameter2(namedParameterName, namedParameterType)];
2771 functionElement.returnType = returnType;
2772 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
2773 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier3("D")));
2774 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara meterElementImpl(ASTFactory.identifier3("E")));
2775 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]);
2776 JUnitTestCase.assertEquals(returnType, result.returnType);
2777 List<Type2> normalParameters = result.normalParameterTypes;
2778 EngineTestCase.assertLength(1, normalParameters);
2779 JUnitTestCase.assertEquals(normalParameterType, normalParameters[0]);
2780 List<Type2> optionalParameters = result.optionalParameterTypes;
2781 EngineTestCase.assertLength(1, optionalParameters);
2782 JUnitTestCase.assertEquals(optionalParameterType, optionalParameters[0]);
2783 Map<String, Type2> namedParameters = result.namedParameterTypes;
2784 EngineTestCase.assertSize2(1, namedParameters);
2785 JUnitTestCase.assertEquals(namedParameterType, namedParameters[namedParamete rName]);
2786 }
2787 static dartSuite() {
2788 _ut.group('FunctionTypeImplTest', () {
2789 _ut.test('test_creation', () {
2790 final __test = new FunctionTypeImplTest();
2791 runJUnitTest(__test, __test.test_creation);
2792 });
2793 _ut.test('test_getElement', () {
2794 final __test = new FunctionTypeImplTest();
2795 runJUnitTest(__test, __test.test_getElement);
2796 });
2797 _ut.test('test_getNamedParameterTypes', () {
2798 final __test = new FunctionTypeImplTest();
2799 runJUnitTest(__test, __test.test_getNamedParameterTypes);
2800 });
2801 _ut.test('test_getNormalParameterTypes', () {
2802 final __test = new FunctionTypeImplTest();
2803 runJUnitTest(__test, __test.test_getNormalParameterTypes);
2804 });
2805 _ut.test('test_getReturnType', () {
2806 final __test = new FunctionTypeImplTest();
2807 runJUnitTest(__test, __test.test_getReturnType);
2808 });
2809 _ut.test('test_getTypeArguments', () {
2810 final __test = new FunctionTypeImplTest();
2811 runJUnitTest(__test, __test.test_getTypeArguments);
2812 });
2813 _ut.test('test_hashCode_element', () {
2814 final __test = new FunctionTypeImplTest();
2815 runJUnitTest(__test, __test.test_hashCode_element);
2816 });
2817 _ut.test('test_hashCode_noElement', () {
2818 final __test = new FunctionTypeImplTest();
2819 runJUnitTest(__test, __test.test_hashCode_noElement);
2820 });
2821 _ut.test('test_isAssignableTo_normalAndPositionalArgs', () {
2822 final __test = new FunctionTypeImplTest();
2823 runJUnitTest(__test, __test.test_isAssignableTo_normalAndPositionalArgs) ;
2824 });
2825 _ut.test('test_isSubtypeOf_Object', () {
2826 final __test = new FunctionTypeImplTest();
2827 runJUnitTest(__test, __test.test_isSubtypeOf_Object);
2828 });
2829 _ut.test('test_isSubtypeOf_baseCase_classFunction', () {
2830 final __test = new FunctionTypeImplTest();
2831 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_classFunction);
2832 });
2833 _ut.test('test_isSubtypeOf_baseCase_notFunctionType', () {
2834 final __test = new FunctionTypeImplTest();
2835 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_notFunctionType);
2836 });
2837 _ut.test('test_isSubtypeOf_baseCase_null', () {
2838 final __test = new FunctionTypeImplTest();
2839 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_null);
2840 });
2841 _ut.test('test_isSubtypeOf_baseCase_self', () {
2842 final __test = new FunctionTypeImplTest();
2843 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_self);
2844 });
2845 _ut.test('test_isSubtypeOf_namedParameters_isAssignable', () {
2846 final __test = new FunctionTypeImplTest();
2847 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isAssignabl e);
2848 });
2849 _ut.test('test_isSubtypeOf_namedParameters_isNotAssignable', () {
2850 final __test = new FunctionTypeImplTest();
2851 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isNotAssign able);
2852 });
2853 _ut.test('test_isSubtypeOf_namedParameters_namesDifferent', () {
2854 final __test = new FunctionTypeImplTest();
2855 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_namesDiffer ent);
2856 });
2857 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams', () {
2858 final __test = new FunctionTypeImplTest();
2859 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms);
2860 });
2861 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams2', () {
2862 final __test = new FunctionTypeImplTest();
2863 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms2);
2864 });
2865 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams3', () {
2866 final __test = new FunctionTypeImplTest();
2867 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms3);
2868 });
2869 _ut.test('test_isSubtypeOf_namedParameters_sHasMoreParams', () {
2870 final __test = new FunctionTypeImplTest();
2871 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_sHasMorePar ams);
2872 });
2873 _ut.test('test_isSubtypeOf_namedParameters_tHasMoreParams', () {
2874 final __test = new FunctionTypeImplTest();
2875 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_tHasMorePar ams);
2876 });
2877 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_1', () {
2878 final __test = new FunctionTypeImplTest();
2879 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_1);
2880 });
2881 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_2', () {
2882 final __test = new FunctionTypeImplTest();
2883 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_2);
2884 });
2885 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_3', () {
2886 final __test = new FunctionTypeImplTest();
2887 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_3);
2888 });
2889 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_4', () {
2890 final __test = new FunctionTypeImplTest();
2891 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_4);
2892 });
2893 _ut.test('test_isSubtypeOf_normalParameters_isAssignable', () {
2894 final __test = new FunctionTypeImplTest();
2895 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isAssignab le);
2896 });
2897 _ut.test('test_isSubtypeOf_normalParameters_isNotAssignable', () {
2898 final __test = new FunctionTypeImplTest();
2899 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isNotAssig nable);
2900 });
2901 _ut.test('test_isSubtypeOf_normalParameters_sHasMoreParams', () {
2902 final __test = new FunctionTypeImplTest();
2903 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_sHasMorePa rams);
2904 });
2905 _ut.test('test_isSubtypeOf_normalParameters_tHasMoreParams', () {
2906 final __test = new FunctionTypeImplTest();
2907 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_tHasMorePa rams);
2908 });
2909 _ut.test('test_isSubtypeOf_positionalParameters_isAssignable', () {
2910 final __test = new FunctionTypeImplTest();
2911 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_isAssi gnable);
2912 });
2913 _ut.test('test_isSubtypeOf_positionalParameters_isNotAssignable', () {
2914 final __test = new FunctionTypeImplTest();
2915 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_isNotA ssignable);
2916 });
2917 _ut.test('test_isSubtypeOf_positionalParameters_sHasMoreParams', () {
2918 final __test = new FunctionTypeImplTest();
2919 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_sHasMo reParams);
2920 });
2921 _ut.test('test_isSubtypeOf_positionalParameters_tHasMoreParams', () {
2922 final __test = new FunctionTypeImplTest();
2923 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_tHasMo reParams);
2924 });
2925 _ut.test('test_isSubtypeOf_returnType_sIsVoid', () {
2926 final __test = new FunctionTypeImplTest();
2927 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_sIsVoid);
2928 });
2929 _ut.test('test_isSubtypeOf_returnType_tAssignableToS', () {
2930 final __test = new FunctionTypeImplTest();
2931 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tAssignableToS);
2932 });
2933 _ut.test('test_isSubtypeOf_returnType_tNotAssignableToS', () {
2934 final __test = new FunctionTypeImplTest();
2935 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tNotAssignableTo S);
2936 });
2937 _ut.test('test_isSubtypeOf_typeParameters_matchesBounds', () {
2938 final __test = new FunctionTypeImplTest();
2939 runJUnitTest(__test, __test.test_isSubtypeOf_typeParameters_matchesBound s);
2940 });
2941 _ut.test('test_isSubtypeOf_wrongFunctionType_normal_named', () {
2942 final __test = new FunctionTypeImplTest();
2943 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_normal_na med);
2944 });
2945 _ut.test('test_isSubtypeOf_wrongFunctionType_optional_named', () {
2946 final __test = new FunctionTypeImplTest();
2947 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_optional_ named);
2948 });
2949 _ut.test('test_setTypeArguments', () {
2950 final __test = new FunctionTypeImplTest();
2951 runJUnitTest(__test, __test.test_setTypeArguments);
2952 });
2953 _ut.test('test_substitute2_equal', () {
2954 final __test = new FunctionTypeImplTest();
2955 runJUnitTest(__test, __test.test_substitute2_equal);
2956 });
2957 _ut.test('test_substitute2_notEqual', () {
2958 final __test = new FunctionTypeImplTest();
2959 runJUnitTest(__test, __test.test_substitute2_notEqual);
2960 });
2961 });
2962 }
2963 }
2964 class InterfaceTypeImpl_23 extends InterfaceTypeImpl {
2965 InterfaceTypeImpl_23(ClassElement arg0) : super.con1(arg0);
2966 bool get isDartCoreFunction => true;
2967 }
2968 main() {
2969 ElementKindTest.dartSuite();
2970 FunctionTypeImplTest.dartSuite();
2971 InterfaceTypeImplTest.dartSuite();
2972 TypeParameterTypeImplTest.dartSuite();
2973 ClassElementImplTest.dartSuite();
2974 ElementLocationImplTest.dartSuite();
2975 ElementImplTest.dartSuite();
2976 LibraryElementImplTest.dartSuite();
2977 MultiplyDefinedElementImplTest.dartSuite();
2978 }
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