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