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

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

Issue 12502002: Update analyzer-experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.element_test; 4 library engine.element_test;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:io';
7 import 'package:analyzer-experimental/src/generated/java_core.dart'; 8 import 'package:analyzer-experimental/src/generated/java_core.dart';
8 import 'package:analyzer-experimental/src/generated/java_engine.dart'; 9 import 'package:analyzer-experimental/src/generated/java_engine.dart';
10 import 'package:analyzer-experimental/src/generated/java_engine_io.dart';
9 import 'package:analyzer-experimental/src/generated/java_junit.dart'; 11 import 'package:analyzer-experimental/src/generated/java_junit.dart';
10 import 'package:analyzer-experimental/src/generated/source.dart'; 12 import 'package:analyzer-experimental/src/generated/source_io.dart';
11 import 'package:analyzer-experimental/src/generated/error.dart'; 13 import 'package:analyzer-experimental/src/generated/error.dart';
12 import 'package:analyzer-experimental/src/generated/scanner.dart'; 14 import 'package:analyzer-experimental/src/generated/scanner.dart';
15 import 'package:analyzer-experimental/src/generated/utilities_dart.dart';
13 import 'package:analyzer-experimental/src/generated/ast.dart' hide Annotation; 16 import 'package:analyzer-experimental/src/generated/ast.dart' hide Annotation;
14 import 'package:analyzer-experimental/src/generated/element.dart' hide Annotatio n; 17 import 'package:analyzer-experimental/src/generated/element.dart' hide Annotatio n;
15 import 'package:analyzer-experimental/src/generated/engine.dart' show AnalysisCo ntext, AnalysisContextImpl; 18 import 'package:analyzer-experimental/src/generated/engine.dart' show AnalysisCo ntext, AnalysisContextImpl;
16 import 'package:unittest/unittest.dart' as _ut; 19 import 'package:unittest/unittest.dart' as _ut;
17 import 'test_support.dart'; 20 import 'test_support.dart';
18 import 'scanner_test.dart' show TokenFactory; 21 import 'scanner_test.dart' show TokenFactory;
19 import 'ast_test.dart' show ASTFactory; 22 import 'ast_test.dart' show ASTFactory;
20 23
21 class ElementLocationImplTest extends EngineTestCase { 24 class ElementLocationImplTest extends EngineTestCase {
22 void test_create_encoding() { 25 void test_create_encoding() {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 final __test = new ElementLocationImplTest(); 87 final __test = new ElementLocationImplTest();
85 runJUnitTest(__test, __test.test_getComponents); 88 runJUnitTest(__test, __test.test_getComponents);
86 }); 89 });
87 _ut.test('test_getEncoding', () { 90 _ut.test('test_getEncoding', () {
88 final __test = new ElementLocationImplTest(); 91 final __test = new ElementLocationImplTest();
89 runJUnitTest(__test, __test.test_getEncoding); 92 runJUnitTest(__test, __test.test_getEncoding);
90 }); 93 });
91 }); 94 });
92 } 95 }
93 } 96 }
94 class FunctionTypeImplTest extends EngineTestCase {
95 void test_creation() {
96 JUnitTestCase.assertNotNull(new FunctionTypeImpl.con1(new FunctionElementImp l.con1(ASTFactory.identifier2("f"))));
97 }
98 void test_getElement() {
99 FunctionElementImpl typeElement = new FunctionElementImpl.con1(ASTFactory.id entifier2("f"));
100 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement);
101 JUnitTestCase.assertEquals(typeElement, type.element);
102 }
103 void test_getNamedParameterTypes() {
104 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
105 Map<String, Type2> types = type.namedParameterTypes;
106 EngineTestCase.assertSize2(0, types);
107 }
108 void test_getNormalParameterTypes() {
109 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
110 List<Type2> types = type.normalParameterTypes;
111 EngineTestCase.assertLength(0, types);
112 }
113 void test_getReturnType() {
114 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
115 Type2 returnType5 = type.returnType;
116 JUnitTestCase.assertEquals(VoidTypeImpl.instance, returnType5);
117 }
118 void test_getTypeArguments() {
119 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
120 List<Type2> types = type.typeArguments;
121 EngineTestCase.assertLength(0, types);
122 }
123 void test_hashCode_element() {
124 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
125 type.hashCode;
126 }
127 void test_hashCode_noElement() {
128 FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement ));
129 type.hashCode;
130 }
131 void test_isSubtypeOf_baseCase_notFunctionType() {
132 FunctionType f = ElementFactory.functionElement("f").type;
133 InterfaceType t = ElementFactory.classElement2("C", []).type;
134 JUnitTestCase.assertFalse(f.isSubtypeOf(t));
135 }
136 void test_isSubtypeOf_baseCase_null() {
137 FunctionType f = ElementFactory.functionElement("f").type;
138 JUnitTestCase.assertFalse(f.isSubtypeOf(null));
139 }
140 void test_isSubtypeOf_baseCase_self() {
141 FunctionType f = ElementFactory.functionElement("f").type;
142 JUnitTestCase.assertTrue(f.isSubtypeOf(f));
143 }
144 void test_isSubtypeOf_namedParameters_isAssignable() {
145 ClassElement a = ElementFactory.classElement2("A", []);
146 ClassElement b = ElementFactory.classElement("B", a.type, []);
147 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
148 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
149 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
150 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
151 }
152 void test_isSubtypeOf_namedParameters_isNotAssignable() {
153 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("A", [])]).type;
154 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("B", [])]).type;
155 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
156 }
157 void test_isSubtypeOf_namedParameters_namesDifferent() {
158 ClassElement a = ElementFactory.classElement2("A", []);
159 ClassElement b = ElementFactory.classElement("B", a.type, []);
160 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
161 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "diff"], <ClassElement> [b]).type;
162 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
163 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
164 }
165 void test_isSubtypeOf_namedParameters_orderOfParams() {
166 ClassElement a = ElementFactory.classElement2("A", []);
167 ClassElement b = ElementFactory.classElement("B", a.type, []);
168 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
169 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
170 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
171 }
172 void test_isSubtypeOf_namedParameters_orderOfParams2() {
173 ClassElement a = ElementFactory.classElement2("A", []);
174 ClassElement b = ElementFactory.classElement("B", a.type, []);
175 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "B"], <ClassElement> [b]).type;
176 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
177 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
178 }
179 void test_isSubtypeOf_namedParameters_orderOfParams3() {
180 ClassElement a = ElementFactory.classElement2("A", []);
181 ClassElement b = ElementFactory.classElement("B", a.type, []);
182 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
183 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B"], <ClassElement> [b]).type;
184 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
185 }
186 void test_isSubtypeOf_namedParameters_sHasMoreParams() {
187 ClassElement a = ElementFactory.classElement2("A", []);
188 ClassElement b = ElementFactory.classElement("B", a.type, []);
189 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
190 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name", "name2"], <ClassElement> [b, b]).type;
191 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
192 }
193 void test_isSubtypeOf_namedParameters_tHasMoreParams() {
194 ClassElement a = ElementFactory.classElement2("A", []);
195 ClassElement b = ElementFactory.classElement("B", a.type, []);
196 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name", "name2"], <ClassElement> [a, a]).type;
197 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
198 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
199 }
200 void test_isSubtypeOf_normalParameters_isAssignable() {
201 ClassElement a = ElementFactory.classElement2("A", []);
202 ClassElement b = ElementFactory.classElement("B", a.type, []);
203 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
204 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
205 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
206 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
207 }
208 void test_isSubtypeOf_normalParameters_isNotAssignable() {
209 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen tFactory.classElement2("A", [])]).type;
210 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen tFactory.classElement2("B", [])]).type;
211 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
212 }
213 void test_isSubtypeOf_normalParameters_sHasMoreParams() {
214 ClassElement a = ElementFactory.classElement2("A", []);
215 ClassElement b = ElementFactory.classElement("B", a.type, []);
216 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
217 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b]) .type;
218 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
219 }
220 void test_isSubtypeOf_normalParameters_tHasMoreParams() {
221 ClassElement a = ElementFactory.classElement2("A", []);
222 ClassElement b = ElementFactory.classElement("B", a.type, []);
223 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a]) .type;
224 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
225 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
226 }
227 void test_isSubtypeOf_optionalParameters_isAssignable() {
228 ClassElement a = ElementFactory.classElement2("A", []);
229 ClassElement b = ElementFactory.classElement("B", a.type, []);
230 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
231 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
232 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
233 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
234 }
235 void test_isSubtypeOf_optionalParameters_isNotAssignable() {
236 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ ElementFactory.classElement2("A", [])]).type;
237 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ ElementFactory.classElement2("B", [])]).type;
238 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
239 }
240 void test_isSubtypeOf_optionalParameters_sHasMoreParams() {
241 ClassElement a = ElementFactory.classElement2("A", []);
242 ClassElement b = ElementFactory.classElement("B", a.type, []);
243 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
244 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b, b]).type;
245 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
246 }
247 void test_isSubtypeOf_optionalParameters_tHasMoreParams() {
248 ClassElement a = ElementFactory.classElement2("A", []);
249 ClassElement b = ElementFactory.classElement("B", a.type, []);
250 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a, a]).type;
251 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
252 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
253 }
254 void test_isSubtypeOf_returnType_sIsVoid() {
255 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A", [])).type;
256 FunctionType s = ElementFactory.functionElement("s").type;
257 JUnitTestCase.assertTrue(VoidTypeImpl.instance == s.returnType);
258 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
259 }
260 void test_isSubtypeOf_returnType_tAssignableToS() {
261 ClassElement a = ElementFactory.classElement2("A", []);
262 ClassElement b = ElementFactory.classElement("B", a.type, []);
263 FunctionType t = ElementFactory.functionElement2("t", a).type;
264 FunctionType s = ElementFactory.functionElement2("s", b).type;
265 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
266 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
267 }
268 void test_isSubtypeOf_returnType_tNotAssignableToS() {
269 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A", [])).type;
270 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl ement2("B", [])).type;
271 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
272 }
273 void test_isSubtypeOf_wrongFunctionType_normal_named() {
274 ClassElement a = ElementFactory.classElement2("A", []);
275 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
276 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
277 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
278 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
279 }
280 void test_isSubtypeOf_wrongFunctionType_normal_optional() {
281 ClassElement a = ElementFactory.classElement2("A", []);
282 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
283 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ a]).type;
284 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
285 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
286 }
287 void test_isSubtypeOf_wrongFunctionType_optional_named() {
288 ClassElement a = ElementFactory.classElement2("A", []);
289 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
290 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
291 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
292 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
293 }
294 void test_setNamedParameterTypes() {
295 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
296 LinkedHashMap<String, Type2> expectedTypes = new LinkedHashMap<String, Type2 >();
297 expectedTypes["a"] = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFact ory.identifier2("C")));
298 type.namedParameterTypes = expectedTypes;
299 Map<String, Type2> types = type.namedParameterTypes;
300 JUnitTestCase.assertEquals(expectedTypes, types);
301 }
302 void test_setNormalParameterTypes() {
303 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
304 List<Type2> expectedTypes = <Type2> [new InterfaceTypeImpl.con1(new ClassEle mentImpl(ASTFactory.identifier2("C")))];
305 type.normalParameterTypes = expectedTypes;
306 List<Type2> types = type.normalParameterTypes;
307 JUnitTestCase.assertEquals(expectedTypes, types);
308 }
309 void test_setReturnType() {
310 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
311 Type2 expectedType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFact ory.identifier2("C")));
312 type.returnType = expectedType;
313 Type2 returnType6 = type.returnType;
314 JUnitTestCase.assertEquals(expectedType, returnType6);
315 }
316 void test_setTypeArguments() {
317 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
318 Type2 expectedType = new TypeVariableTypeImpl(new TypeVariableElementImpl(AS TFactory.identifier2("C")));
319 type.typeArguments = <Type2> [expectedType];
320 List<Type2> arguments = type.typeArguments;
321 EngineTestCase.assertLength(1, arguments);
322 JUnitTestCase.assertEquals(expectedType, arguments[0]);
323 }
324 void test_substitute2_equal() {
325 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier2("f")));
326 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier2("E")));
327 functionType.returnType = parameterType;
328 functionType.normalParameterTypes = <Type2> [parameterType];
329 functionType.optionalParameterTypes = <Type2> [parameterType];
330 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>();
331 String namedParameterName = "c";
332 namedParameterTypes[namedParameterName] = parameterType;
333 functionType.namedParameterTypes = namedParameterTypes;
334 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("D")));
335 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]);
336 JUnitTestCase.assertEquals(argumentType, result.returnType);
337 List<Type2> normalParameters = result.normalParameterTypes;
338 EngineTestCase.assertLength(1, normalParameters);
339 JUnitTestCase.assertEquals(argumentType, normalParameters[0]);
340 List<Type2> optionalParameters = result.optionalParameterTypes;
341 EngineTestCase.assertLength(1, optionalParameters);
342 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]);
343 Map<String, Type2> namedParameters = result.namedParameterTypes;
344 EngineTestCase.assertSize2(1, namedParameters);
345 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] );
346 }
347 void test_substitute2_notEqual() {
348 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier2("f")));
349 Type2 returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFactor y.identifier2("R")));
350 Type2 normalParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl( ASTFactory.identifier2("A")));
351 Type2 optionalParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(ASTFactory.identifier2("B")));
352 Type2 namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl(A STFactory.identifier2("C")));
353 functionType.returnType = returnType;
354 functionType.normalParameterTypes = <Type2> [normalParameterType];
355 functionType.optionalParameterTypes = <Type2> [optionalParameterType];
356 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>();
357 String namedParameterName = "c";
358 namedParameterTypes[namedParameterName] = namedParameterType;
359 functionType.namedParameterTypes = namedParameterTypes;
360 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("D")));
361 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier2("E")));
362 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]);
363 JUnitTestCase.assertEquals(returnType, result.returnType);
364 List<Type2> normalParameters = result.normalParameterTypes;
365 EngineTestCase.assertLength(1, normalParameters);
366 JUnitTestCase.assertEquals(normalParameterType, normalParameters[0]);
367 List<Type2> optionalParameters = result.optionalParameterTypes;
368 EngineTestCase.assertLength(1, optionalParameters);
369 JUnitTestCase.assertEquals(optionalParameterType, optionalParameters[0]);
370 Map<String, Type2> namedParameters = result.namedParameterTypes;
371 EngineTestCase.assertSize2(1, namedParameters);
372 JUnitTestCase.assertEquals(namedParameterType, namedParameters[namedParamete rName]);
373 }
374 static dartSuite() {
375 _ut.group('FunctionTypeImplTest', () {
376 _ut.test('test_creation', () {
377 final __test = new FunctionTypeImplTest();
378 runJUnitTest(__test, __test.test_creation);
379 });
380 _ut.test('test_getElement', () {
381 final __test = new FunctionTypeImplTest();
382 runJUnitTest(__test, __test.test_getElement);
383 });
384 _ut.test('test_getNamedParameterTypes', () {
385 final __test = new FunctionTypeImplTest();
386 runJUnitTest(__test, __test.test_getNamedParameterTypes);
387 });
388 _ut.test('test_getNormalParameterTypes', () {
389 final __test = new FunctionTypeImplTest();
390 runJUnitTest(__test, __test.test_getNormalParameterTypes);
391 });
392 _ut.test('test_getReturnType', () {
393 final __test = new FunctionTypeImplTest();
394 runJUnitTest(__test, __test.test_getReturnType);
395 });
396 _ut.test('test_getTypeArguments', () {
397 final __test = new FunctionTypeImplTest();
398 runJUnitTest(__test, __test.test_getTypeArguments);
399 });
400 _ut.test('test_hashCode_element', () {
401 final __test = new FunctionTypeImplTest();
402 runJUnitTest(__test, __test.test_hashCode_element);
403 });
404 _ut.test('test_hashCode_noElement', () {
405 final __test = new FunctionTypeImplTest();
406 runJUnitTest(__test, __test.test_hashCode_noElement);
407 });
408 _ut.test('test_isSubtypeOf_baseCase_notFunctionType', () {
409 final __test = new FunctionTypeImplTest();
410 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_notFunctionType);
411 });
412 _ut.test('test_isSubtypeOf_baseCase_null', () {
413 final __test = new FunctionTypeImplTest();
414 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_null);
415 });
416 _ut.test('test_isSubtypeOf_baseCase_self', () {
417 final __test = new FunctionTypeImplTest();
418 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_self);
419 });
420 _ut.test('test_isSubtypeOf_namedParameters_isAssignable', () {
421 final __test = new FunctionTypeImplTest();
422 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isAssignabl e);
423 });
424 _ut.test('test_isSubtypeOf_namedParameters_isNotAssignable', () {
425 final __test = new FunctionTypeImplTest();
426 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isNotAssign able);
427 });
428 _ut.test('test_isSubtypeOf_namedParameters_namesDifferent', () {
429 final __test = new FunctionTypeImplTest();
430 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_namesDiffer ent);
431 });
432 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams', () {
433 final __test = new FunctionTypeImplTest();
434 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms);
435 });
436 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams2', () {
437 final __test = new FunctionTypeImplTest();
438 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms2);
439 });
440 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams3', () {
441 final __test = new FunctionTypeImplTest();
442 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms3);
443 });
444 _ut.test('test_isSubtypeOf_namedParameters_sHasMoreParams', () {
445 final __test = new FunctionTypeImplTest();
446 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_sHasMorePar ams);
447 });
448 _ut.test('test_isSubtypeOf_namedParameters_tHasMoreParams', () {
449 final __test = new FunctionTypeImplTest();
450 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_tHasMorePar ams);
451 });
452 _ut.test('test_isSubtypeOf_normalParameters_isAssignable', () {
453 final __test = new FunctionTypeImplTest();
454 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isAssignab le);
455 });
456 _ut.test('test_isSubtypeOf_normalParameters_isNotAssignable', () {
457 final __test = new FunctionTypeImplTest();
458 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isNotAssig nable);
459 });
460 _ut.test('test_isSubtypeOf_normalParameters_sHasMoreParams', () {
461 final __test = new FunctionTypeImplTest();
462 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_sHasMorePa rams);
463 });
464 _ut.test('test_isSubtypeOf_normalParameters_tHasMoreParams', () {
465 final __test = new FunctionTypeImplTest();
466 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_tHasMorePa rams);
467 });
468 _ut.test('test_isSubtypeOf_optionalParameters_isAssignable', () {
469 final __test = new FunctionTypeImplTest();
470 runJUnitTest(__test, __test.test_isSubtypeOf_optionalParameters_isAssign able);
471 });
472 _ut.test('test_isSubtypeOf_optionalParameters_isNotAssignable', () {
473 final __test = new FunctionTypeImplTest();
474 runJUnitTest(__test, __test.test_isSubtypeOf_optionalParameters_isNotAss ignable);
475 });
476 _ut.test('test_isSubtypeOf_optionalParameters_sHasMoreParams', () {
477 final __test = new FunctionTypeImplTest();
478 runJUnitTest(__test, __test.test_isSubtypeOf_optionalParameters_sHasMore Params);
479 });
480 _ut.test('test_isSubtypeOf_optionalParameters_tHasMoreParams', () {
481 final __test = new FunctionTypeImplTest();
482 runJUnitTest(__test, __test.test_isSubtypeOf_optionalParameters_tHasMore Params);
483 });
484 _ut.test('test_isSubtypeOf_returnType_sIsVoid', () {
485 final __test = new FunctionTypeImplTest();
486 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_sIsVoid);
487 });
488 _ut.test('test_isSubtypeOf_returnType_tAssignableToS', () {
489 final __test = new FunctionTypeImplTest();
490 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tAssignableToS);
491 });
492 _ut.test('test_isSubtypeOf_returnType_tNotAssignableToS', () {
493 final __test = new FunctionTypeImplTest();
494 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tNotAssignableTo S);
495 });
496 _ut.test('test_isSubtypeOf_wrongFunctionType_normal_named', () {
497 final __test = new FunctionTypeImplTest();
498 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_normal_na med);
499 });
500 _ut.test('test_isSubtypeOf_wrongFunctionType_normal_optional', () {
501 final __test = new FunctionTypeImplTest();
502 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_normal_op tional);
503 });
504 _ut.test('test_isSubtypeOf_wrongFunctionType_optional_named', () {
505 final __test = new FunctionTypeImplTest();
506 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_optional_ named);
507 });
508 _ut.test('test_setNamedParameterTypes', () {
509 final __test = new FunctionTypeImplTest();
510 runJUnitTest(__test, __test.test_setNamedParameterTypes);
511 });
512 _ut.test('test_setNormalParameterTypes', () {
513 final __test = new FunctionTypeImplTest();
514 runJUnitTest(__test, __test.test_setNormalParameterTypes);
515 });
516 _ut.test('test_setReturnType', () {
517 final __test = new FunctionTypeImplTest();
518 runJUnitTest(__test, __test.test_setReturnType);
519 });
520 _ut.test('test_setTypeArguments', () {
521 final __test = new FunctionTypeImplTest();
522 runJUnitTest(__test, __test.test_setTypeArguments);
523 });
524 _ut.test('test_substitute2_equal', () {
525 final __test = new FunctionTypeImplTest();
526 runJUnitTest(__test, __test.test_substitute2_equal);
527 });
528 _ut.test('test_substitute2_notEqual', () {
529 final __test = new FunctionTypeImplTest();
530 runJUnitTest(__test, __test.test_substitute2_notEqual);
531 });
532 });
533 }
534 }
535 class LibraryElementImplTest extends EngineTestCase { 97 class LibraryElementImplTest extends EngineTestCase {
536 void test_creation() { 98 void test_creation() {
537 JUnitTestCase.assertNotNull(new LibraryElementImpl(new AnalysisContextImpl() , ASTFactory.libraryIdentifier2(["l"]))); 99 JUnitTestCase.assertNotNull(new LibraryElementImpl(new AnalysisContextImpl() , ASTFactory.libraryIdentifier2(["l"])));
538 } 100 }
539 void test_getImportedLibraries() { 101 void test_getImportedLibraries() {
540 AnalysisContext context = new AnalysisContextImpl(); 102 AnalysisContext context = new AnalysisContextImpl();
541 LibraryElementImpl library1 = ElementFactory.library(context, "l1"); 103 LibraryElementImpl library1 = ElementFactory.library(context, "l1");
542 LibraryElementImpl library2 = ElementFactory.library(context, "l2"); 104 LibraryElementImpl library2 = ElementFactory.library(context, "l2");
543 LibraryElementImpl library3 = ElementFactory.library(context, "l3"); 105 LibraryElementImpl library3 = ElementFactory.library(context, "l3");
544 LibraryElementImpl library4 = ElementFactory.library(context, "l4"); 106 LibraryElementImpl library4 = ElementFactory.library(context, "l4");
545 PrefixElement prefixA = new PrefixElementImpl(ASTFactory.identifier2("a")); 107 PrefixElement prefixA = new PrefixElementImpl(ASTFactory.identifier2("a"));
546 PrefixElement prefixB = new PrefixElementImpl(ASTFactory.identifier2("b")); 108 PrefixElement prefixB = new PrefixElementImpl(ASTFactory.identifier2("b"));
547 List<ImportElementImpl> imports = [ElementFactory.importFor(library2, null, []), ElementFactory.importFor(library2, prefixB, []), ElementFactory.importFor(l ibrary3, null, []), ElementFactory.importFor(library3, prefixA, []), ElementFact ory.importFor(library3, prefixB, []), ElementFactory.importFor(library4, prefixA , [])]; 109 List<ImportElementImpl> imports = [ElementFactory.importFor(library2, null, []), ElementFactory.importFor(library2, prefixB, []), ElementFactory.importFor(l ibrary3, null, []), ElementFactory.importFor(library3, prefixA, []), ElementFact ory.importFor(library3, prefixB, []), ElementFactory.importFor(library4, prefixA , [])];
548 library1.imports = imports; 110 library1.imports = imports;
549 List<LibraryElement> libraries = library1.importedLibraries; 111 List<LibraryElement> libraries = library1.importedLibraries;
550 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library2, library3, library4], libraries); 112 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library2, library3, library4], libraries);
551 } 113 }
552 void test_getPrefixes() { 114 void test_getPrefixes() {
553 AnalysisContext context = new AnalysisContextImpl(); 115 AnalysisContext context = new AnalysisContextImpl();
554 LibraryElementImpl library17 = ElementFactory.library(context, "l1"); 116 LibraryElementImpl library18 = ElementFactory.library(context, "l1");
555 PrefixElement prefixA = new PrefixElementImpl(ASTFactory.identifier2("a")); 117 PrefixElement prefixA = new PrefixElementImpl(ASTFactory.identifier2("a"));
556 PrefixElement prefixB = new PrefixElementImpl(ASTFactory.identifier2("b")); 118 PrefixElement prefixB = new PrefixElementImpl(ASTFactory.identifier2("b"));
557 List<ImportElementImpl> imports = [ElementFactory.importFor(ElementFactory.l ibrary(context, "l2"), null, []), ElementFactory.importFor(ElementFactory.librar y(context, "l3"), null, []), ElementFactory.importFor(ElementFactory.library(con text, "l4"), prefixA, []), ElementFactory.importFor(ElementFactory.library(conte xt, "l5"), prefixA, []), ElementFactory.importFor(ElementFactory.library(context , "l6"), prefixB, [])]; 119 List<ImportElementImpl> imports = [ElementFactory.importFor(ElementFactory.l ibrary(context, "l2"), null, []), ElementFactory.importFor(ElementFactory.librar y(context, "l3"), null, []), ElementFactory.importFor(ElementFactory.library(con text, "l4"), prefixA, []), ElementFactory.importFor(ElementFactory.library(conte xt, "l5"), prefixA, []), ElementFactory.importFor(ElementFactory.library(context , "l6"), prefixB, [])];
558 library17.imports = imports; 120 library18.imports = imports;
559 List<PrefixElement> prefixes2 = library17.prefixes; 121 List<PrefixElement> prefixes2 = library18.prefixes;
560 EngineTestCase.assertLength(2, prefixes2); 122 EngineTestCase.assertLength(2, prefixes2);
561 if (identical(prefixA, prefixes2[0])) { 123 if (identical(prefixA, prefixes2[0])) {
562 JUnitTestCase.assertEquals(prefixB, prefixes2[1]); 124 JUnitTestCase.assertSame(prefixB, prefixes2[1]);
563 } else { 125 } else {
564 JUnitTestCase.assertEquals(prefixB, prefixes2[0]); 126 JUnitTestCase.assertSame(prefixB, prefixes2[0]);
565 JUnitTestCase.assertEquals(prefixA, prefixes2[1]); 127 JUnitTestCase.assertSame(prefixA, prefixes2[1]);
566 } 128 }
567 } 129 }
568 void test_setImports() { 130 void test_setImports() {
569 AnalysisContext context = new AnalysisContextImpl(); 131 AnalysisContext context = new AnalysisContextImpl();
570 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["l1"])); 132 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["l1"]));
571 List<ImportElementImpl> expectedImports = [ElementFactory.importFor(ElementF actory.library(context, "l2"), null, []), ElementFactory.importFor(ElementFactor y.library(context, "l3"), null, [])]; 133 List<ImportElementImpl> expectedImports = [ElementFactory.importFor(ElementF actory.library(context, "l2"), null, []), ElementFactory.importFor(ElementFactor y.library(context, "l3"), null, [])];
572 library.imports = expectedImports; 134 library.imports = expectedImports;
573 List<ImportElement> actualImports = library.imports; 135 List<ImportElement> actualImports = library.imports;
574 EngineTestCase.assertLength(expectedImports.length, actualImports); 136 EngineTestCase.assertLength(expectedImports.length, actualImports);
575 for (int i = 0; i < actualImports.length; i++) { 137 for (int i = 0; i < actualImports.length; i++) {
576 JUnitTestCase.assertEquals(expectedImports[i], actualImports[i]); 138 JUnitTestCase.assertSame(expectedImports[i], actualImports[i]);
577 } 139 }
578 } 140 }
579 static dartSuite() { 141 static dartSuite() {
580 _ut.group('LibraryElementImplTest', () { 142 _ut.group('LibraryElementImplTest', () {
581 _ut.test('test_creation', () { 143 _ut.test('test_creation', () {
582 final __test = new LibraryElementImplTest(); 144 final __test = new LibraryElementImplTest();
583 runJUnitTest(__test, __test.test_creation); 145 runJUnitTest(__test, __test.test_creation);
584 }); 146 });
585 _ut.test('test_getImportedLibraries', () { 147 _ut.test('test_getImportedLibraries', () {
586 final __test = new LibraryElementImplTest(); 148 final __test = new LibraryElementImplTest();
587 runJUnitTest(__test, __test.test_getImportedLibraries); 149 runJUnitTest(__test, __test.test_getImportedLibraries);
588 }); 150 });
589 _ut.test('test_getPrefixes', () { 151 // _ut.test('test_getPrefixes', () {
590 final __test = new LibraryElementImplTest(); 152 // final __test = new LibraryElementImplTest();
591 runJUnitTest(__test, __test.test_getPrefixes); 153 // runJUnitTest(__test, __test.test_getPrefixes);
592 }); 154 // });
593 _ut.test('test_setImports', () { 155 _ut.test('test_setImports', () {
594 final __test = new LibraryElementImplTest(); 156 final __test = new LibraryElementImplTest();
595 runJUnitTest(__test, __test.test_setImports); 157 runJUnitTest(__test, __test.test_setImports);
596 }); 158 });
597 }); 159 });
598 } 160 }
599 } 161 }
162 class InterfaceTypeImplTest extends EngineTestCase {
163 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() {
164 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
165 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
166 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
167 ClassElementImpl elementD = ElementFactory.classElement2("D", []);
168 ClassElementImpl elementE = ElementFactory.classElement2("E", []);
169 elementB.interfaces = <InterfaceType> [elementA.type];
170 elementC.interfaces = <InterfaceType> [elementA.type];
171 elementD.interfaces = <InterfaceType> [elementC.type];
172 elementE.interfaces = <InterfaceType> [elementB.type, elementD.type];
173 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementB.type));
174 JUnitTestCase.assertEquals(4, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementE.type));
175 }
176 void test_computeLongestInheritancePathToObject_multipleSuperclassPaths() {
177 ClassElement elementA = ElementFactory.classElement2("A", []);
178 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
179 ClassElement elementC = ElementFactory.classElement("C", elementA.type, []);
180 ClassElement elementD = ElementFactory.classElement("D", elementC.type, []);
181 ClassElementImpl elementE = ElementFactory.classElement("E", elementB.type, []);
182 elementE.interfaces = <InterfaceType> [elementD.type];
183 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementB.type));
184 JUnitTestCase.assertEquals(4, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementE.type));
185 }
186 void test_computeLongestInheritancePathToObject_object() {
187 ClassElement elementA = ElementFactory.classElement2("A", []);
188 InterfaceType object = elementA.supertype;
189 JUnitTestCase.assertEquals(0, InterfaceTypeImpl.computeLongestInheritancePat hToObject(object));
190 }
191 void test_computeLongestInheritancePathToObject_singleInterfacePath() {
192 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
193 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
194 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
195 elementB.interfaces = <InterfaceType> [elementA.type];
196 elementC.interfaces = <InterfaceType> [elementB.type];
197 JUnitTestCase.assertEquals(1, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementA.type));
198 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementB.type));
199 JUnitTestCase.assertEquals(3, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementC.type));
200 }
201 void test_computeLongestInheritancePathToObject_singleSuperclassPath() {
202 ClassElement elementA = ElementFactory.classElement2("A", []);
203 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
204 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
205 JUnitTestCase.assertEquals(1, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementA.type));
206 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementB.type));
207 JUnitTestCase.assertEquals(3, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementC.type));
208 }
209 void test_computeSuperinterfaceSet_multipleInterfacePaths() {
210 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
211 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
212 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
213 ClassElementImpl elementD = ElementFactory.classElement2("D", []);
214 ClassElementImpl elementE = ElementFactory.classElement2("E", []);
215 elementB.interfaces = <InterfaceType> [elementA.type];
216 elementC.interfaces = <InterfaceType> [elementA.type];
217 elementD.interfaces = <InterfaceType> [elementC.type];
218 elementE.interfaces = <InterfaceType> [elementB.type, elementD.type];
219 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(elementD.type);
220 JUnitTestCase.assertNotNull(superinterfacesOfD);
221 JUnitTestCase.assertTrue(superinterfacesOfD.contains(ElementFactory.object.t ype));
222 JUnitTestCase.assertTrue(superinterfacesOfD.contains(elementA.type));
223 JUnitTestCase.assertTrue(superinterfacesOfD.contains(elementC.type));
224 JUnitTestCase.assertEquals(3, superinterfacesOfD.length);
225 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(elementE.type);
226 JUnitTestCase.assertNotNull(superinterfacesOfE);
227 JUnitTestCase.assertTrue(superinterfacesOfE.contains(ElementFactory.object.t ype));
228 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementA.type));
229 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementB.type));
230 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementC.type));
231 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementD.type));
232 JUnitTestCase.assertEquals(5, superinterfacesOfE.length);
233 }
234 void test_computeSuperinterfaceSet_multipleSuperclassPaths() {
235 ClassElement elementA = ElementFactory.classElement2("A", []);
236 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
237 ClassElement elementC = ElementFactory.classElement("C", elementA.type, []);
238 ClassElement elementD = ElementFactory.classElement("D", elementC.type, []);
239 ClassElementImpl elementE = ElementFactory.classElement("E", elementB.type, []);
240 elementE.interfaces = <InterfaceType> [elementD.type];
241 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(elementD.type);
242 JUnitTestCase.assertNotNull(superinterfacesOfD);
243 JUnitTestCase.assertTrue(superinterfacesOfD.contains(ElementFactory.object.t ype));
244 JUnitTestCase.assertTrue(superinterfacesOfD.contains(elementA.type));
245 JUnitTestCase.assertTrue(superinterfacesOfD.contains(elementC.type));
246 JUnitTestCase.assertEquals(3, superinterfacesOfD.length);
247 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(elementE.type);
248 JUnitTestCase.assertNotNull(superinterfacesOfE);
249 JUnitTestCase.assertTrue(superinterfacesOfE.contains(ElementFactory.object.t ype));
250 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementA.type));
251 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementB.type));
252 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementC.type));
253 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementD.type));
254 JUnitTestCase.assertEquals(5, superinterfacesOfE.length);
255 }
256 void test_computeSuperinterfaceSet_singleInterfacePath() {
257 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
258 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
259 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
260 elementB.interfaces = <InterfaceType> [elementA.type];
261 elementC.interfaces = <InterfaceType> [elementB.type];
262 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(elementA.type);
263 JUnitTestCase.assertNotNull(superinterfacesOfA);
264 JUnitTestCase.assertTrue(superinterfacesOfA.contains(ElementFactory.object.t ype));
265 JUnitTestCase.assertEquals(1, superinterfacesOfA.length);
266 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(elementB.type);
267 JUnitTestCase.assertNotNull(superinterfacesOfB);
268 JUnitTestCase.assertTrue(superinterfacesOfB.contains(ElementFactory.object.t ype));
269 JUnitTestCase.assertTrue(superinterfacesOfB.contains(elementA.type));
270 JUnitTestCase.assertEquals(2, superinterfacesOfB.length);
271 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(elementC.type);
272 JUnitTestCase.assertNotNull(superinterfacesOfC);
273 JUnitTestCase.assertTrue(superinterfacesOfC.contains(ElementFactory.object.t ype));
274 JUnitTestCase.assertTrue(superinterfacesOfC.contains(elementA.type));
275 JUnitTestCase.assertTrue(superinterfacesOfC.contains(elementB.type));
276 JUnitTestCase.assertEquals(3, superinterfacesOfC.length);
277 }
278 void test_computeSuperinterfaceSet_singleSuperclassPath() {
279 ClassElement elementA = ElementFactory.classElement2("A", []);
280 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
281 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
282 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(elementA.type);
283 JUnitTestCase.assertNotNull(superinterfacesOfA);
284 JUnitTestCase.assertTrue(superinterfacesOfA.contains(ElementFactory.object.t ype));
285 JUnitTestCase.assertEquals(1, superinterfacesOfA.length);
286 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(elementB.type);
287 JUnitTestCase.assertNotNull(superinterfacesOfB);
288 JUnitTestCase.assertTrue(superinterfacesOfB.contains(ElementFactory.object.t ype));
289 JUnitTestCase.assertTrue(superinterfacesOfB.contains(elementA.type));
290 JUnitTestCase.assertEquals(2, superinterfacesOfB.length);
291 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(elementC.type);
292 JUnitTestCase.assertNotNull(superinterfacesOfC);
293 JUnitTestCase.assertTrue(superinterfacesOfC.contains(ElementFactory.object.t ype));
294 JUnitTestCase.assertTrue(superinterfacesOfC.contains(elementA.type));
295 JUnitTestCase.assertTrue(superinterfacesOfC.contains(elementB.type));
296 JUnitTestCase.assertEquals(3, superinterfacesOfC.length);
297 }
298 void test_creation() {
299 JUnitTestCase.assertNotNull(new InterfaceTypeImpl.con1(new ClassElementImpl( ASTFactory.identifier2("A"))));
300 }
301 void test_getElement() {
302 ClassElementImpl typeElement = new ClassElementImpl(ASTFactory.identifier2(" A"));
303 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement);
304 JUnitTestCase.assertEquals(typeElement, type.element);
305 }
306 void test_getLeastUpperBound_directInterfaceCase() {
307 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
308 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
309 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
310 InterfaceType typeA = elementA.type;
311 InterfaceType typeB = elementB.type;
312 InterfaceType typeC = elementC.type;
313 elementB.interfaces = <InterfaceType> [typeA];
314 elementC.interfaces = <InterfaceType> [typeB];
315 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC));
316 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB));
317 }
318 void test_getLeastUpperBound_directSubclassCase() {
319 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
320 ClassElementImpl elementB = ElementFactory.classElement("B", elementA.type, []);
321 ClassElementImpl elementC = ElementFactory.classElement("C", elementB.type, []);
322 InterfaceType typeB = elementB.type;
323 InterfaceType typeC = elementC.type;
324 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC));
325 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB));
326 }
327 void test_getLeastUpperBound_functionType() {
328 Type2 interfaceType = ElementFactory.classElement2("A", []).type;
329 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier2("f")));
330 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(functionType));
331 }
332 void test_getLeastUpperBound_mixinCase() {
333 ClassElement elementA = ElementFactory.classElement2("A", []);
334 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
335 ClassElement elementC = ElementFactory.classElement("C", elementA.type, []);
336 ClassElementImpl elementD = ElementFactory.classElement("D", elementB.type, []);
337 InterfaceType typeA = elementA.type;
338 InterfaceType typeC = elementC.type;
339 InterfaceType typeD = elementD.type;
340 elementD.mixins = <InterfaceType> [ElementFactory.classElement2("M", []).typ e, ElementFactory.classElement2("N", []).type, ElementFactory.classElement2("O", []).type, ElementFactory.classElement2("P", []).type];
341 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeC));
342 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeD));
343 }
344 void test_getLeastUpperBound_null() {
345 Type2 interfaceType = ElementFactory.classElement2("A", []).type;
346 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(null));
347 }
348 void test_getLeastUpperBound_object() {
349 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
350 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
351 InterfaceType typeA = elementA.type;
352 InterfaceType typeB = elementB.type;
353 Type2 typeObject = typeA.element.supertype;
354 JUnitTestCase.assertNull(((typeObject.element as ClassElement)).supertype);
355 JUnitTestCase.assertEquals(typeObject, typeB.element.supertype);
356 JUnitTestCase.assertEquals(typeObject, typeA.getLeastUpperBound(typeB));
357 }
358 void test_getLeastUpperBound_self() {
359 ClassElement elementA = ElementFactory.classElement2("A", []);
360 InterfaceType typeA = elementA.type;
361 JUnitTestCase.assertEquals(typeA, typeA.getLeastUpperBound(typeA));
362 }
363 void test_getLeastUpperBound_sharedSuperclass1() {
364 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
365 ClassElementImpl elementB = ElementFactory.classElement("B", elementA.type, []);
366 ClassElementImpl elementC = ElementFactory.classElement("C", elementA.type, []);
367 InterfaceType typeA = elementA.type;
368 InterfaceType typeB = elementB.type;
369 InterfaceType typeC = elementC.type;
370 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
371 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
372 }
373 void test_getLeastUpperBound_sharedSuperclass2() {
374 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
375 ClassElementImpl elementB = ElementFactory.classElement("B", elementA.type, []);
376 ClassElementImpl elementC = ElementFactory.classElement("C", elementA.type, []);
377 ClassElementImpl elementD = ElementFactory.classElement("D", elementC.type, []);
378 InterfaceType typeA = elementA.type;
379 InterfaceType typeB = elementB.type;
380 InterfaceType typeD = elementD.type;
381 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeD));
382 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeB));
383 }
384 void test_getLeastUpperBound_sharedSuperclass3() {
385 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
386 ClassElementImpl elementB = ElementFactory.classElement("B", elementA.type, []);
387 ClassElementImpl elementC = ElementFactory.classElement("C", elementB.type, []);
388 ClassElementImpl elementD = ElementFactory.classElement("D", elementB.type, []);
389 InterfaceType typeB = elementB.type;
390 InterfaceType typeC = elementC.type;
391 InterfaceType typeD = elementD.type;
392 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeD));
393 JUnitTestCase.assertEquals(typeB, typeD.getLeastUpperBound(typeC));
394 }
395 void test_getLeastUpperBound_sharedSuperclass4() {
396 ClassElement elementA = ElementFactory.classElement2("A", []);
397 ClassElement elementA2 = ElementFactory.classElement2("A2", []);
398 ClassElement elementA3 = ElementFactory.classElement2("A3", []);
399 ClassElementImpl elementB = ElementFactory.classElement("B", elementA.type, []);
400 ClassElementImpl elementC = ElementFactory.classElement("C", elementA.type, []);
401 InterfaceType typeA = elementA.type;
402 InterfaceType typeA2 = elementA2.type;
403 InterfaceType typeA3 = elementA3.type;
404 InterfaceType typeB = elementB.type;
405 InterfaceType typeC = elementC.type;
406 elementB.interfaces = <InterfaceType> [typeA2];
407 elementC.interfaces = <InterfaceType> [typeA3];
408 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
409 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
410 }
411 void test_getLeastUpperBound_sharedSuperinterface1() {
412 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
413 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
414 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
415 InterfaceType typeA = elementA.type;
416 InterfaceType typeB = elementB.type;
417 InterfaceType typeC = elementC.type;
418 elementB.interfaces = <InterfaceType> [typeA];
419 elementC.interfaces = <InterfaceType> [typeA];
420 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
421 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
422 }
423 void test_getLeastUpperBound_sharedSuperinterface2() {
424 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
425 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
426 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
427 ClassElementImpl elementD = ElementFactory.classElement2("D", []);
428 InterfaceType typeA = elementA.type;
429 InterfaceType typeB = elementB.type;
430 InterfaceType typeC = elementC.type;
431 InterfaceType typeD = elementD.type;
432 elementB.interfaces = <InterfaceType> [typeA];
433 elementC.interfaces = <InterfaceType> [typeA];
434 elementD.interfaces = <InterfaceType> [typeC];
435 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeD));
436 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeB));
437 }
438 void test_getLeastUpperBound_sharedSuperinterface3() {
439 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
440 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
441 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
442 ClassElementImpl elementD = ElementFactory.classElement2("D", []);
443 InterfaceType typeA = elementA.type;
444 InterfaceType typeB = elementB.type;
445 InterfaceType typeC = elementC.type;
446 InterfaceType typeD = elementD.type;
447 elementB.interfaces = <InterfaceType> [typeA];
448 elementC.interfaces = <InterfaceType> [typeB];
449 elementD.interfaces = <InterfaceType> [typeB];
450 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeD));
451 JUnitTestCase.assertEquals(typeB, typeD.getLeastUpperBound(typeC));
452 }
453 void test_getLeastUpperBound_sharedSuperinterface4() {
454 ClassElement elementA = ElementFactory.classElement2("A", []);
455 ClassElement elementA2 = ElementFactory.classElement2("A2", []);
456 ClassElement elementA3 = ElementFactory.classElement2("A3", []);
457 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
458 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
459 InterfaceType typeA = elementA.type;
460 InterfaceType typeA2 = elementA2.type;
461 InterfaceType typeA3 = elementA3.type;
462 InterfaceType typeB = elementB.type;
463 InterfaceType typeC = elementC.type;
464 elementB.interfaces = <InterfaceType> [typeA, typeA2];
465 elementC.interfaces = <InterfaceType> [typeA, typeA3];
466 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
467 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
468 }
469 void test_getTypeArguments() {
470 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(new ClassElementImpl(AST Factory.identifier2("A")));
471 EngineTestCase.assertLength(0, type.typeArguments);
472 }
473 void test_isDirectSupertypeOf_extends() {
474 ClassElement elementA = ElementFactory.classElement2("A", []);
475 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
476 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
477 InterfaceTypeImpl typeB = new InterfaceTypeImpl.con1(elementB);
478 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
479 }
480 void test_isDirectSupertypeOf_false() {
481 ClassElement elementA = ElementFactory.classElement2("A", []);
482 ClassElement elementB = ElementFactory.classElement2("B", []);
483 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
484 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
485 InterfaceTypeImpl typeC = new InterfaceTypeImpl.con1(elementC);
486 JUnitTestCase.assertFalse(typeA.isDirectSupertypeOf(typeC));
487 }
488 void test_isDirectSupertypeOf_implements() {
489 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
490 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
491 elementB.interfaces = <InterfaceType> [elementA.type];
492 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
493 InterfaceTypeImpl typeB = new InterfaceTypeImpl.con1(elementB);
494 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
495 }
496 void test_isDirectSupertypeOf_with() {
497 ClassElementImpl elementA = ElementFactory.classElement2("A", []);
498 ClassElementImpl elementB = ElementFactory.classElement2("B", []);
499 elementB.mixins = <InterfaceType> [elementA.type];
500 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
501 InterfaceTypeImpl typeB = new InterfaceTypeImpl.con1(elementB);
502 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
503 }
504 void test_isMoreSpecificThan_bottom() {
505 Type2 type24 = ElementFactory.classElement2("A", []).type;
506 JUnitTestCase.assertTrue(BottomTypeImpl.instance.isMoreSpecificThan(type24)) ;
507 }
508 void test_isMoreSpecificThan_covariance() {
509 ClassElement elementA = ElementFactory.classElement2("A", ["E"]);
510 ClassElement elementI = ElementFactory.classElement2("I", []);
511 ClassElement elementJ = ElementFactory.classElement("J", elementI.type, []);
512 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(elementA);
513 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(elementA);
514 typeAI.typeArguments = <Type2> [elementI.type];
515 typeAJ.typeArguments = <Type2> [elementJ.type];
516 JUnitTestCase.assertTrue(typeAJ.isMoreSpecificThan(typeAI));
517 JUnitTestCase.assertFalse(typeAI.isMoreSpecificThan(typeAJ));
518 }
519 void test_isMoreSpecificThan_directSupertype() {
520 ClassElement elementA = ElementFactory.classElement2("A", []);
521 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
522 InterfaceType typeA = elementA.type;
523 InterfaceType typeB = elementB.type;
524 JUnitTestCase.assertTrue(typeB.isMoreSpecificThan(typeA));
525 JUnitTestCase.assertFalse(typeA.isMoreSpecificThan(typeB));
526 }
527 void test_isMoreSpecificThan_dynamic() {
528 InterfaceType type25 = ElementFactory.classElement2("A", []).type;
529 JUnitTestCase.assertTrue(type25.isMoreSpecificThan(DynamicTypeImpl.instance) );
530 }
531 void test_isMoreSpecificThan_indirectSupertype() {
532 ClassElement elementA = ElementFactory.classElement2("A", []);
533 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
534 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
535 InterfaceType typeA = elementA.type;
536 InterfaceType typeC = elementC.type;
537 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA));
538 }
539 void test_isMoreSpecificThan_self() {
540 InterfaceType type26 = ElementFactory.classElement2("A", []).type;
541 JUnitTestCase.assertTrue(type26.isMoreSpecificThan(type26));
542 }
543 void test_isSubtypeOf_directSubtype() {
544 ClassElement elementA = ElementFactory.classElement2("A", []);
545 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
546 InterfaceType typeA = elementA.type;
547 InterfaceType typeB = elementB.type;
548 JUnitTestCase.assertTrue(typeB.isSubtypeOf(typeA));
549 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeB));
550 }
551 void test_isSubtypeOf_dynamic() {
552 ClassElement elementA = ElementFactory.classElement2("A", []);
553 InterfaceType typeA = elementA.type;
554 Type2 dynamicType = DynamicTypeImpl.instance;
555 JUnitTestCase.assertFalse(dynamicType.isSubtypeOf(typeA));
556 JUnitTestCase.assertTrue(typeA.isSubtypeOf(dynamicType));
557 }
558 void test_isSubtypeOf_indirectSubtype() {
559 ClassElement elementA = ElementFactory.classElement2("A", []);
560 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
561 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
562 InterfaceType typeA = elementA.type;
563 InterfaceType typeC = elementC.type;
564 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA));
565 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
566 }
567 void test_isSubtypeOf_interface() {
568 ClassElement elementA = ElementFactory.classElement2("A", []);
569 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
570 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
571 InterfaceType typeObject = elementA.supertype;
572 InterfaceType typeA = elementA.type;
573 InterfaceType typeB = elementB.type;
574 InterfaceType typeC = elementC.type;
575 elementC.interfaces = <InterfaceType> [typeB];
576 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeB));
577 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeObject));
578 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA));
579 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
580 }
581 void test_isSubtypeOf_mixins() {
582 ClassElement elementA = ElementFactory.classElement2("A", []);
583 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
584 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
585 InterfaceType typeObject = elementA.supertype;
586 InterfaceType typeA = elementA.type;
587 InterfaceType typeB = elementB.type;
588 InterfaceType typeC = elementC.type;
589 elementC.mixins = <InterfaceType> [typeB];
590 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeB));
591 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeObject));
592 JUnitTestCase.assertFalse(typeC.isSubtypeOf(typeA));
593 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
594 }
595 void test_isSubtypeOf_object() {
596 ClassElement elementA = ElementFactory.classElement2("A", []);
597 InterfaceType typeA = elementA.type;
598 InterfaceType typeObject = elementA.supertype;
599 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeObject));
600 JUnitTestCase.assertFalse(typeObject.isSubtypeOf(typeA));
601 }
602 void test_isSubtypeOf_self() {
603 ClassElement elementA = ElementFactory.classElement2("A", []);
604 InterfaceType typeA = elementA.type;
605 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeA));
606 }
607 void test_isSubtypeOf_typeArguments() {
608 ClassElement elementA = ElementFactory.classElement2("A", ["E"]);
609 ClassElement elementI = ElementFactory.classElement2("I", []);
610 ClassElement elementJ = ElementFactory.classElement("J", elementI.type, []);
611 ClassElement elementK = ElementFactory.classElement2("K", []);
612 InterfaceType typeA = elementA.type;
613 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(elementA);
614 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(elementA);
615 InterfaceTypeImpl typeAK = new InterfaceTypeImpl.con1(elementA);
616 typeAI.typeArguments = <Type2> [elementI.type];
617 typeAJ.typeArguments = <Type2> [elementJ.type];
618 typeAK.typeArguments = <Type2> [elementK.type];
619 JUnitTestCase.assertTrue(typeAJ.isSubtypeOf(typeAI));
620 JUnitTestCase.assertFalse(typeAI.isSubtypeOf(typeAJ));
621 JUnitTestCase.assertTrue(typeAI.isSubtypeOf(typeAI));
622 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeAI));
623 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeAJ));
624 JUnitTestCase.assertTrue(typeAI.isSubtypeOf(typeA));
625 JUnitTestCase.assertTrue(typeAJ.isSubtypeOf(typeA));
626 JUnitTestCase.assertFalse(typeAI.isSubtypeOf(typeAK));
627 JUnitTestCase.assertFalse(typeAK.isSubtypeOf(typeAI));
628 }
629 void test_isSupertypeOf_directSupertype() {
630 ClassElement elementA = ElementFactory.classElement2("A", []);
631 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
632 InterfaceType typeA = elementA.type;
633 InterfaceType typeB = elementB.type;
634 JUnitTestCase.assertFalse(typeB.isSupertypeOf(typeA));
635 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeB));
636 }
637 void test_isSupertypeOf_dynamic() {
638 ClassElement elementA = ElementFactory.classElement2("A", []);
639 InterfaceType typeA = elementA.type;
640 Type2 dynamicType = DynamicTypeImpl.instance;
641 JUnitTestCase.assertTrue(dynamicType.isSupertypeOf(typeA));
642 JUnitTestCase.assertFalse(typeA.isSupertypeOf(dynamicType));
643 }
644 void test_isSupertypeOf_indirectSupertype() {
645 ClassElement elementA = ElementFactory.classElement2("A", []);
646 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
647 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
648 InterfaceType typeA = elementA.type;
649 InterfaceType typeC = elementC.type;
650 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
651 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC));
652 }
653 void test_isSupertypeOf_interface() {
654 ClassElement elementA = ElementFactory.classElement2("A", []);
655 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
656 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
657 InterfaceType typeObject = elementA.supertype;
658 InterfaceType typeA = elementA.type;
659 InterfaceType typeB = elementB.type;
660 InterfaceType typeC = elementC.type;
661 elementC.interfaces = <InterfaceType> [typeB];
662 JUnitTestCase.assertTrue(typeB.isSupertypeOf(typeC));
663 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeC));
664 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC));
665 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
666 }
667 void test_isSupertypeOf_mixins() {
668 ClassElement elementA = ElementFactory.classElement2("A", []);
669 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
670 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
671 InterfaceType typeObject = elementA.supertype;
672 InterfaceType typeA = elementA.type;
673 InterfaceType typeB = elementB.type;
674 InterfaceType typeC = elementC.type;
675 elementC.mixins = <InterfaceType> [typeB];
676 JUnitTestCase.assertTrue(typeB.isSupertypeOf(typeC));
677 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeC));
678 JUnitTestCase.assertFalse(typeA.isSupertypeOf(typeC));
679 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
680 }
681 void test_isSupertypeOf_object() {
682 ClassElement elementA = ElementFactory.classElement2("A", []);
683 InterfaceType typeA = elementA.type;
684 InterfaceType typeObject = elementA.supertype;
685 JUnitTestCase.assertFalse(typeA.isSupertypeOf(typeObject));
686 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeA));
687 }
688 void test_isSupertypeOf_self() {
689 ClassElement elementA = ElementFactory.classElement2("A", []);
690 InterfaceType typeA = elementA.type;
691 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeA));
692 }
693 void test_setTypeArguments() {
694 InterfaceTypeImpl type27 = ElementFactory.classElement2("A", []).type as Int erfaceTypeImpl;
695 List<Type2> typeArguments = <Type2> [new InterfaceTypeImpl.con1(ElementFacto ry.classElement2("B", [])), new InterfaceTypeImpl.con1(ElementFactory.classEleme nt2("C", []))];
696 type27.typeArguments = typeArguments;
697 JUnitTestCase.assertEquals(typeArguments, type27.typeArguments);
698 }
699 void test_substitute_equal() {
700 ClassElementImpl classElement = new ClassElementImpl(ASTFactory.identifier2( "A"));
701 TypeVariableElementImpl parameterElement = new TypeVariableElementImpl(ASTFa ctory.identifier2("E"));
702 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classElement);
703 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(parameterElement);
704 type.typeArguments = <Type2> [parameter];
705 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("B")));
706 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par ameter]);
707 JUnitTestCase.assertEquals(classElement, result.element);
708 List<Type2> resultArguments = result.typeArguments;
709 EngineTestCase.assertLength(1, resultArguments);
710 JUnitTestCase.assertEquals(argumentType, resultArguments[0]);
711 }
712 void test_substitute_notEqual() {
713 ClassElementImpl classElement = new ClassElementImpl(ASTFactory.identifier2( "A"));
714 TypeVariableElementImpl parameterElement = new TypeVariableElementImpl(ASTFa ctory.identifier2("E"));
715 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classElement);
716 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(parameterElement);
717 type.typeArguments = <Type2> [parameter];
718 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("B")));
719 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier2("F")));
720 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par ameterType]);
721 JUnitTestCase.assertEquals(classElement, result.element);
722 List<Type2> resultArguments = result.typeArguments;
723 EngineTestCase.assertLength(1, resultArguments);
724 JUnitTestCase.assertEquals(parameter, resultArguments[0]);
725 }
726 static dartSuite() {
727 _ut.group('InterfaceTypeImplTest', () {
728 _ut.test('test_computeLongestInheritancePathToObject_multipleInterfacePath s', () {
729 final __test = new InterfaceTypeImplTest();
730 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_m ultipleInterfacePaths);
731 });
732 _ut.test('test_computeLongestInheritancePathToObject_multipleSuperclassPat hs', () {
733 final __test = new InterfaceTypeImplTest();
734 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_m ultipleSuperclassPaths);
735 });
736 _ut.test('test_computeLongestInheritancePathToObject_object', () {
737 final __test = new InterfaceTypeImplTest();
738 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_o bject);
739 });
740 _ut.test('test_computeLongestInheritancePathToObject_singleInterfacePath', () {
741 final __test = new InterfaceTypeImplTest();
742 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_s ingleInterfacePath);
743 });
744 _ut.test('test_computeLongestInheritancePathToObject_singleSuperclassPath' , () {
745 final __test = new InterfaceTypeImplTest();
746 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_s ingleSuperclassPath);
747 });
748 _ut.test('test_computeSuperinterfaceSet_multipleInterfacePaths', () {
749 final __test = new InterfaceTypeImplTest();
750 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_multipleInterf acePaths);
751 });
752 _ut.test('test_computeSuperinterfaceSet_multipleSuperclassPaths', () {
753 final __test = new InterfaceTypeImplTest();
754 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_multipleSuperc lassPaths);
755 });
756 _ut.test('test_computeSuperinterfaceSet_singleInterfacePath', () {
757 final __test = new InterfaceTypeImplTest();
758 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_singleInterfac ePath);
759 });
760 _ut.test('test_computeSuperinterfaceSet_singleSuperclassPath', () {
761 final __test = new InterfaceTypeImplTest();
762 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_singleSupercla ssPath);
763 });
764 _ut.test('test_creation', () {
765 final __test = new InterfaceTypeImplTest();
766 runJUnitTest(__test, __test.test_creation);
767 });
768 _ut.test('test_getElement', () {
769 final __test = new InterfaceTypeImplTest();
770 runJUnitTest(__test, __test.test_getElement);
771 });
772 _ut.test('test_getLeastUpperBound_directInterfaceCase', () {
773 final __test = new InterfaceTypeImplTest();
774 runJUnitTest(__test, __test.test_getLeastUpperBound_directInterfaceCase) ;
775 });
776 _ut.test('test_getLeastUpperBound_directSubclassCase', () {
777 final __test = new InterfaceTypeImplTest();
778 runJUnitTest(__test, __test.test_getLeastUpperBound_directSubclassCase);
779 });
780 _ut.test('test_getLeastUpperBound_functionType', () {
781 final __test = new InterfaceTypeImplTest();
782 runJUnitTest(__test, __test.test_getLeastUpperBound_functionType);
783 });
784 _ut.test('test_getLeastUpperBound_mixinCase', () {
785 final __test = new InterfaceTypeImplTest();
786 runJUnitTest(__test, __test.test_getLeastUpperBound_mixinCase);
787 });
788 _ut.test('test_getLeastUpperBound_null', () {
789 final __test = new InterfaceTypeImplTest();
790 runJUnitTest(__test, __test.test_getLeastUpperBound_null);
791 });
792 _ut.test('test_getLeastUpperBound_object', () {
793 final __test = new InterfaceTypeImplTest();
794 runJUnitTest(__test, __test.test_getLeastUpperBound_object);
795 });
796 _ut.test('test_getLeastUpperBound_self', () {
797 final __test = new InterfaceTypeImplTest();
798 runJUnitTest(__test, __test.test_getLeastUpperBound_self);
799 });
800 _ut.test('test_getLeastUpperBound_sharedSuperclass1', () {
801 final __test = new InterfaceTypeImplTest();
802 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass1);
803 });
804 _ut.test('test_getLeastUpperBound_sharedSuperclass2', () {
805 final __test = new InterfaceTypeImplTest();
806 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass2);
807 });
808 _ut.test('test_getLeastUpperBound_sharedSuperclass3', () {
809 final __test = new InterfaceTypeImplTest();
810 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass3);
811 });
812 _ut.test('test_getLeastUpperBound_sharedSuperclass4', () {
813 final __test = new InterfaceTypeImplTest();
814 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass4);
815 });
816 _ut.test('test_getLeastUpperBound_sharedSuperinterface1', () {
817 final __test = new InterfaceTypeImplTest();
818 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 1);
819 });
820 _ut.test('test_getLeastUpperBound_sharedSuperinterface2', () {
821 final __test = new InterfaceTypeImplTest();
822 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 2);
823 });
824 _ut.test('test_getLeastUpperBound_sharedSuperinterface3', () {
825 final __test = new InterfaceTypeImplTest();
826 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 3);
827 });
828 _ut.test('test_getLeastUpperBound_sharedSuperinterface4', () {
829 final __test = new InterfaceTypeImplTest();
830 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 4);
831 });
832 _ut.test('test_getTypeArguments', () {
833 final __test = new InterfaceTypeImplTest();
834 runJUnitTest(__test, __test.test_getTypeArguments);
835 });
836 _ut.test('test_isDirectSupertypeOf_extends', () {
837 final __test = new InterfaceTypeImplTest();
838 runJUnitTest(__test, __test.test_isDirectSupertypeOf_extends);
839 });
840 _ut.test('test_isDirectSupertypeOf_false', () {
841 final __test = new InterfaceTypeImplTest();
842 runJUnitTest(__test, __test.test_isDirectSupertypeOf_false);
843 });
844 _ut.test('test_isDirectSupertypeOf_implements', () {
845 final __test = new InterfaceTypeImplTest();
846 runJUnitTest(__test, __test.test_isDirectSupertypeOf_implements);
847 });
848 _ut.test('test_isDirectSupertypeOf_with', () {
849 final __test = new InterfaceTypeImplTest();
850 runJUnitTest(__test, __test.test_isDirectSupertypeOf_with);
851 });
852 _ut.test('test_isMoreSpecificThan_bottom', () {
853 final __test = new InterfaceTypeImplTest();
854 runJUnitTest(__test, __test.test_isMoreSpecificThan_bottom);
855 });
856 _ut.test('test_isMoreSpecificThan_covariance', () {
857 final __test = new InterfaceTypeImplTest();
858 runJUnitTest(__test, __test.test_isMoreSpecificThan_covariance);
859 });
860 _ut.test('test_isMoreSpecificThan_directSupertype', () {
861 final __test = new InterfaceTypeImplTest();
862 runJUnitTest(__test, __test.test_isMoreSpecificThan_directSupertype);
863 });
864 _ut.test('test_isMoreSpecificThan_dynamic', () {
865 final __test = new InterfaceTypeImplTest();
866 runJUnitTest(__test, __test.test_isMoreSpecificThan_dynamic);
867 });
868 _ut.test('test_isMoreSpecificThan_indirectSupertype', () {
869 final __test = new InterfaceTypeImplTest();
870 runJUnitTest(__test, __test.test_isMoreSpecificThan_indirectSupertype);
871 });
872 _ut.test('test_isMoreSpecificThan_self', () {
873 final __test = new InterfaceTypeImplTest();
874 runJUnitTest(__test, __test.test_isMoreSpecificThan_self);
875 });
876 _ut.test('test_isSubtypeOf_directSubtype', () {
877 final __test = new InterfaceTypeImplTest();
878 runJUnitTest(__test, __test.test_isSubtypeOf_directSubtype);
879 });
880 _ut.test('test_isSubtypeOf_dynamic', () {
881 final __test = new InterfaceTypeImplTest();
882 runJUnitTest(__test, __test.test_isSubtypeOf_dynamic);
883 });
884 _ut.test('test_isSubtypeOf_indirectSubtype', () {
885 final __test = new InterfaceTypeImplTest();
886 runJUnitTest(__test, __test.test_isSubtypeOf_indirectSubtype);
887 });
888 _ut.test('test_isSubtypeOf_interface', () {
889 final __test = new InterfaceTypeImplTest();
890 runJUnitTest(__test, __test.test_isSubtypeOf_interface);
891 });
892 _ut.test('test_isSubtypeOf_mixins', () {
893 final __test = new InterfaceTypeImplTest();
894 runJUnitTest(__test, __test.test_isSubtypeOf_mixins);
895 });
896 _ut.test('test_isSubtypeOf_object', () {
897 final __test = new InterfaceTypeImplTest();
898 runJUnitTest(__test, __test.test_isSubtypeOf_object);
899 });
900 _ut.test('test_isSubtypeOf_self', () {
901 final __test = new InterfaceTypeImplTest();
902 runJUnitTest(__test, __test.test_isSubtypeOf_self);
903 });
904 _ut.test('test_isSubtypeOf_typeArguments', () {
905 final __test = new InterfaceTypeImplTest();
906 runJUnitTest(__test, __test.test_isSubtypeOf_typeArguments);
907 });
908 _ut.test('test_isSupertypeOf_directSupertype', () {
909 final __test = new InterfaceTypeImplTest();
910 runJUnitTest(__test, __test.test_isSupertypeOf_directSupertype);
911 });
912 _ut.test('test_isSupertypeOf_dynamic', () {
913 final __test = new InterfaceTypeImplTest();
914 runJUnitTest(__test, __test.test_isSupertypeOf_dynamic);
915 });
916 _ut.test('test_isSupertypeOf_indirectSupertype', () {
917 final __test = new InterfaceTypeImplTest();
918 runJUnitTest(__test, __test.test_isSupertypeOf_indirectSupertype);
919 });
920 _ut.test('test_isSupertypeOf_interface', () {
921 final __test = new InterfaceTypeImplTest();
922 runJUnitTest(__test, __test.test_isSupertypeOf_interface);
923 });
924 _ut.test('test_isSupertypeOf_mixins', () {
925 final __test = new InterfaceTypeImplTest();
926 runJUnitTest(__test, __test.test_isSupertypeOf_mixins);
927 });
928 _ut.test('test_isSupertypeOf_object', () {
929 final __test = new InterfaceTypeImplTest();
930 runJUnitTest(__test, __test.test_isSupertypeOf_object);
931 });
932 _ut.test('test_isSupertypeOf_self', () {
933 final __test = new InterfaceTypeImplTest();
934 runJUnitTest(__test, __test.test_isSupertypeOf_self);
935 });
936 _ut.test('test_setTypeArguments', () {
937 final __test = new InterfaceTypeImplTest();
938 runJUnitTest(__test, __test.test_setTypeArguments);
939 });
940 _ut.test('test_substitute_equal', () {
941 final __test = new InterfaceTypeImplTest();
942 runJUnitTest(__test, __test.test_substitute_equal);
943 });
944 _ut.test('test_substitute_notEqual', () {
945 final __test = new InterfaceTypeImplTest();
946 runJUnitTest(__test, __test.test_substitute_notEqual);
947 });
948 });
949 }
950 }
951 class TypeVariableTypeImplTest extends EngineTestCase {
952 void test_creation() {
953 JUnitTestCase.assertNotNull(new TypeVariableTypeImpl(new TypeVariableElement Impl(ASTFactory.identifier2("E"))));
954 }
955 void test_getElement() {
956 TypeVariableElementImpl element = new TypeVariableElementImpl(ASTFactory.ide ntifier2("E"));
957 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element);
958 JUnitTestCase.assertEquals(element, type.element);
959 }
960 void test_substitute_equal() {
961 TypeVariableElementImpl element = new TypeVariableElementImpl(ASTFactory.ide ntifier2("E"));
962 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element);
963 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (ASTFactory.identifier2("A")));
964 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(element);
965 JUnitTestCase.assertSame(argument, type.substitute2(<Type2> [argument], <Typ e2> [parameter]));
966 }
967 void test_substitute_notEqual() {
968 TypeVariableTypeImpl type = new TypeVariableTypeImpl(new TypeVariableElement Impl(ASTFactory.identifier2("E")));
969 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (ASTFactory.identifier2("A")));
970 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(new TypeVariableEl ementImpl(ASTFactory.identifier2("F")));
971 JUnitTestCase.assertSame(type, type.substitute2(<Type2> [argument], <Type2> [parameter]));
972 }
973 static dartSuite() {
974 _ut.group('TypeVariableTypeImplTest', () {
975 _ut.test('test_creation', () {
976 final __test = new TypeVariableTypeImplTest();
977 runJUnitTest(__test, __test.test_creation);
978 });
979 _ut.test('test_getElement', () {
980 final __test = new TypeVariableTypeImplTest();
981 runJUnitTest(__test, __test.test_getElement);
982 });
983 _ut.test('test_substitute_equal', () {
984 final __test = new TypeVariableTypeImplTest();
985 runJUnitTest(__test, __test.test_substitute_equal);
986 });
987 _ut.test('test_substitute_notEqual', () {
988 final __test = new TypeVariableTypeImplTest();
989 runJUnitTest(__test, __test.test_substitute_notEqual);
990 });
991 });
992 }
993 }
600 /** 994 /**
601 * The class {@code ElementFactory} defines utility methods used to create eleme nts for testing 995 * The class {@code ElementFactory} defines utility methods used to create eleme nts for testing
602 * purposes. 996 * purposes. The elements that are created are complete in the sense that as muc h of the element
997 * model as can be created, given the provided information, has been created.
603 */ 998 */
604 class ElementFactory { 999 class ElementFactory {
605 /** 1000 /**
606 * The element representing the class 'Object'. 1001 * The element representing the class 'Object'.
607 */ 1002 */
608 static ClassElement _objectElement; 1003 static ClassElementImpl _objectElement;
609 static ClassElement classElement(String typeName, InterfaceType superclassType , List<String> parameterNames) { 1004 static ClassElementImpl classElement(String typeName, InterfaceType superclass Type, List<String> parameterNames) {
610 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier2(typeN ame)); 1005 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier2(typeN ame));
611 element.supertype = superclassType; 1006 element.supertype = superclassType;
612 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); 1007 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element);
613 element.type = type; 1008 element.type = type;
614 int count = parameterNames.length; 1009 int count = parameterNames.length;
615 if (count > 0) { 1010 if (count > 0) {
616 List<TypeVariableElementImpl> typeVariables = new List<TypeVariableElement Impl>(count); 1011 List<TypeVariableElementImpl> typeVariables = new List<TypeVariableElement Impl>(count);
617 List<TypeVariableTypeImpl> typeArguments = new List<TypeVariableTypeImpl>( count); 1012 List<TypeVariableTypeImpl> typeArguments = new List<TypeVariableTypeImpl>( count);
618 for (int i = 0; i < count; i++) { 1013 for (int i = 0; i < count; i++) {
619 TypeVariableElementImpl variable = new TypeVariableElementImpl(ASTFactor y.identifier2(parameterNames[i])); 1014 TypeVariableElementImpl variable = new TypeVariableElementImpl(ASTFactor y.identifier2(parameterNames[i]));
620 typeVariables[i] = variable; 1015 typeVariables[i] = variable;
621 typeArguments[i] = new TypeVariableTypeImpl(variable); 1016 typeArguments[i] = new TypeVariableTypeImpl(variable);
622 variable.type = typeArguments[i]; 1017 variable.type = typeArguments[i];
623 } 1018 }
624 element.typeVariables = typeVariables; 1019 element.typeVariables = typeVariables;
625 type.typeArguments = typeArguments; 1020 type.typeArguments = typeArguments;
626 } 1021 }
627 return element; 1022 return element;
628 } 1023 }
629 static ClassElement classElement2(String typeName, List<String> parameterNames ) => classElement(typeName, object.type, parameterNames); 1024 static ClassElementImpl classElement2(String typeName, List<String> parameterN ames) => classElement(typeName, object.type, parameterNames);
630 static ConstructorElement constructorElement(String name) => new ConstructorEl ementImpl(name == null ? null : ASTFactory.identifier2(name)); 1025 static ConstructorElementImpl constructorElement(String name) => new Construct orElementImpl(name == null ? null : ASTFactory.identifier2(name));
631 static FieldElement fieldElement(String name, bool isStatic, bool isFinal, boo l isConst, Type2 type27) { 1026 static ExportElementImpl exportFor(LibraryElement exportedLibrary4, List<Names paceCombinator> combinators4) {
1027 ExportElementImpl spec = new ExportElementImpl();
1028 spec.exportedLibrary = exportedLibrary4;
1029 spec.combinators = combinators4;
1030 return spec;
1031 }
1032 static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, Type2 type32) {
632 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me)); 1033 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me));
633 field.const2 = isConst; 1034 field.const2 = isConst;
634 field.final2 = isFinal; 1035 field.final2 = isFinal;
635 field.static = isStatic; 1036 field.static = isStatic;
636 field.type = type27; 1037 field.type = type32;
637 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con1(fi eld); 1038 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
638 getter.getter = true; 1039 getter.getter = true;
639 getter.synthetic = true; 1040 getter.synthetic = true;
640 field.getter = getter; 1041 field.getter = getter;
641 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1042 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
642 getterType.returnType = type27; 1043 getterType.returnType = type32;
643 getter.type = getterType; 1044 getter.type = getterType;
644 if (!isConst && !isFinal) { 1045 if (!isConst && !isFinal) {
645 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con1( field); 1046 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2( field);
646 setter.setter = true; 1047 setter.setter = true;
647 setter.synthetic = true; 1048 setter.synthetic = true;
648 field.setter = setter; 1049 field.setter = setter;
649 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter); 1050 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter);
650 setterType.normalParameterTypes = <Type2> [type27]; 1051 setterType.normalParameterTypes = <Type2> [type32];
651 setterType.returnType = VoidTypeImpl.instance; 1052 setterType.returnType = VoidTypeImpl.instance;
652 setter.type = setterType; 1053 setter.type = setterType;
653 } 1054 }
654 return field; 1055 return field;
655 } 1056 }
656 static FunctionElement functionElement(String functionName) => functionElement 4(functionName, null, null, null, null); 1057 static FunctionElementImpl functionElement(String functionName) => functionEle ment4(functionName, null, null, null, null);
657 static FunctionElement functionElement2(String functionName, ClassElement retu rnElement) => functionElement3(functionName, returnElement, null, null); 1058 static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null);
658 static FunctionElement functionElement3(String functionName, ClassElement retu rnElement, List<ClassElement> normalParameters, List<ClassElement> optionalParam eters) { 1059 static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalP arameters) {
659 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier2(functionName)); 1060 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier2(functionName));
660 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 1061 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
661 functionElement.type = functionType; 1062 functionElement.type = functionType;
662 if (returnElement != null) { 1063 if (returnElement != null) {
663 functionType.returnType = returnElement.type; 1064 functionType.returnType = returnElement.type;
664 } 1065 }
665 int count = normalParameters == null ? 0 : normalParameters.length; 1066 int count = normalParameters == null ? 0 : normalParameters.length;
666 if (count > 0) { 1067 if (count > 0) {
667 List<InterfaceType> normalParameterTypes = new List<InterfaceType>(count); 1068 List<InterfaceType> normalParameterTypes = new List<InterfaceType>(count);
668 for (int i = 0; i < count; i++) { 1069 for (int i = 0; i < count; i++) {
669 normalParameterTypes[i] = normalParameters[i].type; 1070 normalParameterTypes[i] = normalParameters[i].type;
670 } 1071 }
671 functionType.normalParameterTypes = normalParameterTypes; 1072 functionType.normalParameterTypes = normalParameterTypes;
672 } 1073 }
673 count = optionalParameters == null ? 0 : optionalParameters.length; 1074 count = optionalParameters == null ? 0 : optionalParameters.length;
674 if (count > 0) { 1075 if (count > 0) {
675 List<InterfaceType> optionalParameterTypes = new List<InterfaceType>(count ); 1076 List<InterfaceType> optionalParameterTypes = new List<InterfaceType>(count );
676 for (int i = 0; i < count; i++) { 1077 for (int i = 0; i < count; i++) {
677 optionalParameterTypes[i] = optionalParameters[i].type; 1078 optionalParameterTypes[i] = optionalParameters[i].type;
678 } 1079 }
679 functionType.optionalParameterTypes = optionalParameterTypes; 1080 functionType.optionalParameterTypes = optionalParameterTypes;
680 } 1081 }
681 return functionElement; 1082 return functionElement;
682 } 1083 }
683 static FunctionElement functionElement4(String functionName, ClassElement retu rnElement, List<ClassElement> normalParameters, List<String> names, List<ClassEl ement> namedParameters) { 1084 static FunctionElementImpl functionElement4(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<String> names, List<Cla ssElement> namedParameters) {
684 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier2(functionName)); 1085 FunctionElementImpl functionElement = new FunctionElementImpl.con1(ASTFactor y.identifier2(functionName));
685 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); 1086 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
686 functionElement.type = functionType; 1087 functionElement.type = functionType;
687 if (returnElement != null) { 1088 if (returnElement != null) {
688 functionType.returnType = returnElement.type; 1089 functionType.returnType = returnElement.type;
689 } 1090 }
690 int count = normalParameters == null ? 0 : normalParameters.length; 1091 int count = normalParameters == null ? 0 : normalParameters.length;
691 if (count > 0) { 1092 if (count > 0) {
692 List<InterfaceType> normalParameterTypes = new List<InterfaceType>(count); 1093 List<InterfaceType> normalParameterTypes = new List<InterfaceType>(count);
693 for (int i = 0; i < count; i++) { 1094 for (int i = 0; i < count; i++) {
694 normalParameterTypes[i] = normalParameters[i].type; 1095 normalParameterTypes[i] = normalParameters[i].type;
695 } 1096 }
696 functionType.normalParameterTypes = normalParameterTypes; 1097 functionType.normalParameterTypes = normalParameterTypes;
697 } 1098 }
698 if (names != null && names.length > 0 && names.length == namedParameters.len gth) { 1099 if (names != null && names.length > 0 && names.length == namedParameters.len gth) {
699 LinkedHashMap<String, Type2> map = new LinkedHashMap<String, Type2>(); 1100 LinkedHashMap<String, Type2> map = new LinkedHashMap<String, Type2>();
700 for (int i = 0; i < names.length; i++) { 1101 for (int i = 0; i < names.length; i++) {
701 map[names[i]] = namedParameters[i].type; 1102 map[names[i]] = namedParameters[i].type;
702 } 1103 }
703 functionType.namedParameterTypes = map; 1104 functionType.namedParameterTypes = map;
704 } else if (names != null) { 1105 } else if (names != null) {
705 throw new IllegalStateException("The passed String[] and ClassElement[] ar rays had different lengths."); 1106 throw new IllegalStateException("The passed String[] and ClassElement[] ar rays had different lengths.");
706 } 1107 }
707 return functionElement; 1108 return functionElement;
708 } 1109 }
709 static FunctionElement functionElement5(String functionName, List<ClassElement > normalParameters) => functionElement3(functionName, null, normalParameters, nu ll); 1110 static FunctionElementImpl functionElement5(String functionName, List<ClassEle ment> normalParameters) => functionElement3(functionName, null, normalParameters , null);
710 static FunctionElement functionElement6(String functionName, List<ClassElement > normalParameters, List<ClassElement> optionalParameters) => functionElement3(f unctionName, null, normalParameters, optionalParameters); 1111 static FunctionElementImpl functionElement6(String functionName, List<ClassEle ment> normalParameters, List<ClassElement> optionalParameters) => functionElemen t3(functionName, null, normalParameters, optionalParameters);
711 static FunctionElement functionElement7(String functionName, List<ClassElement > normalParameters, List<String> names, List<ClassElement> namedParameters) => f unctionElement4(functionName, null, normalParameters, names, namedParameters); 1112 static FunctionElementImpl functionElement7(String functionName, List<ClassEle ment> normalParameters, List<String> names, List<ClassElement> namedParameters) => functionElement4(functionName, null, normalParameters, names, namedParameters );
712 static ClassElement get object { 1113 static ClassElementImpl get object {
713 if (_objectElement == null) { 1114 if (_objectElement == null) {
714 _objectElement = classElement("Object", (null as InterfaceType), []); 1115 _objectElement = classElement("Object", (null as InterfaceType), []);
715 } 1116 }
716 return _objectElement; 1117 return _objectElement;
717 } 1118 }
718 static PropertyAccessorElement getterElement(String name, bool isStatic, Type2 type28) { 1119 static PropertyAccessorElementImpl getterElement(String name, bool isStatic, T ype2 type33) {
719 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me)); 1120 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me));
720 field.static = isStatic; 1121 field.static = isStatic;
721 field.synthetic = true; 1122 field.synthetic = true;
722 field.type = type28; 1123 field.type = type33;
723 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con1(fi eld); 1124 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
724 getter.getter = true; 1125 getter.getter = true;
725 field.getter = getter; 1126 field.getter = getter;
726 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1127 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
727 getterType.returnType = type28; 1128 getterType.returnType = type33;
728 getter.type = getterType; 1129 getter.type = getterType;
729 return getter; 1130 return getter;
730 } 1131 }
731 static ImportElementImpl importFor(LibraryElement importedLibrary4, PrefixElem ent prefix12, List<NamespaceCombinator> combinators4) { 1132 static ImportElementImpl importFor(LibraryElement importedLibrary5, PrefixElem ent prefix13, List<NamespaceCombinator> combinators5) {
732 ImportElementImpl spec = new ImportElementImpl(); 1133 ImportElementImpl spec = new ImportElementImpl();
733 spec.importedLibrary = importedLibrary4; 1134 spec.importedLibrary = importedLibrary5;
734 spec.prefix = prefix12; 1135 spec.prefix = prefix13;
735 spec.combinators = combinators4; 1136 spec.combinators = combinators5;
736 return spec; 1137 return spec;
737 } 1138 }
738 static LibraryElementImpl library(AnalysisContext context, String libraryName) { 1139 static LibraryElementImpl library(AnalysisContext context, String libraryName) {
739 String fileName = "${libraryName}.dart"; 1140 String fileName = "${libraryName}.dart";
740 FileBasedSource source = new FileBasedSource.con1(null, createFile(fileName) ); 1141 FileBasedSource source = new FileBasedSource.con1(null, FileUtilities2.creat eFile(fileName));
741 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName); 1142 CompilationUnitElementImpl unit = new CompilationUnitElementImpl(fileName);
742 unit.source = source; 1143 unit.source = source;
743 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName])); 1144 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName]));
744 library.definingCompilationUnit = unit; 1145 library.definingCompilationUnit = unit;
745 return library; 1146 return library;
746 } 1147 }
747 static MethodElement methodElement(String methodName, Type2 returnType9, List< Type2> argumentTypes) { 1148 static LocalVariableElementImpl localVariableElement(Identifier name) => new L ocalVariableElementImpl(name);
1149 static LocalVariableElementImpl localVariableElement2(String name) => new Loca lVariableElementImpl(ASTFactory.identifier2(name));
1150 static MethodElementImpl methodElement(String methodName, Type2 returnType11, List<Type2> argumentTypes) {
748 MethodElementImpl method = new MethodElementImpl.con1(ASTFactory.identifier2 (methodName)); 1151 MethodElementImpl method = new MethodElementImpl.con1(ASTFactory.identifier2 (methodName));
749 int count = argumentTypes.length; 1152 int count = argumentTypes.length;
750 List<ParameterElement> parameters = new List<ParameterElement>(count); 1153 List<ParameterElement> parameters = new List<ParameterElement>(count);
751 for (int i = 0; i < count; i++) { 1154 for (int i = 0; i < count; i++) {
752 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.ident ifier2("a${i}")); 1155 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.ident ifier2("a${i}"));
753 parameter.type = argumentTypes[i]; 1156 parameter.type = argumentTypes[i];
754 parameters[i] = parameter; 1157 parameters[i] = parameter;
755 } 1158 }
756 method.parameters = parameters; 1159 method.parameters = parameters;
757 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method); 1160 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method);
758 methodType.normalParameterTypes = argumentTypes; 1161 methodType.normalParameterTypes = argumentTypes;
759 methodType.returnType = returnType9; 1162 methodType.returnType = returnType11;
760 method.type = methodType; 1163 method.type = methodType;
761 return method; 1164 return method;
762 } 1165 }
763 static PropertyAccessorElement setterElement(String name, bool isStatic, Type2 type29) { 1166 static ParameterElementImpl namedParameter(String name) {
1167 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier2(name));
1168 parameter.parameterKind = ParameterKind.NAMED;
1169 return parameter;
1170 }
1171 static ParameterElementImpl positionalParameter(String name) {
1172 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier2(name));
1173 parameter.parameterKind = ParameterKind.POSITIONAL;
1174 return parameter;
1175 }
1176 static PrefixElementImpl prefix(String name) => new PrefixElementImpl(ASTFacto ry.identifier2(name));
1177 static ParameterElementImpl requiredParameter(String name) {
1178 ParameterElementImpl parameter = new ParameterElementImpl(ASTFactory.identif ier2(name));
1179 parameter.parameterKind = ParameterKind.REQUIRED;
1180 return parameter;
1181 }
1182 static PropertyAccessorElementImpl setterElement(String name, bool isStatic, T ype2 type34) {
764 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me)); 1183 FieldElementImpl field = new FieldElementImpl.con1(ASTFactory.identifier2(na me));
765 field.static = isStatic; 1184 field.static = isStatic;
766 field.synthetic = true; 1185 field.synthetic = true;
767 field.type = type29; 1186 field.type = type34;
768 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con1(fi eld); 1187 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2(fi eld);
769 getter.getter = true; 1188 getter.getter = true;
770 field.getter = getter; 1189 field.getter = getter;
771 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); 1190 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter);
772 getterType.returnType = type29; 1191 getterType.returnType = type34;
773 getter.type = getterType; 1192 getter.type = getterType;
774 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con1(fi eld); 1193 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con2(fi eld);
775 setter.setter = true; 1194 setter.setter = true;
776 setter.synthetic = true; 1195 setter.synthetic = true;
777 field.setter = setter; 1196 field.setter = setter;
778 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter); 1197 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(getter);
779 setterType.normalParameterTypes = <Type2> [type29]; 1198 setterType.normalParameterTypes = <Type2> [type34];
780 setterType.returnType = VoidTypeImpl.instance; 1199 setterType.returnType = VoidTypeImpl.instance;
781 setter.type = setterType; 1200 setter.type = setterType;
782 return setter; 1201 return setter;
783 } 1202 }
784 static VariableElement variableElement(String name) => new VariableElementImpl .con2(name, -1); 1203 static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.con1(name);
1204 static TopLevelVariableElementImpl topLevelVariableElement2(String name) => ne w TopLevelVariableElementImpl.con2(name);
785 /** 1205 /**
786 * Prevent the creation of instances of this class. 1206 * Prevent the creation of instances of this class.
787 */ 1207 */
788 ElementFactory() { 1208 ElementFactory() {
789 } 1209 }
790 } 1210 }
1211 class ClassElementImplTest extends EngineTestCase {
1212 void test_allSupertypes_interface() {
1213 ClassElement elementA = ElementFactory.classElement2("A", []);
1214 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1215 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
1216 InterfaceType typeObject = elementA.supertype;
1217 InterfaceType typeA = elementA.type;
1218 InterfaceType typeB = elementB.type;
1219 InterfaceType typeC = elementC.type;
1220 elementC.interfaces = <InterfaceType> [typeB];
1221 List<InterfaceType> supers = elementC.allSupertypes;
1222 List<InterfaceType> types = new List<InterfaceType>();
1223 types.addAll(supers);
1224 JUnitTestCase.assertTrue(types.contains(typeA));
1225 JUnitTestCase.assertTrue(types.contains(typeB));
1226 JUnitTestCase.assertTrue(types.contains(typeObject));
1227 JUnitTestCase.assertFalse(types.contains(typeC));
1228 }
1229 void test_allSupertypes_mixins() {
1230 ClassElement elementA = ElementFactory.classElement2("A", []);
1231 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1232 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
1233 InterfaceType typeObject = elementA.supertype;
1234 InterfaceType typeA = elementA.type;
1235 InterfaceType typeB = elementB.type;
1236 InterfaceType typeC = elementC.type;
1237 elementC.mixins = <InterfaceType> [typeB];
1238 List<InterfaceType> supers = elementC.allSupertypes;
1239 List<InterfaceType> types = new List<InterfaceType>();
1240 types.addAll(supers);
1241 JUnitTestCase.assertFalse(types.contains(typeA));
1242 JUnitTestCase.assertTrue(types.contains(typeB));
1243 JUnitTestCase.assertTrue(types.contains(typeObject));
1244 JUnitTestCase.assertFalse(types.contains(typeC));
1245 }
1246 void test_lookUpGetter_declared() {
1247 LibraryElementImpl library6 = ElementFactory.library(new AnalysisContextImpl (), "lib");
1248 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1249 String getterName = "g";
1250 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
1251 classA.accessors = <PropertyAccessorElement> [getter];
1252 ((library6.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classA];
1253 JUnitTestCase.assertSame(getter, classA.lookUpGetter(getterName, library6));
1254 }
1255 void test_lookUpGetter_inherited() {
1256 LibraryElementImpl library7 = ElementFactory.library(new AnalysisContextImpl (), "lib");
1257 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1258 String getterName = "g";
1259 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
1260 classA.accessors = <PropertyAccessorElement> [getter];
1261 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1262 ((library7.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classA, classB];
1263 JUnitTestCase.assertSame(getter, classB.lookUpGetter(getterName, library7));
1264 }
1265 void test_lookUpGetter_undeclared() {
1266 LibraryElementImpl library8 = ElementFactory.library(new AnalysisContextImpl (), "lib");
1267 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1268 ((library8.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classA];
1269 JUnitTestCase.assertNull(classA.lookUpGetter("g", library8));
1270 }
1271 void test_lookUpMethod_declared() {
1272 LibraryElementImpl library9 = ElementFactory.library(new AnalysisContextImpl (), "lib");
1273 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1274 String methodName = "m";
1275 MethodElement method = ElementFactory.methodElement(methodName, null, []);
1276 classA.methods = <MethodElement> [method];
1277 ((library9.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classA];
1278 JUnitTestCase.assertSame(method, classA.lookUpMethod(methodName, library9));
1279 }
1280 void test_lookUpMethod_inherited() {
1281 LibraryElementImpl library10 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1282 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1283 String methodName = "m";
1284 MethodElement method = ElementFactory.methodElement(methodName, null, []);
1285 classA.methods = <MethodElement> [method];
1286 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1287 ((library10.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA, classB];
1288 JUnitTestCase.assertSame(method, classB.lookUpMethod(methodName, library10)) ;
1289 }
1290 void test_lookUpMethod_undeclared() {
1291 LibraryElementImpl library11 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1292 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1293 ((library11.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1294 JUnitTestCase.assertNull(classA.lookUpMethod("m", library11));
1295 }
1296 void test_lookUpSetter_declared() {
1297 LibraryElementImpl library12 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1298 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1299 String setterName = "s";
1300 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
1301 classA.accessors = <PropertyAccessorElement> [setter];
1302 ((library12.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1303 JUnitTestCase.assertSame(setter, classA.lookUpSetter(setterName, library12)) ;
1304 }
1305 void test_lookUpSetter_inherited() {
1306 LibraryElementImpl library13 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1307 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1308 String setterName = "s";
1309 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
1310 classA.accessors = <PropertyAccessorElement> [setter];
1311 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
1312 ((library13.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA, classB];
1313 JUnitTestCase.assertSame(setter, classB.lookUpSetter(setterName, library13)) ;
1314 }
1315 void test_lookUpSetter_undeclared() {
1316 LibraryElementImpl library14 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1317 ClassElementImpl classA = ElementFactory.classElement2("A", []);
1318 ((library14.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1319 JUnitTestCase.assertNull(classA.lookUpSetter("s", library14));
1320 }
1321 static dartSuite() {
1322 _ut.group('ClassElementImplTest', () {
1323 _ut.test('test_allSupertypes_interface', () {
1324 final __test = new ClassElementImplTest();
1325 runJUnitTest(__test, __test.test_allSupertypes_interface);
1326 });
1327 _ut.test('test_allSupertypes_mixins', () {
1328 final __test = new ClassElementImplTest();
1329 runJUnitTest(__test, __test.test_allSupertypes_mixins);
1330 });
1331 _ut.test('test_lookUpGetter_declared', () {
1332 final __test = new ClassElementImplTest();
1333 runJUnitTest(__test, __test.test_lookUpGetter_declared);
1334 });
1335 _ut.test('test_lookUpGetter_inherited', () {
1336 final __test = new ClassElementImplTest();
1337 runJUnitTest(__test, __test.test_lookUpGetter_inherited);
1338 });
1339 _ut.test('test_lookUpGetter_undeclared', () {
1340 final __test = new ClassElementImplTest();
1341 runJUnitTest(__test, __test.test_lookUpGetter_undeclared);
1342 });
1343 _ut.test('test_lookUpMethod_declared', () {
1344 final __test = new ClassElementImplTest();
1345 runJUnitTest(__test, __test.test_lookUpMethod_declared);
1346 });
1347 _ut.test('test_lookUpMethod_inherited', () {
1348 final __test = new ClassElementImplTest();
1349 runJUnitTest(__test, __test.test_lookUpMethod_inherited);
1350 });
1351 _ut.test('test_lookUpMethod_undeclared', () {
1352 final __test = new ClassElementImplTest();
1353 runJUnitTest(__test, __test.test_lookUpMethod_undeclared);
1354 });
1355 _ut.test('test_lookUpSetter_declared', () {
1356 final __test = new ClassElementImplTest();
1357 runJUnitTest(__test, __test.test_lookUpSetter_declared);
1358 });
1359 _ut.test('test_lookUpSetter_inherited', () {
1360 final __test = new ClassElementImplTest();
1361 runJUnitTest(__test, __test.test_lookUpSetter_inherited);
1362 });
1363 _ut.test('test_lookUpSetter_undeclared', () {
1364 final __test = new ClassElementImplTest();
1365 runJUnitTest(__test, __test.test_lookUpSetter_undeclared);
1366 });
1367 });
1368 }
1369 }
791 class ElementImplTest extends EngineTestCase { 1370 class ElementImplTest extends EngineTestCase {
1371 void test_equals() {
1372 LibraryElementImpl library15 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1373 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
1374 ((library15.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classElement];
1375 FieldElement field = ElementFactory.fieldElement("next", false, false, false , classElement.type);
1376 classElement.fields = <FieldElement> [field];
1377 JUnitTestCase.assertTrue(field == field);
1378 JUnitTestCase.assertFalse(field == field.getter);
1379 JUnitTestCase.assertFalse(field == field.setter);
1380 JUnitTestCase.assertFalse(field.getter == field.setter);
1381 }
792 void test_isAccessibleIn_private_differentLibrary() { 1382 void test_isAccessibleIn_private_differentLibrary() {
793 AnalysisContextImpl context = new AnalysisContextImpl(); 1383 AnalysisContextImpl context = new AnalysisContextImpl();
794 LibraryElementImpl library1 = ElementFactory.library(context, "lib1"); 1384 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
795 ClassElement classElement = ElementFactory.classElement2("_C", []); 1385 ClassElement classElement = ElementFactory.classElement2("_C", []);
796 ((library1.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classElement]; 1386 ((library1.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classElement];
797 LibraryElementImpl library2 = ElementFactory.library(context, "lib2"); 1387 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
798 JUnitTestCase.assertFalse(classElement.isAccessibleIn(library2)); 1388 JUnitTestCase.assertFalse(classElement.isAccessibleIn(library2));
799 } 1389 }
800 void test_isAccessibleIn_private_sameLibrary() { 1390 void test_isAccessibleIn_private_sameLibrary() {
801 LibraryElementImpl library15 = ElementFactory.library(new AnalysisContextImp l(), "lib"); 1391 LibraryElementImpl library16 = ElementFactory.library(new AnalysisContextImp l(), "lib");
802 ClassElement classElement = ElementFactory.classElement2("_C", []); 1392 ClassElement classElement = ElementFactory.classElement2("_C", []);
803 ((library15.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classElement]; 1393 ((library16.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classElement];
804 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library15)); 1394 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library16));
805 } 1395 }
806 void test_isAccessibleIn_public_differentLibrary() { 1396 void test_isAccessibleIn_public_differentLibrary() {
807 AnalysisContextImpl context = new AnalysisContextImpl(); 1397 AnalysisContextImpl context = new AnalysisContextImpl();
808 LibraryElementImpl library1 = ElementFactory.library(context, "lib1"); 1398 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
809 ClassElement classElement = ElementFactory.classElement2("C", []); 1399 ClassElement classElement = ElementFactory.classElement2("C", []);
810 ((library1.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classElement]; 1400 ((library1.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classElement];
811 LibraryElementImpl library2 = ElementFactory.library(context, "lib2"); 1401 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
812 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library2)); 1402 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library2));
813 } 1403 }
814 void test_isAccessibleIn_public_sameLibrary() { 1404 void test_isAccessibleIn_public_sameLibrary() {
815 LibraryElementImpl library16 = ElementFactory.library(new AnalysisContextImp l(), "lib"); 1405 LibraryElementImpl library17 = ElementFactory.library(new AnalysisContextImp l(), "lib");
816 ClassElement classElement = ElementFactory.classElement2("C", []); 1406 ClassElement classElement = ElementFactory.classElement2("C", []);
817 ((library16.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classElement]; 1407 ((library17.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classElement];
818 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library16)); 1408 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library17));
819 } 1409 }
820 static dartSuite() { 1410 static dartSuite() {
821 _ut.group('ElementImplTest', () { 1411 _ut.group('ElementImplTest', () {
1412 // _ut.test('test_equals', () {
1413 // final __test = new ElementImplTest();
1414 // runJUnitTest(__test, __test.test_equals);
1415 // });
822 _ut.test('test_isAccessibleIn_private_differentLibrary', () { 1416 _ut.test('test_isAccessibleIn_private_differentLibrary', () {
823 final __test = new ElementImplTest(); 1417 final __test = new ElementImplTest();
824 runJUnitTest(__test, __test.test_isAccessibleIn_private_differentLibrary ); 1418 runJUnitTest(__test, __test.test_isAccessibleIn_private_differentLibrary );
825 }); 1419 });
826 _ut.test('test_isAccessibleIn_private_sameLibrary', () { 1420 _ut.test('test_isAccessibleIn_private_sameLibrary', () {
827 final __test = new ElementImplTest(); 1421 final __test = new ElementImplTest();
828 runJUnitTest(__test, __test.test_isAccessibleIn_private_sameLibrary); 1422 runJUnitTest(__test, __test.test_isAccessibleIn_private_sameLibrary);
829 }); 1423 });
830 _ut.test('test_isAccessibleIn_public_differentLibrary', () { 1424 _ut.test('test_isAccessibleIn_public_differentLibrary', () {
831 final __test = new ElementImplTest(); 1425 final __test = new ElementImplTest();
832 runJUnitTest(__test, __test.test_isAccessibleIn_public_differentLibrary) ; 1426 runJUnitTest(__test, __test.test_isAccessibleIn_public_differentLibrary) ;
833 }); 1427 });
834 _ut.test('test_isAccessibleIn_public_sameLibrary', () { 1428 _ut.test('test_isAccessibleIn_public_sameLibrary', () {
835 final __test = new ElementImplTest(); 1429 final __test = new ElementImplTest();
836 runJUnitTest(__test, __test.test_isAccessibleIn_public_sameLibrary); 1430 runJUnitTest(__test, __test.test_isAccessibleIn_public_sameLibrary);
837 }); 1431 });
838 }); 1432 });
839 } 1433 }
840 } 1434 }
841 class InterfaceTypeImplTest extends EngineTestCase { 1435 class FunctionTypeImplTest extends EngineTestCase {
842 void test_computeLongestInheritancePathToObject_multipleInterfacePaths() {
843 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl);
844 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl);
845 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
846 ClassElementImpl elementD = (ElementFactory.classElement2("D", []) as ClassE lementImpl);
847 ClassElementImpl elementE = (ElementFactory.classElement2("E", []) as ClassE lementImpl);
848 elementB.interfaces = <InterfaceType> [elementA.type];
849 elementC.interfaces = <InterfaceType> [elementA.type];
850 elementD.interfaces = <InterfaceType> [elementC.type];
851 elementE.interfaces = <InterfaceType> [elementB.type, elementD.type];
852 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementB.type));
853 JUnitTestCase.assertEquals(4, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementE.type));
854 }
855 void test_computeLongestInheritancePathToObject_multipleSuperclassPaths() {
856 ClassElement elementA = ElementFactory.classElement2("A", []);
857 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
858 ClassElement elementC = ElementFactory.classElement("C", elementA.type, []);
859 ClassElement elementD = ElementFactory.classElement("D", elementC.type, []);
860 ClassElementImpl elementE = (ElementFactory.classElement("E", elementB.type, []) as ClassElementImpl);
861 elementE.interfaces = <InterfaceType> [elementD.type];
862 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementB.type));
863 JUnitTestCase.assertEquals(4, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementE.type));
864 }
865 void test_computeLongestInheritancePathToObject_object() {
866 ClassElement elementA = ElementFactory.classElement2("A", []);
867 InterfaceType object = elementA.supertype;
868 JUnitTestCase.assertEquals(0, InterfaceTypeImpl.computeLongestInheritancePat hToObject(object));
869 }
870 void test_computeLongestInheritancePathToObject_singleInterfacePath() {
871 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl);
872 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl);
873 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
874 elementB.interfaces = <InterfaceType> [elementA.type];
875 elementC.interfaces = <InterfaceType> [elementB.type];
876 JUnitTestCase.assertEquals(1, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementA.type));
877 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementB.type));
878 JUnitTestCase.assertEquals(3, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementC.type));
879 }
880 void test_computeLongestInheritancePathToObject_singleSuperclassPath() {
881 ClassElement elementA = ElementFactory.classElement2("A", []);
882 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
883 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
884 JUnitTestCase.assertEquals(1, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementA.type));
885 JUnitTestCase.assertEquals(2, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementB.type));
886 JUnitTestCase.assertEquals(3, InterfaceTypeImpl.computeLongestInheritancePat hToObject(elementC.type));
887 }
888 void test_computeSuperinterfaceSet_multipleInterfacePaths() {
889 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl);
890 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl);
891 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
892 ClassElementImpl elementD = (ElementFactory.classElement2("D", []) as ClassE lementImpl);
893 ClassElementImpl elementE = (ElementFactory.classElement2("E", []) as ClassE lementImpl);
894 elementB.interfaces = <InterfaceType> [elementA.type];
895 elementC.interfaces = <InterfaceType> [elementA.type];
896 elementD.interfaces = <InterfaceType> [elementC.type];
897 elementE.interfaces = <InterfaceType> [elementB.type, elementD.type];
898 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(elementD.type);
899 JUnitTestCase.assertNotNull(superinterfacesOfD);
900 JUnitTestCase.assertTrue(superinterfacesOfD.contains(ElementFactory.object.t ype));
901 JUnitTestCase.assertTrue(superinterfacesOfD.contains(elementA.type));
902 JUnitTestCase.assertTrue(superinterfacesOfD.contains(elementC.type));
903 JUnitTestCase.assertEquals(3, superinterfacesOfD.length);
904 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(elementE.type);
905 JUnitTestCase.assertNotNull(superinterfacesOfE);
906 JUnitTestCase.assertTrue(superinterfacesOfE.contains(ElementFactory.object.t ype));
907 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementA.type));
908 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementB.type));
909 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementC.type));
910 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementD.type));
911 JUnitTestCase.assertEquals(5, superinterfacesOfE.length);
912 }
913 void test_computeSuperinterfaceSet_multipleSuperclassPaths() {
914 ClassElement elementA = ElementFactory.classElement2("A", []);
915 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
916 ClassElement elementC = ElementFactory.classElement("C", elementA.type, []);
917 ClassElement elementD = ElementFactory.classElement("D", elementC.type, []);
918 ClassElementImpl elementE = (ElementFactory.classElement("E", elementB.type, []) as ClassElementImpl);
919 elementE.interfaces = <InterfaceType> [elementD.type];
920 Set<InterfaceType> superinterfacesOfD = InterfaceTypeImpl.computeSuperinterf aceSet(elementD.type);
921 JUnitTestCase.assertNotNull(superinterfacesOfD);
922 JUnitTestCase.assertTrue(superinterfacesOfD.contains(ElementFactory.object.t ype));
923 JUnitTestCase.assertTrue(superinterfacesOfD.contains(elementA.type));
924 JUnitTestCase.assertTrue(superinterfacesOfD.contains(elementC.type));
925 JUnitTestCase.assertEquals(3, superinterfacesOfD.length);
926 Set<InterfaceType> superinterfacesOfE = InterfaceTypeImpl.computeSuperinterf aceSet(elementE.type);
927 JUnitTestCase.assertNotNull(superinterfacesOfE);
928 JUnitTestCase.assertTrue(superinterfacesOfE.contains(ElementFactory.object.t ype));
929 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementA.type));
930 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementB.type));
931 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementC.type));
932 JUnitTestCase.assertTrue(superinterfacesOfE.contains(elementD.type));
933 JUnitTestCase.assertEquals(5, superinterfacesOfE.length);
934 }
935 void test_computeSuperinterfaceSet_singleInterfacePath() {
936 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl);
937 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl);
938 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
939 elementB.interfaces = <InterfaceType> [elementA.type];
940 elementC.interfaces = <InterfaceType> [elementB.type];
941 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(elementA.type);
942 JUnitTestCase.assertNotNull(superinterfacesOfA);
943 JUnitTestCase.assertTrue(superinterfacesOfA.contains(ElementFactory.object.t ype));
944 JUnitTestCase.assertEquals(1, superinterfacesOfA.length);
945 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(elementB.type);
946 JUnitTestCase.assertNotNull(superinterfacesOfB);
947 JUnitTestCase.assertTrue(superinterfacesOfB.contains(ElementFactory.object.t ype));
948 JUnitTestCase.assertTrue(superinterfacesOfB.contains(elementA.type));
949 JUnitTestCase.assertEquals(2, superinterfacesOfB.length);
950 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(elementC.type);
951 JUnitTestCase.assertNotNull(superinterfacesOfC);
952 JUnitTestCase.assertTrue(superinterfacesOfC.contains(ElementFactory.object.t ype));
953 JUnitTestCase.assertTrue(superinterfacesOfC.contains(elementA.type));
954 JUnitTestCase.assertTrue(superinterfacesOfC.contains(elementB.type));
955 JUnitTestCase.assertEquals(3, superinterfacesOfC.length);
956 }
957 void test_computeSuperinterfaceSet_singleSuperclassPath() {
958 ClassElement elementA = ElementFactory.classElement2("A", []);
959 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
960 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
961 Set<InterfaceType> superinterfacesOfA = InterfaceTypeImpl.computeSuperinterf aceSet(elementA.type);
962 JUnitTestCase.assertNotNull(superinterfacesOfA);
963 JUnitTestCase.assertTrue(superinterfacesOfA.contains(ElementFactory.object.t ype));
964 JUnitTestCase.assertEquals(1, superinterfacesOfA.length);
965 Set<InterfaceType> superinterfacesOfB = InterfaceTypeImpl.computeSuperinterf aceSet(elementB.type);
966 JUnitTestCase.assertNotNull(superinterfacesOfB);
967 JUnitTestCase.assertTrue(superinterfacesOfB.contains(ElementFactory.object.t ype));
968 JUnitTestCase.assertTrue(superinterfacesOfB.contains(elementA.type));
969 JUnitTestCase.assertEquals(2, superinterfacesOfB.length);
970 Set<InterfaceType> superinterfacesOfC = InterfaceTypeImpl.computeSuperinterf aceSet(elementC.type);
971 JUnitTestCase.assertNotNull(superinterfacesOfC);
972 JUnitTestCase.assertTrue(superinterfacesOfC.contains(ElementFactory.object.t ype));
973 JUnitTestCase.assertTrue(superinterfacesOfC.contains(elementA.type));
974 JUnitTestCase.assertTrue(superinterfacesOfC.contains(elementB.type));
975 JUnitTestCase.assertEquals(3, superinterfacesOfC.length);
976 }
977 void test_creation() { 1436 void test_creation() {
978 JUnitTestCase.assertNotNull(new InterfaceTypeImpl.con1(new ClassElementImpl( ASTFactory.identifier2("A")))); 1437 JUnitTestCase.assertNotNull(new FunctionTypeImpl.con1(new FunctionElementImp l.con1(ASTFactory.identifier2("f"))));
979 } 1438 }
980 void test_getElement() { 1439 void test_getElement() {
981 ClassElementImpl typeElement = new ClassElementImpl(ASTFactory.identifier2(" A")); 1440 FunctionElementImpl typeElement = new FunctionElementImpl.con1(ASTFactory.id entifier2("f"));
982 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(typeElement); 1441 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement);
983 JUnitTestCase.assertEquals(typeElement, type.element); 1442 JUnitTestCase.assertEquals(typeElement, type.element);
984 } 1443 }
985 void test_getLeastUpperBound_directInterfaceCase() { 1444 void test_getNamedParameterTypes() {
986 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl); 1445 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
987 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl); 1446 Map<String, Type2> types = type.namedParameterTypes;
988 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl); 1447 EngineTestCase.assertSize2(0, types);
989 InterfaceType typeA = elementA.type; 1448 }
990 InterfaceType typeB = elementB.type; 1449 void test_getNormalParameterTypes() {
991 InterfaceType typeC = elementC.type; 1450 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
992 elementB.interfaces = <InterfaceType> [typeA]; 1451 List<Type2> types = type.normalParameterTypes;
993 elementC.interfaces = <InterfaceType> [typeB]; 1452 EngineTestCase.assertLength(0, types);
994 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC)); 1453 }
995 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB)); 1454 void test_getReturnType() {
996 } 1455 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
997 void test_getLeastUpperBound_directSubclassCase() { 1456 Type2 returnType7 = type.returnType;
998 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl); 1457 JUnitTestCase.assertEquals(VoidTypeImpl.instance, returnType7);
999 ClassElementImpl elementB = (ElementFactory.classElement("B", elementA.type, []) as ClassElementImpl); 1458 }
1000 ClassElementImpl elementC = (ElementFactory.classElement("C", elementB.type, []) as ClassElementImpl); 1459 void test_getTypeArguments() {
1001 InterfaceType typeB = elementB.type; 1460 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
1002 InterfaceType typeC = elementC.type; 1461 List<Type2> types = type.typeArguments;
1003 JUnitTestCase.assertEquals(typeB, typeB.getLeastUpperBound(typeC)); 1462 EngineTestCase.assertLength(0, types);
1004 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeB)); 1463 }
1005 } 1464 void test_hashCode_element() {
1006 void test_getLeastUpperBound_functionType() { 1465 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
1007 Type2 interfaceType = ElementFactory.classElement2("A", []).type; 1466 type.hashCode;
1467 }
1468 void test_hashCode_noElement() {
1469 FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement ));
1470 type.hashCode;
1471 }
1472 void test_isSubtypeOf_baseCase_classFunction() {
1473 ClassElementImpl functionElement = ElementFactory.classElement2("Function", []);
1474 InterfaceTypeImpl functionType = new InterfaceTypeImpl_11(functionElement);
1475 FunctionType f = ElementFactory.functionElement("f").type;
1476 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType));
1477 }
1478 void test_isSubtypeOf_baseCase_notFunctionType() {
1479 FunctionType f = ElementFactory.functionElement("f").type;
1480 InterfaceType t = ElementFactory.classElement2("C", []).type;
1481 JUnitTestCase.assertFalse(f.isSubtypeOf(t));
1482 }
1483 void test_isSubtypeOf_baseCase_null() {
1484 FunctionType f = ElementFactory.functionElement("f").type;
1485 JUnitTestCase.assertFalse(f.isSubtypeOf(null));
1486 }
1487 void test_isSubtypeOf_baseCase_self() {
1488 FunctionType f = ElementFactory.functionElement("f").type;
1489 JUnitTestCase.assertTrue(f.isSubtypeOf(f));
1490 }
1491 void test_isSubtypeOf_namedParameters_isAssignable() {
1492 ClassElement a = ElementFactory.classElement2("A", []);
1493 ClassElement b = ElementFactory.classElement("B", a.type, []);
1494 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1495 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
1496 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1497 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
1498 }
1499 void test_isSubtypeOf_namedParameters_isNotAssignable() {
1500 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("A", [])]).type;
1501 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("B", [])]).type;
1502 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1503 }
1504 void test_isSubtypeOf_namedParameters_namesDifferent() {
1505 ClassElement a = ElementFactory.classElement2("A", []);
1506 ClassElement b = ElementFactory.classElement("B", a.type, []);
1507 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1508 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "diff"], <ClassElement> [b]).type;
1509 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1510 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1511 }
1512 void test_isSubtypeOf_namedParameters_orderOfParams() {
1513 ClassElement a = ElementFactory.classElement2("A", []);
1514 ClassElement b = ElementFactory.classElement("B", a.type, []);
1515 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
1516 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
1517 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1518 }
1519 void test_isSubtypeOf_namedParameters_orderOfParams2() {
1520 ClassElement a = ElementFactory.classElement2("A", []);
1521 ClassElement b = ElementFactory.classElement("B", a.type, []);
1522 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "B"], <ClassElement> [b]).type;
1523 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
1524 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1525 }
1526 void test_isSubtypeOf_namedParameters_orderOfParams3() {
1527 ClassElement a = ElementFactory.classElement2("A", []);
1528 ClassElement b = ElementFactory.classElement("B", a.type, []);
1529 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
1530 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B"], <ClassElement> [b]).type;
1531 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1532 }
1533 void test_isSubtypeOf_namedParameters_sHasMoreParams() {
1534 ClassElement a = ElementFactory.classElement2("A", []);
1535 ClassElement b = ElementFactory.classElement("B", a.type, []);
1536 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1537 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name", "name2"], <ClassElement> [b, b]).type;
1538 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1539 }
1540 void test_isSubtypeOf_namedParameters_tHasMoreParams() {
1541 ClassElement a = ElementFactory.classElement2("A", []);
1542 ClassElement b = ElementFactory.classElement("B", a.type, []);
1543 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name", "name2"], <ClassElement> [a, a]).type;
1544 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
1545 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1546 }
1547 void test_isSubtypeOf_normalParameters_isAssignable() {
1548 ClassElement a = ElementFactory.classElement2("A", []);
1549 ClassElement b = ElementFactory.classElement("B", a.type, []);
1550 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1551 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
1552 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1553 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
1554 }
1555 void test_isSubtypeOf_normalParameters_isNotAssignable() {
1556 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen tFactory.classElement2("A", [])]).type;
1557 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen tFactory.classElement2("B", [])]).type;
1558 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1559 }
1560 void test_isSubtypeOf_normalParameters_sHasMoreParams() {
1561 ClassElement a = ElementFactory.classElement2("A", []);
1562 ClassElement b = ElementFactory.classElement("B", a.type, []);
1563 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1564 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b]) .type;
1565 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1566 }
1567 void test_isSubtypeOf_normalParameters_tHasMoreParams() {
1568 ClassElement a = ElementFactory.classElement2("A", []);
1569 ClassElement b = ElementFactory.classElement("B", a.type, []);
1570 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a]) .type;
1571 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
1572 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1573 }
1574 void test_isSubtypeOf_optionalParameters_isAssignable() {
1575 ClassElement a = ElementFactory.classElement2("A", []);
1576 ClassElement b = ElementFactory.classElement("B", a.type, []);
1577 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1578 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
1579 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1580 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
1581 }
1582 void test_isSubtypeOf_optionalParameters_isNotAssignable() {
1583 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ ElementFactory.classElement2("A", [])]).type;
1584 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ ElementFactory.classElement2("B", [])]).type;
1585 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1586 }
1587 void test_isSubtypeOf_optionalParameters_sHasMoreParams() {
1588 ClassElement a = ElementFactory.classElement2("A", []);
1589 ClassElement b = ElementFactory.classElement("B", a.type, []);
1590 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1591 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b, b]).type;
1592 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1593 }
1594 void test_isSubtypeOf_optionalParameters_tHasMoreParams() {
1595 ClassElement a = ElementFactory.classElement2("A", []);
1596 ClassElement b = ElementFactory.classElement("B", a.type, []);
1597 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a, a]).type;
1598 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
1599 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1600 }
1601 void test_isSubtypeOf_returnType_sIsVoid() {
1602 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A", [])).type;
1603 FunctionType s = ElementFactory.functionElement("s").type;
1604 JUnitTestCase.assertTrue(VoidTypeImpl.instance == s.returnType);
1605 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1606 }
1607 void test_isSubtypeOf_returnType_tAssignableToS() {
1608 ClassElement a = ElementFactory.classElement2("A", []);
1609 ClassElement b = ElementFactory.classElement("B", a.type, []);
1610 FunctionType t = ElementFactory.functionElement2("t", a).type;
1611 FunctionType s = ElementFactory.functionElement2("s", b).type;
1612 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1613 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
1614 }
1615 void test_isSubtypeOf_returnType_tNotAssignableToS() {
1616 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A", [])).type;
1617 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl ement2("B", [])).type;
1618 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1619 }
1620 void test_isSubtypeOf_wrongFunctionType_normal_named() {
1621 ClassElement a = ElementFactory.classElement2("A", []);
1622 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1623 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
1624 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1625 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1626 }
1627 void test_isSubtypeOf_wrongFunctionType_normal_optional() {
1628 ClassElement a = ElementFactory.classElement2("A", []);
1629 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1630 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ a]).type;
1631 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1632 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1633 }
1634 void test_isSubtypeOf_wrongFunctionType_optional_named() {
1635 ClassElement a = ElementFactory.classElement2("A", []);
1636 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1637 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
1638 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1639 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1640 }
1641 void test_setNamedParameterTypes() {
1642 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
1643 LinkedHashMap<String, Type2> expectedTypes = new LinkedHashMap<String, Type2 >();
1644 expectedTypes["a"] = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFact ory.identifier2("C")));
1645 type.namedParameterTypes = expectedTypes;
1646 Map<String, Type2> types = type.namedParameterTypes;
1647 JUnitTestCase.assertEquals(expectedTypes, types);
1648 }
1649 void test_setNormalParameterTypes() {
1650 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
1651 List<Type2> expectedTypes = <Type2> [new InterfaceTypeImpl.con1(new ClassEle mentImpl(ASTFactory.identifier2("C")))];
1652 type.normalParameterTypes = expectedTypes;
1653 List<Type2> types = type.normalParameterTypes;
1654 JUnitTestCase.assertEquals(expectedTypes, types);
1655 }
1656 void test_setReturnType() {
1657 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
1658 Type2 expectedType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFact ory.identifier2("C")));
1659 type.returnType = expectedType;
1660 Type2 returnType8 = type.returnType;
1661 JUnitTestCase.assertEquals(expectedType, returnType8);
1662 }
1663 void test_setTypeArguments() {
1664 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.co n1(ASTFactory.identifier2("f")));
1665 Type2 expectedType = new TypeVariableTypeImpl(new TypeVariableElementImpl(AS TFactory.identifier2("C")));
1666 type.typeArguments = <Type2> [expectedType];
1667 List<Type2> arguments = type.typeArguments;
1668 EngineTestCase.assertLength(1, arguments);
1669 JUnitTestCase.assertEquals(expectedType, arguments[0]);
1670 }
1671 void test_substitute2_equal() {
1008 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier2("f"))); 1672 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier2("f")));
1009 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(functionType)); 1673 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier2("E")));
1010 } 1674 functionType.returnType = parameterType;
1011 void test_getLeastUpperBound_mixinCase() { 1675 functionType.normalParameterTypes = <Type2> [parameterType];
1012 ClassElement elementA = ElementFactory.classElement2("A", []); 1676 functionType.optionalParameterTypes = <Type2> [parameterType];
1013 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []); 1677 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>();
1014 ClassElement elementC = ElementFactory.classElement("C", elementA.type, []); 1678 String namedParameterName = "c";
1015 ClassElementImpl elementD = (ElementFactory.classElement("D", elementB.type, []) as ClassElementImpl); 1679 namedParameterTypes[namedParameterName] = parameterType;
1016 InterfaceType typeA = elementA.type; 1680 functionType.namedParameterTypes = namedParameterTypes;
1017 InterfaceType typeC = elementC.type; 1681 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("D")));
1018 InterfaceType typeD = elementD.type; 1682 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]);
1019 elementD.mixins = <InterfaceType> [ElementFactory.classElement2("M", []).typ e, ElementFactory.classElement2("N", []).type, ElementFactory.classElement2("O", []).type, ElementFactory.classElement2("P", []).type]; 1683 JUnitTestCase.assertEquals(argumentType, result.returnType);
1020 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeC)); 1684 List<Type2> normalParameters = result.normalParameterTypes;
1021 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeD)); 1685 EngineTestCase.assertLength(1, normalParameters);
1022 } 1686 JUnitTestCase.assertEquals(argumentType, normalParameters[0]);
1023 void test_getLeastUpperBound_null() { 1687 List<Type2> optionalParameters = result.optionalParameterTypes;
1024 Type2 interfaceType = ElementFactory.classElement2("A", []).type; 1688 EngineTestCase.assertLength(1, optionalParameters);
1025 JUnitTestCase.assertNull(interfaceType.getLeastUpperBound(null)); 1689 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]);
1026 } 1690 Map<String, Type2> namedParameters = result.namedParameterTypes;
1027 void test_getLeastUpperBound_object() { 1691 EngineTestCase.assertSize2(1, namedParameters);
1028 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl); 1692 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] );
1029 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl); 1693 }
1030 InterfaceType typeA = elementA.type; 1694 void test_substitute2_notEqual() {
1031 InterfaceType typeB = elementB.type; 1695 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(new FunctionElemen tImpl.con1(ASTFactory.identifier2("f")));
1032 Type2 typeObject = typeA.element.supertype; 1696 Type2 returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(ASTFactor y.identifier2("R")));
1033 JUnitTestCase.assertNull(((typeObject.element as ClassElement)).supertype); 1697 Type2 normalParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl( ASTFactory.identifier2("A")));
1034 JUnitTestCase.assertEquals(typeObject, typeB.element.supertype); 1698 Type2 optionalParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(ASTFactory.identifier2("B")));
1035 JUnitTestCase.assertEquals(typeObject, typeA.getLeastUpperBound(typeB)); 1699 Type2 namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImpl(A STFactory.identifier2("C")));
1036 } 1700 functionType.returnType = returnType;
1037 void test_getLeastUpperBound_self() { 1701 functionType.normalParameterTypes = <Type2> [normalParameterType];
1038 ClassElement elementA = ElementFactory.classElement2("A", []); 1702 functionType.optionalParameterTypes = <Type2> [optionalParameterType];
1039 InterfaceType typeA = elementA.type; 1703 LinkedHashMap<String, Type2> namedParameterTypes = new LinkedHashMap<String, Type2>();
1040 JUnitTestCase.assertEquals(typeA, typeA.getLeastUpperBound(typeA)); 1704 String namedParameterName = "c";
1041 } 1705 namedParameterTypes[namedParameterName] = namedParameterType;
1042 void test_getLeastUpperBound_sharedSuperclass1() { 1706 functionType.namedParameterTypes = namedParameterTypes;
1043 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl); 1707 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("D")));
1044 ClassElementImpl elementB = (ElementFactory.classElement("B", elementA.type, []) as ClassElementImpl); 1708 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier2("E")));
1045 ClassElementImpl elementC = (ElementFactory.classElement("C", elementA.type, []) as ClassElementImpl); 1709 FunctionType result = functionType.substitute2(<Type2> [argumentType], <Type 2> [parameterType]);
1046 InterfaceType typeA = elementA.type; 1710 JUnitTestCase.assertEquals(returnType, result.returnType);
1047 InterfaceType typeB = elementB.type; 1711 List<Type2> normalParameters = result.normalParameterTypes;
1048 InterfaceType typeC = elementC.type; 1712 EngineTestCase.assertLength(1, normalParameters);
1049 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC)); 1713 JUnitTestCase.assertEquals(normalParameterType, normalParameters[0]);
1050 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB)); 1714 List<Type2> optionalParameters = result.optionalParameterTypes;
1051 } 1715 EngineTestCase.assertLength(1, optionalParameters);
1052 void test_getLeastUpperBound_sharedSuperclass2() { 1716 JUnitTestCase.assertEquals(optionalParameterType, optionalParameters[0]);
1053 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl); 1717 Map<String, Type2> namedParameters = result.namedParameterTypes;
1054 ClassElementImpl elementB = (ElementFactory.classElement("B", elementA.type, []) as ClassElementImpl); 1718 EngineTestCase.assertSize2(1, namedParameters);
1055 ClassElementImpl elementC = (ElementFactory.classElement("C", elementA.type, []) as ClassElementImpl); 1719 JUnitTestCase.assertEquals(namedParameterType, namedParameters[namedParamete rName]);
1056 ClassElementImpl elementD = (ElementFactory.classElement("D", elementC.type, []) as ClassElementImpl);
1057 InterfaceType typeA = elementA.type;
1058 InterfaceType typeB = elementB.type;
1059 InterfaceType typeD = elementD.type;
1060 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeD));
1061 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeB));
1062 }
1063 void test_getLeastUpperBound_sharedSuperclass3() {
1064 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl);
1065 ClassElementImpl elementB = (ElementFactory.classElement("B", elementA.type, []) as ClassElementImpl);
1066 ClassElementImpl elementC = (ElementFactory.classElement("C", elementB.type, []) as ClassElementImpl);
1067 ClassElementImpl elementD = (ElementFactory.classElement("D", elementB.type, []) as ClassElementImpl);
1068 InterfaceType typeB = elementB.type;
1069 InterfaceType typeC = elementC.type;
1070 InterfaceType typeD = elementD.type;
1071 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeD));
1072 JUnitTestCase.assertEquals(typeB, typeD.getLeastUpperBound(typeC));
1073 }
1074 void test_getLeastUpperBound_sharedSuperclass4() {
1075 ClassElement elementA = ElementFactory.classElement2("A", []);
1076 ClassElement elementA2 = ElementFactory.classElement2("A2", []);
1077 ClassElement elementA3 = ElementFactory.classElement2("A3", []);
1078 ClassElementImpl elementB = (ElementFactory.classElement("B", elementA.type, []) as ClassElementImpl);
1079 ClassElementImpl elementC = (ElementFactory.classElement("C", elementA.type, []) as ClassElementImpl);
1080 InterfaceType typeA = elementA.type;
1081 InterfaceType typeA2 = elementA2.type;
1082 InterfaceType typeA3 = elementA3.type;
1083 InterfaceType typeB = elementB.type;
1084 InterfaceType typeC = elementC.type;
1085 elementB.interfaces = <InterfaceType> [typeA2];
1086 elementC.interfaces = <InterfaceType> [typeA3];
1087 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
1088 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
1089 }
1090 void test_getLeastUpperBound_sharedSuperinterface1() {
1091 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl);
1092 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl);
1093 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1094 InterfaceType typeA = elementA.type;
1095 InterfaceType typeB = elementB.type;
1096 InterfaceType typeC = elementC.type;
1097 elementB.interfaces = <InterfaceType> [typeA];
1098 elementC.interfaces = <InterfaceType> [typeA];
1099 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
1100 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
1101 }
1102 void test_getLeastUpperBound_sharedSuperinterface2() {
1103 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl);
1104 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl);
1105 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1106 ClassElementImpl elementD = (ElementFactory.classElement2("D", []) as ClassE lementImpl);
1107 InterfaceType typeA = elementA.type;
1108 InterfaceType typeB = elementB.type;
1109 InterfaceType typeC = elementC.type;
1110 InterfaceType typeD = elementD.type;
1111 elementB.interfaces = <InterfaceType> [typeA];
1112 elementC.interfaces = <InterfaceType> [typeA];
1113 elementD.interfaces = <InterfaceType> [typeC];
1114 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeD));
1115 JUnitTestCase.assertEquals(typeA, typeD.getLeastUpperBound(typeB));
1116 }
1117 void test_getLeastUpperBound_sharedSuperinterface3() {
1118 ClassElementImpl elementA = (ElementFactory.classElement2("A", []) as ClassE lementImpl);
1119 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl);
1120 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1121 ClassElementImpl elementD = (ElementFactory.classElement2("D", []) as ClassE lementImpl);
1122 InterfaceType typeA = elementA.type;
1123 InterfaceType typeB = elementB.type;
1124 InterfaceType typeC = elementC.type;
1125 InterfaceType typeD = elementD.type;
1126 elementB.interfaces = <InterfaceType> [typeA];
1127 elementC.interfaces = <InterfaceType> [typeB];
1128 elementD.interfaces = <InterfaceType> [typeB];
1129 JUnitTestCase.assertEquals(typeB, typeC.getLeastUpperBound(typeD));
1130 JUnitTestCase.assertEquals(typeB, typeD.getLeastUpperBound(typeC));
1131 }
1132 void test_getLeastUpperBound_sharedSuperinterface4() {
1133 ClassElement elementA = ElementFactory.classElement2("A", []);
1134 ClassElement elementA2 = ElementFactory.classElement2("A2", []);
1135 ClassElement elementA3 = ElementFactory.classElement2("A3", []);
1136 ClassElementImpl elementB = (ElementFactory.classElement2("B", []) as ClassE lementImpl);
1137 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1138 InterfaceType typeA = elementA.type;
1139 InterfaceType typeA2 = elementA2.type;
1140 InterfaceType typeA3 = elementA3.type;
1141 InterfaceType typeB = elementB.type;
1142 InterfaceType typeC = elementC.type;
1143 elementB.interfaces = <InterfaceType> [typeA, typeA2];
1144 elementC.interfaces = <InterfaceType> [typeA, typeA3];
1145 JUnitTestCase.assertEquals(typeA, typeB.getLeastUpperBound(typeC));
1146 JUnitTestCase.assertEquals(typeA, typeC.getLeastUpperBound(typeB));
1147 }
1148 void test_getTypeArguments() {
1149 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(new ClassElementImpl(AST Factory.identifier2("A")));
1150 EngineTestCase.assertLength(0, type.typeArguments);
1151 }
1152 void test_isDirectSupertypeOf_extends() {
1153 ClassElement elementA = ElementFactory.classElement2("A", []);
1154 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1155 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
1156 InterfaceTypeImpl typeB = new InterfaceTypeImpl.con1(elementB);
1157 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
1158 }
1159 void test_isDirectSupertypeOf_false() {
1160 ClassElement elementA = ElementFactory.classElement2("A", []);
1161 ClassElement elementB = ElementFactory.classElement2("B", []);
1162 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
1163 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
1164 InterfaceTypeImpl typeC = new InterfaceTypeImpl.con1(elementC);
1165 JUnitTestCase.assertFalse(typeA.isDirectSupertypeOf(typeC));
1166 }
1167 void test_isDirectSupertypeOf_implements() {
1168 ClassElement elementA = ElementFactory.classElement2("A", []);
1169 ClassElement elementB = ElementFactory.classElement2("B", []);
1170 ((elementB as ClassElementImpl)).interfaces = <InterfaceType> [elementA.type ];
1171 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
1172 InterfaceTypeImpl typeB = new InterfaceTypeImpl.con1(elementB);
1173 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
1174 }
1175 void test_isDirectSupertypeOf_with() {
1176 ClassElement elementA = ElementFactory.classElement2("A", []);
1177 ClassElement elementB = ElementFactory.classElement2("B", []);
1178 ((elementB as ClassElementImpl)).mixins = <InterfaceType> [elementA.type];
1179 InterfaceTypeImpl typeA = new InterfaceTypeImpl.con1(elementA);
1180 InterfaceTypeImpl typeB = new InterfaceTypeImpl.con1(elementB);
1181 JUnitTestCase.assertTrue(typeA.isDirectSupertypeOf(typeB));
1182 }
1183 void test_isMoreSpecificThan_bottom() {
1184 Type2 type19 = ElementFactory.classElement2("A", []).type;
1185 JUnitTestCase.assertTrue(BottomTypeImpl.instance.isMoreSpecificThan(type19)) ;
1186 }
1187 void test_isMoreSpecificThan_covariance() {
1188 ClassElement elementA = ElementFactory.classElement2("A", ["E"]);
1189 ClassElement elementI = ElementFactory.classElement2("I", []);
1190 ClassElement elementJ = ElementFactory.classElement("J", elementI.type, []);
1191 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(elementA);
1192 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(elementA);
1193 typeAI.typeArguments = <Type2> [elementI.type];
1194 typeAJ.typeArguments = <Type2> [elementJ.type];
1195 JUnitTestCase.assertTrue(typeAJ.isMoreSpecificThan(typeAI));
1196 JUnitTestCase.assertFalse(typeAI.isMoreSpecificThan(typeAJ));
1197 }
1198 void test_isMoreSpecificThan_directSupertype() {
1199 ClassElement elementA = ElementFactory.classElement2("A", []);
1200 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1201 InterfaceType typeA = elementA.type;
1202 InterfaceType typeB = elementB.type;
1203 JUnitTestCase.assertTrue(typeB.isMoreSpecificThan(typeA));
1204 JUnitTestCase.assertFalse(typeA.isMoreSpecificThan(typeB));
1205 }
1206 void test_isMoreSpecificThan_dynamic() {
1207 InterfaceType type20 = ElementFactory.classElement2("A", []).type;
1208 JUnitTestCase.assertTrue(type20.isMoreSpecificThan(DynamicTypeImpl.instance) );
1209 }
1210 void test_isMoreSpecificThan_indirectSupertype() {
1211 ClassElement elementA = ElementFactory.classElement2("A", []);
1212 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1213 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
1214 InterfaceType typeA = elementA.type;
1215 InterfaceType typeC = elementC.type;
1216 JUnitTestCase.assertTrue(typeC.isMoreSpecificThan(typeA));
1217 }
1218 void test_isMoreSpecificThan_self() {
1219 InterfaceType type21 = ElementFactory.classElement2("A", []).type;
1220 JUnitTestCase.assertTrue(type21.isMoreSpecificThan(type21));
1221 }
1222 void test_isSubtypeOf_directSubtype() {
1223 ClassElement elementA = ElementFactory.classElement2("A", []);
1224 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1225 InterfaceType typeA = elementA.type;
1226 InterfaceType typeB = elementB.type;
1227 JUnitTestCase.assertTrue(typeB.isSubtypeOf(typeA));
1228 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeB));
1229 }
1230 void test_isSubtypeOf_dynamic() {
1231 ClassElement elementA = ElementFactory.classElement2("A", []);
1232 InterfaceType typeA = elementA.type;
1233 Type2 dynamicType = DynamicTypeImpl.instance;
1234 JUnitTestCase.assertFalse(dynamicType.isSubtypeOf(typeA));
1235 JUnitTestCase.assertTrue(typeA.isSubtypeOf(dynamicType));
1236 }
1237 void test_isSubtypeOf_indirectSubtype() {
1238 ClassElement elementA = ElementFactory.classElement2("A", []);
1239 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1240 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
1241 InterfaceType typeA = elementA.type;
1242 InterfaceType typeC = elementC.type;
1243 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA));
1244 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
1245 }
1246 void test_isSubtypeOf_interface() {
1247 ClassElement elementA = ElementFactory.classElement2("A", []);
1248 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1249 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1250 InterfaceType typeObject = elementA.supertype;
1251 InterfaceType typeA = elementA.type;
1252 InterfaceType typeB = elementB.type;
1253 InterfaceType typeC = elementC.type;
1254 elementC.interfaces = <InterfaceType> [typeB];
1255 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeB));
1256 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeObject));
1257 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeA));
1258 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
1259 }
1260 void test_isSubtypeOf_mixins() {
1261 ClassElement elementA = ElementFactory.classElement2("A", []);
1262 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1263 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1264 InterfaceType typeObject = elementA.supertype;
1265 InterfaceType typeA = elementA.type;
1266 InterfaceType typeB = elementB.type;
1267 InterfaceType typeC = elementC.type;
1268 elementC.mixins = <InterfaceType> [typeB];
1269 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeB));
1270 JUnitTestCase.assertTrue(typeC.isSubtypeOf(typeObject));
1271 JUnitTestCase.assertFalse(typeC.isSubtypeOf(typeA));
1272 JUnitTestCase.assertFalse(typeA.isSubtypeOf(typeC));
1273 }
1274 void test_isSubtypeOf_object() {
1275 ClassElement elementA = ElementFactory.classElement2("A", []);
1276 InterfaceType typeA = elementA.type;
1277 InterfaceType typeObject = elementA.supertype;
1278 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeObject));
1279 JUnitTestCase.assertFalse(typeObject.isSubtypeOf(typeA));
1280 }
1281 void test_isSubtypeOf_self() {
1282 ClassElement elementA = ElementFactory.classElement2("A", []);
1283 InterfaceType typeA = elementA.type;
1284 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeA));
1285 }
1286 void test_isSubtypeOf_typeArguments() {
1287 ClassElement elementA = ElementFactory.classElement2("A", ["E"]);
1288 ClassElement elementI = ElementFactory.classElement2("I", []);
1289 ClassElement elementJ = ElementFactory.classElement("J", elementI.type, []);
1290 ClassElement elementK = ElementFactory.classElement2("K", []);
1291 InterfaceType typeA = elementA.type;
1292 InterfaceTypeImpl typeAI = new InterfaceTypeImpl.con1(elementA);
1293 InterfaceTypeImpl typeAJ = new InterfaceTypeImpl.con1(elementA);
1294 InterfaceTypeImpl typeAK = new InterfaceTypeImpl.con1(elementA);
1295 typeAI.typeArguments = <Type2> [elementI.type];
1296 typeAJ.typeArguments = <Type2> [elementJ.type];
1297 typeAK.typeArguments = <Type2> [elementK.type];
1298 JUnitTestCase.assertTrue(typeAJ.isSubtypeOf(typeAI));
1299 JUnitTestCase.assertFalse(typeAI.isSubtypeOf(typeAJ));
1300 JUnitTestCase.assertTrue(typeAI.isSubtypeOf(typeAI));
1301 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeAI));
1302 JUnitTestCase.assertTrue(typeA.isSubtypeOf(typeAJ));
1303 JUnitTestCase.assertTrue(typeAI.isSubtypeOf(typeA));
1304 JUnitTestCase.assertTrue(typeAJ.isSubtypeOf(typeA));
1305 JUnitTestCase.assertFalse(typeAI.isSubtypeOf(typeAK));
1306 JUnitTestCase.assertFalse(typeAK.isSubtypeOf(typeAI));
1307 }
1308 void test_isSupertypeOf_directSupertype() {
1309 ClassElement elementA = ElementFactory.classElement2("A", []);
1310 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1311 InterfaceType typeA = elementA.type;
1312 InterfaceType typeB = elementB.type;
1313 JUnitTestCase.assertFalse(typeB.isSupertypeOf(typeA));
1314 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeB));
1315 }
1316 void test_isSupertypeOf_dynamic() {
1317 ClassElement elementA = ElementFactory.classElement2("A", []);
1318 InterfaceType typeA = elementA.type;
1319 Type2 dynamicType = DynamicTypeImpl.instance;
1320 JUnitTestCase.assertTrue(dynamicType.isSupertypeOf(typeA));
1321 JUnitTestCase.assertFalse(typeA.isSupertypeOf(dynamicType));
1322 }
1323 void test_isSupertypeOf_indirectSupertype() {
1324 ClassElement elementA = ElementFactory.classElement2("A", []);
1325 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1326 ClassElement elementC = ElementFactory.classElement("C", elementB.type, []);
1327 InterfaceType typeA = elementA.type;
1328 InterfaceType typeC = elementC.type;
1329 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
1330 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC));
1331 }
1332 void test_isSupertypeOf_interface() {
1333 ClassElement elementA = ElementFactory.classElement2("A", []);
1334 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1335 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1336 InterfaceType typeObject = elementA.supertype;
1337 InterfaceType typeA = elementA.type;
1338 InterfaceType typeB = elementB.type;
1339 InterfaceType typeC = elementC.type;
1340 elementC.interfaces = <InterfaceType> [typeB];
1341 JUnitTestCase.assertTrue(typeB.isSupertypeOf(typeC));
1342 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeC));
1343 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeC));
1344 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
1345 }
1346 void test_isSupertypeOf_mixins() {
1347 ClassElement elementA = ElementFactory.classElement2("A", []);
1348 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1349 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1350 InterfaceType typeObject = elementA.supertype;
1351 InterfaceType typeA = elementA.type;
1352 InterfaceType typeB = elementB.type;
1353 InterfaceType typeC = elementC.type;
1354 elementC.mixins = <InterfaceType> [typeB];
1355 JUnitTestCase.assertTrue(typeB.isSupertypeOf(typeC));
1356 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeC));
1357 JUnitTestCase.assertFalse(typeA.isSupertypeOf(typeC));
1358 JUnitTestCase.assertFalse(typeC.isSupertypeOf(typeA));
1359 }
1360 void test_isSupertypeOf_object() {
1361 ClassElement elementA = ElementFactory.classElement2("A", []);
1362 InterfaceType typeA = elementA.type;
1363 InterfaceType typeObject = elementA.supertype;
1364 JUnitTestCase.assertFalse(typeA.isSupertypeOf(typeObject));
1365 JUnitTestCase.assertTrue(typeObject.isSupertypeOf(typeA));
1366 }
1367 void test_isSupertypeOf_self() {
1368 ClassElement elementA = ElementFactory.classElement2("A", []);
1369 InterfaceType typeA = elementA.type;
1370 JUnitTestCase.assertTrue(typeA.isSupertypeOf(typeA));
1371 }
1372 void test_setTypeArguments() {
1373 InterfaceTypeImpl type22 = (ElementFactory.classElement2("A", []).type as In terfaceTypeImpl);
1374 List<Type2> typeArguments = <Type2> [new InterfaceTypeImpl.con1(ElementFacto ry.classElement2("B", [])), new InterfaceTypeImpl.con1(ElementFactory.classEleme nt2("C", []))];
1375 type22.typeArguments = typeArguments;
1376 JUnitTestCase.assertEquals(typeArguments, type22.typeArguments);
1377 }
1378 void test_substitute_equal() {
1379 ClassElementImpl classElement = new ClassElementImpl(ASTFactory.identifier2( "A"));
1380 TypeVariableElementImpl parameterElement = new TypeVariableElementImpl(ASTFa ctory.identifier2("E"));
1381 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classElement);
1382 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(parameterElement);
1383 type.typeArguments = <Type2> [parameter];
1384 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("B")));
1385 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par ameter]);
1386 JUnitTestCase.assertEquals(classElement, result.element);
1387 List<Type2> resultArguments = result.typeArguments;
1388 EngineTestCase.assertLength(1, resultArguments);
1389 JUnitTestCase.assertEquals(argumentType, resultArguments[0]);
1390 }
1391 void test_substitute_notEqual() {
1392 ClassElementImpl classElement = new ClassElementImpl(ASTFactory.identifier2( "A"));
1393 TypeVariableElementImpl parameterElement = new TypeVariableElementImpl(ASTFa ctory.identifier2("E"));
1394 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(classElement);
1395 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(parameterElement);
1396 type.typeArguments = <Type2> [parameter];
1397 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(ASTFactory.identifier2("B")));
1398 TypeVariableTypeImpl parameterType = new TypeVariableTypeImpl(new TypeVariab leElementImpl(ASTFactory.identifier2("F")));
1399 InterfaceType result = type.substitute2(<Type2> [argumentType], <Type2> [par ameterType]);
1400 JUnitTestCase.assertEquals(classElement, result.element);
1401 List<Type2> resultArguments = result.typeArguments;
1402 EngineTestCase.assertLength(1, resultArguments);
1403 JUnitTestCase.assertEquals(parameter, resultArguments[0]);
1404 } 1720 }
1405 static dartSuite() { 1721 static dartSuite() {
1406 _ut.group('InterfaceTypeImplTest', () { 1722 _ut.group('FunctionTypeImplTest', () {
1407 _ut.test('test_computeLongestInheritancePathToObject_multipleInterfacePath s', () {
1408 final __test = new InterfaceTypeImplTest();
1409 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_m ultipleInterfacePaths);
1410 });
1411 _ut.test('test_computeLongestInheritancePathToObject_multipleSuperclassPat hs', () {
1412 final __test = new InterfaceTypeImplTest();
1413 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_m ultipleSuperclassPaths);
1414 });
1415 _ut.test('test_computeLongestInheritancePathToObject_object', () {
1416 final __test = new InterfaceTypeImplTest();
1417 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_o bject);
1418 });
1419 _ut.test('test_computeLongestInheritancePathToObject_singleInterfacePath', () {
1420 final __test = new InterfaceTypeImplTest();
1421 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_s ingleInterfacePath);
1422 });
1423 _ut.test('test_computeLongestInheritancePathToObject_singleSuperclassPath' , () {
1424 final __test = new InterfaceTypeImplTest();
1425 runJUnitTest(__test, __test.test_computeLongestInheritancePathToObject_s ingleSuperclassPath);
1426 });
1427 _ut.test('test_computeSuperinterfaceSet_multipleInterfacePaths', () {
1428 final __test = new InterfaceTypeImplTest();
1429 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_multipleInterf acePaths);
1430 });
1431 _ut.test('test_computeSuperinterfaceSet_multipleSuperclassPaths', () {
1432 final __test = new InterfaceTypeImplTest();
1433 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_multipleSuperc lassPaths);
1434 });
1435 _ut.test('test_computeSuperinterfaceSet_singleInterfacePath', () {
1436 final __test = new InterfaceTypeImplTest();
1437 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_singleInterfac ePath);
1438 });
1439 _ut.test('test_computeSuperinterfaceSet_singleSuperclassPath', () {
1440 final __test = new InterfaceTypeImplTest();
1441 runJUnitTest(__test, __test.test_computeSuperinterfaceSet_singleSupercla ssPath);
1442 });
1443 _ut.test('test_creation', () { 1723 _ut.test('test_creation', () {
1444 final __test = new InterfaceTypeImplTest(); 1724 final __test = new FunctionTypeImplTest();
1445 runJUnitTest(__test, __test.test_creation); 1725 runJUnitTest(__test, __test.test_creation);
1446 }); 1726 });
1447 _ut.test('test_getElement', () { 1727 _ut.test('test_getElement', () {
1448 final __test = new InterfaceTypeImplTest(); 1728 final __test = new FunctionTypeImplTest();
1449 runJUnitTest(__test, __test.test_getElement); 1729 runJUnitTest(__test, __test.test_getElement);
1450 }); 1730 });
1451 _ut.test('test_getLeastUpperBound_directInterfaceCase', () { 1731 _ut.test('test_getNamedParameterTypes', () {
1452 final __test = new InterfaceTypeImplTest(); 1732 final __test = new FunctionTypeImplTest();
1453 runJUnitTest(__test, __test.test_getLeastUpperBound_directInterfaceCase) ; 1733 runJUnitTest(__test, __test.test_getNamedParameterTypes);
1454 }); 1734 });
1455 _ut.test('test_getLeastUpperBound_directSubclassCase', () { 1735 _ut.test('test_getNormalParameterTypes', () {
1456 final __test = new InterfaceTypeImplTest(); 1736 final __test = new FunctionTypeImplTest();
1457 runJUnitTest(__test, __test.test_getLeastUpperBound_directSubclassCase); 1737 runJUnitTest(__test, __test.test_getNormalParameterTypes);
1458 }); 1738 });
1459 _ut.test('test_getLeastUpperBound_functionType', () { 1739 _ut.test('test_getReturnType', () {
1460 final __test = new InterfaceTypeImplTest(); 1740 final __test = new FunctionTypeImplTest();
1461 runJUnitTest(__test, __test.test_getLeastUpperBound_functionType); 1741 runJUnitTest(__test, __test.test_getReturnType);
1462 });
1463 _ut.test('test_getLeastUpperBound_mixinCase', () {
1464 final __test = new InterfaceTypeImplTest();
1465 runJUnitTest(__test, __test.test_getLeastUpperBound_mixinCase);
1466 });
1467 _ut.test('test_getLeastUpperBound_null', () {
1468 final __test = new InterfaceTypeImplTest();
1469 runJUnitTest(__test, __test.test_getLeastUpperBound_null);
1470 });
1471 _ut.test('test_getLeastUpperBound_object', () {
1472 final __test = new InterfaceTypeImplTest();
1473 runJUnitTest(__test, __test.test_getLeastUpperBound_object);
1474 });
1475 _ut.test('test_getLeastUpperBound_self', () {
1476 final __test = new InterfaceTypeImplTest();
1477 runJUnitTest(__test, __test.test_getLeastUpperBound_self);
1478 });
1479 _ut.test('test_getLeastUpperBound_sharedSuperclass1', () {
1480 final __test = new InterfaceTypeImplTest();
1481 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass1);
1482 });
1483 _ut.test('test_getLeastUpperBound_sharedSuperclass2', () {
1484 final __test = new InterfaceTypeImplTest();
1485 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass2);
1486 });
1487 _ut.test('test_getLeastUpperBound_sharedSuperclass3', () {
1488 final __test = new InterfaceTypeImplTest();
1489 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass3);
1490 });
1491 _ut.test('test_getLeastUpperBound_sharedSuperclass4', () {
1492 final __test = new InterfaceTypeImplTest();
1493 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperclass4);
1494 });
1495 _ut.test('test_getLeastUpperBound_sharedSuperinterface1', () {
1496 final __test = new InterfaceTypeImplTest();
1497 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 1);
1498 });
1499 _ut.test('test_getLeastUpperBound_sharedSuperinterface2', () {
1500 final __test = new InterfaceTypeImplTest();
1501 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 2);
1502 });
1503 _ut.test('test_getLeastUpperBound_sharedSuperinterface3', () {
1504 final __test = new InterfaceTypeImplTest();
1505 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 3);
1506 });
1507 _ut.test('test_getLeastUpperBound_sharedSuperinterface4', () {
1508 final __test = new InterfaceTypeImplTest();
1509 runJUnitTest(__test, __test.test_getLeastUpperBound_sharedSuperinterface 4);
1510 }); 1742 });
1511 _ut.test('test_getTypeArguments', () { 1743 _ut.test('test_getTypeArguments', () {
1512 final __test = new InterfaceTypeImplTest(); 1744 final __test = new FunctionTypeImplTest();
1513 runJUnitTest(__test, __test.test_getTypeArguments); 1745 runJUnitTest(__test, __test.test_getTypeArguments);
1514 }); 1746 });
1515 _ut.test('test_isDirectSupertypeOf_extends', () { 1747 _ut.test('test_hashCode_element', () {
1516 final __test = new InterfaceTypeImplTest(); 1748 final __test = new FunctionTypeImplTest();
1517 runJUnitTest(__test, __test.test_isDirectSupertypeOf_extends); 1749 runJUnitTest(__test, __test.test_hashCode_element);
1518 }); 1750 });
1519 _ut.test('test_isDirectSupertypeOf_false', () { 1751 _ut.test('test_hashCode_noElement', () {
1520 final __test = new InterfaceTypeImplTest(); 1752 final __test = new FunctionTypeImplTest();
1521 runJUnitTest(__test, __test.test_isDirectSupertypeOf_false); 1753 runJUnitTest(__test, __test.test_hashCode_noElement);
1522 }); 1754 });
1523 _ut.test('test_isDirectSupertypeOf_implements', () { 1755 _ut.test('test_isSubtypeOf_baseCase_classFunction', () {
1524 final __test = new InterfaceTypeImplTest(); 1756 final __test = new FunctionTypeImplTest();
1525 runJUnitTest(__test, __test.test_isDirectSupertypeOf_implements); 1757 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_classFunction);
1526 }); 1758 });
1527 _ut.test('test_isDirectSupertypeOf_with', () { 1759 _ut.test('test_isSubtypeOf_baseCase_notFunctionType', () {
1528 final __test = new InterfaceTypeImplTest(); 1760 final __test = new FunctionTypeImplTest();
1529 runJUnitTest(__test, __test.test_isDirectSupertypeOf_with); 1761 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_notFunctionType);
1530 }); 1762 });
1531 _ut.test('test_isMoreSpecificThan_bottom', () { 1763 _ut.test('test_isSubtypeOf_baseCase_null', () {
1532 final __test = new InterfaceTypeImplTest(); 1764 final __test = new FunctionTypeImplTest();
1533 runJUnitTest(__test, __test.test_isMoreSpecificThan_bottom); 1765 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_null);
1534 }); 1766 });
1535 _ut.test('test_isMoreSpecificThan_covariance', () { 1767 _ut.test('test_isSubtypeOf_baseCase_self', () {
1536 final __test = new InterfaceTypeImplTest(); 1768 final __test = new FunctionTypeImplTest();
1537 runJUnitTest(__test, __test.test_isMoreSpecificThan_covariance); 1769 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_self);
1538 }); 1770 });
1539 _ut.test('test_isMoreSpecificThan_directSupertype', () { 1771 _ut.test('test_isSubtypeOf_namedParameters_isAssignable', () {
1540 final __test = new InterfaceTypeImplTest(); 1772 final __test = new FunctionTypeImplTest();
1541 runJUnitTest(__test, __test.test_isMoreSpecificThan_directSupertype); 1773 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isAssignabl e);
1542 }); 1774 });
1543 _ut.test('test_isMoreSpecificThan_dynamic', () { 1775 _ut.test('test_isSubtypeOf_namedParameters_isNotAssignable', () {
1544 final __test = new InterfaceTypeImplTest(); 1776 final __test = new FunctionTypeImplTest();
1545 runJUnitTest(__test, __test.test_isMoreSpecificThan_dynamic); 1777 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isNotAssign able);
1546 }); 1778 });
1547 _ut.test('test_isMoreSpecificThan_indirectSupertype', () { 1779 _ut.test('test_isSubtypeOf_namedParameters_namesDifferent', () {
1548 final __test = new InterfaceTypeImplTest(); 1780 final __test = new FunctionTypeImplTest();
1549 runJUnitTest(__test, __test.test_isMoreSpecificThan_indirectSupertype); 1781 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_namesDiffer ent);
1550 }); 1782 });
1551 _ut.test('test_isMoreSpecificThan_self', () { 1783 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams', () {
1552 final __test = new InterfaceTypeImplTest(); 1784 final __test = new FunctionTypeImplTest();
1553 runJUnitTest(__test, __test.test_isMoreSpecificThan_self); 1785 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms);
1554 }); 1786 });
1555 _ut.test('test_isSubtypeOf_directSubtype', () { 1787 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams2', () {
1556 final __test = new InterfaceTypeImplTest(); 1788 final __test = new FunctionTypeImplTest();
1557 runJUnitTest(__test, __test.test_isSubtypeOf_directSubtype); 1789 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms2);
1558 }); 1790 });
1559 _ut.test('test_isSubtypeOf_dynamic', () { 1791 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams3', () {
1560 final __test = new InterfaceTypeImplTest(); 1792 final __test = new FunctionTypeImplTest();
1561 runJUnitTest(__test, __test.test_isSubtypeOf_dynamic); 1793 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms3);
1562 }); 1794 });
1563 _ut.test('test_isSubtypeOf_indirectSubtype', () { 1795 _ut.test('test_isSubtypeOf_namedParameters_sHasMoreParams', () {
1564 final __test = new InterfaceTypeImplTest(); 1796 final __test = new FunctionTypeImplTest();
1565 runJUnitTest(__test, __test.test_isSubtypeOf_indirectSubtype); 1797 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_sHasMorePar ams);
1566 }); 1798 });
1567 _ut.test('test_isSubtypeOf_interface', () { 1799 _ut.test('test_isSubtypeOf_namedParameters_tHasMoreParams', () {
1568 final __test = new InterfaceTypeImplTest(); 1800 final __test = new FunctionTypeImplTest();
1569 runJUnitTest(__test, __test.test_isSubtypeOf_interface); 1801 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_tHasMorePar ams);
1570 }); 1802 });
1571 _ut.test('test_isSubtypeOf_mixins', () { 1803 _ut.test('test_isSubtypeOf_normalParameters_isAssignable', () {
1572 final __test = new InterfaceTypeImplTest(); 1804 final __test = new FunctionTypeImplTest();
1573 runJUnitTest(__test, __test.test_isSubtypeOf_mixins); 1805 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isAssignab le);
1574 }); 1806 });
1575 _ut.test('test_isSubtypeOf_object', () { 1807 _ut.test('test_isSubtypeOf_normalParameters_isNotAssignable', () {
1576 final __test = new InterfaceTypeImplTest(); 1808 final __test = new FunctionTypeImplTest();
1577 runJUnitTest(__test, __test.test_isSubtypeOf_object); 1809 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isNotAssig nable);
1578 }); 1810 });
1579 _ut.test('test_isSubtypeOf_self', () { 1811 _ut.test('test_isSubtypeOf_normalParameters_sHasMoreParams', () {
1580 final __test = new InterfaceTypeImplTest(); 1812 final __test = new FunctionTypeImplTest();
1581 runJUnitTest(__test, __test.test_isSubtypeOf_self); 1813 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_sHasMorePa rams);
1582 }); 1814 });
1583 _ut.test('test_isSubtypeOf_typeArguments', () { 1815 _ut.test('test_isSubtypeOf_normalParameters_tHasMoreParams', () {
1584 final __test = new InterfaceTypeImplTest(); 1816 final __test = new FunctionTypeImplTest();
1585 runJUnitTest(__test, __test.test_isSubtypeOf_typeArguments); 1817 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_tHasMorePa rams);
1586 }); 1818 });
1587 _ut.test('test_isSupertypeOf_directSupertype', () { 1819 _ut.test('test_isSubtypeOf_optionalParameters_isAssignable', () {
1588 final __test = new InterfaceTypeImplTest(); 1820 final __test = new FunctionTypeImplTest();
1589 runJUnitTest(__test, __test.test_isSupertypeOf_directSupertype); 1821 runJUnitTest(__test, __test.test_isSubtypeOf_optionalParameters_isAssign able);
1590 }); 1822 });
1591 _ut.test('test_isSupertypeOf_dynamic', () { 1823 _ut.test('test_isSubtypeOf_optionalParameters_isNotAssignable', () {
1592 final __test = new InterfaceTypeImplTest(); 1824 final __test = new FunctionTypeImplTest();
1593 runJUnitTest(__test, __test.test_isSupertypeOf_dynamic); 1825 runJUnitTest(__test, __test.test_isSubtypeOf_optionalParameters_isNotAss ignable);
1594 }); 1826 });
1595 _ut.test('test_isSupertypeOf_indirectSupertype', () { 1827 _ut.test('test_isSubtypeOf_optionalParameters_sHasMoreParams', () {
1596 final __test = new InterfaceTypeImplTest(); 1828 final __test = new FunctionTypeImplTest();
1597 runJUnitTest(__test, __test.test_isSupertypeOf_indirectSupertype); 1829 runJUnitTest(__test, __test.test_isSubtypeOf_optionalParameters_sHasMore Params);
1598 }); 1830 });
1599 _ut.test('test_isSupertypeOf_interface', () { 1831 _ut.test('test_isSubtypeOf_optionalParameters_tHasMoreParams', () {
1600 final __test = new InterfaceTypeImplTest(); 1832 final __test = new FunctionTypeImplTest();
1601 runJUnitTest(__test, __test.test_isSupertypeOf_interface); 1833 runJUnitTest(__test, __test.test_isSubtypeOf_optionalParameters_tHasMore Params);
1602 }); 1834 });
1603 _ut.test('test_isSupertypeOf_mixins', () { 1835 _ut.test('test_isSubtypeOf_returnType_sIsVoid', () {
1604 final __test = new InterfaceTypeImplTest(); 1836 final __test = new FunctionTypeImplTest();
1605 runJUnitTest(__test, __test.test_isSupertypeOf_mixins); 1837 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_sIsVoid);
1606 }); 1838 });
1607 _ut.test('test_isSupertypeOf_object', () { 1839 _ut.test('test_isSubtypeOf_returnType_tAssignableToS', () {
1608 final __test = new InterfaceTypeImplTest(); 1840 final __test = new FunctionTypeImplTest();
1609 runJUnitTest(__test, __test.test_isSupertypeOf_object); 1841 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tAssignableToS);
1610 }); 1842 });
1611 _ut.test('test_isSupertypeOf_self', () { 1843 _ut.test('test_isSubtypeOf_returnType_tNotAssignableToS', () {
1612 final __test = new InterfaceTypeImplTest(); 1844 final __test = new FunctionTypeImplTest();
1613 runJUnitTest(__test, __test.test_isSupertypeOf_self); 1845 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tNotAssignableTo S);
1846 });
1847 _ut.test('test_isSubtypeOf_wrongFunctionType_normal_named', () {
1848 final __test = new FunctionTypeImplTest();
1849 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_normal_na med);
1850 });
1851 _ut.test('test_isSubtypeOf_wrongFunctionType_normal_optional', () {
1852 final __test = new FunctionTypeImplTest();
1853 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_normal_op tional);
1854 });
1855 _ut.test('test_isSubtypeOf_wrongFunctionType_optional_named', () {
1856 final __test = new FunctionTypeImplTest();
1857 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_optional_ named);
1858 });
1859 _ut.test('test_setNamedParameterTypes', () {
1860 final __test = new FunctionTypeImplTest();
1861 runJUnitTest(__test, __test.test_setNamedParameterTypes);
1862 });
1863 _ut.test('test_setNormalParameterTypes', () {
1864 final __test = new FunctionTypeImplTest();
1865 runJUnitTest(__test, __test.test_setNormalParameterTypes);
1866 });
1867 _ut.test('test_setReturnType', () {
1868 final __test = new FunctionTypeImplTest();
1869 runJUnitTest(__test, __test.test_setReturnType);
1614 }); 1870 });
1615 _ut.test('test_setTypeArguments', () { 1871 _ut.test('test_setTypeArguments', () {
1616 final __test = new InterfaceTypeImplTest(); 1872 final __test = new FunctionTypeImplTest();
1617 runJUnitTest(__test, __test.test_setTypeArguments); 1873 runJUnitTest(__test, __test.test_setTypeArguments);
1618 }); 1874 });
1619 _ut.test('test_substitute_equal', () { 1875 _ut.test('test_substitute2_equal', () {
1620 final __test = new InterfaceTypeImplTest(); 1876 final __test = new FunctionTypeImplTest();
1621 runJUnitTest(__test, __test.test_substitute_equal); 1877 runJUnitTest(__test, __test.test_substitute2_equal);
1622 }); 1878 });
1623 _ut.test('test_substitute_notEqual', () { 1879 _ut.test('test_substitute2_notEqual', () {
1624 final __test = new InterfaceTypeImplTest(); 1880 final __test = new FunctionTypeImplTest();
1625 runJUnitTest(__test, __test.test_substitute_notEqual); 1881 runJUnitTest(__test, __test.test_substitute2_notEqual);
1626 }); 1882 });
1627 }); 1883 });
1628 } 1884 }
1629 } 1885 }
1630 class ClassElementImplTest extends EngineTestCase { 1886 class InterfaceTypeImpl_11 extends InterfaceTypeImpl {
1631 void test_allSupertypes_interface() { 1887 InterfaceTypeImpl_11(ClassElement arg0) : super.con1(arg0);
1632 ClassElement elementA = ElementFactory.classElement2("A", []); 1888 bool isDartCoreFunction() => true;
1633 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1634 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1635 InterfaceType typeObject = elementA.supertype;
1636 InterfaceType typeA = elementA.type;
1637 InterfaceType typeB = elementB.type;
1638 InterfaceType typeC = elementC.type;
1639 elementC.interfaces = <InterfaceType> [typeB];
1640 List<InterfaceType> supers = elementC.allSupertypes;
1641 List<InterfaceType> types = new List<InterfaceType>();
1642 types.addAll(supers);
1643 JUnitTestCase.assertTrue(types.contains(typeA));
1644 JUnitTestCase.assertTrue(types.contains(typeB));
1645 JUnitTestCase.assertTrue(types.contains(typeObject));
1646 JUnitTestCase.assertFalse(types.contains(typeC));
1647 }
1648 void test_allSupertypes_mixins() {
1649 ClassElement elementA = ElementFactory.classElement2("A", []);
1650 ClassElement elementB = ElementFactory.classElement("B", elementA.type, []);
1651 ClassElementImpl elementC = (ElementFactory.classElement2("C", []) as ClassE lementImpl);
1652 InterfaceType typeObject = elementA.supertype;
1653 InterfaceType typeA = elementA.type;
1654 InterfaceType typeB = elementB.type;
1655 InterfaceType typeC = elementC.type;
1656 elementC.mixins = <InterfaceType> [typeB];
1657 List<InterfaceType> supers = elementC.allSupertypes;
1658 List<InterfaceType> types = new List<InterfaceType>();
1659 types.addAll(supers);
1660 JUnitTestCase.assertFalse(types.contains(typeA));
1661 JUnitTestCase.assertTrue(types.contains(typeB));
1662 JUnitTestCase.assertTrue(types.contains(typeObject));
1663 JUnitTestCase.assertFalse(types.contains(typeC));
1664 }
1665 void test_lookUpGetter_declared() {
1666 LibraryElementImpl library6 = ElementFactory.library(new AnalysisContextImpl (), "lib");
1667 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1668 String getterName = "g";
1669 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
1670 classA.accessors = <PropertyAccessorElement> [getter];
1671 ((library6.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classA];
1672 JUnitTestCase.assertSame(getter, classA.lookUpGetter(getterName, library6));
1673 }
1674 void test_lookUpGetter_inherited() {
1675 LibraryElementImpl library7 = ElementFactory.library(new AnalysisContextImpl (), "lib");
1676 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1677 String getterName = "g";
1678 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
1679 classA.accessors = <PropertyAccessorElement> [getter];
1680 ClassElementImpl classB = (ElementFactory.classElement("B", classA.type, []) as ClassElementImpl);
1681 ((library7.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classA, classB];
1682 JUnitTestCase.assertSame(getter, classB.lookUpGetter(getterName, library7));
1683 }
1684 void test_lookUpGetter_undeclared() {
1685 LibraryElementImpl library8 = ElementFactory.library(new AnalysisContextImpl (), "lib");
1686 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1687 ((library8.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classA];
1688 JUnitTestCase.assertNull(classA.lookUpGetter("g", library8));
1689 }
1690 void test_lookUpMethod_declared() {
1691 LibraryElementImpl library9 = ElementFactory.library(new AnalysisContextImpl (), "lib");
1692 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1693 String methodName = "m";
1694 MethodElement method = ElementFactory.methodElement(methodName, null, []);
1695 classA.methods = <MethodElement> [method];
1696 ((library9.definingCompilationUnit as CompilationUnitElementImpl)).types = < ClassElement> [classA];
1697 JUnitTestCase.assertSame(method, classA.lookUpMethod(methodName, library9));
1698 }
1699 void test_lookUpMethod_inherited() {
1700 LibraryElementImpl library10 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1701 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1702 String methodName = "m";
1703 MethodElement method = ElementFactory.methodElement(methodName, null, []);
1704 classA.methods = <MethodElement> [method];
1705 ClassElementImpl classB = (ElementFactory.classElement("B", classA.type, []) as ClassElementImpl);
1706 ((library10.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA, classB];
1707 JUnitTestCase.assertSame(method, classB.lookUpMethod(methodName, library10)) ;
1708 }
1709 void test_lookUpMethod_undeclared() {
1710 LibraryElementImpl library11 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1711 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1712 ((library11.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1713 JUnitTestCase.assertNull(classA.lookUpMethod("m", library11));
1714 }
1715 void test_lookUpSetter_declared() {
1716 LibraryElementImpl library12 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1717 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1718 String setterName = "s";
1719 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
1720 classA.accessors = <PropertyAccessorElement> [setter];
1721 ((library12.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1722 JUnitTestCase.assertSame(setter, classA.lookUpSetter(setterName, library12)) ;
1723 }
1724 void test_lookUpSetter_inherited() {
1725 LibraryElementImpl library13 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1726 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1727 String setterName = "s";
1728 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
1729 classA.accessors = <PropertyAccessorElement> [setter];
1730 ClassElementImpl classB = (ElementFactory.classElement("B", classA.type, []) as ClassElementImpl);
1731 ((library13.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA, classB];
1732 JUnitTestCase.assertSame(setter, classB.lookUpSetter(setterName, library13)) ;
1733 }
1734 void test_lookUpSetter_undeclared() {
1735 LibraryElementImpl library14 = ElementFactory.library(new AnalysisContextImp l(), "lib");
1736 ClassElementImpl classA = (ElementFactory.classElement2("A", []) as ClassEle mentImpl);
1737 ((library14.definingCompilationUnit as CompilationUnitElementImpl)).types = <ClassElement> [classA];
1738 JUnitTestCase.assertNull(classA.lookUpSetter("s", library14));
1739 }
1740 static dartSuite() {
1741 _ut.group('ClassElementImplTest', () {
1742 _ut.test('test_allSupertypes_interface', () {
1743 final __test = new ClassElementImplTest();
1744 runJUnitTest(__test, __test.test_allSupertypes_interface);
1745 });
1746 _ut.test('test_allSupertypes_mixins', () {
1747 final __test = new ClassElementImplTest();
1748 runJUnitTest(__test, __test.test_allSupertypes_mixins);
1749 });
1750 _ut.test('test_lookUpGetter_declared', () {
1751 final __test = new ClassElementImplTest();
1752 runJUnitTest(__test, __test.test_lookUpGetter_declared);
1753 });
1754 _ut.test('test_lookUpGetter_inherited', () {
1755 final __test = new ClassElementImplTest();
1756 runJUnitTest(__test, __test.test_lookUpGetter_inherited);
1757 });
1758 _ut.test('test_lookUpGetter_undeclared', () {
1759 final __test = new ClassElementImplTest();
1760 runJUnitTest(__test, __test.test_lookUpGetter_undeclared);
1761 });
1762 _ut.test('test_lookUpMethod_declared', () {
1763 final __test = new ClassElementImplTest();
1764 runJUnitTest(__test, __test.test_lookUpMethod_declared);
1765 });
1766 _ut.test('test_lookUpMethod_inherited', () {
1767 final __test = new ClassElementImplTest();
1768 runJUnitTest(__test, __test.test_lookUpMethod_inherited);
1769 });
1770 _ut.test('test_lookUpMethod_undeclared', () {
1771 final __test = new ClassElementImplTest();
1772 runJUnitTest(__test, __test.test_lookUpMethod_undeclared);
1773 });
1774 _ut.test('test_lookUpSetter_declared', () {
1775 final __test = new ClassElementImplTest();
1776 runJUnitTest(__test, __test.test_lookUpSetter_declared);
1777 });
1778 _ut.test('test_lookUpSetter_inherited', () {
1779 final __test = new ClassElementImplTest();
1780 runJUnitTest(__test, __test.test_lookUpSetter_inherited);
1781 });
1782 _ut.test('test_lookUpSetter_undeclared', () {
1783 final __test = new ClassElementImplTest();
1784 runJUnitTest(__test, __test.test_lookUpSetter_undeclared);
1785 });
1786 });
1787 }
1788 }
1789 class TypeVariableTypeImplTest extends EngineTestCase {
1790 void test_creation() {
1791 JUnitTestCase.assertNotNull(new TypeVariableTypeImpl(new TypeVariableElement Impl(ASTFactory.identifier2("E"))));
1792 }
1793 void test_getElement() {
1794 TypeVariableElementImpl element = new TypeVariableElementImpl(ASTFactory.ide ntifier2("E"));
1795 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element);
1796 JUnitTestCase.assertEquals(element, type.element);
1797 }
1798 void test_substitute_equal() {
1799 TypeVariableElementImpl element = new TypeVariableElementImpl(ASTFactory.ide ntifier2("E"));
1800 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element);
1801 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (ASTFactory.identifier2("A")));
1802 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(element);
1803 JUnitTestCase.assertSame(argument, type.substitute2(<Type2> [argument], <Typ e2> [parameter]));
1804 }
1805 void test_substitute_notEqual() {
1806 TypeVariableTypeImpl type = new TypeVariableTypeImpl(new TypeVariableElement Impl(ASTFactory.identifier2("E")));
1807 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (ASTFactory.identifier2("A")));
1808 TypeVariableTypeImpl parameter = new TypeVariableTypeImpl(new TypeVariableEl ementImpl(ASTFactory.identifier2("F")));
1809 JUnitTestCase.assertSame(type, type.substitute2(<Type2> [argument], <Type2> [parameter]));
1810 }
1811 static dartSuite() {
1812 _ut.group('TypeVariableTypeImplTest', () {
1813 _ut.test('test_creation', () {
1814 final __test = new TypeVariableTypeImplTest();
1815 runJUnitTest(__test, __test.test_creation);
1816 });
1817 _ut.test('test_getElement', () {
1818 final __test = new TypeVariableTypeImplTest();
1819 runJUnitTest(__test, __test.test_getElement);
1820 });
1821 _ut.test('test_substitute_equal', () {
1822 final __test = new TypeVariableTypeImplTest();
1823 runJUnitTest(__test, __test.test_substitute_equal);
1824 });
1825 _ut.test('test_substitute_notEqual', () {
1826 final __test = new TypeVariableTypeImplTest();
1827 runJUnitTest(__test, __test.test_substitute_notEqual);
1828 });
1829 });
1830 }
1831 } 1889 }
1832 main() { 1890 main() {
1891 FunctionTypeImplTest.dartSuite();
1892 InterfaceTypeImplTest.dartSuite();
1893 TypeVariableTypeImplTest.dartSuite();
1833 ClassElementImplTest.dartSuite(); 1894 ClassElementImplTest.dartSuite();
1834 ElementLocationImplTest.dartSuite(); 1895 ElementLocationImplTest.dartSuite();
1835 ElementImplTest.dartSuite(); 1896 ElementImplTest.dartSuite();
1836 LibraryElementImplTest.dartSuite(); 1897 LibraryElementImplTest.dartSuite();
1837 FunctionTypeImplTest.dartSuite();
1838 InterfaceTypeImplTest.dartSuite();
1839 TypeVariableTypeImplTest.dartSuite();
1840 } 1898 }
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