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

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

Issue 259773005: New analyzer snapshot. Sorted unit members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.element_test; 8 library engine.element_test;
9 9
10 import 'package:analyzer/src/generated/java_core.dart'; 10 import 'package:analyzer/src/generated/java_core.dart';
11 import 'package:analyzer/src/generated/java_engine_io.dart'; 11 import 'package:analyzer/src/generated/java_engine_io.dart';
12 import 'package:analyzer/src/generated/java_junit.dart'; 12 import 'package:analyzer/src/generated/java_junit.dart';
13 import 'package:analyzer/src/generated/source_io.dart'; 13 import 'package:analyzer/src/generated/source_io.dart';
14 import 'package:analyzer/src/generated/utilities_dart.dart'; 14 import 'package:analyzer/src/generated/utilities_dart.dart';
15 import 'package:analyzer/src/generated/ast.dart'; 15 import 'package:analyzer/src/generated/ast.dart';
16 import 'package:analyzer/src/generated/element.dart'; 16 import 'package:analyzer/src/generated/element.dart';
17 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext, Analys isContextImpl; 17 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext, Analys isContextImpl;
18 import 'package:unittest/unittest.dart' as _ut; 18 import 'package:unittest/unittest.dart' as _ut;
19 import 'test_support.dart'; 19 import 'test_support.dart';
20 import 'ast_test.dart' show AstFactory; 20 import 'ast_test.dart' show AstFactory;
21 import 'resolver_test.dart' show TestTypeProvider, AnalysisContextHelper; 21 import 'resolver_test.dart' show TestTypeProvider, AnalysisContextHelper;
22 22
23 class AngularPropertyKindTest extends EngineTestCase {
24 void test_ATTR() {
25 AngularPropertyKind kind = AngularPropertyKind.ATTR;
26 JUnitTestCase.assertFalse(kind.callsGetter());
27 JUnitTestCase.assertTrue(kind.callsSetter());
28 }
29
30 void test_CALLBACK() {
31 AngularPropertyKind kind = AngularPropertyKind.CALLBACK;
32 JUnitTestCase.assertFalse(kind.callsGetter());
33 JUnitTestCase.assertTrue(kind.callsSetter());
34 }
35
36 void test_ONE_WAY() {
37 AngularPropertyKind kind = AngularPropertyKind.ONE_WAY;
38 JUnitTestCase.assertFalse(kind.callsGetter());
39 JUnitTestCase.assertTrue(kind.callsSetter());
40 }
41
42 void test_ONE_WAY_ONE_TIME() {
43 AngularPropertyKind kind = AngularPropertyKind.ONE_WAY_ONE_TIME;
44 JUnitTestCase.assertFalse(kind.callsGetter());
45 JUnitTestCase.assertTrue(kind.callsSetter());
46 }
47
48 void test_TWO_WAY() {
49 AngularPropertyKind kind = AngularPropertyKind.TWO_WAY;
50 JUnitTestCase.assertTrue(kind.callsGetter());
51 JUnitTestCase.assertTrue(kind.callsSetter());
52 }
53
54 static dartSuite() {
55 _ut.group('AngularPropertyKindTest', () {
56 _ut.test('test_ATTR', () {
57 final __test = new AngularPropertyKindTest();
58 runJUnitTest(__test, __test.test_ATTR);
59 });
60 _ut.test('test_CALLBACK', () {
61 final __test = new AngularPropertyKindTest();
62 runJUnitTest(__test, __test.test_CALLBACK);
63 });
64 _ut.test('test_ONE_WAY', () {
65 final __test = new AngularPropertyKindTest();
66 runJUnitTest(__test, __test.test_ONE_WAY);
67 });
68 _ut.test('test_ONE_WAY_ONE_TIME', () {
69 final __test = new AngularPropertyKindTest();
70 runJUnitTest(__test, __test.test_ONE_WAY_ONE_TIME);
71 });
72 _ut.test('test_TWO_WAY', () {
73 final __test = new AngularPropertyKindTest();
74 runJUnitTest(__test, __test.test_TWO_WAY);
75 });
76 });
77 }
78 }
79
80 class ClassElementImplTest extends EngineTestCase {
81 void test_getAllSupertypes_interface() {
82 ClassElement classA = ElementFactory.classElement2("A", []);
83 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
84 ClassElementImpl elementC = ElementFactory.classElement2("C", []);
85 InterfaceType typeObject = classA.supertype;
86 InterfaceType typeA = classA.type;
87 InterfaceType typeB = classB.type;
88 InterfaceType typeC = elementC.type;
89 elementC.interfaces = <InterfaceType> [typeB];
90 List<InterfaceType> supers = elementC.allSupertypes;
91 List<InterfaceType> types = new List<InterfaceType>();
92 types.addAll(supers);
93 JUnitTestCase.assertTrue(types.contains(typeA));
94 JUnitTestCase.assertTrue(types.contains(typeB));
95 JUnitTestCase.assertTrue(types.contains(typeObject));
96 JUnitTestCase.assertFalse(types.contains(typeC));
97 }
98
99 void test_getAllSupertypes_mixins() {
100 ClassElement classA = ElementFactory.classElement2("A", []);
101 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
102 ClassElementImpl classC = ElementFactory.classElement2("C", []);
103 InterfaceType typeObject = classA.supertype;
104 InterfaceType typeA = classA.type;
105 InterfaceType typeB = classB.type;
106 InterfaceType typeC = classC.type;
107 classC.mixins = <InterfaceType> [typeB];
108 List<InterfaceType> supers = classC.allSupertypes;
109 List<InterfaceType> types = new List<InterfaceType>();
110 types.addAll(supers);
111 JUnitTestCase.assertFalse(types.contains(typeA));
112 JUnitTestCase.assertTrue(types.contains(typeB));
113 JUnitTestCase.assertTrue(types.contains(typeObject));
114 JUnitTestCase.assertFalse(types.contains(typeC));
115 }
116
117 void test_getAllSupertypes_recursive() {
118 ClassElementImpl classA = ElementFactory.classElement2("A", []);
119 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
120 classA.supertype = classB.type;
121 List<InterfaceType> supers = classB.allSupertypes;
122 EngineTestCase.assertLength(1, supers);
123 }
124
125 void test_getField() {
126 ClassElementImpl classA = ElementFactory.classElement2("A", []);
127 String fieldName = "f";
128 FieldElementImpl field = ElementFactory.fieldElement(fieldName, false, false , false, null);
129 classA.fields = <FieldElement> [field];
130 JUnitTestCase.assertSame(field, classA.getField(fieldName));
131 // no such field
132 JUnitTestCase.assertSame(null, classA.getField("noSuchField"));
133 }
134
135 void test_getMethod_declared() {
136 ClassElementImpl classA = ElementFactory.classElement2("A", []);
137 String methodName = "m";
138 MethodElement method = ElementFactory.methodElement(methodName, null, []);
139 classA.methods = <MethodElement> [method];
140 JUnitTestCase.assertSame(method, classA.getMethod(methodName));
141 }
142
143 void test_getMethod_undeclared() {
144 ClassElementImpl classA = ElementFactory.classElement2("A", []);
145 String methodName = "m";
146 MethodElement method = ElementFactory.methodElement(methodName, null, []);
147 classA.methods = <MethodElement> [method];
148 JUnitTestCase.assertNull(classA.getMethod("${methodName}x"));
149 }
150
151 void test_getNode() {
152 AnalysisContextHelper contextHelper = new AnalysisContextHelper();
153 AnalysisContext context = contextHelper.context;
154 Source source = contextHelper.addSource("/test.dart", EngineTestCase.createS ource(["class A {}", "class B {}"]));
155 // prepare CompilationUnitElement
156 LibraryElement libraryElement = context.computeLibraryElement(source);
157 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit;
158 // A
159 {
160 ClassElement elementA = unitElement.getType("A");
161 ClassDeclaration nodeA = elementA.node;
162 JUnitTestCase.assertNotNull(nodeA);
163 JUnitTestCase.assertEquals("A", nodeA.name.name);
164 JUnitTestCase.assertSame(elementA, nodeA.element);
165 }
166 // B
167 {
168 ClassElement elementB = unitElement.getType("B");
169 ClassDeclaration nodeB = elementB.node;
170 JUnitTestCase.assertNotNull(nodeB);
171 JUnitTestCase.assertEquals("B", nodeB.name.name);
172 JUnitTestCase.assertSame(elementB, nodeB.element);
173 }
174 }
175
176 void test_hasNonFinalField_false_const() {
177 ClassElementImpl classA = ElementFactory.classElement2("A", []);
178 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, true, classA.type)];
179 JUnitTestCase.assertFalse(classA.hasNonFinalField);
180 }
181
182 void test_hasNonFinalField_false_final() {
183 ClassElementImpl classA = ElementFactory.classElement2("A", []);
184 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, true , false, classA.type)];
185 JUnitTestCase.assertFalse(classA.hasNonFinalField);
186 }
187
188 void test_hasNonFinalField_false_recursive() {
189 ClassElementImpl classA = ElementFactory.classElement2("A", []);
190 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
191 classA.supertype = classB.type;
192 JUnitTestCase.assertFalse(classA.hasNonFinalField);
193 }
194
195 void test_hasNonFinalField_true_immediate() {
196 ClassElementImpl classA = ElementFactory.classElement2("A", []);
197 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)];
198 JUnitTestCase.assertTrue(classA.hasNonFinalField);
199 }
200
201 void test_hasNonFinalField_true_inherited() {
202 ClassElementImpl classA = ElementFactory.classElement2("A", []);
203 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
204 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)];
205 JUnitTestCase.assertTrue(classB.hasNonFinalField);
206 }
207
208 void test_hasStaticMember_false_empty() {
209 ClassElementImpl classA = ElementFactory.classElement2("A", []);
210 // no members
211 JUnitTestCase.assertFalse(classA.hasStaticMember);
212 }
213
214 void test_hasStaticMember_false_instanceMethod() {
215 ClassElementImpl classA = ElementFactory.classElement2("A", []);
216 MethodElement method = ElementFactory.methodElement("foo", null, []);
217 classA.methods = <MethodElement> [method];
218 JUnitTestCase.assertFalse(classA.hasStaticMember);
219 }
220
221 void test_hasStaticMember_instanceGetter() {
222 ClassElementImpl classA = ElementFactory.classElement2("A", []);
223 PropertyAccessorElement getter = ElementFactory.getterElement("foo", false, null);
224 classA.accessors = <PropertyAccessorElement> [getter];
225 JUnitTestCase.assertFalse(classA.hasStaticMember);
226 }
227
228 void test_hasStaticMember_true_getter() {
229 ClassElementImpl classA = ElementFactory.classElement2("A", []);
230 PropertyAccessorElementImpl getter = ElementFactory.getterElement("foo", fal se, null);
231 classA.accessors = <PropertyAccessorElement> [getter];
232 // "foo" is static
233 getter.static = true;
234 JUnitTestCase.assertTrue(classA.hasStaticMember);
235 }
236
237 void test_hasStaticMember_true_method() {
238 ClassElementImpl classA = ElementFactory.classElement2("A", []);
239 MethodElementImpl method = ElementFactory.methodElement("foo", null, []);
240 classA.methods = <MethodElement> [method];
241 // "foo" is static
242 method.static = true;
243 JUnitTestCase.assertTrue(classA.hasStaticMember);
244 }
245
246 void test_hasStaticMember_true_setter() {
247 ClassElementImpl classA = ElementFactory.classElement2("A", []);
248 PropertyAccessorElementImpl setter = ElementFactory.setterElement("foo", fal se, null);
249 classA.accessors = <PropertyAccessorElement> [setter];
250 // "foo" is static
251 setter.static = true;
252 JUnitTestCase.assertTrue(classA.hasStaticMember);
253 }
254
255 void test_lookUpGetter_declared() {
256 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
257 ClassElementImpl classA = ElementFactory.classElement2("A", []);
258 String getterName = "g";
259 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
260 classA.accessors = <PropertyAccessorElement> [getter];
261 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
262 JUnitTestCase.assertSame(getter, classA.lookUpGetter(getterName, library));
263 }
264
265 void test_lookUpGetter_inherited() {
266 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
267 ClassElementImpl classA = ElementFactory.classElement2("A", []);
268 String getterName = "g";
269 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null);
270 classA.accessors = <PropertyAccessorElement> [getter];
271 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
272 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
273 JUnitTestCase.assertSame(getter, classB.lookUpGetter(getterName, library));
274 }
275
276 void test_lookUpGetter_undeclared() {
277 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
278 ClassElementImpl classA = ElementFactory.classElement2("A", []);
279 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
280 JUnitTestCase.assertNull(classA.lookUpGetter("g", library));
281 }
282
283 void test_lookUpGetter_undeclared_recursive() {
284 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
285 ClassElementImpl classA = ElementFactory.classElement2("A", []);
286 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
287 classA.supertype = classB.type;
288 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
289 JUnitTestCase.assertNull(classA.lookUpGetter("g", library));
290 }
291
292 void test_lookUpMethod_declared() {
293 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
294 ClassElementImpl classA = ElementFactory.classElement2("A", []);
295 String methodName = "m";
296 MethodElement method = ElementFactory.methodElement(methodName, null, []);
297 classA.methods = <MethodElement> [method];
298 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
299 JUnitTestCase.assertSame(method, classA.lookUpMethod(methodName, library));
300 }
301
302 void test_lookUpMethod_inherited() {
303 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
304 ClassElementImpl classA = ElementFactory.classElement2("A", []);
305 String methodName = "m";
306 MethodElement method = ElementFactory.methodElement(methodName, null, []);
307 classA.methods = <MethodElement> [method];
308 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
309 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
310 JUnitTestCase.assertSame(method, classB.lookUpMethod(methodName, library));
311 }
312
313 void test_lookUpMethod_undeclared() {
314 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
315 ClassElementImpl classA = ElementFactory.classElement2("A", []);
316 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
317 JUnitTestCase.assertNull(classA.lookUpMethod("m", library));
318 }
319
320 void test_lookUpMethod_undeclared_recursive() {
321 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
322 ClassElementImpl classA = ElementFactory.classElement2("A", []);
323 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
324 classA.supertype = classB.type;
325 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
326 JUnitTestCase.assertNull(classA.lookUpMethod("m", library));
327 }
328
329 void test_lookUpSetter_declared() {
330 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
331 ClassElementImpl classA = ElementFactory.classElement2("A", []);
332 String setterName = "s";
333 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
334 classA.accessors = <PropertyAccessorElement> [setter];
335 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
336 JUnitTestCase.assertSame(setter, classA.lookUpSetter(setterName, library));
337 }
338
339 void test_lookUpSetter_inherited() {
340 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
341 ClassElementImpl classA = ElementFactory.classElement2("A", []);
342 String setterName = "s";
343 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null);
344 classA.accessors = <PropertyAccessorElement> [setter];
345 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
346 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
347 JUnitTestCase.assertSame(setter, classB.lookUpSetter(setterName, library));
348 }
349
350 void test_lookUpSetter_undeclared() {
351 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
352 ClassElementImpl classA = ElementFactory.classElement2("A", []);
353 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA];
354 JUnitTestCase.assertNull(classA.lookUpSetter("s", library));
355 }
356
357 void test_lookUpSetter_undeclared_recursive() {
358 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
359 ClassElementImpl classA = ElementFactory.classElement2("A", []);
360 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
361 classA.supertype = classB.type;
362 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB];
363 JUnitTestCase.assertNull(classA.lookUpSetter("s", library));
364 }
365
366 static dartSuite() {
367 _ut.group('ClassElementImplTest', () {
368 _ut.test('test_getAllSupertypes_interface', () {
369 final __test = new ClassElementImplTest();
370 runJUnitTest(__test, __test.test_getAllSupertypes_interface);
371 });
372 _ut.test('test_getAllSupertypes_mixins', () {
373 final __test = new ClassElementImplTest();
374 runJUnitTest(__test, __test.test_getAllSupertypes_mixins);
375 });
376 _ut.test('test_getAllSupertypes_recursive', () {
377 final __test = new ClassElementImplTest();
378 runJUnitTest(__test, __test.test_getAllSupertypes_recursive);
379 });
380 _ut.test('test_getField', () {
381 final __test = new ClassElementImplTest();
382 runJUnitTest(__test, __test.test_getField);
383 });
384 _ut.test('test_getMethod_declared', () {
385 final __test = new ClassElementImplTest();
386 runJUnitTest(__test, __test.test_getMethod_declared);
387 });
388 _ut.test('test_getMethod_undeclared', () {
389 final __test = new ClassElementImplTest();
390 runJUnitTest(__test, __test.test_getMethod_undeclared);
391 });
392 _ut.test('test_getNode', () {
393 final __test = new ClassElementImplTest();
394 runJUnitTest(__test, __test.test_getNode);
395 });
396 _ut.test('test_hasNonFinalField_false_const', () {
397 final __test = new ClassElementImplTest();
398 runJUnitTest(__test, __test.test_hasNonFinalField_false_const);
399 });
400 _ut.test('test_hasNonFinalField_false_final', () {
401 final __test = new ClassElementImplTest();
402 runJUnitTest(__test, __test.test_hasNonFinalField_false_final);
403 });
404 _ut.test('test_hasNonFinalField_false_recursive', () {
405 final __test = new ClassElementImplTest();
406 runJUnitTest(__test, __test.test_hasNonFinalField_false_recursive);
407 });
408 _ut.test('test_hasNonFinalField_true_immediate', () {
409 final __test = new ClassElementImplTest();
410 runJUnitTest(__test, __test.test_hasNonFinalField_true_immediate);
411 });
412 _ut.test('test_hasNonFinalField_true_inherited', () {
413 final __test = new ClassElementImplTest();
414 runJUnitTest(__test, __test.test_hasNonFinalField_true_inherited);
415 });
416 _ut.test('test_hasStaticMember_false_empty', () {
417 final __test = new ClassElementImplTest();
418 runJUnitTest(__test, __test.test_hasStaticMember_false_empty);
419 });
420 _ut.test('test_hasStaticMember_false_instanceMethod', () {
421 final __test = new ClassElementImplTest();
422 runJUnitTest(__test, __test.test_hasStaticMember_false_instanceMethod);
423 });
424 _ut.test('test_hasStaticMember_instanceGetter', () {
425 final __test = new ClassElementImplTest();
426 runJUnitTest(__test, __test.test_hasStaticMember_instanceGetter);
427 });
428 _ut.test('test_hasStaticMember_true_getter', () {
429 final __test = new ClassElementImplTest();
430 runJUnitTest(__test, __test.test_hasStaticMember_true_getter);
431 });
432 _ut.test('test_hasStaticMember_true_method', () {
433 final __test = new ClassElementImplTest();
434 runJUnitTest(__test, __test.test_hasStaticMember_true_method);
435 });
436 _ut.test('test_hasStaticMember_true_setter', () {
437 final __test = new ClassElementImplTest();
438 runJUnitTest(__test, __test.test_hasStaticMember_true_setter);
439 });
440 _ut.test('test_lookUpGetter_declared', () {
441 final __test = new ClassElementImplTest();
442 runJUnitTest(__test, __test.test_lookUpGetter_declared);
443 });
444 _ut.test('test_lookUpGetter_inherited', () {
445 final __test = new ClassElementImplTest();
446 runJUnitTest(__test, __test.test_lookUpGetter_inherited);
447 });
448 _ut.test('test_lookUpGetter_undeclared', () {
449 final __test = new ClassElementImplTest();
450 runJUnitTest(__test, __test.test_lookUpGetter_undeclared);
451 });
452 _ut.test('test_lookUpGetter_undeclared_recursive', () {
453 final __test = new ClassElementImplTest();
454 runJUnitTest(__test, __test.test_lookUpGetter_undeclared_recursive);
455 });
456 _ut.test('test_lookUpMethod_declared', () {
457 final __test = new ClassElementImplTest();
458 runJUnitTest(__test, __test.test_lookUpMethod_declared);
459 });
460 _ut.test('test_lookUpMethod_inherited', () {
461 final __test = new ClassElementImplTest();
462 runJUnitTest(__test, __test.test_lookUpMethod_inherited);
463 });
464 _ut.test('test_lookUpMethod_undeclared', () {
465 final __test = new ClassElementImplTest();
466 runJUnitTest(__test, __test.test_lookUpMethod_undeclared);
467 });
468 _ut.test('test_lookUpMethod_undeclared_recursive', () {
469 final __test = new ClassElementImplTest();
470 runJUnitTest(__test, __test.test_lookUpMethod_undeclared_recursive);
471 });
472 _ut.test('test_lookUpSetter_declared', () {
473 final __test = new ClassElementImplTest();
474 runJUnitTest(__test, __test.test_lookUpSetter_declared);
475 });
476 _ut.test('test_lookUpSetter_inherited', () {
477 final __test = new ClassElementImplTest();
478 runJUnitTest(__test, __test.test_lookUpSetter_inherited);
479 });
480 _ut.test('test_lookUpSetter_undeclared', () {
481 final __test = new ClassElementImplTest();
482 runJUnitTest(__test, __test.test_lookUpSetter_undeclared);
483 });
484 _ut.test('test_lookUpSetter_undeclared_recursive', () {
485 final __test = new ClassElementImplTest();
486 runJUnitTest(__test, __test.test_lookUpSetter_undeclared_recursive);
487 });
488 });
489 }
490 }
491
23 /** 492 /**
24 * The class `ElementFactory` defines utility methods used to create elements fo r testing 493 * The class `ElementFactory` defines utility methods used to create elements fo r testing
25 * purposes. The elements that are created are complete in the sense that as muc h of the element 494 * purposes. The elements that are created are complete in the sense that as muc h of the element
26 * model as can be created, given the provided information, has been created. 495 * model as can be created, given the provided information, has been created.
27 */ 496 */
28 class ElementFactory { 497 class ElementFactory {
29 /** 498 /**
30 * The element representing the class 'Object'. 499 * The element representing the class 'Object'.
31 */ 500 */
32 static ClassElementImpl _objectElement; 501 static ClassElementImpl _objectElement;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 setter.variable = variable; 845 setter.variable = variable;
377 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ e)]; 846 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ e)];
378 setter.returnType = VoidTypeImpl.instance; 847 setter.returnType = VoidTypeImpl.instance;
379 setter.type = new FunctionTypeImpl.con1(setter); 848 setter.type = new FunctionTypeImpl.con1(setter);
380 variable.setter = setter; 849 variable.setter = setter;
381 } 850 }
382 return variable; 851 return variable;
383 } 852 }
384 } 853 }
385 854
386 class HtmlElementImplTest extends EngineTestCase { 855 class ElementImplTest extends EngineTestCase {
387 void test_equals_differentSource() { 856 void test_equals() {
857 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
858 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
859 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
860 FieldElement field = ElementFactory.fieldElement("next", false, false, false , classElement.type);
861 classElement.fields = <FieldElement> [field];
862 JUnitTestCase.assertTrue(field == field);
863 JUnitTestCase.assertFalse(field == field.getter);
864 JUnitTestCase.assertFalse(field == field.setter);
865 JUnitTestCase.assertFalse(field.getter == field.setter);
866 }
867
868 void test_isAccessibleIn_private_differentLibrary() {
388 AnalysisContextImpl context = createAnalysisContext(); 869 AnalysisContextImpl context = createAnalysisContext();
389 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "indexA.html"); 870 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
390 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "indexB.html"); 871 ClassElement classElement = ElementFactory.classElement2("_C", []);
391 JUnitTestCase.assertFalse(elementA == elementB); 872 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl assElement> [classElement];
392 } 873 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
393 874 JUnitTestCase.assertFalse(classElement.isAccessibleIn(library2));
394 void test_equals_null() { 875 }
876
877 void test_isAccessibleIn_private_sameLibrary() {
878 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
879 ClassElement classElement = ElementFactory.classElement2("_C", []);
880 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
881 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library));
882 }
883
884 void test_isAccessibleIn_public_differentLibrary() {
395 AnalysisContextImpl context = createAnalysisContext(); 885 AnalysisContextImpl context = createAnalysisContext();
396 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); 886 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
397 JUnitTestCase.assertFalse(element == null); 887 ClassElement classElement = ElementFactory.classElement2("C", []);
398 } 888 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl assElement> [classElement];
399 889 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
400 void test_equals_sameSource() { 890 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library2));
401 AnalysisContextImpl context = createAnalysisContext(); 891 }
402 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "index.html"); 892
403 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "index.html"); 893 void test_isAccessibleIn_public_sameLibrary() {
404 JUnitTestCase.assertTrue(elementA == elementB); 894 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
405 } 895 ClassElement classElement = ElementFactory.classElement2("C", []);
406 896 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
407 void test_equals_self() { 897 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library));
408 AnalysisContextImpl context = createAnalysisContext(); 898 }
409 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html"); 899
410 JUnitTestCase.assertTrue(element == element); 900 void test_isPrivate_false() {
901 Element element = ElementFactory.classElement2("C", []);
902 JUnitTestCase.assertFalse(element.isPrivate);
903 }
904
905 void test_isPrivate_null() {
906 Element element = ElementFactory.classElement2(null, []);
907 JUnitTestCase.assertTrue(element.isPrivate);
908 }
909
910 void test_isPrivate_true() {
911 Element element = ElementFactory.classElement2("_C", []);
912 JUnitTestCase.assertTrue(element.isPrivate);
913 }
914
915 void test_isPublic_false() {
916 Element element = ElementFactory.classElement2("_C", []);
917 JUnitTestCase.assertFalse(element.isPublic);
918 }
919
920 void test_isPublic_null() {
921 Element element = ElementFactory.classElement2(null, []);
922 JUnitTestCase.assertFalse(element.isPublic);
923 }
924
925 void test_isPublic_true() {
926 Element element = ElementFactory.classElement2("C", []);
927 JUnitTestCase.assertTrue(element.isPublic);
928 }
929
930 void test_SORT_BY_OFFSET() {
931 ClassElementImpl classElementA = ElementFactory.classElement2("A", []);
932 classElementA.nameOffset = 1;
933 ClassElementImpl classElementB = ElementFactory.classElement2("B", []);
934 classElementB.nameOffset = 2;
935 JUnitTestCase.assertEquals(0, Element.SORT_BY_OFFSET(classElementA, classEle mentA));
936 JUnitTestCase.assertTrue(Element.SORT_BY_OFFSET(classElementA, classElementB ) < 0);
937 JUnitTestCase.assertTrue(Element.SORT_BY_OFFSET(classElementB, classElementA ) > 0);
411 } 938 }
412 939
413 static dartSuite() { 940 static dartSuite() {
414 _ut.group('HtmlElementImplTest', () { 941 _ut.group('ElementImplTest', () {
415 _ut.test('test_equals_differentSource', () { 942 _ut.test('test_SORT_BY_OFFSET', () {
416 final __test = new HtmlElementImplTest(); 943 final __test = new ElementImplTest();
417 runJUnitTest(__test, __test.test_equals_differentSource); 944 runJUnitTest(__test, __test.test_SORT_BY_OFFSET);
418 }); 945 });
419 _ut.test('test_equals_null', () { 946 _ut.test('test_equals', () {
420 final __test = new HtmlElementImplTest(); 947 final __test = new ElementImplTest();
421 runJUnitTest(__test, __test.test_equals_null); 948 runJUnitTest(__test, __test.test_equals);
422 }); 949 });
423 _ut.test('test_equals_sameSource', () { 950 _ut.test('test_isAccessibleIn_private_differentLibrary', () {
424 final __test = new HtmlElementImplTest(); 951 final __test = new ElementImplTest();
425 runJUnitTest(__test, __test.test_equals_sameSource); 952 runJUnitTest(__test, __test.test_isAccessibleIn_private_differentLibrary );
426 }); 953 });
427 _ut.test('test_equals_self', () { 954 _ut.test('test_isAccessibleIn_private_sameLibrary', () {
428 final __test = new HtmlElementImplTest(); 955 final __test = new ElementImplTest();
429 runJUnitTest(__test, __test.test_equals_self); 956 runJUnitTest(__test, __test.test_isAccessibleIn_private_sameLibrary);
957 });
958 _ut.test('test_isAccessibleIn_public_differentLibrary', () {
959 final __test = new ElementImplTest();
960 runJUnitTest(__test, __test.test_isAccessibleIn_public_differentLibrary) ;
961 });
962 _ut.test('test_isAccessibleIn_public_sameLibrary', () {
963 final __test = new ElementImplTest();
964 runJUnitTest(__test, __test.test_isAccessibleIn_public_sameLibrary);
965 });
966 _ut.test('test_isPrivate_false', () {
967 final __test = new ElementImplTest();
968 runJUnitTest(__test, __test.test_isPrivate_false);
969 });
970 _ut.test('test_isPrivate_null', () {
971 final __test = new ElementImplTest();
972 runJUnitTest(__test, __test.test_isPrivate_null);
973 });
974 _ut.test('test_isPrivate_true', () {
975 final __test = new ElementImplTest();
976 runJUnitTest(__test, __test.test_isPrivate_true);
977 });
978 _ut.test('test_isPublic_false', () {
979 final __test = new ElementImplTest();
980 runJUnitTest(__test, __test.test_isPublic_false);
981 });
982 _ut.test('test_isPublic_null', () {
983 final __test = new ElementImplTest();
984 runJUnitTest(__test, __test.test_isPublic_null);
985 });
986 _ut.test('test_isPublic_true', () {
987 final __test = new ElementImplTest();
988 runJUnitTest(__test, __test.test_isPublic_true);
430 }); 989 });
431 }); 990 });
432 } 991 }
433 } 992 }
434 993
435 class MultiplyDefinedElementImplTest extends EngineTestCase { 994 class ElementKindTest extends EngineTestCase {
436 void test_fromElements_conflicting() { 995 void test_of_nonNull() {
437 Element firstElement = ElementFactory.localVariableElement2("xx"); 996 JUnitTestCase.assertSame(ElementKind.CLASS, ElementKind.of(ElementFactory.cl assElement2("A", [])));
438 Element secondElement = ElementFactory.localVariableElement2("yy"); 997 }
439 Element result = MultiplyDefinedElementImpl.fromElements(null, firstElement, secondElement); 998
440 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, Mult iplyDefinedElement, result); 999 void test_of_null() {
441 List<Element> elements = (result as MultiplyDefinedElement).conflictingEleme nts; 1000 JUnitTestCase.assertSame(ElementKind.ERROR, ElementKind.of(null));
442 EngineTestCase.assertLength(2, elements);
443 for (int i = 0; i < elements.length; i++) {
444 EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement, Loca lVariableElement, elements[i]);
445 }
446 }
447
448 void test_fromElements_multiple() {
449 Element firstElement = ElementFactory.localVariableElement2("xx");
450 Element secondElement = ElementFactory.localVariableElement2("yy");
451 Element thirdElement = ElementFactory.localVariableElement2("zz");
452 Element result = MultiplyDefinedElementImpl.fromElements(null, MultiplyDefin edElementImpl.fromElements(null, firstElement, secondElement), thirdElement);
453 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, Mult iplyDefinedElement, result);
454 List<Element> elements = (result as MultiplyDefinedElement).conflictingEleme nts;
455 EngineTestCase.assertLength(3, elements);
456 for (int i = 0; i < elements.length; i++) {
457 EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement, Loca lVariableElement, elements[i]);
458 }
459 }
460
461 void test_fromElements_nonConflicting() {
462 Element element = ElementFactory.localVariableElement2("xx");
463 JUnitTestCase.assertSame(element, MultiplyDefinedElementImpl.fromElements(nu ll, element, element));
464 } 1001 }
465 1002
466 static dartSuite() { 1003 static dartSuite() {
467 _ut.group('MultiplyDefinedElementImplTest', () { 1004 _ut.group('ElementKindTest', () {
468 _ut.test('test_fromElements_conflicting', () { 1005 _ut.test('test_of_nonNull', () {
469 final __test = new MultiplyDefinedElementImplTest(); 1006 final __test = new ElementKindTest();
470 runJUnitTest(__test, __test.test_fromElements_conflicting); 1007 runJUnitTest(__test, __test.test_of_nonNull);
471 }); 1008 });
472 _ut.test('test_fromElements_multiple', () { 1009 _ut.test('test_of_null', () {
473 final __test = new MultiplyDefinedElementImplTest(); 1010 final __test = new ElementKindTest();
474 runJUnitTest(__test, __test.test_fromElements_multiple); 1011 runJUnitTest(__test, __test.test_of_null);
475 });
476 _ut.test('test_fromElements_nonConflicting', () {
477 final __test = new MultiplyDefinedElementImplTest();
478 runJUnitTest(__test, __test.test_fromElements_nonConflicting);
479 }); 1012 });
480 }); 1013 });
481 } 1014 }
482 }
483
484 class FunctionTypeImplTest extends EngineTestCase {
485 void test_creation() {
486 JUnitTestCase.assertNotNull(new FunctionTypeImpl.con1(new FunctionElementImp l.forNode(AstFactory.identifier3("f"))));
487 }
488
489 void test_getElement() {
490 FunctionElementImpl typeElement = new FunctionElementImpl.forNode(AstFactory .identifier3("f"));
491 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement);
492 JUnitTestCase.assertEquals(typeElement, type.element);
493 }
494
495 void test_getNamedParameterTypes() {
496 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
497 Map<String, DartType> types = type.namedParameterTypes;
498 EngineTestCase.assertSizeOfMap(0, types);
499 }
500
501 void test_getNormalParameterTypes() {
502 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
503 List<DartType> types = type.normalParameterTypes;
504 EngineTestCase.assertLength(0, types);
505 }
506
507 void test_getReturnType() {
508 DartType expectedReturnType = VoidTypeImpl.instance;
509 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
510 functionElement.returnType = expectedReturnType;
511 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement);
512 DartType returnType = type.returnType;
513 JUnitTestCase.assertEquals(expectedReturnType, returnType);
514 }
515
516 void test_getTypeArguments() {
517 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
518 List<DartType> types = type.typeArguments;
519 EngineTestCase.assertLength(0, types);
520 }
521
522 void test_hashCode_element() {
523 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
524 type.hashCode;
525 }
526
527 void test_hashCode_noElement() {
528 FunctionTypeImpl type = new FunctionTypeImpl.con1(null);
529 type.hashCode;
530 }
531
532 void test_isAssignableTo_normalAndPositionalArgs() {
533 // ([a]) -> void <: (a) -> void
534 ClassElement a = ElementFactory.classElement2("A", []);
535 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
536 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
537 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
538 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
539 // assignable iff subtype
540 JUnitTestCase.assertTrue(t.isAssignableTo(s));
541 JUnitTestCase.assertFalse(s.isAssignableTo(t));
542 }
543
544 void test_isSubtypeOf_baseCase_classFunction() {
545 // () -> void <: Function
546 ClassElementImpl functionElement = ElementFactory.classElement2("Function", []);
547 InterfaceTypeImpl functionType = new InterfaceTypeImpl_FunctionTypeImplTest_ test_isSubtypeOf_baseCase_classFunction(functionElement);
548 FunctionType f = ElementFactory.functionElement("f").type;
549 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType));
550 }
551
552 void test_isSubtypeOf_baseCase_notFunctionType() {
553 // class C
554 // ! () -> void <: C
555 FunctionType f = ElementFactory.functionElement("f").type;
556 InterfaceType t = ElementFactory.classElement2("C", []).type;
557 JUnitTestCase.assertFalse(f.isSubtypeOf(t));
558 }
559
560 void test_isSubtypeOf_baseCase_null() {
561 // ! () -> void <: null
562 FunctionType f = ElementFactory.functionElement("f").type;
563 JUnitTestCase.assertFalse(f.isSubtypeOf(null));
564 }
565
566 void test_isSubtypeOf_baseCase_self() {
567 // () -> void <: () -> void
568 FunctionType f = ElementFactory.functionElement("f").type;
569 JUnitTestCase.assertTrue(f.isSubtypeOf(f));
570 }
571
572 void test_isSubtypeOf_namedParameters_isAssignable() {
573 // B extends A
574 // ({name: A}) -> void <: ({name: B}) -> void
575 // ({name: B}) -> void <: ({name: A}) -> void
576 ClassElement a = ElementFactory.classElement2("A", []);
577 ClassElement b = ElementFactory.classElement("B", a.type, []);
578 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
579 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
580 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
581 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
582 }
583
584 void test_isSubtypeOf_namedParameters_isNotAssignable() {
585 // ! ({name: A}) -> void <: ({name: B}) -> void
586 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("A", [])]).type;
587 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("B", [])]).type;
588 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
589 }
590
591 void test_isSubtypeOf_namedParameters_namesDifferent() {
592 // B extends A
593 // void t({A name}) {}
594 // void s({A diff}) {}
595 // ! t <: s
596 // ! s <: t
597 ClassElement a = ElementFactory.classElement2("A", []);
598 ClassElement b = ElementFactory.classElement("B", a.type, []);
599 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
600 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "diff"], <ClassElement> [b]).type;
601 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
602 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
603 }
604
605 void test_isSubtypeOf_namedParameters_orderOfParams() {
606 // B extends A
607 // ({A: A, B: B}) -> void <: ({B: B, A: A}) -> void
608 ClassElement a = ElementFactory.classElement2("A", []);
609 ClassElement b = ElementFactory.classElement("B", a.type, []);
610 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
611 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
612 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
613 }
614
615 void test_isSubtypeOf_namedParameters_orderOfParams2() {
616 // B extends A
617 // ! ({B: B}) -> void <: ({B: B, A: A}) -> void
618 ClassElement a = ElementFactory.classElement2("A", []);
619 ClassElement b = ElementFactory.classElement("B", a.type, []);
620 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "B"], <ClassElement> [b]).type;
621 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
622 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
623 }
624
625 void test_isSubtypeOf_namedParameters_orderOfParams3() {
626 // B extends A
627 // ({A: A, B: B}) -> void <: ({A: A}) -> void
628 ClassElement a = ElementFactory.classElement2("A", []);
629 ClassElement b = ElementFactory.classElement("B", a.type, []);
630 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
631 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B"], <ClassElement> [b]).type;
632 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
633 }
634
635 void test_isSubtypeOf_namedParameters_sHasMoreParams() {
636 // B extends A
637 // ! ({name: A}) -> void <: ({name: B, name2: B}) -> void
638 ClassElement a = ElementFactory.classElement2("A", []);
639 ClassElement b = ElementFactory.classElement("B", a.type, []);
640 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
641 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name", "name2"], <ClassElement> [b, b]).type;
642 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
643 }
644
645 void test_isSubtypeOf_namedParameters_tHasMoreParams() {
646 // B extends A
647 // ({name: A, name2: A}) -> void <: ({name: B}) -> void
648 ClassElement a = ElementFactory.classElement2("A", []);
649 ClassElement b = ElementFactory.classElement("B", a.type, []);
650 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name", "name2"], <ClassElement> [a, a]).type;
651 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
652 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
653 }
654
655 void test_isSubtypeOf_normalAndPositionalArgs_1() {
656 // ([a]) -> void <: (a) -> void
657 ClassElement a = ElementFactory.classElement2("A", []);
658 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
659 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
660 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
661 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
662 }
663
664 void test_isSubtypeOf_normalAndPositionalArgs_2() {
665 // (a, [a]) -> void <: (a) -> void
666 ClassElement a = ElementFactory.classElement2("A", []);
667 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a], <C lassElement> [a]).type;
668 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
669 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
670 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
671 }
672
673 void test_isSubtypeOf_normalAndPositionalArgs_3() {
674 // ([a]) -> void <: () -> void
675 ClassElement a = ElementFactory.classElement2("A", []);
676 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
677 FunctionType s = ElementFactory.functionElement("s").type;
678 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
679 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
680 }
681
682 void test_isSubtypeOf_normalAndPositionalArgs_4() {
683 // (a, b, [c, d, e]) -> void <: (a, b, c, [d]) -> void
684 ClassElement a = ElementFactory.classElement2("A", []);
685 ClassElement b = ElementFactory.classElement2("B", []);
686 ClassElement c = ElementFactory.classElement2("C", []);
687 ClassElement d = ElementFactory.classElement2("D", []);
688 ClassElement e = ElementFactory.classElement2("E", []);
689 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a, b], <ClassElement> [c, d, e]).type;
690 FunctionType s = ElementFactory.functionElement6("s", <ClassElement> [a, b, c], <ClassElement> [d]).type;
691 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
692 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
693 }
694
695 void test_isSubtypeOf_normalParameters_isAssignable() {
696 // B extends A
697 // (a) -> void <: (b) -> void
698 // (b) -> void <: (a) -> void
699 ClassElement a = ElementFactory.classElement2("A", []);
700 ClassElement b = ElementFactory.classElement("B", a.type, []);
701 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
702 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
703 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
704 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
705 }
706
707 void test_isSubtypeOf_normalParameters_isNotAssignable() {
708 // ! (a) -> void <: (b) -> void
709 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen tFactory.classElement2("A", [])]).type;
710 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen tFactory.classElement2("B", [])]).type;
711 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
712 }
713
714 void test_isSubtypeOf_normalParameters_sHasMoreParams() {
715 // B extends A
716 // ! (a) -> void <: (b, b) -> void
717 ClassElement a = ElementFactory.classElement2("A", []);
718 ClassElement b = ElementFactory.classElement("B", a.type, []);
719 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
720 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b]) .type;
721 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
722 }
723
724 void test_isSubtypeOf_normalParameters_tHasMoreParams() {
725 // B extends A
726 // ! (a, a) -> void <: (a) -> void
727 ClassElement a = ElementFactory.classElement2("A", []);
728 ClassElement b = ElementFactory.classElement("B", a.type, []);
729 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a]) .type;
730 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
731 // note, this is a different assertion from the other "tHasMoreParams" tests , this is
732 // intentional as it is a difference of the "normal parameters"
733 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
734 }
735
736 void test_isSubtypeOf_Object() {
737 // () -> void <: Object
738 FunctionType f = ElementFactory.functionElement("f").type;
739 InterfaceType t = ElementFactory.object.type;
740 JUnitTestCase.assertTrue(f.isSubtypeOf(t));
741 }
742
743 void test_isSubtypeOf_positionalParameters_isAssignable() {
744 // B extends A
745 // ([a]) -> void <: ([b]) -> void
746 // ([b]) -> void <: ([a]) -> void
747 ClassElement a = ElementFactory.classElement2("A", []);
748 ClassElement b = ElementFactory.classElement("B", a.type, []);
749 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
750 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
751 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
752 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
753 }
754
755 void test_isSubtypeOf_positionalParameters_isNotAssignable() {
756 // ! ([a]) -> void <: ([b]) -> void
757 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ ElementFactory.classElement2("A", [])]).type;
758 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ ElementFactory.classElement2("B", [])]).type;
759 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
760 }
761
762 void test_isSubtypeOf_positionalParameters_sHasMoreParams() {
763 // B extends A
764 // ! ([a]) -> void <: ([b, b]) -> void
765 ClassElement a = ElementFactory.classElement2("A", []);
766 ClassElement b = ElementFactory.classElement("B", a.type, []);
767 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
768 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b, b]).type;
769 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
770 }
771
772 void test_isSubtypeOf_positionalParameters_tHasMoreParams() {
773 // B extends A
774 // ([a, a]) -> void <: ([b]) -> void
775 ClassElement a = ElementFactory.classElement2("A", []);
776 ClassElement b = ElementFactory.classElement("B", a.type, []);
777 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a, a]).type;
778 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
779 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
780 }
781
782 void test_isSubtypeOf_returnType_sIsVoid() {
783 // () -> void <: void
784 FunctionType t = ElementFactory.functionElement("t").type;
785 FunctionType s = ElementFactory.functionElement("s").type;
786 // function s has the implicit return type of void, we assert it here
787 JUnitTestCase.assertTrue(VoidTypeImpl.instance == s.returnType);
788 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
789 }
790
791 void test_isSubtypeOf_returnType_tAssignableToS() {
792 // B extends A
793 // () -> A <: () -> B
794 // () -> B <: () -> A
795 ClassElement a = ElementFactory.classElement2("A", []);
796 ClassElement b = ElementFactory.classElement("B", a.type, []);
797 FunctionType t = ElementFactory.functionElement2("t", a).type;
798 FunctionType s = ElementFactory.functionElement2("s", b).type;
799 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
800 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
801 }
802
803 void test_isSubtypeOf_returnType_tNotAssignableToS() {
804 // ! () -> A <: () -> B
805 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A", [])).type;
806 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl ement2("B", [])).type;
807 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
808 }
809
810 void test_isSubtypeOf_typeParameters_matchesBounds() {
811 TestTypeProvider provider = new TestTypeProvider();
812 InterfaceType boolType = provider.boolType;
813 InterfaceType stringType = provider.stringType;
814 TypeParameterElementImpl parameterB = new TypeParameterElementImpl(AstFactor y.identifier3("B"));
815 parameterB.bound = boolType;
816 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB);
817 TypeParameterElementImpl parameterS = new TypeParameterElementImpl(AstFactor y.identifier3("S"));
818 parameterS.bound = stringType;
819 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS);
820 FunctionElementImpl functionAliasElement = new FunctionElementImpl.forNode(A stFactory.identifier3("func"));
821 functionAliasElement.parameters = <ParameterElement> [
822 ElementFactory.requiredParameter2("a", typeB),
823 ElementFactory.positionalParameter2("b", typeS)];
824 functionAliasElement.returnType = stringType;
825 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias Element);
826 functionAliasElement.type = functionAliasType;
827 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
828 functionElement.parameters = <ParameterElement> [
829 ElementFactory.requiredParameter2("c", boolType),
830 ElementFactory.positionalParameter2("d", stringType)];
831 functionElement.returnType = provider.dynamicType;
832 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
833 functionElement.type = functionType;
834 JUnitTestCase.assertTrue(functionType.isAssignableTo(functionAliasType));
835 }
836
837 void test_isSubtypeOf_wrongFunctionType_normal_named() {
838 // ! (a) -> void <: ({name: A}) -> void
839 // ! ({name: A}) -> void <: (a) -> void
840 ClassElement a = ElementFactory.classElement2("A", []);
841 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
842 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
843 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
844 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
845 }
846
847 void test_isSubtypeOf_wrongFunctionType_optional_named() {
848 // ! ([a]) -> void <: ({name: A}) -> void
849 // ! ({name: A}) -> void <: ([a]) -> void
850 ClassElement a = ElementFactory.classElement2("A", []);
851 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
852 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
853 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
854 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
855 }
856
857 void test_setTypeArguments() {
858 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]);
859 MethodElementImpl methodElement = new MethodElementImpl.forNode(AstFactory.i dentifier3("m"));
860 enclosingClass.methods = <MethodElement> [methodElement];
861 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement);
862 DartType expectedType = enclosingClass.typeParameters[0].type;
863 type.typeArguments = <DartType> [expectedType];
864 List<DartType> arguments = type.typeArguments;
865 EngineTestCase.assertLength(1, arguments);
866 JUnitTestCase.assertEquals(expectedType, arguments[0]);
867 }
868
869 void test_substitute2_equal() {
870 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]);
871 TypeParameterType parameterType = definingClass.typeParameters[0].type;
872 MethodElementImpl functionElement = new MethodElementImpl.forNode(AstFactory .identifier3("m"));
873 String namedParameterName = "c";
874 functionElement.parameters = <ParameterElement> [
875 ElementFactory.requiredParameter2("a", parameterType),
876 ElementFactory.positionalParameter2("b", parameterType),
877 ElementFactory.namedParameter2(namedParameterName, parameterType)];
878 functionElement.returnType = parameterType;
879 definingClass.methods = <MethodElement> [functionElement];
880 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
881 functionType.typeArguments = <DartType> [parameterType];
882 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("D")));
883 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D artType> [parameterType]);
884 JUnitTestCase.assertEquals(argumentType, result.returnType);
885 List<DartType> normalParameters = result.normalParameterTypes;
886 EngineTestCase.assertLength(1, normalParameters);
887 JUnitTestCase.assertEquals(argumentType, normalParameters[0]);
888 List<DartType> optionalParameters = result.optionalParameterTypes;
889 EngineTestCase.assertLength(1, optionalParameters);
890 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]);
891 Map<String, DartType> namedParameters = result.namedParameterTypes;
892 EngineTestCase.assertSizeOfMap(1, namedParameters);
893 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] );
894 }
895
896 void test_substitute2_notEqual() {
897 DartType returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(AstFac tory.identifier3("R")));
898 DartType normalParameterType = new InterfaceTypeImpl.con1(new ClassElementIm pl(AstFactory.identifier3("A")));
899 DartType optionalParameterType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("B")));
900 DartType namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(AstFactory.identifier3("C")));
901 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
902 String namedParameterName = "c";
903 functionElement.parameters = <ParameterElement> [
904 ElementFactory.requiredParameter2("a", normalParameterType),
905 ElementFactory.positionalParameter2("b", optionalParameterType),
906 ElementFactory.namedParameter2(namedParameterName, namedParameterType)];
907 functionElement.returnType = returnType;
908 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
909 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("D")));
910 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara meterElementImpl(AstFactory.identifier3("E")));
911 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D artType> [parameterType]);
912 JUnitTestCase.assertEquals(returnType, result.returnType);
913 List<DartType> normalParameters = result.normalParameterTypes;
914 EngineTestCase.assertLength(1, normalParameters);
915 JUnitTestCase.assertEquals(normalParameterType, normalParameters[0]);
916 List<DartType> optionalParameters = result.optionalParameterTypes;
917 EngineTestCase.assertLength(1, optionalParameters);
918 JUnitTestCase.assertEquals(optionalParameterType, optionalParameters[0]);
919 Map<String, DartType> namedParameters = result.namedParameterTypes;
920 EngineTestCase.assertSizeOfMap(1, namedParameters);
921 JUnitTestCase.assertEquals(namedParameterType, namedParameters[namedParamete rName]);
922 }
923
924 static dartSuite() {
925 _ut.group('FunctionTypeImplTest', () {
926 _ut.test('test_creation', () {
927 final __test = new FunctionTypeImplTest();
928 runJUnitTest(__test, __test.test_creation);
929 });
930 _ut.test('test_getElement', () {
931 final __test = new FunctionTypeImplTest();
932 runJUnitTest(__test, __test.test_getElement);
933 });
934 _ut.test('test_getNamedParameterTypes', () {
935 final __test = new FunctionTypeImplTest();
936 runJUnitTest(__test, __test.test_getNamedParameterTypes);
937 });
938 _ut.test('test_getNormalParameterTypes', () {
939 final __test = new FunctionTypeImplTest();
940 runJUnitTest(__test, __test.test_getNormalParameterTypes);
941 });
942 _ut.test('test_getReturnType', () {
943 final __test = new FunctionTypeImplTest();
944 runJUnitTest(__test, __test.test_getReturnType);
945 });
946 _ut.test('test_getTypeArguments', () {
947 final __test = new FunctionTypeImplTest();
948 runJUnitTest(__test, __test.test_getTypeArguments);
949 });
950 _ut.test('test_hashCode_element', () {
951 final __test = new FunctionTypeImplTest();
952 runJUnitTest(__test, __test.test_hashCode_element);
953 });
954 _ut.test('test_hashCode_noElement', () {
955 final __test = new FunctionTypeImplTest();
956 runJUnitTest(__test, __test.test_hashCode_noElement);
957 });
958 _ut.test('test_isAssignableTo_normalAndPositionalArgs', () {
959 final __test = new FunctionTypeImplTest();
960 runJUnitTest(__test, __test.test_isAssignableTo_normalAndPositionalArgs) ;
961 });
962 _ut.test('test_isSubtypeOf_Object', () {
963 final __test = new FunctionTypeImplTest();
964 runJUnitTest(__test, __test.test_isSubtypeOf_Object);
965 });
966 _ut.test('test_isSubtypeOf_baseCase_classFunction', () {
967 final __test = new FunctionTypeImplTest();
968 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_classFunction);
969 });
970 _ut.test('test_isSubtypeOf_baseCase_notFunctionType', () {
971 final __test = new FunctionTypeImplTest();
972 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_notFunctionType);
973 });
974 _ut.test('test_isSubtypeOf_baseCase_null', () {
975 final __test = new FunctionTypeImplTest();
976 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_null);
977 });
978 _ut.test('test_isSubtypeOf_baseCase_self', () {
979 final __test = new FunctionTypeImplTest();
980 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_self);
981 });
982 _ut.test('test_isSubtypeOf_namedParameters_isAssignable', () {
983 final __test = new FunctionTypeImplTest();
984 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isAssignabl e);
985 });
986 _ut.test('test_isSubtypeOf_namedParameters_isNotAssignable', () {
987 final __test = new FunctionTypeImplTest();
988 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isNotAssign able);
989 });
990 _ut.test('test_isSubtypeOf_namedParameters_namesDifferent', () {
991 final __test = new FunctionTypeImplTest();
992 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_namesDiffer ent);
993 });
994 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams', () {
995 final __test = new FunctionTypeImplTest();
996 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms);
997 });
998 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams2', () {
999 final __test = new FunctionTypeImplTest();
1000 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms2);
1001 });
1002 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams3', () {
1003 final __test = new FunctionTypeImplTest();
1004 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms3);
1005 });
1006 _ut.test('test_isSubtypeOf_namedParameters_sHasMoreParams', () {
1007 final __test = new FunctionTypeImplTest();
1008 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_sHasMorePar ams);
1009 });
1010 _ut.test('test_isSubtypeOf_namedParameters_tHasMoreParams', () {
1011 final __test = new FunctionTypeImplTest();
1012 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_tHasMorePar ams);
1013 });
1014 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_1', () {
1015 final __test = new FunctionTypeImplTest();
1016 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_1);
1017 });
1018 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_2', () {
1019 final __test = new FunctionTypeImplTest();
1020 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_2);
1021 });
1022 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_3', () {
1023 final __test = new FunctionTypeImplTest();
1024 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_3);
1025 });
1026 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_4', () {
1027 final __test = new FunctionTypeImplTest();
1028 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_4);
1029 });
1030 _ut.test('test_isSubtypeOf_normalParameters_isAssignable', () {
1031 final __test = new FunctionTypeImplTest();
1032 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isAssignab le);
1033 });
1034 _ut.test('test_isSubtypeOf_normalParameters_isNotAssignable', () {
1035 final __test = new FunctionTypeImplTest();
1036 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isNotAssig nable);
1037 });
1038 _ut.test('test_isSubtypeOf_normalParameters_sHasMoreParams', () {
1039 final __test = new FunctionTypeImplTest();
1040 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_sHasMorePa rams);
1041 });
1042 _ut.test('test_isSubtypeOf_normalParameters_tHasMoreParams', () {
1043 final __test = new FunctionTypeImplTest();
1044 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_tHasMorePa rams);
1045 });
1046 _ut.test('test_isSubtypeOf_positionalParameters_isAssignable', () {
1047 final __test = new FunctionTypeImplTest();
1048 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_isAssi gnable);
1049 });
1050 _ut.test('test_isSubtypeOf_positionalParameters_isNotAssignable', () {
1051 final __test = new FunctionTypeImplTest();
1052 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_isNotA ssignable);
1053 });
1054 _ut.test('test_isSubtypeOf_positionalParameters_sHasMoreParams', () {
1055 final __test = new FunctionTypeImplTest();
1056 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_sHasMo reParams);
1057 });
1058 _ut.test('test_isSubtypeOf_positionalParameters_tHasMoreParams', () {
1059 final __test = new FunctionTypeImplTest();
1060 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_tHasMo reParams);
1061 });
1062 _ut.test('test_isSubtypeOf_returnType_sIsVoid', () {
1063 final __test = new FunctionTypeImplTest();
1064 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_sIsVoid);
1065 });
1066 _ut.test('test_isSubtypeOf_returnType_tAssignableToS', () {
1067 final __test = new FunctionTypeImplTest();
1068 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tAssignableToS);
1069 });
1070 _ut.test('test_isSubtypeOf_returnType_tNotAssignableToS', () {
1071 final __test = new FunctionTypeImplTest();
1072 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tNotAssignableTo S);
1073 });
1074 _ut.test('test_isSubtypeOf_typeParameters_matchesBounds', () {
1075 final __test = new FunctionTypeImplTest();
1076 runJUnitTest(__test, __test.test_isSubtypeOf_typeParameters_matchesBound s);
1077 });
1078 _ut.test('test_isSubtypeOf_wrongFunctionType_normal_named', () {
1079 final __test = new FunctionTypeImplTest();
1080 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_normal_na med);
1081 });
1082 _ut.test('test_isSubtypeOf_wrongFunctionType_optional_named', () {
1083 final __test = new FunctionTypeImplTest();
1084 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_optional_ named);
1085 });
1086 _ut.test('test_setTypeArguments', () {
1087 final __test = new FunctionTypeImplTest();
1088 runJUnitTest(__test, __test.test_setTypeArguments);
1089 });
1090 _ut.test('test_substitute2_equal', () {
1091 final __test = new FunctionTypeImplTest();
1092 runJUnitTest(__test, __test.test_substitute2_equal);
1093 });
1094 _ut.test('test_substitute2_notEqual', () {
1095 final __test = new FunctionTypeImplTest();
1096 runJUnitTest(__test, __test.test_substitute2_notEqual);
1097 });
1098 });
1099 }
1100 }
1101
1102 class InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunc tion extends InterfaceTypeImpl {
1103 InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunction (ClassElement arg0) : super.con1(arg0);
1104
1105 @override
1106 bool get isDartCoreFunction => true;
1107 }
1108
1109 class LibraryElementImplTest extends EngineTestCase {
1110 void test_creation() {
1111 JUnitTestCase.assertNotNull(new LibraryElementImpl(createAnalysisContext(), AstFactory.libraryIdentifier2(["l"])));
1112 }
1113
1114 void test_getImportedLibraries() {
1115 AnalysisContext context = createAnalysisContext();
1116 LibraryElementImpl library1 = ElementFactory.library(context, "l1");
1117 LibraryElementImpl library2 = ElementFactory.library(context, "l2");
1118 LibraryElementImpl library3 = ElementFactory.library(context, "l3");
1119 LibraryElementImpl library4 = ElementFactory.library(context, "l4");
1120 PrefixElement prefixA = new PrefixElementImpl(AstFactory.identifier3("a"));
1121 PrefixElement prefixB = new PrefixElementImpl(AstFactory.identifier3("b"));
1122 List<ImportElementImpl> imports = [
1123 ElementFactory.importFor(library2, null, []),
1124 ElementFactory.importFor(library2, prefixB, []),
1125 ElementFactory.importFor(library3, null, []),
1126 ElementFactory.importFor(library3, prefixA, []),
1127 ElementFactory.importFor(library3, prefixB, []),
1128 ElementFactory.importFor(library4, prefixA, [])];
1129 library1.imports = imports;
1130 List<LibraryElement> libraries = library1.importedLibraries;
1131 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library2, library3, library4], libraries);
1132 }
1133
1134 void test_getPrefixes() {
1135 AnalysisContext context = createAnalysisContext();
1136 LibraryElementImpl library = ElementFactory.library(context, "l1");
1137 PrefixElement prefixA = new PrefixElementImpl(AstFactory.identifier3("a"));
1138 PrefixElement prefixB = new PrefixElementImpl(AstFactory.identifier3("b"));
1139 List<ImportElementImpl> imports = [
1140 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, [] ),
1141 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, [] ),
1142 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA, []),
1143 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA, []),
1144 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB, [])];
1145 library.imports = imports;
1146 List<PrefixElement> prefixes = library.prefixes;
1147 EngineTestCase.assertLength(2, prefixes);
1148 if (identical(prefixA, prefixes[0])) {
1149 JUnitTestCase.assertSame(prefixB, prefixes[1]);
1150 } else {
1151 JUnitTestCase.assertSame(prefixB, prefixes[0]);
1152 JUnitTestCase.assertSame(prefixA, prefixes[1]);
1153 }
1154 }
1155
1156 void test_getUnits() {
1157 AnalysisContext context = createAnalysisContext();
1158 LibraryElementImpl library = ElementFactory.library(context, "test");
1159 CompilationUnitElement unitLib = library.definingCompilationUnit;
1160 CompilationUnitElementImpl unitA = ElementFactory.compilationUnit("unit_a.da rt");
1161 CompilationUnitElementImpl unitB = ElementFactory.compilationUnit("unit_b.da rt");
1162 library.parts = <CompilationUnitElement> [unitA, unitB];
1163 EngineTestCase.assertEqualsIgnoreOrder(<CompilationUnitElement> [unitLib, un itA, unitB], library.units);
1164 }
1165
1166 void test_getVisibleLibraries_cycle() {
1167 AnalysisContext context = createAnalysisContext();
1168 LibraryElementImpl library = ElementFactory.library(context, "app");
1169 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
1170 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(library, nu ll, [])];
1171 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])];
1172 List<LibraryElement> libraries = library.visibleLibraries;
1173 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA], libraries);
1174 }
1175
1176 void test_getVisibleLibraries_directExports() {
1177 AnalysisContext context = createAnalysisContext();
1178 LibraryElementImpl library = ElementFactory.library(context, "app");
1179 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
1180 library.exports = <ExportElementImpl> [ElementFactory.exportFor(libraryA, [] )];
1181 List<LibraryElement> libraries = library.visibleLibraries;
1182 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library], libraries );
1183 }
1184
1185 void test_getVisibleLibraries_directImports() {
1186 AnalysisContext context = createAnalysisContext();
1187 LibraryElementImpl library = ElementFactory.library(context, "app");
1188 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
1189 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])];
1190 List<LibraryElement> libraries = library.visibleLibraries;
1191 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA], libraries);
1192 }
1193
1194 void test_getVisibleLibraries_indirectExports() {
1195 AnalysisContext context = createAnalysisContext();
1196 LibraryElementImpl library = ElementFactory.library(context, "app");
1197 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
1198 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA");
1199 libraryA.exports = <ExportElementImpl> [ElementFactory.exportFor(libraryAA, [])];
1200 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])];
1201 List<LibraryElement> libraries = library.visibleLibraries;
1202 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA, libraryAA], libraries);
1203 }
1204
1205 void test_getVisibleLibraries_indirectImports() {
1206 AnalysisContext context = createAnalysisContext();
1207 LibraryElementImpl library = ElementFactory.library(context, "app");
1208 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
1209 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA");
1210 LibraryElementImpl libraryB = ElementFactory.library(context, "B");
1211 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(libraryAA, null, [])];
1212 library.imports = <ImportElementImpl> [
1213 ElementFactory.importFor(libraryA, null, []),
1214 ElementFactory.importFor(libraryB, null, [])];
1215 List<LibraryElement> libraries = library.visibleLibraries;
1216 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA, libraryAA, libraryB], libraries);
1217 }
1218
1219 void test_getVisibleLibraries_noImports() {
1220 AnalysisContext context = createAnalysisContext();
1221 LibraryElementImpl library = ElementFactory.library(context, "app");
1222 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library], library.v isibleLibraries);
1223 }
1224
1225 void test_isUpToDate() {
1226 AnalysisContext context = createAnalysisContext();
1227 context.sourceFactory = new SourceFactory([]);
1228 LibraryElement library = ElementFactory.library(context, "foo");
1229 context.setContents(library.definingCompilationUnit.source, "sdfsdff");
1230 // Assert that we are not up to date if the target has an old time stamp.
1231 JUnitTestCase.assertFalse(library.isUpToDate(0));
1232 // Assert that we are up to date with a target modification time in the futu re.
1233 JUnitTestCase.assertTrue(library.isUpToDate(JavaSystem.currentTimeMillis() + 1000));
1234 }
1235
1236 void test_setImports() {
1237 AnalysisContext context = createAnalysisContext();
1238 LibraryElementImpl library = new LibraryElementImpl(context, AstFactory.libr aryIdentifier2(["l1"]));
1239 List<ImportElementImpl> expectedImports = [
1240 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, [] ),
1241 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, [] )];
1242 library.imports = expectedImports;
1243 List<ImportElement> actualImports = library.imports;
1244 EngineTestCase.assertLength(expectedImports.length, actualImports);
1245 for (int i = 0; i < actualImports.length; i++) {
1246 JUnitTestCase.assertSame(expectedImports[i], actualImports[i]);
1247 }
1248 }
1249
1250 static dartSuite() {
1251 _ut.group('LibraryElementImplTest', () {
1252 _ut.test('test_creation', () {
1253 final __test = new LibraryElementImplTest();
1254 runJUnitTest(__test, __test.test_creation);
1255 });
1256 _ut.test('test_getImportedLibraries', () {
1257 final __test = new LibraryElementImplTest();
1258 runJUnitTest(__test, __test.test_getImportedLibraries);
1259 });
1260 _ut.test('test_getPrefixes', () {
1261 final __test = new LibraryElementImplTest();
1262 runJUnitTest(__test, __test.test_getPrefixes);
1263 });
1264 _ut.test('test_getUnits', () {
1265 final __test = new LibraryElementImplTest();
1266 runJUnitTest(__test, __test.test_getUnits);
1267 });
1268 _ut.test('test_getVisibleLibraries_cycle', () {
1269 final __test = new LibraryElementImplTest();
1270 runJUnitTest(__test, __test.test_getVisibleLibraries_cycle);
1271 });
1272 _ut.test('test_getVisibleLibraries_directExports', () {
1273 final __test = new LibraryElementImplTest();
1274 runJUnitTest(__test, __test.test_getVisibleLibraries_directExports);
1275 });
1276 _ut.test('test_getVisibleLibraries_directImports', () {
1277 final __test = new LibraryElementImplTest();
1278 runJUnitTest(__test, __test.test_getVisibleLibraries_directImports);
1279 });
1280 _ut.test('test_getVisibleLibraries_indirectExports', () {
1281 final __test = new LibraryElementImplTest();
1282 runJUnitTest(__test, __test.test_getVisibleLibraries_indirectExports);
1283 });
1284 _ut.test('test_getVisibleLibraries_indirectImports', () {
1285 final __test = new LibraryElementImplTest();
1286 runJUnitTest(__test, __test.test_getVisibleLibraries_indirectImports);
1287 });
1288 _ut.test('test_getVisibleLibraries_noImports', () {
1289 final __test = new LibraryElementImplTest();
1290 runJUnitTest(__test, __test.test_getVisibleLibraries_noImports);
1291 });
1292 _ut.test('test_isUpToDate', () {
1293 final __test = new LibraryElementImplTest();
1294 runJUnitTest(__test, __test.test_isUpToDate);
1295 });
1296 _ut.test('test_setImports', () {
1297 final __test = new LibraryElementImplTest();
1298 runJUnitTest(__test, __test.test_setImports);
1299 });
1300 });
1301 }
1302 }
1303
1304 class TypeParameterTypeImplTest extends EngineTestCase {
1305 void test_creation() {
1306 JUnitTestCase.assertNotNull(new TypeParameterTypeImpl(new TypeParameterEleme ntImpl(AstFactory.identifier3("E"))));
1307 }
1308
1309 void test_getElement() {
1310 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
1311 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
1312 JUnitTestCase.assertEquals(element, type.element);
1313 }
1314
1315 void test_isMoreSpecificThan_typeArguments_bottom() {
1316 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
1317 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
1318 // E << bottom
1319 JUnitTestCase.assertTrue(type.isMoreSpecificThan(BottomTypeImpl.instance));
1320 }
1321
1322 void test_isMoreSpecificThan_typeArguments_dynamic() {
1323 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
1324 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
1325 // E << dynamic
1326 JUnitTestCase.assertTrue(type.isMoreSpecificThan(DynamicTypeImpl.instance));
1327 }
1328
1329 void test_isMoreSpecificThan_typeArguments_object() {
1330 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
1331 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
1332 // E << Object
1333 JUnitTestCase.assertTrue(type.isMoreSpecificThan(ElementFactory.object.type) );
1334 }
1335
1336 void test_isMoreSpecificThan_typeArguments_resursive() {
1337 ClassElementImpl classS = ElementFactory.classElement2("A", []);
1338 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl(AstFa ctory.identifier3("U"));
1339 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU);
1340 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(AstFa ctory.identifier3("T"));
1341 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
1342 typeParameterT.bound = typeParameterTypeU;
1343 typeParameterU.bound = typeParameterTypeU;
1344 // <T extends U> and <U extends T>
1345 // T << S
1346 JUnitTestCase.assertFalse(typeParameterTypeT.isMoreSpecificThan(classS.type) );
1347 }
1348
1349 void test_isMoreSpecificThan_typeArguments_self() {
1350 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
1351 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
1352 // E << E
1353 JUnitTestCase.assertTrue(type.isMoreSpecificThan(type));
1354 }
1355
1356 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() {
1357 // class A {}
1358 // class B extends A {}
1359 //
1360 ClassElement classA = ElementFactory.classElement2("A", []);
1361 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
1362 InterfaceType typeA = classA.type;
1363 InterfaceType typeB = classB.type;
1364 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(AstFa ctory.identifier3("T"));
1365 typeParameterT.bound = typeB;
1366 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
1367 // <T extends B>
1368 // T << A
1369 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(typeA));
1370 }
1371
1372 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() {
1373 ClassElementImpl classS = ElementFactory.classElement2("A", []);
1374 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl(AstFa ctory.identifier3("U"));
1375 typeParameterU.bound = classS.type;
1376 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU);
1377 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(AstFa ctory.identifier3("T"));
1378 typeParameterT.bound = typeParameterTypeU;
1379 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
1380 // <T extends U> and <U extends S>
1381 // T << S
1382 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type)) ;
1383 }
1384
1385 void test_isMoreSpecificThan_typeArguments_upperBound() {
1386 ClassElementImpl classS = ElementFactory.classElement2("A", []);
1387 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(AstFa ctory.identifier3("T"));
1388 typeParameterT.bound = classS.type;
1389 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
1390 // <T extends S>
1391 // T << S
1392 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type)) ;
1393 }
1394
1395 void test_substitute_equal() {
1396 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
1397 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
1398 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (AstFactory.identifier3("A")));
1399 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element);
1400 JUnitTestCase.assertSame(argument, type.substitute2(<DartType> [argument], < DartType> [parameter]));
1401 }
1402
1403 void test_substitute_notEqual() {
1404 TypeParameterTypeImpl type = new TypeParameterTypeImpl(new TypeParameterElem entImpl(AstFactory.identifier3("E")));
1405 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (AstFactory.identifier3("A")));
1406 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(new TypeParamete rElementImpl(AstFactory.identifier3("F")));
1407 JUnitTestCase.assertSame(type, type.substitute2(<DartType> [argument], <Dart Type> [parameter]));
1408 }
1409
1410 static dartSuite() {
1411 _ut.group('TypeParameterTypeImplTest', () {
1412 _ut.test('test_creation', () {
1413 final __test = new TypeParameterTypeImplTest();
1414 runJUnitTest(__test, __test.test_creation);
1415 });
1416 _ut.test('test_getElement', () {
1417 final __test = new TypeParameterTypeImplTest();
1418 runJUnitTest(__test, __test.test_getElement);
1419 });
1420 _ut.test('test_isMoreSpecificThan_typeArguments_bottom', () {
1421 final __test = new TypeParameterTypeImplTest();
1422 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_bottom );
1423 });
1424 _ut.test('test_isMoreSpecificThan_typeArguments_dynamic', () {
1425 final __test = new TypeParameterTypeImplTest();
1426 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_dynami c);
1427 });
1428 _ut.test('test_isMoreSpecificThan_typeArguments_object', () {
1429 final __test = new TypeParameterTypeImplTest();
1430 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_object );
1431 });
1432 _ut.test('test_isMoreSpecificThan_typeArguments_resursive', () {
1433 final __test = new TypeParameterTypeImplTest();
1434 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_resurs ive);
1435 });
1436 _ut.test('test_isMoreSpecificThan_typeArguments_self', () {
1437 final __test = new TypeParameterTypeImplTest();
1438 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_self);
1439 });
1440 _ut.test('test_isMoreSpecificThan_typeArguments_transitivity_interfaceType s', () {
1441 final __test = new TypeParameterTypeImplTest();
1442 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_transi tivity_interfaceTypes);
1443 });
1444 _ut.test('test_isMoreSpecificThan_typeArguments_transitivity_typeParameter s', () {
1445 final __test = new TypeParameterTypeImplTest();
1446 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_transi tivity_typeParameters);
1447 });
1448 _ut.test('test_isMoreSpecificThan_typeArguments_upperBound', () {
1449 final __test = new TypeParameterTypeImplTest();
1450 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_upperB ound);
1451 });
1452 _ut.test('test_substitute_equal', () {
1453 final __test = new TypeParameterTypeImplTest();
1454 runJUnitTest(__test, __test.test_substitute_equal);
1455 });
1456 _ut.test('test_substitute_notEqual', () {
1457 final __test = new TypeParameterTypeImplTest();
1458 runJUnitTest(__test, __test.test_substitute_notEqual);
1459 });
1460 });
1461 }
1462 } 1015 }
1463 1016
1464 class ElementLocationImplTest extends EngineTestCase { 1017 class ElementLocationImplTest extends EngineTestCase {
1465 void test_create_encoding() { 1018 void test_create_encoding() {
1466 String encoding = "a;b;c"; 1019 String encoding = "a;b;c";
1467 ElementLocationImpl location = new ElementLocationImpl.con2(encoding); 1020 ElementLocationImpl location = new ElementLocationImpl.con2(encoding);
1468 JUnitTestCase.assertEquals(encoding, location.encoding); 1021 JUnitTestCase.assertEquals(encoding, location.encoding);
1469 } 1022 }
1470 1023
1471 void test_equals_equal() { 1024 void test_equals_equal() {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 runJUnitTest(__test, __test.test_hashCode_equal); 1119 runJUnitTest(__test, __test.test_hashCode_equal);
1567 }); 1120 });
1568 _ut.test('test_hashCode_equalWithDifferentUriKind', () { 1121 _ut.test('test_hashCode_equalWithDifferentUriKind', () {
1569 final __test = new ElementLocationImplTest(); 1122 final __test = new ElementLocationImplTest();
1570 runJUnitTest(__test, __test.test_hashCode_equalWithDifferentUriKind); 1123 runJUnitTest(__test, __test.test_hashCode_equalWithDifferentUriKind);
1571 }); 1124 });
1572 }); 1125 });
1573 } 1126 }
1574 } 1127 }
1575 1128
1576 class ClassElementImplTest extends EngineTestCase { 1129 class FunctionTypeImplTest extends EngineTestCase {
1577 void test_getAllSupertypes_interface() { 1130 void test_creation() {
1578 ClassElement classA = ElementFactory.classElement2("A", []); 1131 JUnitTestCase.assertNotNull(new FunctionTypeImpl.con1(new FunctionElementImp l.forNode(AstFactory.identifier3("f"))));
1579 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 1132 }
1580 ClassElementImpl elementC = ElementFactory.classElement2("C", []); 1133
1581 InterfaceType typeObject = classA.supertype; 1134 void test_getElement() {
1582 InterfaceType typeA = classA.type; 1135 FunctionElementImpl typeElement = new FunctionElementImpl.forNode(AstFactory .identifier3("f"));
1583 InterfaceType typeB = classB.type; 1136 FunctionTypeImpl type = new FunctionTypeImpl.con1(typeElement);
1584 InterfaceType typeC = elementC.type; 1137 JUnitTestCase.assertEquals(typeElement, type.element);
1585 elementC.interfaces = <InterfaceType> [typeB]; 1138 }
1586 List<InterfaceType> supers = elementC.allSupertypes; 1139
1587 List<InterfaceType> types = new List<InterfaceType>(); 1140 void test_getNamedParameterTypes() {
1588 types.addAll(supers); 1141 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
1589 JUnitTestCase.assertTrue(types.contains(typeA)); 1142 Map<String, DartType> types = type.namedParameterTypes;
1590 JUnitTestCase.assertTrue(types.contains(typeB)); 1143 EngineTestCase.assertSizeOfMap(0, types);
1591 JUnitTestCase.assertTrue(types.contains(typeObject)); 1144 }
1592 JUnitTestCase.assertFalse(types.contains(typeC)); 1145
1593 } 1146 void test_getNormalParameterTypes() {
1594 1147 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
1595 void test_getAllSupertypes_mixins() { 1148 List<DartType> types = type.normalParameterTypes;
1596 ClassElement classA = ElementFactory.classElement2("A", []); 1149 EngineTestCase.assertLength(0, types);
1597 ClassElement classB = ElementFactory.classElement("B", classA.type, []); 1150 }
1598 ClassElementImpl classC = ElementFactory.classElement2("C", []); 1151
1599 InterfaceType typeObject = classA.supertype; 1152 void test_getReturnType() {
1600 InterfaceType typeA = classA.type; 1153 DartType expectedReturnType = VoidTypeImpl.instance;
1601 InterfaceType typeB = classB.type; 1154 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
1602 InterfaceType typeC = classC.type; 1155 functionElement.returnType = expectedReturnType;
1603 classC.mixins = <InterfaceType> [typeB]; 1156 FunctionTypeImpl type = new FunctionTypeImpl.con1(functionElement);
1604 List<InterfaceType> supers = classC.allSupertypes; 1157 DartType returnType = type.returnType;
1605 List<InterfaceType> types = new List<InterfaceType>(); 1158 JUnitTestCase.assertEquals(expectedReturnType, returnType);
1606 types.addAll(supers); 1159 }
1607 JUnitTestCase.assertFalse(types.contains(typeA)); 1160
1608 JUnitTestCase.assertTrue(types.contains(typeB)); 1161 void test_getTypeArguments() {
1609 JUnitTestCase.assertTrue(types.contains(typeObject)); 1162 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
1610 JUnitTestCase.assertFalse(types.contains(typeC)); 1163 List<DartType> types = type.typeArguments;
1611 } 1164 EngineTestCase.assertLength(0, types);
1612 1165 }
1613 void test_getAllSupertypes_recursive() { 1166
1614 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1167 void test_hashCode_element() {
1615 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1168 FunctionTypeImpl type = new FunctionTypeImpl.con1(new FunctionElementImpl.fo rNode(AstFactory.identifier3("f")));
1616 classA.supertype = classB.type; 1169 type.hashCode;
1617 List<InterfaceType> supers = classB.allSupertypes; 1170 }
1618 EngineTestCase.assertLength(1, supers); 1171
1619 } 1172 void test_hashCode_noElement() {
1620 1173 FunctionTypeImpl type = new FunctionTypeImpl.con1(null);
1621 void test_getField() { 1174 type.hashCode;
1622 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1175 }
1623 String fieldName = "f"; 1176
1624 FieldElementImpl field = ElementFactory.fieldElement(fieldName, false, false , false, null); 1177 void test_isAssignableTo_normalAndPositionalArgs() {
1625 classA.fields = <FieldElement> [field]; 1178 // ([a]) -> void <: (a) -> void
1626 JUnitTestCase.assertSame(field, classA.getField(fieldName)); 1179 ClassElement a = ElementFactory.classElement2("A", []);
1627 // no such field 1180 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1628 JUnitTestCase.assertSame(null, classA.getField("noSuchField")); 1181 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
1629 } 1182 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1630 1183 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1631 void test_getMethod_declared() { 1184 // assignable iff subtype
1632 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1185 JUnitTestCase.assertTrue(t.isAssignableTo(s));
1633 String methodName = "m"; 1186 JUnitTestCase.assertFalse(s.isAssignableTo(t));
1634 MethodElement method = ElementFactory.methodElement(methodName, null, []); 1187 }
1635 classA.methods = <MethodElement> [method]; 1188
1636 JUnitTestCase.assertSame(method, classA.getMethod(methodName)); 1189 void test_isSubtypeOf_baseCase_classFunction() {
1637 } 1190 // () -> void <: Function
1638 1191 ClassElementImpl functionElement = ElementFactory.classElement2("Function", []);
1639 void test_getMethod_undeclared() { 1192 InterfaceTypeImpl functionType = new InterfaceTypeImpl_FunctionTypeImplTest_ test_isSubtypeOf_baseCase_classFunction(functionElement);
1640 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1193 FunctionType f = ElementFactory.functionElement("f").type;
1641 String methodName = "m"; 1194 JUnitTestCase.assertTrue(f.isSubtypeOf(functionType));
1642 MethodElement method = ElementFactory.methodElement(methodName, null, []); 1195 }
1643 classA.methods = <MethodElement> [method]; 1196
1644 JUnitTestCase.assertNull(classA.getMethod("${methodName}x")); 1197 void test_isSubtypeOf_baseCase_notFunctionType() {
1645 } 1198 // class C
1646 1199 // ! () -> void <: C
1647 void test_getNode() { 1200 FunctionType f = ElementFactory.functionElement("f").type;
1648 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); 1201 InterfaceType t = ElementFactory.classElement2("C", []).type;
1649 AnalysisContext context = contextHelper.context; 1202 JUnitTestCase.assertFalse(f.isSubtypeOf(t));
1650 Source source = contextHelper.addSource("/test.dart", EngineTestCase.createS ource(["class A {}", "class B {}"])); 1203 }
1651 // prepare CompilationUnitElement 1204
1652 LibraryElement libraryElement = context.computeLibraryElement(source); 1205 void test_isSubtypeOf_baseCase_null() {
1653 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; 1206 // ! () -> void <: null
1654 // A 1207 FunctionType f = ElementFactory.functionElement("f").type;
1655 { 1208 JUnitTestCase.assertFalse(f.isSubtypeOf(null));
1656 ClassElement elementA = unitElement.getType("A"); 1209 }
1657 ClassDeclaration nodeA = elementA.node; 1210
1658 JUnitTestCase.assertNotNull(nodeA); 1211 void test_isSubtypeOf_baseCase_self() {
1659 JUnitTestCase.assertEquals("A", nodeA.name.name); 1212 // () -> void <: () -> void
1660 JUnitTestCase.assertSame(elementA, nodeA.element); 1213 FunctionType f = ElementFactory.functionElement("f").type;
1661 } 1214 JUnitTestCase.assertTrue(f.isSubtypeOf(f));
1662 // B 1215 }
1663 { 1216
1664 ClassElement elementB = unitElement.getType("B"); 1217 void test_isSubtypeOf_namedParameters_isAssignable() {
1665 ClassDeclaration nodeB = elementB.node; 1218 // B extends A
1666 JUnitTestCase.assertNotNull(nodeB); 1219 // ({name: A}) -> void <: ({name: B}) -> void
1667 JUnitTestCase.assertEquals("B", nodeB.name.name); 1220 // ({name: B}) -> void <: ({name: A}) -> void
1668 JUnitTestCase.assertSame(elementB, nodeB.element); 1221 ClassElement a = ElementFactory.classElement2("A", []);
1669 } 1222 ClassElement b = ElementFactory.classElement("B", a.type, []);
1670 } 1223 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1671 1224 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
1672 void test_hasNonFinalField_false_const() { 1225 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1673 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1226 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
1674 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, true, classA.type)]; 1227 }
1675 JUnitTestCase.assertFalse(classA.hasNonFinalField); 1228
1676 } 1229 void test_isSubtypeOf_namedParameters_isNotAssignable() {
1677 1230 // ! ({name: A}) -> void <: ({name: B}) -> void
1678 void test_hasNonFinalField_false_final() { 1231 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("A", [])]).type;
1679 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1232 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [ElementFactory.classElement2("B", [])]).type;
1680 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, true , false, classA.type)]; 1233 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1681 JUnitTestCase.assertFalse(classA.hasNonFinalField); 1234 }
1682 } 1235
1683 1236 void test_isSubtypeOf_namedParameters_namesDifferent() {
1684 void test_hasNonFinalField_false_recursive() { 1237 // B extends A
1685 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1238 // void t({A name}) {}
1686 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1239 // void s({A diff}) {}
1687 classA.supertype = classB.type; 1240 // ! t <: s
1688 JUnitTestCase.assertFalse(classA.hasNonFinalField); 1241 // ! s <: t
1689 } 1242 ClassElement a = ElementFactory.classElement2("A", []);
1690 1243 ClassElement b = ElementFactory.classElement("B", a.type, []);
1691 void test_hasNonFinalField_true_immediate() { 1244 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1692 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1245 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "diff"], <ClassElement> [b]).type;
1693 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)]; 1246 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1694 JUnitTestCase.assertTrue(classA.hasNonFinalField); 1247 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1695 } 1248 }
1696 1249
1697 void test_hasNonFinalField_true_inherited() { 1250 void test_isSubtypeOf_namedParameters_orderOfParams() {
1698 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1251 // B extends A
1699 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1252 // ({A: A, B: B}) -> void <: ({B: B, A: A}) -> void
1700 classA.fields = <FieldElement> [ElementFactory.fieldElement("f", false, fals e, false, classA.type)]; 1253 ClassElement a = ElementFactory.classElement2("A", []);
1701 JUnitTestCase.assertTrue(classB.hasNonFinalField); 1254 ClassElement b = ElementFactory.classElement("B", a.type, []);
1702 } 1255 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
1703 1256 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
1704 void test_hasStaticMember_false_empty() { 1257 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1705 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1258 }
1706 // no members 1259
1707 JUnitTestCase.assertFalse(classA.hasStaticMember); 1260 void test_isSubtypeOf_namedParameters_orderOfParams2() {
1708 } 1261 // B extends A
1709 1262 // ! ({B: B}) -> void <: ({B: B, A: A}) -> void
1710 void test_hasStaticMember_false_instanceMethod() { 1263 ClassElement a = ElementFactory.classElement2("A", []);
1711 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1264 ClassElement b = ElementFactory.classElement("B", a.type, []);
1712 MethodElement method = ElementFactory.methodElement("foo", null, []); 1265 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "B"], <ClassElement> [b]).type;
1713 classA.methods = <MethodElement> [method]; 1266 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B", "A"], <ClassElement> [b, a]).type;
1714 JUnitTestCase.assertFalse(classA.hasStaticMember); 1267 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1715 } 1268 }
1716 1269
1717 void test_hasStaticMember_instanceGetter() { 1270 void test_isSubtypeOf_namedParameters_orderOfParams3() {
1718 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1271 // B extends A
1719 PropertyAccessorElement getter = ElementFactory.getterElement("foo", false, null); 1272 // ({A: A, B: B}) -> void <: ({A: A}) -> void
1720 classA.accessors = <PropertyAccessorElement> [getter]; 1273 ClassElement a = ElementFactory.classElement2("A", []);
1721 JUnitTestCase.assertFalse(classA.hasStaticMember); 1274 ClassElement b = ElementFactory.classElement("B", a.type, []);
1722 } 1275 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "A", "B"], <ClassElement> [a, b]).type;
1723 1276 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "B"], <ClassElement> [b]).type;
1724 void test_hasStaticMember_true_getter() { 1277 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1725 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1278 }
1726 PropertyAccessorElementImpl getter = ElementFactory.getterElement("foo", fal se, null); 1279
1727 classA.accessors = <PropertyAccessorElement> [getter]; 1280 void test_isSubtypeOf_namedParameters_sHasMoreParams() {
1728 // "foo" is static 1281 // B extends A
1729 getter.static = true; 1282 // ! ({name: A}) -> void <: ({name: B, name2: B}) -> void
1730 JUnitTestCase.assertTrue(classA.hasStaticMember); 1283 ClassElement a = ElementFactory.classElement2("A", []);
1731 } 1284 ClassElement b = ElementFactory.classElement("B", a.type, []);
1732 1285 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name"], <ClassElement> [a]).type;
1733 void test_hasStaticMember_true_method() { 1286 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name", "name2"], <ClassElement> [b, b]).type;
1734 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1287 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1735 MethodElementImpl method = ElementFactory.methodElement("foo", null, []); 1288 }
1736 classA.methods = <MethodElement> [method]; 1289
1737 // "foo" is static 1290 void test_isSubtypeOf_namedParameters_tHasMoreParams() {
1738 method.static = true; 1291 // B extends A
1739 JUnitTestCase.assertTrue(classA.hasStaticMember); 1292 // ({name: A, name2: A}) -> void <: ({name: B}) -> void
1740 } 1293 ClassElement a = ElementFactory.classElement2("A", []);
1741 1294 ClassElement b = ElementFactory.classElement("B", a.type, []);
1742 void test_hasStaticMember_true_setter() { 1295 FunctionType t = ElementFactory.functionElement4("t", null, null, <String> [ "name", "name2"], <ClassElement> [a, a]).type;
1743 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1296 FunctionType s = ElementFactory.functionElement4("s", null, null, <String> [ "name"], <ClassElement> [b]).type;
1744 PropertyAccessorElementImpl setter = ElementFactory.setterElement("foo", fal se, null); 1297 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1745 classA.accessors = <PropertyAccessorElement> [setter]; 1298 }
1746 // "foo" is static 1299
1747 setter.static = true; 1300 void test_isSubtypeOf_normalAndPositionalArgs_1() {
1748 JUnitTestCase.assertTrue(classA.hasStaticMember); 1301 // ([a]) -> void <: (a) -> void
1749 } 1302 ClassElement a = ElementFactory.classElement2("A", []);
1750 1303 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1751 void test_lookUpGetter_declared() { 1304 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
1752 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1305 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1753 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1306 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1754 String getterName = "g"; 1307 }
1755 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null); 1308
1756 classA.accessors = <PropertyAccessorElement> [getter]; 1309 void test_isSubtypeOf_normalAndPositionalArgs_2() {
1757 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 1310 // (a, [a]) -> void <: (a) -> void
1758 JUnitTestCase.assertSame(getter, classA.lookUpGetter(getterName, library)); 1311 ClassElement a = ElementFactory.classElement2("A", []);
1759 } 1312 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a], <C lassElement> [a]).type;
1760 1313 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [a]).ty pe;
1761 void test_lookUpGetter_inherited() { 1314 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1762 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1315 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1763 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1316 }
1764 String getterName = "g"; 1317
1765 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, null); 1318 void test_isSubtypeOf_normalAndPositionalArgs_3() {
1766 classA.accessors = <PropertyAccessorElement> [getter]; 1319 // ([a]) -> void <: () -> void
1767 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1320 ClassElement a = ElementFactory.classElement2("A", []);
1768 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 1321 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1769 JUnitTestCase.assertSame(getter, classB.lookUpGetter(getterName, library)); 1322 FunctionType s = ElementFactory.functionElement("s").type;
1770 } 1323 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1771 1324 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1772 void test_lookUpGetter_undeclared() { 1325 }
1773 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1326
1774 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1327 void test_isSubtypeOf_normalAndPositionalArgs_4() {
1775 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 1328 // (a, b, [c, d, e]) -> void <: (a, b, c, [d]) -> void
1776 JUnitTestCase.assertNull(classA.lookUpGetter("g", library)); 1329 ClassElement a = ElementFactory.classElement2("A", []);
1777 } 1330 ClassElement b = ElementFactory.classElement2("B", []);
1778 1331 ClassElement c = ElementFactory.classElement2("C", []);
1779 void test_lookUpGetter_undeclared_recursive() { 1332 ClassElement d = ElementFactory.classElement2("D", []);
1780 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1333 ClassElement e = ElementFactory.classElement2("E", []);
1781 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1334 FunctionType t = ElementFactory.functionElement6("t", <ClassElement> [a, b], <ClassElement> [c, d, e]).type;
1782 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1335 FunctionType s = ElementFactory.functionElement6("s", <ClassElement> [a, b, c], <ClassElement> [d]).type;
1783 classA.supertype = classB.type; 1336 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1784 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 1337 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1785 JUnitTestCase.assertNull(classA.lookUpGetter("g", library)); 1338 }
1786 } 1339
1787 1340 void test_isSubtypeOf_normalParameters_isAssignable() {
1788 void test_lookUpMethod_declared() { 1341 // B extends A
1789 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1342 // (a) -> void <: (b) -> void
1790 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1343 // (b) -> void <: (a) -> void
1791 String methodName = "m"; 1344 ClassElement a = ElementFactory.classElement2("A", []);
1792 MethodElement method = ElementFactory.methodElement(methodName, null, []); 1345 ClassElement b = ElementFactory.classElement("B", a.type, []);
1793 classA.methods = <MethodElement> [method]; 1346 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1794 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 1347 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
1795 JUnitTestCase.assertSame(method, classA.lookUpMethod(methodName, library)); 1348 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1796 } 1349 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
1797 1350 }
1798 void test_lookUpMethod_inherited() { 1351
1799 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1352 void test_isSubtypeOf_normalParameters_isNotAssignable() {
1800 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1353 // ! (a) -> void <: (b) -> void
1801 String methodName = "m"; 1354 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [Elemen tFactory.classElement2("A", [])]).type;
1802 MethodElement method = ElementFactory.methodElement(methodName, null, []); 1355 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [Elemen tFactory.classElement2("B", [])]).type;
1803 classA.methods = <MethodElement> [method]; 1356 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1804 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1357 }
1805 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 1358
1806 JUnitTestCase.assertSame(method, classB.lookUpMethod(methodName, library)); 1359 void test_isSubtypeOf_normalParameters_sHasMoreParams() {
1807 } 1360 // B extends A
1808 1361 // ! (a) -> void <: (b, b) -> void
1809 void test_lookUpMethod_undeclared() { 1362 ClassElement a = ElementFactory.classElement2("A", []);
1810 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1363 ClassElement b = ElementFactory.classElement("B", a.type, []);
1811 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1364 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1812 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 1365 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b, b]) .type;
1813 JUnitTestCase.assertNull(classA.lookUpMethod("m", library)); 1366 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1814 } 1367 }
1815 1368
1816 void test_lookUpMethod_undeclared_recursive() { 1369 void test_isSubtypeOf_normalParameters_tHasMoreParams() {
1817 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1370 // B extends A
1818 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1371 // ! (a, a) -> void <: (a) -> void
1819 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1372 ClassElement a = ElementFactory.classElement2("A", []);
1820 classA.supertype = classB.type; 1373 ClassElement b = ElementFactory.classElement("B", a.type, []);
1821 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 1374 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a, a]) .type;
1822 JUnitTestCase.assertNull(classA.lookUpMethod("m", library)); 1375 FunctionType s = ElementFactory.functionElement5("s", <ClassElement> [b]).ty pe;
1823 } 1376 // note, this is a different assertion from the other "tHasMoreParams" tests , this is
1824 1377 // intentional as it is a difference of the "normal parameters"
1825 void test_lookUpSetter_declared() { 1378 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1826 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1379 }
1827 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1380
1828 String setterName = "s"; 1381 void test_isSubtypeOf_Object() {
1829 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null); 1382 // () -> void <: Object
1830 classA.accessors = <PropertyAccessorElement> [setter]; 1383 FunctionType f = ElementFactory.functionElement("f").type;
1831 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 1384 InterfaceType t = ElementFactory.object.type;
1832 JUnitTestCase.assertSame(setter, classA.lookUpSetter(setterName, library)); 1385 JUnitTestCase.assertTrue(f.isSubtypeOf(t));
1833 } 1386 }
1834 1387
1835 void test_lookUpSetter_inherited() { 1388 void test_isSubtypeOf_positionalParameters_isAssignable() {
1836 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1389 // B extends A
1837 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1390 // ([a]) -> void <: ([b]) -> void
1838 String setterName = "s"; 1391 // ([b]) -> void <: ([a]) -> void
1839 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, null); 1392 ClassElement a = ElementFactory.classElement2("A", []);
1840 classA.accessors = <PropertyAccessorElement> [setter]; 1393 ClassElement b = ElementFactory.classElement("B", a.type, []);
1841 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1394 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1842 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 1395 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
1843 JUnitTestCase.assertSame(setter, classB.lookUpSetter(setterName, library)); 1396 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1844 } 1397 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
1845 1398 }
1846 void test_lookUpSetter_undeclared() { 1399
1847 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1400 void test_isSubtypeOf_positionalParameters_isNotAssignable() {
1848 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1401 // ! ([a]) -> void <: ([b]) -> void
1849 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA]; 1402 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ ElementFactory.classElement2("A", [])]).type;
1850 JUnitTestCase.assertNull(classA.lookUpSetter("s", library)); 1403 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ ElementFactory.classElement2("B", [])]).type;
1851 } 1404 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1852 1405 }
1853 void test_lookUpSetter_undeclared_recursive() { 1406
1854 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib"); 1407 void test_isSubtypeOf_positionalParameters_sHasMoreParams() {
1855 ClassElementImpl classA = ElementFactory.classElement2("A", []); 1408 // B extends A
1856 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []); 1409 // ! ([a]) -> void <: ([b, b]) -> void
1857 classA.supertype = classB.type; 1410 ClassElement a = ElementFactory.classElement2("A", []);
1858 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classA, classB]; 1411 ClassElement b = ElementFactory.classElement("B", a.type, []);
1859 JUnitTestCase.assertNull(classA.lookUpSetter("s", library)); 1412 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1413 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b, b]).type;
1414 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1415 }
1416
1417 void test_isSubtypeOf_positionalParameters_tHasMoreParams() {
1418 // B extends A
1419 // ([a, a]) -> void <: ([b]) -> void
1420 ClassElement a = ElementFactory.classElement2("A", []);
1421 ClassElement b = ElementFactory.classElement("B", a.type, []);
1422 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a, a]).type;
1423 FunctionType s = ElementFactory.functionElement6("s", null, <ClassElement> [ b]).type;
1424 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1425 }
1426
1427 void test_isSubtypeOf_returnType_sIsVoid() {
1428 // () -> void <: void
1429 FunctionType t = ElementFactory.functionElement("t").type;
1430 FunctionType s = ElementFactory.functionElement("s").type;
1431 // function s has the implicit return type of void, we assert it here
1432 JUnitTestCase.assertTrue(VoidTypeImpl.instance == s.returnType);
1433 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1434 }
1435
1436 void test_isSubtypeOf_returnType_tAssignableToS() {
1437 // B extends A
1438 // () -> A <: () -> B
1439 // () -> B <: () -> A
1440 ClassElement a = ElementFactory.classElement2("A", []);
1441 ClassElement b = ElementFactory.classElement("B", a.type, []);
1442 FunctionType t = ElementFactory.functionElement2("t", a).type;
1443 FunctionType s = ElementFactory.functionElement2("s", b).type;
1444 JUnitTestCase.assertTrue(t.isSubtypeOf(s));
1445 JUnitTestCase.assertTrue(s.isSubtypeOf(t));
1446 }
1447
1448 void test_isSubtypeOf_returnType_tNotAssignableToS() {
1449 // ! () -> A <: () -> B
1450 FunctionType t = ElementFactory.functionElement2("t", ElementFactory.classEl ement2("A", [])).type;
1451 FunctionType s = ElementFactory.functionElement2("s", ElementFactory.classEl ement2("B", [])).type;
1452 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1453 }
1454
1455 void test_isSubtypeOf_typeParameters_matchesBounds() {
1456 TestTypeProvider provider = new TestTypeProvider();
1457 InterfaceType boolType = provider.boolType;
1458 InterfaceType stringType = provider.stringType;
1459 TypeParameterElementImpl parameterB = new TypeParameterElementImpl(AstFactor y.identifier3("B"));
1460 parameterB.bound = boolType;
1461 TypeParameterTypeImpl typeB = new TypeParameterTypeImpl(parameterB);
1462 TypeParameterElementImpl parameterS = new TypeParameterElementImpl(AstFactor y.identifier3("S"));
1463 parameterS.bound = stringType;
1464 TypeParameterTypeImpl typeS = new TypeParameterTypeImpl(parameterS);
1465 FunctionElementImpl functionAliasElement = new FunctionElementImpl.forNode(A stFactory.identifier3("func"));
1466 functionAliasElement.parameters = <ParameterElement> [
1467 ElementFactory.requiredParameter2("a", typeB),
1468 ElementFactory.positionalParameter2("b", typeS)];
1469 functionAliasElement.returnType = stringType;
1470 FunctionTypeImpl functionAliasType = new FunctionTypeImpl.con1(functionAlias Element);
1471 functionAliasElement.type = functionAliasType;
1472 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
1473 functionElement.parameters = <ParameterElement> [
1474 ElementFactory.requiredParameter2("c", boolType),
1475 ElementFactory.positionalParameter2("d", stringType)];
1476 functionElement.returnType = provider.dynamicType;
1477 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
1478 functionElement.type = functionType;
1479 JUnitTestCase.assertTrue(functionType.isAssignableTo(functionAliasType));
1480 }
1481
1482 void test_isSubtypeOf_wrongFunctionType_normal_named() {
1483 // ! (a) -> void <: ({name: A}) -> void
1484 // ! ({name: A}) -> void <: (a) -> void
1485 ClassElement a = ElementFactory.classElement2("A", []);
1486 FunctionType t = ElementFactory.functionElement5("t", <ClassElement> [a]).ty pe;
1487 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
1488 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1489 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1490 }
1491
1492 void test_isSubtypeOf_wrongFunctionType_optional_named() {
1493 // ! ([a]) -> void <: ({name: A}) -> void
1494 // ! ({name: A}) -> void <: ([a]) -> void
1495 ClassElement a = ElementFactory.classElement2("A", []);
1496 FunctionType t = ElementFactory.functionElement6("t", null, <ClassElement> [ a]).type;
1497 FunctionType s = ElementFactory.functionElement7("s", null, <String> ["name" ], <ClassElement> [a]).type;
1498 JUnitTestCase.assertFalse(t.isSubtypeOf(s));
1499 JUnitTestCase.assertFalse(s.isSubtypeOf(t));
1500 }
1501
1502 void test_setTypeArguments() {
1503 ClassElementImpl enclosingClass = ElementFactory.classElement2("C", ["E"]);
1504 MethodElementImpl methodElement = new MethodElementImpl.forNode(AstFactory.i dentifier3("m"));
1505 enclosingClass.methods = <MethodElement> [methodElement];
1506 FunctionTypeImpl type = new FunctionTypeImpl.con1(methodElement);
1507 DartType expectedType = enclosingClass.typeParameters[0].type;
1508 type.typeArguments = <DartType> [expectedType];
1509 List<DartType> arguments = type.typeArguments;
1510 EngineTestCase.assertLength(1, arguments);
1511 JUnitTestCase.assertEquals(expectedType, arguments[0]);
1512 }
1513
1514 void test_substitute2_equal() {
1515 ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]);
1516 TypeParameterType parameterType = definingClass.typeParameters[0].type;
1517 MethodElementImpl functionElement = new MethodElementImpl.forNode(AstFactory .identifier3("m"));
1518 String namedParameterName = "c";
1519 functionElement.parameters = <ParameterElement> [
1520 ElementFactory.requiredParameter2("a", parameterType),
1521 ElementFactory.positionalParameter2("b", parameterType),
1522 ElementFactory.namedParameter2(namedParameterName, parameterType)];
1523 functionElement.returnType = parameterType;
1524 definingClass.methods = <MethodElement> [functionElement];
1525 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
1526 functionType.typeArguments = <DartType> [parameterType];
1527 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("D")));
1528 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D artType> [parameterType]);
1529 JUnitTestCase.assertEquals(argumentType, result.returnType);
1530 List<DartType> normalParameters = result.normalParameterTypes;
1531 EngineTestCase.assertLength(1, normalParameters);
1532 JUnitTestCase.assertEquals(argumentType, normalParameters[0]);
1533 List<DartType> optionalParameters = result.optionalParameterTypes;
1534 EngineTestCase.assertLength(1, optionalParameters);
1535 JUnitTestCase.assertEquals(argumentType, optionalParameters[0]);
1536 Map<String, DartType> namedParameters = result.namedParameterTypes;
1537 EngineTestCase.assertSizeOfMap(1, namedParameters);
1538 JUnitTestCase.assertEquals(argumentType, namedParameters[namedParameterName] );
1539 }
1540
1541 void test_substitute2_notEqual() {
1542 DartType returnType = new InterfaceTypeImpl.con1(new ClassElementImpl(AstFac tory.identifier3("R")));
1543 DartType normalParameterType = new InterfaceTypeImpl.con1(new ClassElementIm pl(AstFactory.identifier3("A")));
1544 DartType optionalParameterType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("B")));
1545 DartType namedParameterType = new InterfaceTypeImpl.con1(new ClassElementImp l(AstFactory.identifier3("C")));
1546 FunctionElementImpl functionElement = new FunctionElementImpl.forNode(AstFac tory.identifier3("f"));
1547 String namedParameterName = "c";
1548 functionElement.parameters = <ParameterElement> [
1549 ElementFactory.requiredParameter2("a", normalParameterType),
1550 ElementFactory.positionalParameter2("b", optionalParameterType),
1551 ElementFactory.namedParameter2(namedParameterName, namedParameterType)];
1552 functionElement.returnType = returnType;
1553 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement);
1554 InterfaceTypeImpl argumentType = new InterfaceTypeImpl.con1(new ClassElement Impl(AstFactory.identifier3("D")));
1555 TypeParameterTypeImpl parameterType = new TypeParameterTypeImpl(new TypePara meterElementImpl(AstFactory.identifier3("E")));
1556 FunctionType result = functionType.substitute2(<DartType> [argumentType], <D artType> [parameterType]);
1557 JUnitTestCase.assertEquals(returnType, result.returnType);
1558 List<DartType> normalParameters = result.normalParameterTypes;
1559 EngineTestCase.assertLength(1, normalParameters);
1560 JUnitTestCase.assertEquals(normalParameterType, normalParameters[0]);
1561 List<DartType> optionalParameters = result.optionalParameterTypes;
1562 EngineTestCase.assertLength(1, optionalParameters);
1563 JUnitTestCase.assertEquals(optionalParameterType, optionalParameters[0]);
1564 Map<String, DartType> namedParameters = result.namedParameterTypes;
1565 EngineTestCase.assertSizeOfMap(1, namedParameters);
1566 JUnitTestCase.assertEquals(namedParameterType, namedParameters[namedParamete rName]);
1860 } 1567 }
1861 1568
1862 static dartSuite() { 1569 static dartSuite() {
1863 _ut.group('ClassElementImplTest', () { 1570 _ut.group('FunctionTypeImplTest', () {
1864 _ut.test('test_getAllSupertypes_interface', () { 1571 _ut.test('test_creation', () {
1865 final __test = new ClassElementImplTest(); 1572 final __test = new FunctionTypeImplTest();
1866 runJUnitTest(__test, __test.test_getAllSupertypes_interface); 1573 runJUnitTest(__test, __test.test_creation);
1867 }); 1574 });
1868 _ut.test('test_getAllSupertypes_mixins', () { 1575 _ut.test('test_getElement', () {
1869 final __test = new ClassElementImplTest(); 1576 final __test = new FunctionTypeImplTest();
1870 runJUnitTest(__test, __test.test_getAllSupertypes_mixins); 1577 runJUnitTest(__test, __test.test_getElement);
1871 }); 1578 });
1872 _ut.test('test_getAllSupertypes_recursive', () { 1579 _ut.test('test_getNamedParameterTypes', () {
1873 final __test = new ClassElementImplTest(); 1580 final __test = new FunctionTypeImplTest();
1874 runJUnitTest(__test, __test.test_getAllSupertypes_recursive); 1581 runJUnitTest(__test, __test.test_getNamedParameterTypes);
1875 }); 1582 });
1876 _ut.test('test_getField', () { 1583 _ut.test('test_getNormalParameterTypes', () {
1877 final __test = new ClassElementImplTest(); 1584 final __test = new FunctionTypeImplTest();
1878 runJUnitTest(__test, __test.test_getField); 1585 runJUnitTest(__test, __test.test_getNormalParameterTypes);
1879 }); 1586 });
1880 _ut.test('test_getMethod_declared', () { 1587 _ut.test('test_getReturnType', () {
1881 final __test = new ClassElementImplTest(); 1588 final __test = new FunctionTypeImplTest();
1882 runJUnitTest(__test, __test.test_getMethod_declared); 1589 runJUnitTest(__test, __test.test_getReturnType);
1883 }); 1590 });
1884 _ut.test('test_getMethod_undeclared', () { 1591 _ut.test('test_getTypeArguments', () {
1885 final __test = new ClassElementImplTest(); 1592 final __test = new FunctionTypeImplTest();
1886 runJUnitTest(__test, __test.test_getMethod_undeclared); 1593 runJUnitTest(__test, __test.test_getTypeArguments);
1887 }); 1594 });
1888 _ut.test('test_getNode', () { 1595 _ut.test('test_hashCode_element', () {
1889 final __test = new ClassElementImplTest(); 1596 final __test = new FunctionTypeImplTest();
1890 runJUnitTest(__test, __test.test_getNode); 1597 runJUnitTest(__test, __test.test_hashCode_element);
1891 }); 1598 });
1892 _ut.test('test_hasNonFinalField_false_const', () { 1599 _ut.test('test_hashCode_noElement', () {
1893 final __test = new ClassElementImplTest(); 1600 final __test = new FunctionTypeImplTest();
1894 runJUnitTest(__test, __test.test_hasNonFinalField_false_const); 1601 runJUnitTest(__test, __test.test_hashCode_noElement);
1895 }); 1602 });
1896 _ut.test('test_hasNonFinalField_false_final', () { 1603 _ut.test('test_isAssignableTo_normalAndPositionalArgs', () {
1897 final __test = new ClassElementImplTest(); 1604 final __test = new FunctionTypeImplTest();
1898 runJUnitTest(__test, __test.test_hasNonFinalField_false_final); 1605 runJUnitTest(__test, __test.test_isAssignableTo_normalAndPositionalArgs) ;
1899 }); 1606 });
1900 _ut.test('test_hasNonFinalField_false_recursive', () { 1607 _ut.test('test_isSubtypeOf_Object', () {
1901 final __test = new ClassElementImplTest(); 1608 final __test = new FunctionTypeImplTest();
1902 runJUnitTest(__test, __test.test_hasNonFinalField_false_recursive); 1609 runJUnitTest(__test, __test.test_isSubtypeOf_Object);
1903 }); 1610 });
1904 _ut.test('test_hasNonFinalField_true_immediate', () { 1611 _ut.test('test_isSubtypeOf_baseCase_classFunction', () {
1905 final __test = new ClassElementImplTest(); 1612 final __test = new FunctionTypeImplTest();
1906 runJUnitTest(__test, __test.test_hasNonFinalField_true_immediate); 1613 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_classFunction);
1907 }); 1614 });
1908 _ut.test('test_hasNonFinalField_true_inherited', () { 1615 _ut.test('test_isSubtypeOf_baseCase_notFunctionType', () {
1909 final __test = new ClassElementImplTest(); 1616 final __test = new FunctionTypeImplTest();
1910 runJUnitTest(__test, __test.test_hasNonFinalField_true_inherited); 1617 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_notFunctionType);
1911 }); 1618 });
1912 _ut.test('test_hasStaticMember_false_empty', () { 1619 _ut.test('test_isSubtypeOf_baseCase_null', () {
1913 final __test = new ClassElementImplTest(); 1620 final __test = new FunctionTypeImplTest();
1914 runJUnitTest(__test, __test.test_hasStaticMember_false_empty); 1621 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_null);
1915 }); 1622 });
1916 _ut.test('test_hasStaticMember_false_instanceMethod', () { 1623 _ut.test('test_isSubtypeOf_baseCase_self', () {
1917 final __test = new ClassElementImplTest(); 1624 final __test = new FunctionTypeImplTest();
1918 runJUnitTest(__test, __test.test_hasStaticMember_false_instanceMethod); 1625 runJUnitTest(__test, __test.test_isSubtypeOf_baseCase_self);
1919 }); 1626 });
1920 _ut.test('test_hasStaticMember_instanceGetter', () { 1627 _ut.test('test_isSubtypeOf_namedParameters_isAssignable', () {
1921 final __test = new ClassElementImplTest(); 1628 final __test = new FunctionTypeImplTest();
1922 runJUnitTest(__test, __test.test_hasStaticMember_instanceGetter); 1629 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isAssignabl e);
1923 }); 1630 });
1924 _ut.test('test_hasStaticMember_true_getter', () { 1631 _ut.test('test_isSubtypeOf_namedParameters_isNotAssignable', () {
1925 final __test = new ClassElementImplTest(); 1632 final __test = new FunctionTypeImplTest();
1926 runJUnitTest(__test, __test.test_hasStaticMember_true_getter); 1633 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_isNotAssign able);
1927 }); 1634 });
1928 _ut.test('test_hasStaticMember_true_method', () { 1635 _ut.test('test_isSubtypeOf_namedParameters_namesDifferent', () {
1929 final __test = new ClassElementImplTest(); 1636 final __test = new FunctionTypeImplTest();
1930 runJUnitTest(__test, __test.test_hasStaticMember_true_method); 1637 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_namesDiffer ent);
1931 }); 1638 });
1932 _ut.test('test_hasStaticMember_true_setter', () { 1639 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams', () {
1933 final __test = new ClassElementImplTest(); 1640 final __test = new FunctionTypeImplTest();
1934 runJUnitTest(__test, __test.test_hasStaticMember_true_setter); 1641 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms);
1935 }); 1642 });
1936 _ut.test('test_lookUpGetter_declared', () { 1643 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams2', () {
1937 final __test = new ClassElementImplTest(); 1644 final __test = new FunctionTypeImplTest();
1938 runJUnitTest(__test, __test.test_lookUpGetter_declared); 1645 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms2);
1939 }); 1646 });
1940 _ut.test('test_lookUpGetter_inherited', () { 1647 _ut.test('test_isSubtypeOf_namedParameters_orderOfParams3', () {
1941 final __test = new ClassElementImplTest(); 1648 final __test = new FunctionTypeImplTest();
1942 runJUnitTest(__test, __test.test_lookUpGetter_inherited); 1649 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_orderOfPara ms3);
1943 }); 1650 });
1944 _ut.test('test_lookUpGetter_undeclared', () { 1651 _ut.test('test_isSubtypeOf_namedParameters_sHasMoreParams', () {
1945 final __test = new ClassElementImplTest(); 1652 final __test = new FunctionTypeImplTest();
1946 runJUnitTest(__test, __test.test_lookUpGetter_undeclared); 1653 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_sHasMorePar ams);
1947 }); 1654 });
1948 _ut.test('test_lookUpGetter_undeclared_recursive', () { 1655 _ut.test('test_isSubtypeOf_namedParameters_tHasMoreParams', () {
1949 final __test = new ClassElementImplTest(); 1656 final __test = new FunctionTypeImplTest();
1950 runJUnitTest(__test, __test.test_lookUpGetter_undeclared_recursive); 1657 runJUnitTest(__test, __test.test_isSubtypeOf_namedParameters_tHasMorePar ams);
1951 }); 1658 });
1952 _ut.test('test_lookUpMethod_declared', () { 1659 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_1', () {
1953 final __test = new ClassElementImplTest(); 1660 final __test = new FunctionTypeImplTest();
1954 runJUnitTest(__test, __test.test_lookUpMethod_declared); 1661 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_1);
1955 }); 1662 });
1956 _ut.test('test_lookUpMethod_inherited', () { 1663 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_2', () {
1957 final __test = new ClassElementImplTest(); 1664 final __test = new FunctionTypeImplTest();
1958 runJUnitTest(__test, __test.test_lookUpMethod_inherited); 1665 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_2);
1959 }); 1666 });
1960 _ut.test('test_lookUpMethod_undeclared', () { 1667 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_3', () {
1961 final __test = new ClassElementImplTest(); 1668 final __test = new FunctionTypeImplTest();
1962 runJUnitTest(__test, __test.test_lookUpMethod_undeclared); 1669 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_3);
1963 }); 1670 });
1964 _ut.test('test_lookUpMethod_undeclared_recursive', () { 1671 _ut.test('test_isSubtypeOf_normalAndPositionalArgs_4', () {
1965 final __test = new ClassElementImplTest(); 1672 final __test = new FunctionTypeImplTest();
1966 runJUnitTest(__test, __test.test_lookUpMethod_undeclared_recursive); 1673 runJUnitTest(__test, __test.test_isSubtypeOf_normalAndPositionalArgs_4);
1967 }); 1674 });
1968 _ut.test('test_lookUpSetter_declared', () { 1675 _ut.test('test_isSubtypeOf_normalParameters_isAssignable', () {
1969 final __test = new ClassElementImplTest(); 1676 final __test = new FunctionTypeImplTest();
1970 runJUnitTest(__test, __test.test_lookUpSetter_declared); 1677 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isAssignab le);
1971 }); 1678 });
1972 _ut.test('test_lookUpSetter_inherited', () { 1679 _ut.test('test_isSubtypeOf_normalParameters_isNotAssignable', () {
1973 final __test = new ClassElementImplTest(); 1680 final __test = new FunctionTypeImplTest();
1974 runJUnitTest(__test, __test.test_lookUpSetter_inherited); 1681 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_isNotAssig nable);
1975 }); 1682 });
1976 _ut.test('test_lookUpSetter_undeclared', () { 1683 _ut.test('test_isSubtypeOf_normalParameters_sHasMoreParams', () {
1977 final __test = new ClassElementImplTest(); 1684 final __test = new FunctionTypeImplTest();
1978 runJUnitTest(__test, __test.test_lookUpSetter_undeclared); 1685 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_sHasMorePa rams);
1979 }); 1686 });
1980 _ut.test('test_lookUpSetter_undeclared_recursive', () { 1687 _ut.test('test_isSubtypeOf_normalParameters_tHasMoreParams', () {
1981 final __test = new ClassElementImplTest(); 1688 final __test = new FunctionTypeImplTest();
1982 runJUnitTest(__test, __test.test_lookUpSetter_undeclared_recursive); 1689 runJUnitTest(__test, __test.test_isSubtypeOf_normalParameters_tHasMorePa rams);
1690 });
1691 _ut.test('test_isSubtypeOf_positionalParameters_isAssignable', () {
1692 final __test = new FunctionTypeImplTest();
1693 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_isAssi gnable);
1694 });
1695 _ut.test('test_isSubtypeOf_positionalParameters_isNotAssignable', () {
1696 final __test = new FunctionTypeImplTest();
1697 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_isNotA ssignable);
1698 });
1699 _ut.test('test_isSubtypeOf_positionalParameters_sHasMoreParams', () {
1700 final __test = new FunctionTypeImplTest();
1701 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_sHasMo reParams);
1702 });
1703 _ut.test('test_isSubtypeOf_positionalParameters_tHasMoreParams', () {
1704 final __test = new FunctionTypeImplTest();
1705 runJUnitTest(__test, __test.test_isSubtypeOf_positionalParameters_tHasMo reParams);
1706 });
1707 _ut.test('test_isSubtypeOf_returnType_sIsVoid', () {
1708 final __test = new FunctionTypeImplTest();
1709 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_sIsVoid);
1710 });
1711 _ut.test('test_isSubtypeOf_returnType_tAssignableToS', () {
1712 final __test = new FunctionTypeImplTest();
1713 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tAssignableToS);
1714 });
1715 _ut.test('test_isSubtypeOf_returnType_tNotAssignableToS', () {
1716 final __test = new FunctionTypeImplTest();
1717 runJUnitTest(__test, __test.test_isSubtypeOf_returnType_tNotAssignableTo S);
1718 });
1719 _ut.test('test_isSubtypeOf_typeParameters_matchesBounds', () {
1720 final __test = new FunctionTypeImplTest();
1721 runJUnitTest(__test, __test.test_isSubtypeOf_typeParameters_matchesBound s);
1722 });
1723 _ut.test('test_isSubtypeOf_wrongFunctionType_normal_named', () {
1724 final __test = new FunctionTypeImplTest();
1725 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_normal_na med);
1726 });
1727 _ut.test('test_isSubtypeOf_wrongFunctionType_optional_named', () {
1728 final __test = new FunctionTypeImplTest();
1729 runJUnitTest(__test, __test.test_isSubtypeOf_wrongFunctionType_optional_ named);
1730 });
1731 _ut.test('test_setTypeArguments', () {
1732 final __test = new FunctionTypeImplTest();
1733 runJUnitTest(__test, __test.test_setTypeArguments);
1734 });
1735 _ut.test('test_substitute2_equal', () {
1736 final __test = new FunctionTypeImplTest();
1737 runJUnitTest(__test, __test.test_substitute2_equal);
1738 });
1739 _ut.test('test_substitute2_notEqual', () {
1740 final __test = new FunctionTypeImplTest();
1741 runJUnitTest(__test, __test.test_substitute2_notEqual);
1983 }); 1742 });
1984 }); 1743 });
1985 } 1744 }
1986 } 1745 }
1987 1746
1988 class AngularPropertyKindTest extends EngineTestCase { 1747 class HtmlElementImplTest extends EngineTestCase {
1989 void test_ATTR() { 1748 void test_equals_differentSource() {
1990 AngularPropertyKind kind = AngularPropertyKind.ATTR; 1749 AnalysisContextImpl context = createAnalysisContext();
1991 JUnitTestCase.assertFalse(kind.callsGetter()); 1750 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "indexA.html");
1992 JUnitTestCase.assertTrue(kind.callsSetter()); 1751 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "indexB.html");
1993 } 1752 JUnitTestCase.assertFalse(elementA == elementB);
1994 1753 }
1995 void test_CALLBACK() { 1754
1996 AngularPropertyKind kind = AngularPropertyKind.CALLBACK; 1755 void test_equals_null() {
1997 JUnitTestCase.assertFalse(kind.callsGetter()); 1756 AnalysisContextImpl context = createAnalysisContext();
1998 JUnitTestCase.assertTrue(kind.callsSetter()); 1757 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html");
1999 } 1758 JUnitTestCase.assertFalse(element == null);
2000 1759 }
2001 void test_ONE_WAY() { 1760
2002 AngularPropertyKind kind = AngularPropertyKind.ONE_WAY; 1761 void test_equals_sameSource() {
2003 JUnitTestCase.assertFalse(kind.callsGetter()); 1762 AnalysisContextImpl context = createAnalysisContext();
2004 JUnitTestCase.assertTrue(kind.callsSetter()); 1763 HtmlElementImpl elementA = ElementFactory.htmlUnit(context, "index.html");
2005 } 1764 HtmlElementImpl elementB = ElementFactory.htmlUnit(context, "index.html");
2006 1765 JUnitTestCase.assertTrue(elementA == elementB);
2007 void test_ONE_WAY_ONE_TIME() { 1766 }
2008 AngularPropertyKind kind = AngularPropertyKind.ONE_WAY_ONE_TIME; 1767
2009 JUnitTestCase.assertFalse(kind.callsGetter()); 1768 void test_equals_self() {
2010 JUnitTestCase.assertTrue(kind.callsSetter()); 1769 AnalysisContextImpl context = createAnalysisContext();
2011 } 1770 HtmlElementImpl element = ElementFactory.htmlUnit(context, "index.html");
2012 1771 JUnitTestCase.assertTrue(element == element);
2013 void test_TWO_WAY() {
2014 AngularPropertyKind kind = AngularPropertyKind.TWO_WAY;
2015 JUnitTestCase.assertTrue(kind.callsGetter());
2016 JUnitTestCase.assertTrue(kind.callsSetter());
2017 } 1772 }
2018 1773
2019 static dartSuite() { 1774 static dartSuite() {
2020 _ut.group('AngularPropertyKindTest', () { 1775 _ut.group('HtmlElementImplTest', () {
2021 _ut.test('test_ATTR', () { 1776 _ut.test('test_equals_differentSource', () {
2022 final __test = new AngularPropertyKindTest(); 1777 final __test = new HtmlElementImplTest();
2023 runJUnitTest(__test, __test.test_ATTR); 1778 runJUnitTest(__test, __test.test_equals_differentSource);
2024 }); 1779 });
2025 _ut.test('test_CALLBACK', () { 1780 _ut.test('test_equals_null', () {
2026 final __test = new AngularPropertyKindTest(); 1781 final __test = new HtmlElementImplTest();
2027 runJUnitTest(__test, __test.test_CALLBACK); 1782 runJUnitTest(__test, __test.test_equals_null);
2028 }); 1783 });
2029 _ut.test('test_ONE_WAY', () { 1784 _ut.test('test_equals_sameSource', () {
2030 final __test = new AngularPropertyKindTest(); 1785 final __test = new HtmlElementImplTest();
2031 runJUnitTest(__test, __test.test_ONE_WAY); 1786 runJUnitTest(__test, __test.test_equals_sameSource);
2032 }); 1787 });
2033 _ut.test('test_ONE_WAY_ONE_TIME', () { 1788 _ut.test('test_equals_self', () {
2034 final __test = new AngularPropertyKindTest(); 1789 final __test = new HtmlElementImplTest();
2035 runJUnitTest(__test, __test.test_ONE_WAY_ONE_TIME); 1790 runJUnitTest(__test, __test.test_equals_self);
2036 });
2037 _ut.test('test_TWO_WAY', () {
2038 final __test = new AngularPropertyKindTest();
2039 runJUnitTest(__test, __test.test_TWO_WAY);
2040 }); 1791 });
2041 }); 1792 });
2042 } 1793 }
2043 }
2044
2045 class ElementImplTest extends EngineTestCase {
2046 void test_equals() {
2047 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2048 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
2049 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
2050 FieldElement field = ElementFactory.fieldElement("next", false, false, false , classElement.type);
2051 classElement.fields = <FieldElement> [field];
2052 JUnitTestCase.assertTrue(field == field);
2053 JUnitTestCase.assertFalse(field == field.getter);
2054 JUnitTestCase.assertFalse(field == field.setter);
2055 JUnitTestCase.assertFalse(field.getter == field.setter);
2056 }
2057
2058 void test_isAccessibleIn_private_differentLibrary() {
2059 AnalysisContextImpl context = createAnalysisContext();
2060 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
2061 ClassElement classElement = ElementFactory.classElement2("_C", []);
2062 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl assElement> [classElement];
2063 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
2064 JUnitTestCase.assertFalse(classElement.isAccessibleIn(library2));
2065 }
2066
2067 void test_isAccessibleIn_private_sameLibrary() {
2068 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2069 ClassElement classElement = ElementFactory.classElement2("_C", []);
2070 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
2071 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library));
2072 }
2073
2074 void test_isAccessibleIn_public_differentLibrary() {
2075 AnalysisContextImpl context = createAnalysisContext();
2076 LibraryElementImpl library1 = ElementFactory.library(context, "lib1");
2077 ClassElement classElement = ElementFactory.classElement2("C", []);
2078 (library1.definingCompilationUnit as CompilationUnitElementImpl).types = <Cl assElement> [classElement];
2079 LibraryElementImpl library2 = ElementFactory.library(context, "lib2");
2080 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library2));
2081 }
2082
2083 void test_isAccessibleIn_public_sameLibrary() {
2084 LibraryElementImpl library = ElementFactory.library(createAnalysisContext(), "lib");
2085 ClassElement classElement = ElementFactory.classElement2("C", []);
2086 (library.definingCompilationUnit as CompilationUnitElementImpl).types = <Cla ssElement> [classElement];
2087 JUnitTestCase.assertTrue(classElement.isAccessibleIn(library));
2088 }
2089
2090 void test_isPrivate_false() {
2091 Element element = ElementFactory.classElement2("C", []);
2092 JUnitTestCase.assertFalse(element.isPrivate);
2093 }
2094
2095 void test_isPrivate_null() {
2096 Element element = ElementFactory.classElement2(null, []);
2097 JUnitTestCase.assertTrue(element.isPrivate);
2098 }
2099
2100 void test_isPrivate_true() {
2101 Element element = ElementFactory.classElement2("_C", []);
2102 JUnitTestCase.assertTrue(element.isPrivate);
2103 }
2104
2105 void test_isPublic_false() {
2106 Element element = ElementFactory.classElement2("_C", []);
2107 JUnitTestCase.assertFalse(element.isPublic);
2108 }
2109
2110 void test_isPublic_null() {
2111 Element element = ElementFactory.classElement2(null, []);
2112 JUnitTestCase.assertFalse(element.isPublic);
2113 }
2114
2115 void test_isPublic_true() {
2116 Element element = ElementFactory.classElement2("C", []);
2117 JUnitTestCase.assertTrue(element.isPublic);
2118 }
2119
2120 void test_SORT_BY_OFFSET() {
2121 ClassElementImpl classElementA = ElementFactory.classElement2("A", []);
2122 classElementA.nameOffset = 1;
2123 ClassElementImpl classElementB = ElementFactory.classElement2("B", []);
2124 classElementB.nameOffset = 2;
2125 JUnitTestCase.assertEquals(0, Element.SORT_BY_OFFSET(classElementA, classEle mentA));
2126 JUnitTestCase.assertTrue(Element.SORT_BY_OFFSET(classElementA, classElementB ) < 0);
2127 JUnitTestCase.assertTrue(Element.SORT_BY_OFFSET(classElementB, classElementA ) > 0);
2128 }
2129
2130 static dartSuite() {
2131 _ut.group('ElementImplTest', () {
2132 _ut.test('test_SORT_BY_OFFSET', () {
2133 final __test = new ElementImplTest();
2134 runJUnitTest(__test, __test.test_SORT_BY_OFFSET);
2135 });
2136 _ut.test('test_equals', () {
2137 final __test = new ElementImplTest();
2138 runJUnitTest(__test, __test.test_equals);
2139 });
2140 _ut.test('test_isAccessibleIn_private_differentLibrary', () {
2141 final __test = new ElementImplTest();
2142 runJUnitTest(__test, __test.test_isAccessibleIn_private_differentLibrary );
2143 });
2144 _ut.test('test_isAccessibleIn_private_sameLibrary', () {
2145 final __test = new ElementImplTest();
2146 runJUnitTest(__test, __test.test_isAccessibleIn_private_sameLibrary);
2147 });
2148 _ut.test('test_isAccessibleIn_public_differentLibrary', () {
2149 final __test = new ElementImplTest();
2150 runJUnitTest(__test, __test.test_isAccessibleIn_public_differentLibrary) ;
2151 });
2152 _ut.test('test_isAccessibleIn_public_sameLibrary', () {
2153 final __test = new ElementImplTest();
2154 runJUnitTest(__test, __test.test_isAccessibleIn_public_sameLibrary);
2155 });
2156 _ut.test('test_isPrivate_false', () {
2157 final __test = new ElementImplTest();
2158 runJUnitTest(__test, __test.test_isPrivate_false);
2159 });
2160 _ut.test('test_isPrivate_null', () {
2161 final __test = new ElementImplTest();
2162 runJUnitTest(__test, __test.test_isPrivate_null);
2163 });
2164 _ut.test('test_isPrivate_true', () {
2165 final __test = new ElementImplTest();
2166 runJUnitTest(__test, __test.test_isPrivate_true);
2167 });
2168 _ut.test('test_isPublic_false', () {
2169 final __test = new ElementImplTest();
2170 runJUnitTest(__test, __test.test_isPublic_false);
2171 });
2172 _ut.test('test_isPublic_null', () {
2173 final __test = new ElementImplTest();
2174 runJUnitTest(__test, __test.test_isPublic_null);
2175 });
2176 _ut.test('test_isPublic_true', () {
2177 final __test = new ElementImplTest();
2178 runJUnitTest(__test, __test.test_isPublic_true);
2179 });
2180 });
2181 }
2182 }
2183
2184 class ElementKindTest extends EngineTestCase {
2185 void test_of_nonNull() {
2186 JUnitTestCase.assertSame(ElementKind.CLASS, ElementKind.of(ElementFactory.cl assElement2("A", [])));
2187 }
2188
2189 void test_of_null() {
2190 JUnitTestCase.assertSame(ElementKind.ERROR, ElementKind.of(null));
2191 }
2192
2193 static dartSuite() {
2194 _ut.group('ElementKindTest', () {
2195 _ut.test('test_of_nonNull', () {
2196 final __test = new ElementKindTest();
2197 runJUnitTest(__test, __test.test_of_nonNull);
2198 });
2199 _ut.test('test_of_null', () {
2200 final __test = new ElementKindTest();
2201 runJUnitTest(__test, __test.test_of_null);
2202 });
2203 });
2204 }
2205 } 1794 }
2206 1795
2207 class InterfaceTypeImplTest extends EngineTestCase { 1796 class InterfaceTypeImplTest extends EngineTestCase {
2208 /** 1797 /**
2209 * The type provider used to access the types. 1798 * The type provider used to access the types.
2210 */ 1799 */
2211 TestTypeProvider _typeProvider; 1800 TestTypeProvider _typeProvider;
2212 1801
2213 @override 1802 @override
2214 void setUp() { 1803 void setUp() {
(...skipping 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 }); 3724 });
4136 _ut.test('test_substitute_exception', () { 3725 _ut.test('test_substitute_exception', () {
4137 final __test = new InterfaceTypeImplTest(); 3726 final __test = new InterfaceTypeImplTest();
4138 runJUnitTest(__test, __test.test_substitute_exception); 3727 runJUnitTest(__test, __test.test_substitute_exception);
4139 }); 3728 });
4140 _ut.test('test_substitute_notEqual', () { 3729 _ut.test('test_substitute_notEqual', () {
4141 final __test = new InterfaceTypeImplTest(); 3730 final __test = new InterfaceTypeImplTest();
4142 runJUnitTest(__test, __test.test_substitute_notEqual); 3731 runJUnitTest(__test, __test.test_substitute_notEqual);
4143 }); 3732 });
4144 }); 3733 });
3734 }
3735 }
3736
3737 class InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunc tion extends InterfaceTypeImpl {
3738 InterfaceTypeImpl_FunctionTypeImplTest_test_isSubtypeOf_baseCase_classFunction (ClassElement arg0) : super.con1(arg0);
3739
3740 @override
3741 bool get isDartCoreFunction => true;
3742 }
3743
3744 class LibraryElementImplTest extends EngineTestCase {
3745 void test_creation() {
3746 JUnitTestCase.assertNotNull(new LibraryElementImpl(createAnalysisContext(), AstFactory.libraryIdentifier2(["l"])));
3747 }
3748
3749 void test_getImportedLibraries() {
3750 AnalysisContext context = createAnalysisContext();
3751 LibraryElementImpl library1 = ElementFactory.library(context, "l1");
3752 LibraryElementImpl library2 = ElementFactory.library(context, "l2");
3753 LibraryElementImpl library3 = ElementFactory.library(context, "l3");
3754 LibraryElementImpl library4 = ElementFactory.library(context, "l4");
3755 PrefixElement prefixA = new PrefixElementImpl(AstFactory.identifier3("a"));
3756 PrefixElement prefixB = new PrefixElementImpl(AstFactory.identifier3("b"));
3757 List<ImportElementImpl> imports = [
3758 ElementFactory.importFor(library2, null, []),
3759 ElementFactory.importFor(library2, prefixB, []),
3760 ElementFactory.importFor(library3, null, []),
3761 ElementFactory.importFor(library3, prefixA, []),
3762 ElementFactory.importFor(library3, prefixB, []),
3763 ElementFactory.importFor(library4, prefixA, [])];
3764 library1.imports = imports;
3765 List<LibraryElement> libraries = library1.importedLibraries;
3766 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library2, library3, library4], libraries);
3767 }
3768
3769 void test_getPrefixes() {
3770 AnalysisContext context = createAnalysisContext();
3771 LibraryElementImpl library = ElementFactory.library(context, "l1");
3772 PrefixElement prefixA = new PrefixElementImpl(AstFactory.identifier3("a"));
3773 PrefixElement prefixB = new PrefixElementImpl(AstFactory.identifier3("b"));
3774 List<ImportElementImpl> imports = [
3775 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, [] ),
3776 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, [] ),
3777 ElementFactory.importFor(ElementFactory.library(context, "l4"), prefixA, []),
3778 ElementFactory.importFor(ElementFactory.library(context, "l5"), prefixA, []),
3779 ElementFactory.importFor(ElementFactory.library(context, "l6"), prefixB, [])];
3780 library.imports = imports;
3781 List<PrefixElement> prefixes = library.prefixes;
3782 EngineTestCase.assertLength(2, prefixes);
3783 if (identical(prefixA, prefixes[0])) {
3784 JUnitTestCase.assertSame(prefixB, prefixes[1]);
3785 } else {
3786 JUnitTestCase.assertSame(prefixB, prefixes[0]);
3787 JUnitTestCase.assertSame(prefixA, prefixes[1]);
3788 }
3789 }
3790
3791 void test_getUnits() {
3792 AnalysisContext context = createAnalysisContext();
3793 LibraryElementImpl library = ElementFactory.library(context, "test");
3794 CompilationUnitElement unitLib = library.definingCompilationUnit;
3795 CompilationUnitElementImpl unitA = ElementFactory.compilationUnit("unit_a.da rt");
3796 CompilationUnitElementImpl unitB = ElementFactory.compilationUnit("unit_b.da rt");
3797 library.parts = <CompilationUnitElement> [unitA, unitB];
3798 EngineTestCase.assertEqualsIgnoreOrder(<CompilationUnitElement> [unitLib, un itA, unitB], library.units);
3799 }
3800
3801 void test_getVisibleLibraries_cycle() {
3802 AnalysisContext context = createAnalysisContext();
3803 LibraryElementImpl library = ElementFactory.library(context, "app");
3804 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3805 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(library, nu ll, [])];
3806 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])];
3807 List<LibraryElement> libraries = library.visibleLibraries;
3808 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA], libraries);
3809 }
3810
3811 void test_getVisibleLibraries_directExports() {
3812 AnalysisContext context = createAnalysisContext();
3813 LibraryElementImpl library = ElementFactory.library(context, "app");
3814 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3815 library.exports = <ExportElementImpl> [ElementFactory.exportFor(libraryA, [] )];
3816 List<LibraryElement> libraries = library.visibleLibraries;
3817 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library], libraries );
3818 }
3819
3820 void test_getVisibleLibraries_directImports() {
3821 AnalysisContext context = createAnalysisContext();
3822 LibraryElementImpl library = ElementFactory.library(context, "app");
3823 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3824 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])];
3825 List<LibraryElement> libraries = library.visibleLibraries;
3826 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA], libraries);
3827 }
3828
3829 void test_getVisibleLibraries_indirectExports() {
3830 AnalysisContext context = createAnalysisContext();
3831 LibraryElementImpl library = ElementFactory.library(context, "app");
3832 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3833 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA");
3834 libraryA.exports = <ExportElementImpl> [ElementFactory.exportFor(libraryAA, [])];
3835 library.imports = <ImportElementImpl> [ElementFactory.importFor(libraryA, nu ll, [])];
3836 List<LibraryElement> libraries = library.visibleLibraries;
3837 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA, libraryAA], libraries);
3838 }
3839
3840 void test_getVisibleLibraries_indirectImports() {
3841 AnalysisContext context = createAnalysisContext();
3842 LibraryElementImpl library = ElementFactory.library(context, "app");
3843 LibraryElementImpl libraryA = ElementFactory.library(context, "A");
3844 LibraryElementImpl libraryAA = ElementFactory.library(context, "AA");
3845 LibraryElementImpl libraryB = ElementFactory.library(context, "B");
3846 libraryA.imports = <ImportElementImpl> [ElementFactory.importFor(libraryAA, null, [])];
3847 library.imports = <ImportElementImpl> [
3848 ElementFactory.importFor(libraryA, null, []),
3849 ElementFactory.importFor(libraryB, null, [])];
3850 List<LibraryElement> libraries = library.visibleLibraries;
3851 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library, libraryA, libraryAA, libraryB], libraries);
3852 }
3853
3854 void test_getVisibleLibraries_noImports() {
3855 AnalysisContext context = createAnalysisContext();
3856 LibraryElementImpl library = ElementFactory.library(context, "app");
3857 EngineTestCase.assertEqualsIgnoreOrder(<LibraryElement> [library], library.v isibleLibraries);
3858 }
3859
3860 void test_isUpToDate() {
3861 AnalysisContext context = createAnalysisContext();
3862 context.sourceFactory = new SourceFactory([]);
3863 LibraryElement library = ElementFactory.library(context, "foo");
3864 context.setContents(library.definingCompilationUnit.source, "sdfsdff");
3865 // Assert that we are not up to date if the target has an old time stamp.
3866 JUnitTestCase.assertFalse(library.isUpToDate(0));
3867 // Assert that we are up to date with a target modification time in the futu re.
3868 JUnitTestCase.assertTrue(library.isUpToDate(JavaSystem.currentTimeMillis() + 1000));
3869 }
3870
3871 void test_setImports() {
3872 AnalysisContext context = createAnalysisContext();
3873 LibraryElementImpl library = new LibraryElementImpl(context, AstFactory.libr aryIdentifier2(["l1"]));
3874 List<ImportElementImpl> expectedImports = [
3875 ElementFactory.importFor(ElementFactory.library(context, "l2"), null, [] ),
3876 ElementFactory.importFor(ElementFactory.library(context, "l3"), null, [] )];
3877 library.imports = expectedImports;
3878 List<ImportElement> actualImports = library.imports;
3879 EngineTestCase.assertLength(expectedImports.length, actualImports);
3880 for (int i = 0; i < actualImports.length; i++) {
3881 JUnitTestCase.assertSame(expectedImports[i], actualImports[i]);
3882 }
3883 }
3884
3885 static dartSuite() {
3886 _ut.group('LibraryElementImplTest', () {
3887 _ut.test('test_creation', () {
3888 final __test = new LibraryElementImplTest();
3889 runJUnitTest(__test, __test.test_creation);
3890 });
3891 _ut.test('test_getImportedLibraries', () {
3892 final __test = new LibraryElementImplTest();
3893 runJUnitTest(__test, __test.test_getImportedLibraries);
3894 });
3895 _ut.test('test_getPrefixes', () {
3896 final __test = new LibraryElementImplTest();
3897 runJUnitTest(__test, __test.test_getPrefixes);
3898 });
3899 _ut.test('test_getUnits', () {
3900 final __test = new LibraryElementImplTest();
3901 runJUnitTest(__test, __test.test_getUnits);
3902 });
3903 _ut.test('test_getVisibleLibraries_cycle', () {
3904 final __test = new LibraryElementImplTest();
3905 runJUnitTest(__test, __test.test_getVisibleLibraries_cycle);
3906 });
3907 _ut.test('test_getVisibleLibraries_directExports', () {
3908 final __test = new LibraryElementImplTest();
3909 runJUnitTest(__test, __test.test_getVisibleLibraries_directExports);
3910 });
3911 _ut.test('test_getVisibleLibraries_directImports', () {
3912 final __test = new LibraryElementImplTest();
3913 runJUnitTest(__test, __test.test_getVisibleLibraries_directImports);
3914 });
3915 _ut.test('test_getVisibleLibraries_indirectExports', () {
3916 final __test = new LibraryElementImplTest();
3917 runJUnitTest(__test, __test.test_getVisibleLibraries_indirectExports);
3918 });
3919 _ut.test('test_getVisibleLibraries_indirectImports', () {
3920 final __test = new LibraryElementImplTest();
3921 runJUnitTest(__test, __test.test_getVisibleLibraries_indirectImports);
3922 });
3923 _ut.test('test_getVisibleLibraries_noImports', () {
3924 final __test = new LibraryElementImplTest();
3925 runJUnitTest(__test, __test.test_getVisibleLibraries_noImports);
3926 });
3927 _ut.test('test_isUpToDate', () {
3928 final __test = new LibraryElementImplTest();
3929 runJUnitTest(__test, __test.test_isUpToDate);
3930 });
3931 _ut.test('test_setImports', () {
3932 final __test = new LibraryElementImplTest();
3933 runJUnitTest(__test, __test.test_setImports);
3934 });
3935 });
3936 }
3937 }
3938
3939 class MultiplyDefinedElementImplTest extends EngineTestCase {
3940 void test_fromElements_conflicting() {
3941 Element firstElement = ElementFactory.localVariableElement2("xx");
3942 Element secondElement = ElementFactory.localVariableElement2("yy");
3943 Element result = MultiplyDefinedElementImpl.fromElements(null, firstElement, secondElement);
3944 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, Mult iplyDefinedElement, result);
3945 List<Element> elements = (result as MultiplyDefinedElement).conflictingEleme nts;
3946 EngineTestCase.assertLength(2, elements);
3947 for (int i = 0; i < elements.length; i++) {
3948 EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement, Loca lVariableElement, elements[i]);
3949 }
3950 }
3951
3952 void test_fromElements_multiple() {
3953 Element firstElement = ElementFactory.localVariableElement2("xx");
3954 Element secondElement = ElementFactory.localVariableElement2("yy");
3955 Element thirdElement = ElementFactory.localVariableElement2("zz");
3956 Element result = MultiplyDefinedElementImpl.fromElements(null, MultiplyDefin edElementImpl.fromElements(null, firstElement, secondElement), thirdElement);
3957 EngineTestCase.assertInstanceOf((obj) => obj is MultiplyDefinedElement, Mult iplyDefinedElement, result);
3958 List<Element> elements = (result as MultiplyDefinedElement).conflictingEleme nts;
3959 EngineTestCase.assertLength(3, elements);
3960 for (int i = 0; i < elements.length; i++) {
3961 EngineTestCase.assertInstanceOf((obj) => obj is LocalVariableElement, Loca lVariableElement, elements[i]);
3962 }
3963 }
3964
3965 void test_fromElements_nonConflicting() {
3966 Element element = ElementFactory.localVariableElement2("xx");
3967 JUnitTestCase.assertSame(element, MultiplyDefinedElementImpl.fromElements(nu ll, element, element));
3968 }
3969
3970 static dartSuite() {
3971 _ut.group('MultiplyDefinedElementImplTest', () {
3972 _ut.test('test_fromElements_conflicting', () {
3973 final __test = new MultiplyDefinedElementImplTest();
3974 runJUnitTest(__test, __test.test_fromElements_conflicting);
3975 });
3976 _ut.test('test_fromElements_multiple', () {
3977 final __test = new MultiplyDefinedElementImplTest();
3978 runJUnitTest(__test, __test.test_fromElements_multiple);
3979 });
3980 _ut.test('test_fromElements_nonConflicting', () {
3981 final __test = new MultiplyDefinedElementImplTest();
3982 runJUnitTest(__test, __test.test_fromElements_nonConflicting);
3983 });
3984 });
3985 }
3986 }
3987
3988 class TypeParameterTypeImplTest extends EngineTestCase {
3989 void test_creation() {
3990 JUnitTestCase.assertNotNull(new TypeParameterTypeImpl(new TypeParameterEleme ntImpl(AstFactory.identifier3("E"))));
3991 }
3992
3993 void test_getElement() {
3994 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
3995 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
3996 JUnitTestCase.assertEquals(element, type.element);
3997 }
3998
3999 void test_isMoreSpecificThan_typeArguments_bottom() {
4000 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
4001 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4002 // E << bottom
4003 JUnitTestCase.assertTrue(type.isMoreSpecificThan(BottomTypeImpl.instance));
4004 }
4005
4006 void test_isMoreSpecificThan_typeArguments_dynamic() {
4007 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
4008 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4009 // E << dynamic
4010 JUnitTestCase.assertTrue(type.isMoreSpecificThan(DynamicTypeImpl.instance));
4011 }
4012
4013 void test_isMoreSpecificThan_typeArguments_object() {
4014 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
4015 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4016 // E << Object
4017 JUnitTestCase.assertTrue(type.isMoreSpecificThan(ElementFactory.object.type) );
4018 }
4019
4020 void test_isMoreSpecificThan_typeArguments_resursive() {
4021 ClassElementImpl classS = ElementFactory.classElement2("A", []);
4022 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl(AstFa ctory.identifier3("U"));
4023 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU);
4024 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(AstFa ctory.identifier3("T"));
4025 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
4026 typeParameterT.bound = typeParameterTypeU;
4027 typeParameterU.bound = typeParameterTypeU;
4028 // <T extends U> and <U extends T>
4029 // T << S
4030 JUnitTestCase.assertFalse(typeParameterTypeT.isMoreSpecificThan(classS.type) );
4031 }
4032
4033 void test_isMoreSpecificThan_typeArguments_self() {
4034 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
4035 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4036 // E << E
4037 JUnitTestCase.assertTrue(type.isMoreSpecificThan(type));
4038 }
4039
4040 void test_isMoreSpecificThan_typeArguments_transitivity_interfaceTypes() {
4041 // class A {}
4042 // class B extends A {}
4043 //
4044 ClassElement classA = ElementFactory.classElement2("A", []);
4045 ClassElement classB = ElementFactory.classElement("B", classA.type, []);
4046 InterfaceType typeA = classA.type;
4047 InterfaceType typeB = classB.type;
4048 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(AstFa ctory.identifier3("T"));
4049 typeParameterT.bound = typeB;
4050 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
4051 // <T extends B>
4052 // T << A
4053 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(typeA));
4054 }
4055
4056 void test_isMoreSpecificThan_typeArguments_transitivity_typeParameters() {
4057 ClassElementImpl classS = ElementFactory.classElement2("A", []);
4058 TypeParameterElementImpl typeParameterU = new TypeParameterElementImpl(AstFa ctory.identifier3("U"));
4059 typeParameterU.bound = classS.type;
4060 TypeParameterTypeImpl typeParameterTypeU = new TypeParameterTypeImpl(typePar ameterU);
4061 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(AstFa ctory.identifier3("T"));
4062 typeParameterT.bound = typeParameterTypeU;
4063 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
4064 // <T extends U> and <U extends S>
4065 // T << S
4066 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type)) ;
4067 }
4068
4069 void test_isMoreSpecificThan_typeArguments_upperBound() {
4070 ClassElementImpl classS = ElementFactory.classElement2("A", []);
4071 TypeParameterElementImpl typeParameterT = new TypeParameterElementImpl(AstFa ctory.identifier3("T"));
4072 typeParameterT.bound = classS.type;
4073 TypeParameterTypeImpl typeParameterTypeT = new TypeParameterTypeImpl(typePar ameterT);
4074 // <T extends S>
4075 // T << S
4076 JUnitTestCase.assertTrue(typeParameterTypeT.isMoreSpecificThan(classS.type)) ;
4077 }
4078
4079 void test_substitute_equal() {
4080 TypeParameterElementImpl element = new TypeParameterElementImpl(AstFactory.i dentifier3("E"));
4081 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element);
4082 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (AstFactory.identifier3("A")));
4083 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(element);
4084 JUnitTestCase.assertSame(argument, type.substitute2(<DartType> [argument], < DartType> [parameter]));
4085 }
4086
4087 void test_substitute_notEqual() {
4088 TypeParameterTypeImpl type = new TypeParameterTypeImpl(new TypeParameterElem entImpl(AstFactory.identifier3("E")));
4089 InterfaceTypeImpl argument = new InterfaceTypeImpl.con1(new ClassElementImpl (AstFactory.identifier3("A")));
4090 TypeParameterTypeImpl parameter = new TypeParameterTypeImpl(new TypeParamete rElementImpl(AstFactory.identifier3("F")));
4091 JUnitTestCase.assertSame(type, type.substitute2(<DartType> [argument], <Dart Type> [parameter]));
4092 }
4093
4094 static dartSuite() {
4095 _ut.group('TypeParameterTypeImplTest', () {
4096 _ut.test('test_creation', () {
4097 final __test = new TypeParameterTypeImplTest();
4098 runJUnitTest(__test, __test.test_creation);
4099 });
4100 _ut.test('test_getElement', () {
4101 final __test = new TypeParameterTypeImplTest();
4102 runJUnitTest(__test, __test.test_getElement);
4103 });
4104 _ut.test('test_isMoreSpecificThan_typeArguments_bottom', () {
4105 final __test = new TypeParameterTypeImplTest();
4106 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_bottom );
4107 });
4108 _ut.test('test_isMoreSpecificThan_typeArguments_dynamic', () {
4109 final __test = new TypeParameterTypeImplTest();
4110 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_dynami c);
4111 });
4112 _ut.test('test_isMoreSpecificThan_typeArguments_object', () {
4113 final __test = new TypeParameterTypeImplTest();
4114 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_object );
4115 });
4116 _ut.test('test_isMoreSpecificThan_typeArguments_resursive', () {
4117 final __test = new TypeParameterTypeImplTest();
4118 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_resurs ive);
4119 });
4120 _ut.test('test_isMoreSpecificThan_typeArguments_self', () {
4121 final __test = new TypeParameterTypeImplTest();
4122 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_self);
4123 });
4124 _ut.test('test_isMoreSpecificThan_typeArguments_transitivity_interfaceType s', () {
4125 final __test = new TypeParameterTypeImplTest();
4126 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_transi tivity_interfaceTypes);
4127 });
4128 _ut.test('test_isMoreSpecificThan_typeArguments_transitivity_typeParameter s', () {
4129 final __test = new TypeParameterTypeImplTest();
4130 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_transi tivity_typeParameters);
4131 });
4132 _ut.test('test_isMoreSpecificThan_typeArguments_upperBound', () {
4133 final __test = new TypeParameterTypeImplTest();
4134 runJUnitTest(__test, __test.test_isMoreSpecificThan_typeArguments_upperB ound);
4135 });
4136 _ut.test('test_substitute_equal', () {
4137 final __test = new TypeParameterTypeImplTest();
4138 runJUnitTest(__test, __test.test_substitute_equal);
4139 });
4140 _ut.test('test_substitute_notEqual', () {
4141 final __test = new TypeParameterTypeImplTest();
4142 runJUnitTest(__test, __test.test_substitute_notEqual);
4143 });
4144 });
4145 } 4145 }
4146 } 4146 }
4147 4147
4148 class VoidTypeImplTest extends EngineTestCase { 4148 class VoidTypeImplTest extends EngineTestCase {
4149 /** 4149 /**
4150 * Reference {code VoidTypeImpl.getInstance()}. 4150 * Reference {code VoidTypeImpl.getInstance()}.
4151 */ 4151 */
4152 DartType _voidType = VoidTypeImpl.instance; 4152 DartType _voidType = VoidTypeImpl.instance;
4153 4153
4154 void test_isMoreSpecificThan_void_A() { 4154 void test_isMoreSpecificThan_void_A() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4209 }); 4209 });
4210 _ut.test('test_isVoid', () { 4210 _ut.test('test_isVoid', () {
4211 final __test = new VoidTypeImplTest(); 4211 final __test = new VoidTypeImplTest();
4212 runJUnitTest(__test, __test.test_isVoid); 4212 runJUnitTest(__test, __test.test_isVoid);
4213 }); 4213 });
4214 }); 4214 });
4215 } 4215 }
4216 } 4216 }
4217 4217
4218 main() { 4218 main() {
4219 ElementKindTest.dartSuite();
4220 AngularPropertyKindTest.dartSuite();
4219 FunctionTypeImplTest.dartSuite(); 4221 FunctionTypeImplTest.dartSuite();
4220 InterfaceTypeImplTest.dartSuite(); 4222 InterfaceTypeImplTest.dartSuite();
4221 TypeParameterTypeImplTest.dartSuite(); 4223 TypeParameterTypeImplTest.dartSuite();
4222 VoidTypeImplTest.dartSuite(); 4224 VoidTypeImplTest.dartSuite();
4223 ClassElementImplTest.dartSuite(); 4225 ClassElementImplTest.dartSuite();
4224 ElementLocationImplTest.dartSuite(); 4226 ElementLocationImplTest.dartSuite();
4225 ElementImplTest.dartSuite(); 4227 ElementImplTest.dartSuite();
4226 HtmlElementImplTest.dartSuite(); 4228 HtmlElementImplTest.dartSuite();
4227 LibraryElementImplTest.dartSuite(); 4229 LibraryElementImplTest.dartSuite();
4228 MultiplyDefinedElementImplTest.dartSuite(); 4230 MultiplyDefinedElementImplTest.dartSuite();
4229 AngularPropertyKindTest.dartSuite();
4230 ElementKindTest.dartSuite();
4231 } 4231 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/ast_test.dart ('k') | pkg/analyzer/test/generated/java_core_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698