OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Test for iterators on for [SubclassNode]. | 5 // Test for iterators on for [SubclassNode]. |
6 | 6 |
7 library class_set_test; | 7 library class_set_test; |
8 | 8 |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 import 'package:async_helper/async_helper.dart'; | 10 import 'package:async_helper/async_helper.dart'; |
11 import 'type_test_helper.dart'; | 11 import 'type_test_helper.dart'; |
12 import 'package:compiler/src/elements/elements.dart' | 12 import 'package:compiler/src/elements/elements.dart' show Element, ClassElement; |
13 show Element, ClassElement; | |
14 import 'package:compiler/src/universe/class_set.dart'; | 13 import 'package:compiler/src/universe/class_set.dart'; |
15 import 'package:compiler/src/util/enumset.dart'; | 14 import 'package:compiler/src/util/enumset.dart'; |
16 import 'package:compiler/src/util/util.dart'; | 15 import 'package:compiler/src/util/util.dart'; |
17 import 'package:compiler/src/world.dart'; | 16 import 'package:compiler/src/world.dart'; |
18 | 17 |
19 void main() { | 18 void main() { |
20 asyncTest(() async { | 19 asyncTest(() async { |
21 await testIterators(); | 20 await testIterators(); |
22 await testForEach(); | 21 await testForEach(); |
23 }); | 22 }); |
24 } | 23 } |
25 | 24 |
26 testIterators() async { | 25 testIterators() async { |
27 var env = await TypeEnvironment.create(r""" | 26 var env = await TypeEnvironment.create( |
| 27 r""" |
28 /// A | 28 /// A |
29 /// / \ | 29 /// / \ |
30 /// B C | 30 /// B C |
31 /// / /|\ | 31 /// / /|\ |
32 /// D E F G | 32 /// D E F G |
33 /// | 33 /// |
34 class A {} | 34 class A {} |
35 class B extends A {} | 35 class B extends A {} |
36 class C extends A {} | 36 class C extends A {} |
37 class D extends B {} | 37 class D extends B {} |
38 class E extends C {} | 38 class E extends C {} |
39 class F extends C {} | 39 class F extends C {} |
40 class G extends C {} | 40 class G extends C {} |
41 """, | 41 """, |
42 mainSource: r""" | 42 mainSource: r""" |
43 main() { | 43 main() { |
44 new A(); | 44 new A(); |
45 new C(); | 45 new C(); |
46 new D(); | 46 new D(); |
47 new E(); | 47 new E(); |
48 new F(); | 48 new F(); |
49 new G(); | 49 new G(); |
50 } | 50 } |
51 """, | 51 """, |
52 useMockCompiler: false); | 52 useMockCompiler: false); |
53 World world = env.compiler.world; | 53 World world = env.compiler.world; |
54 | 54 |
55 ClassElement A = env.getElement("A"); | 55 ClassElement A = env.getElement("A"); |
56 ClassElement B = env.getElement("B"); | 56 ClassElement B = env.getElement("B"); |
57 ClassElement C = env.getElement("C"); | 57 ClassElement C = env.getElement("C"); |
58 ClassElement D = env.getElement("D"); | 58 ClassElement D = env.getElement("D"); |
59 ClassElement E = env.getElement("E"); | 59 ClassElement E = env.getElement("E"); |
60 ClassElement F = env.getElement("F"); | 60 ClassElement F = env.getElement("F"); |
61 ClassElement G = env.getElement("G"); | 61 ClassElement G = env.getElement("G"); |
62 | 62 |
63 void checkClass(ClassElement cls, | 63 void checkClass(ClassElement cls, |
64 {bool directlyInstantiated: false, | 64 {bool directlyInstantiated: false, bool indirectlyInstantiated: false}) { |
65 bool indirectlyInstantiated: false}) { | |
66 ClassHierarchyNode node = world.getClassHierarchyNode(cls); | 65 ClassHierarchyNode node = world.getClassHierarchyNode(cls); |
67 Expect.isNotNull(node, "Expected ClassHierarchyNode for $cls."); | 66 Expect.isNotNull(node, "Expected ClassHierarchyNode for $cls."); |
68 Expect.equals( | 67 Expect.equals( |
69 directlyInstantiated || indirectlyInstantiated, | 68 directlyInstantiated || indirectlyInstantiated, |
70 node.isInstantiated, | 69 node.isInstantiated, |
71 "Unexpected `isInstantiated` on ClassHierarchyNode for $cls."); | 70 "Unexpected `isInstantiated` on ClassHierarchyNode for $cls."); |
72 Expect.equals( | 71 Expect.equals( |
73 directlyInstantiated, | 72 directlyInstantiated, |
74 node.isDirectlyInstantiated, | 73 node.isDirectlyInstantiated, |
75 "Unexpected `isDirectlyInstantiated` on ClassHierarchyNode for " | 74 "Unexpected `isDirectlyInstantiated` on ClassHierarchyNode for " |
76 "$cls."); | 75 "$cls."); |
77 Expect.equals( | 76 Expect.equals( |
78 indirectlyInstantiated, | 77 indirectlyInstantiated, |
79 node.isIndirectlyInstantiated, | 78 node.isIndirectlyInstantiated, |
80 "Unexpected `isIndirectlyInstantiated` on ClassHierarchyNode for " | 79 "Unexpected `isIndirectlyInstantiated` on ClassHierarchyNode for " |
81 "$cls."); | 80 "$cls."); |
82 } | 81 } |
83 | 82 |
84 | |
85 checkClass(A, directlyInstantiated: true, indirectlyInstantiated: true); | 83 checkClass(A, directlyInstantiated: true, indirectlyInstantiated: true); |
86 checkClass(B, indirectlyInstantiated: true); | 84 checkClass(B, indirectlyInstantiated: true); |
87 checkClass(C, directlyInstantiated: true, indirectlyInstantiated: true); | 85 checkClass(C, directlyInstantiated: true, indirectlyInstantiated: true); |
88 checkClass(D, directlyInstantiated: true); | 86 checkClass(D, directlyInstantiated: true); |
89 checkClass(E, directlyInstantiated: true); | 87 checkClass(E, directlyInstantiated: true); |
90 checkClass(F, directlyInstantiated: true); | 88 checkClass(F, directlyInstantiated: true); |
91 checkClass(G, directlyInstantiated: true); | 89 checkClass(G, directlyInstantiated: true); |
92 | 90 |
93 ClassHierarchyNodeIterator iterator; | 91 ClassHierarchyNodeIterator iterator; |
94 | 92 |
95 void checkState( | 93 void checkState(ClassElement root, |
96 ClassElement root, | 94 {ClassElement currentNode, List<List<ClassElement>> stack}) { |
97 {ClassElement currentNode, | |
98 List<List<ClassElement>> stack}) { | |
99 | |
100 ClassElement classOf(ClassHierarchyNode node) { | 95 ClassElement classOf(ClassHierarchyNode node) { |
101 return node != null ? node.cls : null; | 96 return node != null ? node.cls : null; |
102 } | 97 } |
103 | 98 |
104 List<ClassElement> classesOf(Link<ClassHierarchyNode> link) { | 99 List<ClassElement> classesOf(Link<ClassHierarchyNode> link) { |
105 if (link == null) return null; | 100 if (link == null) return null; |
106 return link.map(classOf).toList(); | 101 return link.map(classOf).toList(); |
107 } | 102 } |
108 | 103 |
109 ClassElement foundRoot = iterator.root.cls; | 104 ClassElement foundRoot = iterator.root.cls; |
110 ClassElement foundCurrentNode = classOf(iterator.currentNode); | 105 ClassElement foundCurrentNode = classOf(iterator.currentNode); |
111 List<ClassElement> foundStack = classesOf(iterator.stack); | 106 List<ClassElement> foundStack = classesOf(iterator.stack); |
112 | 107 |
113 StringBuffer sb = new StringBuffer(); | 108 StringBuffer sb = new StringBuffer(); |
114 sb.write('{\n root: $foundRoot'); | 109 sb.write('{\n root: $foundRoot'); |
115 sb.write('\n currentNode: $foundCurrentNode'); | 110 sb.write('\n currentNode: $foundCurrentNode'); |
116 sb.write('\n stack: $foundStack\n}'); | 111 sb.write('\n stack: $foundStack\n}'); |
117 | 112 |
118 Expect.equals(root, foundRoot, | 113 Expect.equals(root, foundRoot, "Expected root $root in $sb."); |
119 "Expected root $root in $sb."); | |
120 if (currentNode == null) { | 114 if (currentNode == null) { |
121 Expect.isNull(iterator.currentNode, | 115 Expect.isNull( |
122 "Unexpected non-null currentNode in $sb."); | 116 iterator.currentNode, "Unexpected non-null currentNode in $sb."); |
123 } else { | 117 } else { |
124 Expect.isNotNull(foundCurrentNode, | 118 Expect.isNotNull(foundCurrentNode, |
125 "Expected non-null currentNode ${currentNode} in $sb."); | 119 "Expected non-null currentNode ${currentNode} in $sb."); |
126 Expect.equals(currentNode, foundCurrentNode, | 120 Expect.equals(currentNode, foundCurrentNode, |
127 "Expected currentNode $currentNode in $sb."); | 121 "Expected currentNode $currentNode in $sb."); |
128 } | 122 } |
129 if (stack == null) { | 123 if (stack == null) { |
130 Expect.isNull(foundStack, | 124 Expect.isNull(foundStack, "Unexpected non-null stack in $sb."); |
131 "Unexpected non-null stack in $sb."); | |
132 } else { | 125 } else { |
133 Expect.isNotNull(foundStack, | 126 Expect.isNotNull(foundStack, "Expected non-null stack ${stack} in $sb."); |
134 "Expected non-null stack ${stack} in $sb."); | 127 Expect.listEquals( |
135 Expect.listEquals(stack, foundStack, | 128 stack, |
| 129 foundStack, |
136 "Expected stack ${stack}, " | 130 "Expected stack ${stack}, " |
137 "found ${foundStack} in $sb."); | 131 "found ${foundStack} in $sb."); |
138 } | 132 } |
139 } | 133 } |
140 | 134 |
141 iterator = new ClassHierarchyNodeIterable( | 135 iterator = new ClassHierarchyNodeIterable( |
142 world.getClassHierarchyNode(G), | 136 world.getClassHierarchyNode(G), ClassHierarchyNode.ALL) |
143 ClassHierarchyNode.ALL).iterator; | 137 .iterator; |
144 checkState(G, currentNode: null, stack: null); | 138 checkState(G, currentNode: null, stack: null); |
145 Expect.isNull(iterator.current); | 139 Expect.isNull(iterator.current); |
146 Expect.isTrue(iterator.moveNext()); | 140 Expect.isTrue(iterator.moveNext()); |
147 checkState(G, currentNode: G, stack: []); | 141 checkState(G, currentNode: G, stack: []); |
148 Expect.equals(G, iterator.current); | 142 Expect.equals(G, iterator.current); |
149 Expect.isFalse(iterator.moveNext()); | 143 Expect.isFalse(iterator.moveNext()); |
150 checkState(G, currentNode: null, stack: []); | 144 checkState(G, currentNode: null, stack: []); |
151 Expect.isNull(iterator.current); | 145 Expect.isNull(iterator.current); |
152 | 146 |
153 iterator = new ClassHierarchyNodeIterable( | 147 iterator = new ClassHierarchyNodeIterable( |
154 world.getClassHierarchyNode(G), | 148 world.getClassHierarchyNode(G), ClassHierarchyNode.ALL, |
155 ClassHierarchyNode.ALL, | 149 includeRoot: false) |
156 includeRoot: false).iterator; | 150 .iterator; |
157 checkState(G, currentNode: null, stack: null); | 151 checkState(G, currentNode: null, stack: null); |
158 Expect.isNull(iterator.current); | 152 Expect.isNull(iterator.current); |
159 Expect.isFalse(iterator.moveNext()); | 153 Expect.isFalse(iterator.moveNext()); |
160 checkState(G, currentNode: null, stack: []); | 154 checkState(G, currentNode: null, stack: []); |
161 Expect.isNull(iterator.current); | 155 Expect.isNull(iterator.current); |
162 | 156 |
163 iterator = new ClassHierarchyNodeIterable( | 157 iterator = new ClassHierarchyNodeIterable( |
164 world.getClassHierarchyNode(C), | 158 world.getClassHierarchyNode(C), ClassHierarchyNode.ALL) |
165 ClassHierarchyNode.ALL).iterator; | 159 .iterator; |
166 checkState(C, currentNode: null, stack: null); | 160 checkState(C, currentNode: null, stack: null); |
167 Expect.isNull(iterator.current); | 161 Expect.isNull(iterator.current); |
168 Expect.isTrue(iterator.moveNext()); | 162 Expect.isTrue(iterator.moveNext()); |
169 checkState(C, currentNode: C, stack: [E, F, G]); | 163 checkState(C, currentNode: C, stack: [E, F, G]); |
170 Expect.equals(C, iterator.current); | 164 Expect.equals(C, iterator.current); |
171 Expect.isTrue(iterator.moveNext()); | 165 Expect.isTrue(iterator.moveNext()); |
172 checkState(C, currentNode: E, stack: [F, G]); | 166 checkState(C, currentNode: E, stack: [F, G]); |
173 Expect.equals(E, iterator.current); | 167 Expect.equals(E, iterator.current); |
174 Expect.isTrue(iterator.moveNext()); | 168 Expect.isTrue(iterator.moveNext()); |
175 checkState(C, currentNode: F, stack: [G]); | 169 checkState(C, currentNode: F, stack: [G]); |
176 Expect.equals(F, iterator.current); | 170 Expect.equals(F, iterator.current); |
177 Expect.isTrue(iterator.moveNext()); | 171 Expect.isTrue(iterator.moveNext()); |
178 checkState(C, currentNode: G, stack: []); | 172 checkState(C, currentNode: G, stack: []); |
179 Expect.equals(G, iterator.current); | 173 Expect.equals(G, iterator.current); |
180 Expect.isFalse(iterator.moveNext()); | 174 Expect.isFalse(iterator.moveNext()); |
181 checkState(C, currentNode: null, stack: []); | 175 checkState(C, currentNode: null, stack: []); |
182 Expect.isNull(iterator.current); | 176 Expect.isNull(iterator.current); |
183 | 177 |
184 iterator = new ClassHierarchyNodeIterable( | 178 iterator = new ClassHierarchyNodeIterable( |
185 world.getClassHierarchyNode(D), | 179 world.getClassHierarchyNode(D), ClassHierarchyNode.ALL) |
186 ClassHierarchyNode.ALL).iterator; | 180 .iterator; |
187 checkState(D, currentNode: null, stack: null); | 181 checkState(D, currentNode: null, stack: null); |
188 Expect.isNull(iterator.current); | 182 Expect.isNull(iterator.current); |
189 Expect.isTrue(iterator.moveNext()); | 183 Expect.isTrue(iterator.moveNext()); |
190 checkState(D, currentNode: D, stack: []); | 184 checkState(D, currentNode: D, stack: []); |
191 Expect.equals(D, iterator.current); | 185 Expect.equals(D, iterator.current); |
192 Expect.isFalse(iterator.moveNext()); | 186 Expect.isFalse(iterator.moveNext()); |
193 checkState(D, currentNode: null, stack: []); | 187 checkState(D, currentNode: null, stack: []); |
194 Expect.isNull(iterator.current); | 188 Expect.isNull(iterator.current); |
195 | 189 |
196 iterator = new ClassHierarchyNodeIterable( | 190 iterator = new ClassHierarchyNodeIterable( |
197 world.getClassHierarchyNode(B), | 191 world.getClassHierarchyNode(B), ClassHierarchyNode.ALL) |
198 ClassHierarchyNode.ALL).iterator; | 192 .iterator; |
199 checkState(B, currentNode: null, stack: null); | 193 checkState(B, currentNode: null, stack: null); |
200 Expect.isNull(iterator.current); | 194 Expect.isNull(iterator.current); |
201 Expect.isTrue(iterator.moveNext()); | 195 Expect.isTrue(iterator.moveNext()); |
202 checkState(B, currentNode: B, stack: [D]); | 196 checkState(B, currentNode: B, stack: [D]); |
203 Expect.equals(B, iterator.current); | 197 Expect.equals(B, iterator.current); |
204 Expect.isTrue(iterator.moveNext()); | 198 Expect.isTrue(iterator.moveNext()); |
205 checkState(B, currentNode: D, stack: []); | 199 checkState(B, currentNode: D, stack: []); |
206 Expect.equals(D, iterator.current); | 200 Expect.equals(D, iterator.current); |
207 Expect.isFalse(iterator.moveNext()); | 201 Expect.isFalse(iterator.moveNext()); |
208 checkState(B, currentNode: null, stack: []); | 202 checkState(B, currentNode: null, stack: []); |
209 Expect.isNull(iterator.current); | 203 Expect.isNull(iterator.current); |
210 | 204 |
211 iterator = new ClassHierarchyNodeIterable( | 205 iterator = new ClassHierarchyNodeIterable( |
212 world.getClassHierarchyNode(B), | 206 world.getClassHierarchyNode(B), ClassHierarchyNode.ALL, |
213 ClassHierarchyNode.ALL, | 207 includeRoot: false) |
214 includeRoot: false).iterator; | 208 .iterator; |
215 checkState(B, currentNode: null, stack: null); | 209 checkState(B, currentNode: null, stack: null); |
216 Expect.isNull(iterator.current); | 210 Expect.isNull(iterator.current); |
217 Expect.isTrue(iterator.moveNext()); | 211 Expect.isTrue(iterator.moveNext()); |
218 checkState(B, currentNode: D, stack: []); | 212 checkState(B, currentNode: D, stack: []); |
219 Expect.equals(D, iterator.current); | 213 Expect.equals(D, iterator.current); |
220 Expect.isFalse(iterator.moveNext()); | 214 Expect.isFalse(iterator.moveNext()); |
221 checkState(B, currentNode: null, stack: []); | 215 checkState(B, currentNode: null, stack: []); |
222 Expect.isNull(iterator.current); | 216 Expect.isNull(iterator.current); |
223 | 217 |
224 iterator = new ClassHierarchyNodeIterable( | 218 iterator = new ClassHierarchyNodeIterable( |
225 world.getClassHierarchyNode(B), | 219 world.getClassHierarchyNode(B), |
226 new EnumSet<Instantiation>.fromValues(<Instantiation>[ | 220 new EnumSet<Instantiation>.fromValues(<Instantiation>[ |
227 Instantiation.DIRECTLY_INSTANTIATED, | 221 Instantiation.DIRECTLY_INSTANTIATED, |
228 Instantiation.UNINSTANTIATED])).iterator; | 222 Instantiation.UNINSTANTIATED |
| 223 ])).iterator; |
229 checkState(B, currentNode: null, stack: null); | 224 checkState(B, currentNode: null, stack: null); |
230 Expect.isNull(iterator.current); | 225 Expect.isNull(iterator.current); |
231 Expect.isTrue(iterator.moveNext()); | 226 Expect.isTrue(iterator.moveNext()); |
232 checkState(B, currentNode: D, stack: []); | 227 checkState(B, currentNode: D, stack: []); |
233 Expect.equals(D, iterator.current); | 228 Expect.equals(D, iterator.current); |
234 Expect.isFalse(iterator.moveNext()); | 229 Expect.isFalse(iterator.moveNext()); |
235 checkState(B, currentNode: null, stack: []); | 230 checkState(B, currentNode: null, stack: []); |
236 Expect.isNull(iterator.current); | 231 Expect.isNull(iterator.current); |
237 | 232 |
238 iterator = new ClassHierarchyNodeIterable( | 233 iterator = new ClassHierarchyNodeIterable( |
239 world.getClassHierarchyNode(A), | 234 world.getClassHierarchyNode(A), ClassHierarchyNode.ALL) |
240 ClassHierarchyNode.ALL).iterator; | 235 .iterator; |
241 checkState(A, currentNode: null, stack: null); | 236 checkState(A, currentNode: null, stack: null); |
242 Expect.isNull(iterator.current); | 237 Expect.isNull(iterator.current); |
243 Expect.isTrue(iterator.moveNext()); | 238 Expect.isTrue(iterator.moveNext()); |
244 checkState(A, currentNode: A, stack: [C, B]); | 239 checkState(A, currentNode: A, stack: [C, B]); |
245 Expect.equals(A, iterator.current); | 240 Expect.equals(A, iterator.current); |
246 Expect.isTrue(iterator.moveNext()); | 241 Expect.isTrue(iterator.moveNext()); |
247 checkState(A, currentNode: C, stack: [E, F, G, B]); | 242 checkState(A, currentNode: C, stack: [E, F, G, B]); |
248 Expect.equals(C, iterator.current); | 243 Expect.equals(C, iterator.current); |
249 Expect.isTrue(iterator.moveNext()); | 244 Expect.isTrue(iterator.moveNext()); |
250 checkState(A, currentNode: E, stack: [F, G, B]); | 245 checkState(A, currentNode: E, stack: [F, G, B]); |
251 Expect.equals(E, iterator.current); | 246 Expect.equals(E, iterator.current); |
252 Expect.isTrue(iterator.moveNext()); | 247 Expect.isTrue(iterator.moveNext()); |
253 checkState(A, currentNode: F, stack: [G, B]); | 248 checkState(A, currentNode: F, stack: [G, B]); |
254 Expect.equals(F, iterator.current); | 249 Expect.equals(F, iterator.current); |
255 Expect.isTrue(iterator.moveNext()); | 250 Expect.isTrue(iterator.moveNext()); |
256 checkState(A, currentNode: G, stack: [B]); | 251 checkState(A, currentNode: G, stack: [B]); |
257 Expect.equals(G, iterator.current); | 252 Expect.equals(G, iterator.current); |
258 Expect.isTrue(iterator.moveNext()); | 253 Expect.isTrue(iterator.moveNext()); |
259 checkState(A, currentNode: B, stack: [D]); | 254 checkState(A, currentNode: B, stack: [D]); |
260 Expect.equals(B, iterator.current); | 255 Expect.equals(B, iterator.current); |
261 Expect.isTrue(iterator.moveNext()); | 256 Expect.isTrue(iterator.moveNext()); |
262 checkState(A, currentNode: D, stack: []); | 257 checkState(A, currentNode: D, stack: []); |
263 Expect.equals(D, iterator.current); | 258 Expect.equals(D, iterator.current); |
264 Expect.isFalse(iterator.moveNext()); | 259 Expect.isFalse(iterator.moveNext()); |
265 checkState(A, currentNode: null, stack: []); | 260 checkState(A, currentNode: null, stack: []); |
266 Expect.isNull(iterator.current); | 261 Expect.isNull(iterator.current); |
267 | 262 |
268 iterator = new ClassHierarchyNodeIterable( | 263 iterator = new ClassHierarchyNodeIterable( |
269 world.getClassHierarchyNode(A), | 264 world.getClassHierarchyNode(A), ClassHierarchyNode.ALL, |
270 ClassHierarchyNode.ALL, | 265 includeRoot: false) |
271 includeRoot: false).iterator; | 266 .iterator; |
272 checkState(A, currentNode: null, stack: null); | 267 checkState(A, currentNode: null, stack: null); |
273 Expect.isNull(iterator.current); | 268 Expect.isNull(iterator.current); |
274 Expect.isTrue(iterator.moveNext()); | 269 Expect.isTrue(iterator.moveNext()); |
275 checkState(A, currentNode: C, stack: [E, F, G, B]); | 270 checkState(A, currentNode: C, stack: [E, F, G, B]); |
276 Expect.equals(C, iterator.current); | 271 Expect.equals(C, iterator.current); |
277 Expect.isTrue(iterator.moveNext()); | 272 Expect.isTrue(iterator.moveNext()); |
278 checkState(A, currentNode: E, stack: [F, G, B]); | 273 checkState(A, currentNode: E, stack: [F, G, B]); |
279 Expect.equals(E, iterator.current); | 274 Expect.equals(E, iterator.current); |
280 Expect.isTrue(iterator.moveNext()); | 275 Expect.isTrue(iterator.moveNext()); |
281 checkState(A, currentNode: F, stack: [G, B]); | 276 checkState(A, currentNode: F, stack: [G, B]); |
282 Expect.equals(F, iterator.current); | 277 Expect.equals(F, iterator.current); |
283 Expect.isTrue(iterator.moveNext()); | 278 Expect.isTrue(iterator.moveNext()); |
284 checkState(A, currentNode: G, stack: [B]); | 279 checkState(A, currentNode: G, stack: [B]); |
285 Expect.equals(G, iterator.current); | 280 Expect.equals(G, iterator.current); |
286 Expect.isTrue(iterator.moveNext()); | 281 Expect.isTrue(iterator.moveNext()); |
287 checkState(A, currentNode: B, stack: [D]); | 282 checkState(A, currentNode: B, stack: [D]); |
288 Expect.equals(B, iterator.current); | 283 Expect.equals(B, iterator.current); |
289 Expect.isTrue(iterator.moveNext()); | 284 Expect.isTrue(iterator.moveNext()); |
290 checkState(A, currentNode: D, stack: []); | 285 checkState(A, currentNode: D, stack: []); |
291 Expect.equals(D, iterator.current); | 286 Expect.equals(D, iterator.current); |
292 Expect.isFalse(iterator.moveNext()); | 287 Expect.isFalse(iterator.moveNext()); |
293 checkState(A, currentNode: null, stack: []); | 288 checkState(A, currentNode: null, stack: []); |
294 Expect.isNull(iterator.current); | 289 Expect.isNull(iterator.current); |
295 | 290 |
296 iterator = new ClassHierarchyNodeIterable( | 291 iterator = new ClassHierarchyNodeIterable( |
297 world.getClassHierarchyNode(A), | 292 world.getClassHierarchyNode(A), |
298 new EnumSet<Instantiation>.fromValues(<Instantiation>[ | 293 new EnumSet<Instantiation>.fromValues(<Instantiation>[ |
299 Instantiation.DIRECTLY_INSTANTIATED, | 294 Instantiation.DIRECTLY_INSTANTIATED, |
300 Instantiation.UNINSTANTIATED])).iterator; | 295 Instantiation.UNINSTANTIATED |
| 296 ])).iterator; |
301 checkState(A, currentNode: null, stack: null); | 297 checkState(A, currentNode: null, stack: null); |
302 Expect.isNull(iterator.current); | 298 Expect.isNull(iterator.current); |
303 Expect.isTrue(iterator.moveNext()); | 299 Expect.isTrue(iterator.moveNext()); |
304 checkState(A, currentNode: A, stack: [C, B]); | 300 checkState(A, currentNode: A, stack: [C, B]); |
305 Expect.equals(A, iterator.current); | 301 Expect.equals(A, iterator.current); |
306 Expect.isTrue(iterator.moveNext()); | 302 Expect.isTrue(iterator.moveNext()); |
307 checkState(A, currentNode: C, stack: [E, F, G, B]); | 303 checkState(A, currentNode: C, stack: [E, F, G, B]); |
308 Expect.equals(C, iterator.current); | 304 Expect.equals(C, iterator.current); |
309 Expect.isTrue(iterator.moveNext()); | 305 Expect.isTrue(iterator.moveNext()); |
310 checkState(A, currentNode: E, stack: [F, G, B]); | 306 checkState(A, currentNode: E, stack: [F, G, B]); |
311 Expect.equals(E, iterator.current); | 307 Expect.equals(E, iterator.current); |
312 Expect.isTrue(iterator.moveNext()); | 308 Expect.isTrue(iterator.moveNext()); |
313 checkState(A, currentNode: F, stack: [G, B]); | 309 checkState(A, currentNode: F, stack: [G, B]); |
314 Expect.equals(F, iterator.current); | 310 Expect.equals(F, iterator.current); |
315 Expect.isTrue(iterator.moveNext()); | 311 Expect.isTrue(iterator.moveNext()); |
316 checkState(A, currentNode: G, stack: [B]); | 312 checkState(A, currentNode: G, stack: [B]); |
317 Expect.equals(G, iterator.current); | 313 Expect.equals(G, iterator.current); |
318 Expect.isTrue(iterator.moveNext()); | 314 Expect.isTrue(iterator.moveNext()); |
319 checkState(A, currentNode: D, stack: []); | 315 checkState(A, currentNode: D, stack: []); |
320 Expect.equals(D, iterator.current); | 316 Expect.equals(D, iterator.current); |
321 Expect.isFalse(iterator.moveNext()); | 317 Expect.isFalse(iterator.moveNext()); |
322 checkState(A, currentNode: null, stack: []); | 318 checkState(A, currentNode: null, stack: []); |
323 Expect.isNull(iterator.current); | 319 Expect.isNull(iterator.current); |
324 | 320 |
325 iterator = new ClassHierarchyNodeIterable( | 321 iterator = new ClassHierarchyNodeIterable( |
326 world.getClassHierarchyNode(A), | 322 world.getClassHierarchyNode(A), |
327 new EnumSet<Instantiation>.fromValues(<Instantiation>[ | 323 new EnumSet<Instantiation>.fromValues(<Instantiation>[ |
328 Instantiation.DIRECTLY_INSTANTIATED, | 324 Instantiation.DIRECTLY_INSTANTIATED, |
329 Instantiation.UNINSTANTIATED]), | 325 Instantiation.UNINSTANTIATED |
330 includeRoot: false).iterator; | 326 ]), |
| 327 includeRoot: false) |
| 328 .iterator; |
331 checkState(A, currentNode: null, stack: null); | 329 checkState(A, currentNode: null, stack: null); |
332 Expect.isNull(iterator.current); | 330 Expect.isNull(iterator.current); |
333 Expect.isTrue(iterator.moveNext()); | 331 Expect.isTrue(iterator.moveNext()); |
334 checkState(A, currentNode: C, stack: [E, F, G, B]); | 332 checkState(A, currentNode: C, stack: [E, F, G, B]); |
335 Expect.equals(C, iterator.current); | 333 Expect.equals(C, iterator.current); |
336 Expect.isTrue(iterator.moveNext()); | 334 Expect.isTrue(iterator.moveNext()); |
337 checkState(A, currentNode: E, stack: [F, G, B]); | 335 checkState(A, currentNode: E, stack: [F, G, B]); |
338 Expect.equals(E, iterator.current); | 336 Expect.equals(E, iterator.current); |
339 Expect.isTrue(iterator.moveNext()); | 337 Expect.isTrue(iterator.moveNext()); |
340 checkState(A, currentNode: F, stack: [G, B]); | 338 checkState(A, currentNode: F, stack: [G, B]); |
341 Expect.equals(F, iterator.current); | 339 Expect.equals(F, iterator.current); |
342 Expect.isTrue(iterator.moveNext()); | 340 Expect.isTrue(iterator.moveNext()); |
343 checkState(A, currentNode: G, stack: [B]); | 341 checkState(A, currentNode: G, stack: [B]); |
344 Expect.equals(G, iterator.current); | 342 Expect.equals(G, iterator.current); |
345 Expect.isTrue(iterator.moveNext()); | 343 Expect.isTrue(iterator.moveNext()); |
346 checkState(A, currentNode: D, stack: []); | 344 checkState(A, currentNode: D, stack: []); |
347 Expect.equals(D, iterator.current); | 345 Expect.equals(D, iterator.current); |
348 Expect.isFalse(iterator.moveNext()); | 346 Expect.isFalse(iterator.moveNext()); |
349 checkState(A, currentNode: null, stack: []); | 347 checkState(A, currentNode: null, stack: []); |
350 Expect.isNull(iterator.current); | 348 Expect.isNull(iterator.current); |
351 } | 349 } |
352 | 350 |
353 testForEach() async { | 351 testForEach() async { |
354 var env = await TypeEnvironment.create(r""" | 352 var env = await TypeEnvironment.create( |
| 353 r""" |
355 /// A | 354 /// A |
356 /// / \ | 355 /// / \ |
357 /// B C | 356 /// B C |
358 /// / /|\ | 357 /// / /|\ |
359 /// D E F G | 358 /// D E F G |
360 /// / \ | 359 /// / \ |
361 /// H I | 360 /// H I |
362 /// | 361 /// |
363 class A implements X {} | 362 class A implements X {} |
364 class B extends A {} | 363 class B extends A {} |
365 class C extends A {} | 364 class C extends A {} |
366 class D extends B {} | 365 class D extends B {} |
367 class E extends C {} | 366 class E extends C {} |
368 class F extends C implements B {} | 367 class F extends C implements B {} |
369 class G extends C implements D {} | 368 class G extends C implements D {} |
370 class H extends F {} | 369 class H extends F {} |
371 class I extends F {} | 370 class I extends F {} |
372 class X {} | 371 class X {} |
373 """, | 372 """, |
374 mainSource: r""" | 373 mainSource: r""" |
375 main() { | 374 main() { |
376 new A(); | 375 new A(); |
377 new C(); | 376 new C(); |
378 new D(); | 377 new D(); |
379 new E(); | 378 new E(); |
380 new F(); | 379 new F(); |
381 new G(); | 380 new G(); |
382 new H(); | 381 new H(); |
383 new I(); | 382 new I(); |
384 } | 383 } |
(...skipping 12 matching lines...) Expand all Loading... |
397 ClassElement I = env.getElement("I"); | 396 ClassElement I = env.getElement("I"); |
398 ClassElement X = env.getElement("X"); | 397 ClassElement X = env.getElement("X"); |
399 | 398 |
400 void checkForEachSubclass(ClassElement cls, List<ClassElement> expected) { | 399 void checkForEachSubclass(ClassElement cls, List<ClassElement> expected) { |
401 ClassSet classSet = world.getClassSet(cls); | 400 ClassSet classSet = world.getClassSet(cls); |
402 List<ClassElement> visited = <ClassElement>[]; | 401 List<ClassElement> visited = <ClassElement>[]; |
403 classSet.forEachSubclass((ClassElement cls) { | 402 classSet.forEachSubclass((ClassElement cls) { |
404 visited.add(cls); | 403 visited.add(cls); |
405 }, ClassHierarchyNode.ALL); | 404 }, ClassHierarchyNode.ALL); |
406 | 405 |
407 Expect.listEquals(expected, visited, | 406 Expect.listEquals( |
| 407 expected, |
| 408 visited, |
408 "Unexpected classes on $cls.forEachSubclass:\n" | 409 "Unexpected classes on $cls.forEachSubclass:\n" |
409 "Actual: $visited, expected: $expected\n$classSet"); | 410 "Actual: $visited, expected: $expected\n$classSet"); |
410 | 411 |
411 visited = <ClassElement>[]; | 412 visited = <ClassElement>[]; |
412 classSet.forEachSubclass((ClassElement cls) { | 413 classSet.forEachSubclass((ClassElement cls) { |
413 visited.add(cls); | 414 visited.add(cls); |
414 return IterationStep.CONTINUE; | 415 return IterationStep.CONTINUE; |
415 }, ClassHierarchyNode.ALL); | 416 }, ClassHierarchyNode.ALL); |
416 | 417 |
417 Expect.listEquals(expected, visited, | 418 Expect.listEquals( |
| 419 expected, |
| 420 visited, |
418 "Unexpected classes on $cls.forEachSubclass:\n" | 421 "Unexpected classes on $cls.forEachSubclass:\n" |
419 "Actual: $visited, expected: $expected\n$classSet"); | 422 "Actual: $visited, expected: $expected\n$classSet"); |
420 } | 423 } |
421 | 424 |
422 checkForEachSubclass(A, [A, B, D, C, G, F, I, H, E]); | 425 checkForEachSubclass(A, [A, B, D, C, G, F, I, H, E]); |
423 checkForEachSubclass(B, [B, D]); | 426 checkForEachSubclass(B, [B, D]); |
424 checkForEachSubclass(C, [C, G, F, I, H, E]); | 427 checkForEachSubclass(C, [C, G, F, I, H, E]); |
425 checkForEachSubclass(D, [D]); | 428 checkForEachSubclass(D, [D]); |
426 checkForEachSubclass(E, [E]); | 429 checkForEachSubclass(E, [E]); |
427 checkForEachSubclass(F, [F, I, H]); | 430 checkForEachSubclass(F, [F, I, H]); |
428 checkForEachSubclass(G, [G]); | 431 checkForEachSubclass(G, [G]); |
429 checkForEachSubclass(H, [H]); | 432 checkForEachSubclass(H, [H]); |
430 checkForEachSubclass(I, [I]); | 433 checkForEachSubclass(I, [I]); |
431 checkForEachSubclass(X, [X]); | 434 checkForEachSubclass(X, [X]); |
432 | 435 |
433 void checkForEachSubtype(ClassElement cls, List<ClassElement> expected) { | 436 void checkForEachSubtype(ClassElement cls, List<ClassElement> expected) { |
434 ClassSet classSet = world.getClassSet(cls); | 437 ClassSet classSet = world.getClassSet(cls); |
435 List<ClassElement> visited = <ClassElement>[]; | 438 List<ClassElement> visited = <ClassElement>[]; |
436 classSet.forEachSubtype((ClassElement cls) { | 439 classSet.forEachSubtype((ClassElement cls) { |
437 visited.add(cls); | 440 visited.add(cls); |
438 }, ClassHierarchyNode.ALL); | 441 }, ClassHierarchyNode.ALL); |
439 | 442 |
440 Expect.listEquals(expected, visited, | 443 Expect.listEquals( |
| 444 expected, |
| 445 visited, |
441 "Unexpected classes on $cls.forEachSubtype:\n" | 446 "Unexpected classes on $cls.forEachSubtype:\n" |
442 "Actual: $visited, expected: $expected\n$classSet"); | 447 "Actual: $visited, expected: $expected\n$classSet"); |
443 | 448 |
444 visited = <ClassElement>[]; | 449 visited = <ClassElement>[]; |
445 classSet.forEachSubtype((ClassElement cls) { | 450 classSet.forEachSubtype((ClassElement cls) { |
446 visited.add(cls); | 451 visited.add(cls); |
447 return IterationStep.CONTINUE; | 452 return IterationStep.CONTINUE; |
448 }, ClassHierarchyNode.ALL); | 453 }, ClassHierarchyNode.ALL); |
449 | 454 |
450 Expect.listEquals(expected, visited, | 455 Expect.listEquals( |
| 456 expected, |
| 457 visited, |
451 "Unexpected classes on $cls.forEachSubtype:\n" | 458 "Unexpected classes on $cls.forEachSubtype:\n" |
452 "Actual: $visited, expected: $expected\n$classSet"); | 459 "Actual: $visited, expected: $expected\n$classSet"); |
453 } | 460 } |
454 | 461 |
455 checkForEachSubtype(A, [A, B, D, C, G, F, I, H, E]); | 462 checkForEachSubtype(A, [A, B, D, C, G, F, I, H, E]); |
456 checkForEachSubtype(B, [B, D, F, I, H, G]); | 463 checkForEachSubtype(B, [B, D, F, I, H, G]); |
457 checkForEachSubtype(C, [C, G, F, I, H, E]); | 464 checkForEachSubtype(C, [C, G, F, I, H, E]); |
458 checkForEachSubtype(D, [D, G]); | 465 checkForEachSubtype(D, [D, G]); |
459 checkForEachSubtype(E, [E]); | 466 checkForEachSubtype(E, [E]); |
460 checkForEachSubtype(F, [F, I, H]); | 467 checkForEachSubtype(F, [F, I, H]); |
461 checkForEachSubtype(G, [G]); | 468 checkForEachSubtype(G, [G]); |
462 checkForEachSubtype(H, [H]); | 469 checkForEachSubtype(H, [H]); |
463 checkForEachSubtype(I, [I]); | 470 checkForEachSubtype(I, [I]); |
464 checkForEachSubtype(X, [X, A, B, D, C, G, F, I, H, E]); | 471 checkForEachSubtype(X, [X, A, B, D, C, G, F, I, H, E]); |
465 | 472 |
466 void checkForEach( | 473 void checkForEach(ClassElement cls, List<ClassElement> expected, |
467 ClassElement cls, | |
468 List<ClassElement> expected, | |
469 {ClassElement stop, | 474 {ClassElement stop, |
470 List<ClassElement> skipSubclasses: const <ClassElement>[], | 475 List<ClassElement> skipSubclasses: const <ClassElement>[], |
471 bool forEachSubtype: false, | 476 bool forEachSubtype: false, |
472 EnumSet<Instantiation> mask}) { | 477 EnumSet<Instantiation> mask}) { |
473 | |
474 if (mask == null) { | 478 if (mask == null) { |
475 mask = ClassHierarchyNode.ALL; | 479 mask = ClassHierarchyNode.ALL; |
476 } | 480 } |
477 | 481 |
478 ClassSet classSet = world.getClassSet(cls); | 482 ClassSet classSet = world.getClassSet(cls); |
479 List<ClassElement> visited = <ClassElement>[]; | 483 List<ClassElement> visited = <ClassElement>[]; |
480 | 484 |
481 IterationStep visit(ClassElement cls) { | 485 IterationStep visit(ClassElement cls) { |
482 visited.add(cls); | 486 visited.add(cls); |
483 if (cls == stop) { | 487 if (cls == stop) { |
484 return IterationStep.STOP; | 488 return IterationStep.STOP; |
485 } else if (skipSubclasses.contains(cls)) { | 489 } else if (skipSubclasses.contains(cls)) { |
486 return IterationStep.SKIP_SUBCLASSES; | 490 return IterationStep.SKIP_SUBCLASSES; |
487 } | 491 } |
488 return IterationStep.CONTINUE; | 492 return IterationStep.CONTINUE; |
489 } | 493 } |
490 | 494 |
491 if (forEachSubtype) { | 495 if (forEachSubtype) { |
492 classSet.forEachSubtype(visit, mask); | 496 classSet.forEachSubtype(visit, mask); |
493 } else { | 497 } else { |
494 classSet.forEachSubclass(visit, mask); | 498 classSet.forEachSubclass(visit, mask); |
495 } | 499 } |
496 | 500 |
497 Expect.listEquals(expected, visited, | 501 Expect.listEquals( |
| 502 expected, |
| 503 visited, |
498 "Unexpected classes on $cls." | 504 "Unexpected classes on $cls." |
499 "forEach${forEachSubtype ? 'Subtype' : 'Subclass'} " | 505 "forEach${forEachSubtype ? 'Subtype' : 'Subclass'} " |
500 "(stop:$stop, skipSubclasses:$skipSubclasses):\n" | 506 "(stop:$stop, skipSubclasses:$skipSubclasses):\n" |
501 "Actual: $visited, expected: $expected\n$classSet"); | 507 "Actual: $visited, expected: $expected\n$classSet"); |
502 } | 508 } |
503 | 509 |
504 checkForEach(A, [A, B, D, C, G, F, I, H, E]); | 510 checkForEach(A, [A, B, D, C, G, F, I, H, E]); |
505 checkForEach(A, [A], stop: A); | 511 checkForEach(A, [A], stop: A); |
506 checkForEach(A, [A, B, C, G, F, I, H, E], skipSubclasses: [B]); | 512 checkForEach(A, [A, B, C, G, F, I, H, E], skipSubclasses: [B]); |
507 checkForEach(A, [A, B, C], skipSubclasses: [B, C]); | 513 checkForEach(A, [A, B, C], skipSubclasses: [B, C]); |
508 checkForEach(A, [A, B, C, G], stop: G, skipSubclasses: [B]); | 514 checkForEach(A, [A, B, C, G], stop: G, skipSubclasses: [B]); |
509 | 515 |
510 checkForEach(B, [B, D, F, I, H, G], forEachSubtype: true); | 516 checkForEach(B, [B, D, F, I, H, G], forEachSubtype: true); |
511 checkForEach(B, [B, D], stop: D, forEachSubtype: true); | 517 checkForEach(B, [B, D], stop: D, forEachSubtype: true); |
512 checkForEach(B, [B, D, F, G], skipSubclasses: [F], forEachSubtype: true); | 518 checkForEach(B, [B, D, F, G], skipSubclasses: [F], forEachSubtype: true); |
513 checkForEach(B, [B, F, I, H, G], skipSubclasses: [B], forEachSubtype: true); | 519 checkForEach(B, [B, F, I, H, G], skipSubclasses: [B], forEachSubtype: true); |
514 checkForEach(B, [B, D, F, I, H, G], skipSubclasses: [D], forEachSubtype: true)
; | 520 checkForEach(B, [B, D, F, I, H, G], |
| 521 skipSubclasses: [D], forEachSubtype: true); |
515 | 522 |
516 checkForEach(X, [X, A, B, D, C, G, F, I, H, E], forEachSubtype: true); | 523 checkForEach(X, [X, A, B, D, C, G, F, I, H, E], forEachSubtype: true); |
517 checkForEach(X, [X, A, B, D], stop: D, forEachSubtype: true); | 524 checkForEach(X, [X, A, B, D], stop: D, forEachSubtype: true); |
518 checkForEach(X, [X, A, B, D, C, G, F, E], | 525 checkForEach(X, [X, A, B, D, C, G, F, E], |
519 skipSubclasses: [F], forEachSubtype: true); | 526 skipSubclasses: [F], forEachSubtype: true); |
520 checkForEach(X, [X, A, B, D, C, G, F, I, H, E], | 527 checkForEach(X, [X, A, B, D, C, G, F, I, H, E], |
521 skipSubclasses: [X], forEachSubtype: true); | 528 skipSubclasses: [X], forEachSubtype: true); |
522 checkForEach(X, [X, A, B, D, C, G, F, I, H, E], | 529 checkForEach(X, [X, A, B, D, C, G, F, I, H, E], |
523 skipSubclasses: [D], forEachSubtype: true); | 530 skipSubclasses: [D], forEachSubtype: true); |
524 checkForEach(X, [A, D, C, G, F, I, H, E], | 531 checkForEach(X, [A, D, C, G, F, I, H, E], |
525 forEachSubtype: true, | 532 forEachSubtype: true, mask: ClassHierarchyNode.DIRECTLY_INSTANTIATED); |
526 mask: ClassHierarchyNode.DIRECTLY_INSTANTIATED); | |
527 checkForEach(X, [A, B, D, C, G, F, I, H, E], | 533 checkForEach(X, [A, B, D, C, G, F, I, H, E], |
528 forEachSubtype: true, | 534 forEachSubtype: true, mask: ClassHierarchyNode.INSTANTIATED); |
529 mask: ClassHierarchyNode.INSTANTIATED); | |
530 | 535 |
531 void checkAny( | 536 void checkAny(ClassElement cls, List<ClassElement> expected, |
532 ClassElement cls, | 537 {ClassElement find, bool expectedResult, bool anySubtype: false}) { |
533 List<ClassElement> expected, | |
534 {ClassElement find, | |
535 bool expectedResult, | |
536 bool anySubtype: false}) { | |
537 ClassSet classSet = world.getClassSet(cls); | 538 ClassSet classSet = world.getClassSet(cls); |
538 List<ClassElement> visited = <ClassElement>[]; | 539 List<ClassElement> visited = <ClassElement>[]; |
539 | 540 |
540 bool visit(ClassElement cls) { | 541 bool visit(ClassElement cls) { |
541 visited.add(cls); | 542 visited.add(cls); |
542 return cls == find; | 543 return cls == find; |
543 } | 544 } |
544 | 545 |
545 bool result; | 546 bool result; |
546 if (anySubtype) { | 547 if (anySubtype) { |
547 result = classSet.anySubtype(visit, ClassHierarchyNode.ALL); | 548 result = classSet.anySubtype(visit, ClassHierarchyNode.ALL); |
548 } else { | 549 } else { |
549 result = classSet.anySubclass(visit, ClassHierarchyNode.ALL); | 550 result = classSet.anySubclass(visit, ClassHierarchyNode.ALL); |
550 } | 551 } |
551 | 552 |
552 Expect.equals(expectedResult, result, | 553 Expect.equals( |
| 554 expectedResult, |
| 555 result, |
553 "Unexpected result on $cls." | 556 "Unexpected result on $cls." |
554 "any${anySubtype ? 'Subtype' : 'Subclass'} " | 557 "any${anySubtype ? 'Subtype' : 'Subclass'} " |
555 "(find:$find)."); | 558 "(find:$find)."); |
556 | 559 |
557 Expect.listEquals(expected, visited, | 560 Expect.listEquals( |
| 561 expected, |
| 562 visited, |
558 "Unexpected classes on $cls." | 563 "Unexpected classes on $cls." |
559 "any${anySubtype ? 'Subtype' : 'Subclass'} " | 564 "any${anySubtype ? 'Subtype' : 'Subclass'} " |
560 "(find:$find):\n" | 565 "(find:$find):\n" |
561 "Actual: $visited, expected: $expected\n$classSet"); | 566 "Actual: $visited, expected: $expected\n$classSet"); |
562 } | 567 } |
563 | 568 |
564 checkAny(A, [A, B, D, C, G, F, I, H, E], expectedResult: false); | 569 checkAny(A, [A, B, D, C, G, F, I, H, E], expectedResult: false); |
565 checkAny(A, [A], find: A, expectedResult: true); | 570 checkAny(A, [A], find: A, expectedResult: true); |
566 checkAny(A, [A, B, D, C, G, F, I], find: I, expectedResult: true); | 571 checkAny(A, [A, B, D, C, G, F, I], find: I, expectedResult: true); |
567 | 572 |
568 checkAny(B, [B, D, F, I, H, G], anySubtype: true, expectedResult: false); | 573 checkAny(B, [B, D, F, I, H, G], anySubtype: true, expectedResult: false); |
569 checkAny(B, [B, D, F, I, H, G], | 574 checkAny(B, [B, D, F, I, H, G], |
570 find: A, anySubtype: true, expectedResult: false); | 575 find: A, anySubtype: true, expectedResult: false); |
571 checkAny(B, [B, D], | 576 checkAny(B, [B, D], find: D, anySubtype: true, expectedResult: true); |
572 find: D, anySubtype: true, expectedResult: true); | 577 checkAny(B, [B, D, F, I], find: I, anySubtype: true, expectedResult: true); |
573 checkAny(B, [B, D, F, I], | |
574 find: I, anySubtype: true, expectedResult: true); | |
575 | 578 |
576 checkAny(X, [X, A, B, D, C, G, F, I, H, E], | 579 checkAny(X, [X, A, B, D, C, G, F, I, H, E], |
577 anySubtype: true, expectedResult: false); | 580 anySubtype: true, expectedResult: false); |
578 checkAny(X, [X, A], | 581 checkAny(X, [X, A], find: A, anySubtype: true, expectedResult: true); |
579 find: A, anySubtype: true, expectedResult: true); | 582 checkAny(X, [X, A, B, D], find: D, anySubtype: true, expectedResult: true); |
580 checkAny(X, [X, A, B, D], | |
581 find: D, anySubtype: true, expectedResult: true); | |
582 checkAny(X, [X, A, B, D, C, G, F, I], | 583 checkAny(X, [X, A, B, D, C, G, F, I], |
583 find: I, anySubtype: true, expectedResult: true); | 584 find: I, anySubtype: true, expectedResult: true); |
584 } | 585 } |
OLD | NEW |