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

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

Issue 45573002: Rename analyzer_experimental to analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks before publishing. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information.
3 library engine.resolver_test;
4 import 'package:analyzer_experimental/src/generated/java_core.dart';
5 import 'package:analyzer_experimental/src/generated/java_junit.dart';
6 import 'package:analyzer_experimental/src/generated/source_io.dart';
7 import 'package:analyzer_experimental/src/generated/error.dart';
8 import 'package:analyzer_experimental/src/generated/scanner.dart';
9 import 'package:analyzer_experimental/src/generated/ast.dart';
10 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode;
11 import 'package:analyzer_experimental/src/generated/element.dart';
12 import 'package:analyzer_experimental/src/generated/resolver.dart';
13 import 'package:analyzer_experimental/src/generated/engine.dart';
14 import 'package:analyzer_experimental/src/generated/java_engine_io.dart';
15 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk;
16 import 'package:analyzer_experimental/src/generated/sdk_io.dart' show DirectoryB asedDartSdk;
17 import 'package:unittest/unittest.dart' as _ut;
18 import 'test_support.dart';
19 import 'ast_test.dart' show ASTFactory;
20 import 'element_test.dart' show ElementFactory;
21 class TypePropagationTest extends ResolverTestCase {
22 void fail_functionExpression_asInvocationArgument_functionExpressionInvocation () {
23 String code = EngineTestCase.createSource([
24 "main() {",
25 " (f(String value)) {} ((v) {",
26 " v;",
27 " });",
28 "}"]);
29 Source source = addSource(code);
30 LibraryElement library = resolve(source);
31 assertNoErrors(source);
32 verify([source]);
33 CompilationUnit unit = resolveCompilationUnit(source, library);
34 Type2 dynamicType = typeProvider.dynamicType;
35 Type2 stringType = typeProvider.stringType;
36 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Forma lParameter);
37 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType);
38 JUnitTestCase.assertSame(dynamicType, vParameter.identifier.staticType);
39 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim pleIdentifier);
40 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType);
41 JUnitTestCase.assertSame(dynamicType, vIdentifier.staticType);
42 }
43 void fail_propagatedReturnType_functionExpression() {
44 String code = EngineTestCase.createSource(["main() {", " var v = (() {retur n 42;})();", "}"]);
45 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
46 }
47 void test_as() {
48 Source source = addSource(EngineTestCase.createSource([
49 "class A {",
50 " bool get g => true;",
51 "}",
52 "A f(var p) {",
53 " if ((p as A).g) {",
54 " return p;",
55 " } else {",
56 " return null;",
57 " }",
58 "}"]));
59 LibraryElement library = resolve(source);
60 assertNoErrors(source);
61 verify([source]);
62 CompilationUnit unit = resolveCompilationUnit(source, library);
63 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
64 InterfaceType typeA = classA.element.type;
65 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
66 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
67 IfStatement ifStatement = body.block.statements[0] as IfStatement;
68 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
69 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
70 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
71 }
72 void test_assert() {
73 Source source = addSource(EngineTestCase.createSource([
74 "class A {}",
75 "A f(var p) {",
76 " assert (p is A);",
77 " return p;",
78 "}"]));
79 LibraryElement library = resolve(source);
80 assertNoErrors(source);
81 verify([source]);
82 CompilationUnit unit = resolveCompilationUnit(source, library);
83 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
84 InterfaceType typeA = classA.element.type;
85 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
86 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
87 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
88 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
89 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
90 }
91 void test_assignment() {
92 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;", " v = 0;", " return v;", "}"]));
93 LibraryElement library = resolve(source);
94 assertNoErrors(source);
95 verify([source]);
96 CompilationUnit unit = resolveCompilationUnit(source, library);
97 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
98 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
99 ReturnStatement statement = body.block.statements[2] as ReturnStatement;
100 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
101 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType);
102 }
103 void test_assignment_afterInitializer() {
104 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0 ;", " v = 1.0;", " return v;", "}"]));
105 LibraryElement library = resolve(source);
106 assertNoErrors(source);
107 verify([source]);
108 CompilationUnit unit = resolveCompilationUnit(source, library);
109 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
110 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
111 ReturnStatement statement = body.block.statements[2] as ReturnStatement;
112 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
113 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.propagatedTyp e);
114 }
115 void test_forEach() {
116 String code = EngineTestCase.createSource([
117 "f(List<String> p) {",
118 " for (var e in p) {",
119 " e;",
120 " }",
121 "}"]);
122 Source source = addSource(code);
123 LibraryElement library = resolve(source);
124 assertNoErrors(source);
125 verify([source]);
126 CompilationUnit unit = resolveCompilationUnit(source, library);
127 InterfaceType stringType = typeProvider.stringType;
128 {
129 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e in", SimpleIdentifier);
130 JUnitTestCase.assertSame(stringType, identifier.propagatedType);
131 }
132 {
133 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "e;", Si mpleIdentifier);
134 JUnitTestCase.assertSame(stringType, identifier.propagatedType);
135 }
136 }
137 void test_functionExpression_asInvocationArgument() {
138 String code = EngineTestCase.createSource([
139 "class MyMap<K, V> {",
140 " forEach(f(K key, V value)) {}",
141 "}",
142 "f(MyMap<int, String> m) {",
143 " m.forEach((k, v) {",
144 " k;",
145 " v;",
146 " });",
147 "}"]);
148 Source source = addSource(code);
149 LibraryElement library = resolve(source);
150 assertNoErrors(source);
151 verify([source]);
152 CompilationUnit unit = resolveCompilationUnit(source, library);
153 Type2 intType = typeProvider.intType;
154 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp leFormalParameter);
155 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType);
156 SimpleIdentifier kIdentifier = EngineTestCase.findNode(unit, code, "k;", Sim pleIdentifier);
157 JUnitTestCase.assertSame(intType, kIdentifier.propagatedType);
158 JUnitTestCase.assertSame(typeProvider.dynamicType, kIdentifier.staticType);
159 Type2 stringType = typeProvider.stringType;
160 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl eFormalParameter);
161 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType);
162 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim pleIdentifier);
163 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType);
164 JUnitTestCase.assertSame(typeProvider.dynamicType, vIdentifier.staticType);
165 }
166 void test_functionExpression_asInvocationArgument_fromInferredInvocation() {
167 String code = EngineTestCase.createSource([
168 "class MyMap<K, V> {",
169 " forEach(f(K key, V value)) {}",
170 "}",
171 "f(MyMap<int, String> m) {",
172 " var m2 = m;",
173 " m2.forEach((k, v) {});",
174 "}"]);
175 Source source = addSource(code);
176 LibraryElement library = resolve(source);
177 assertNoErrors(source);
178 verify([source]);
179 CompilationUnit unit = resolveCompilationUnit(source, library);
180 Type2 intType = typeProvider.intType;
181 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp leFormalParameter);
182 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType);
183 Type2 stringType = typeProvider.stringType;
184 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl eFormalParameter);
185 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType);
186 }
187 void test_functionExpression_asInvocationArgument_keepIfLessSpecific() {
188 String code = EngineTestCase.createSource([
189 "class MyList {",
190 " forEach(f(Object value)) {}",
191 "}",
192 "f(MyList list) {",
193 " list.forEach((int v) {",
194 " v;",
195 " });",
196 "}"]);
197 Source source = addSource(code);
198 LibraryElement library = resolve(source);
199 assertNoErrors(source);
200 verify([source]);
201 CompilationUnit unit = resolveCompilationUnit(source, library);
202 Type2 intType = typeProvider.intType;
203 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl eFormalParameter);
204 JUnitTestCase.assertSame(null, vParameter.identifier.propagatedType);
205 JUnitTestCase.assertSame(intType, vParameter.identifier.staticType);
206 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim pleIdentifier);
207 JUnitTestCase.assertSame(intType, vIdentifier.staticType);
208 JUnitTestCase.assertSame(null, vIdentifier.propagatedType);
209 }
210 void test_functionExpression_asInvocationArgument_replaceIfMoreSpecific() {
211 String code = EngineTestCase.createSource([
212 "class MyList<E> {",
213 " forEach(f(E value)) {}",
214 "}",
215 "f(MyList<String> list) {",
216 " list.forEach((Object v) {",
217 " v;",
218 " });",
219 "}"]);
220 Source source = addSource(code);
221 LibraryElement library = resolve(source);
222 assertNoErrors(source);
223 verify([source]);
224 CompilationUnit unit = resolveCompilationUnit(source, library);
225 Type2 stringType = typeProvider.stringType;
226 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl eFormalParameter);
227 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType);
228 JUnitTestCase.assertSame(typeProvider.objectType, vParameter.identifier.stat icType);
229 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim pleIdentifier);
230 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType);
231 }
232 void test_Future_then() {
233 String code = EngineTestCase.createSource([
234 "import 'dart:async';",
235 "main(Future<int> firstFuture) {",
236 " firstFuture.then((p1) {",
237 " return 1.0;",
238 " }).then((p2) {",
239 " return new Future<String>.value('str');",
240 " }).then((p3) {",
241 " });",
242 "}"]);
243 Source source = addSource(code);
244 LibraryElement library = resolve(source);
245 assertNoErrors(source);
246 verify([source]);
247 CompilationUnit unit = resolveCompilationUnit(source, library);
248 FormalParameter p1 = EngineTestCase.findNode(unit, code, "p1) {", SimpleForm alParameter);
249 JUnitTestCase.assertSame(typeProvider.intType, p1.identifier.propagatedType) ;
250 FormalParameter p2 = EngineTestCase.findNode(unit, code, "p2) {", SimpleForm alParameter);
251 JUnitTestCase.assertSame(typeProvider.doubleType, p2.identifier.propagatedTy pe);
252 FormalParameter p3 = EngineTestCase.findNode(unit, code, "p3) {", SimpleForm alParameter);
253 JUnitTestCase.assertSame(typeProvider.stringType, p3.identifier.propagatedTy pe);
254 }
255 void test_initializer() {
256 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0 ;", " return v;", "}"]));
257 LibraryElement library = resolve(source);
258 assertNoErrors(source);
259 verify([source]);
260 CompilationUnit unit = resolveCompilationUnit(source, library);
261 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
262 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
263 NodeList<Statement> statements = body.block.statements;
264 {
265 VariableDeclarationStatement statement = statements[0] as VariableDeclarat ionStatement;
266 SimpleIdentifier variableName = statement.variables.variables[0].name;
267 JUnitTestCase.assertSame(typeProvider.dynamicType, variableName.staticType );
268 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType );
269 }
270 {
271 ReturnStatement statement = statements[1] as ReturnStatement;
272 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
273 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType );
274 }
275 }
276 void test_initializer_dereference() {
277 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = ' String';", " v.", "}"]));
278 LibraryElement library = resolve(source);
279 CompilationUnit unit = resolveCompilationUnit(source, library);
280 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
281 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
282 ExpressionStatement statement = body.block.statements[1] as ExpressionStatem ent;
283 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier;
284 SimpleIdentifier variableName = invocation.prefix;
285 JUnitTestCase.assertSame(typeProvider.stringType, variableName.propagatedTyp e);
286 }
287 void test_is_conditional() {
288 Source source = addSource(EngineTestCase.createSource([
289 "class A {}",
290 "A f(var p) {",
291 " return (p is A) ? p : null;",
292 "}"]));
293 LibraryElement library = resolve(source);
294 assertNoErrors(source);
295 verify([source]);
296 CompilationUnit unit = resolveCompilationUnit(source, library);
297 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
298 InterfaceType typeA = classA.element.type;
299 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
300 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
301 ReturnStatement statement = body.block.statements[0] as ReturnStatement;
302 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion;
303 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi er;
304 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
305 }
306 void test_is_if() {
307 Source source = addSource(EngineTestCase.createSource([
308 "class A {}",
309 "A f(var p) {",
310 " if (p is A) {",
311 " return p;",
312 " } else {",
313 " return null;",
314 " }",
315 "}"]));
316 LibraryElement library = resolve(source);
317 assertNoErrors(source);
318 verify([source]);
319 CompilationUnit unit = resolveCompilationUnit(source, library);
320 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
321 InterfaceType typeA = classA.element.type;
322 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
323 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
324 IfStatement ifStatement = body.block.statements[0] as IfStatement;
325 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
326 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
327 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
328 }
329 void test_is_if_lessSpecific() {
330 Source source = addSource(EngineTestCase.createSource([
331 "class A {}",
332 "A f(A p) {",
333 " if (p is String) {",
334 " return p;",
335 " } else {",
336 " return null;",
337 " }",
338 "}"]));
339 LibraryElement library = resolve(source);
340 assertNoErrors(source);
341 verify([source]);
342 CompilationUnit unit = resolveCompilationUnit(source, library);
343 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
344 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
345 IfStatement ifStatement = body.block.statements[0] as IfStatement;
346 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
347 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
348 JUnitTestCase.assertSame(null, variableName.propagatedType);
349 }
350 void test_is_if_logicalAnd() {
351 Source source = addSource(EngineTestCase.createSource([
352 "class A {}",
353 "A f(var p) {",
354 " if (p is A && p != null) {",
355 " return p;",
356 " } else {",
357 " return null;",
358 " }",
359 "}"]));
360 LibraryElement library = resolve(source);
361 assertNoErrors(source);
362 verify([source]);
363 CompilationUnit unit = resolveCompilationUnit(source, library);
364 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
365 InterfaceType typeA = classA.element.type;
366 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
367 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
368 IfStatement ifStatement = body.block.statements[0] as IfStatement;
369 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
370 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
371 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
372 }
373 void test_is_postConditional() {
374 Source source = addSource(EngineTestCase.createSource([
375 "class A {}",
376 "A f(var p) {",
377 " A a = (p is A) ? p : throw null;",
378 " return p;",
379 "}"]));
380 LibraryElement library = resolve(source);
381 assertNoErrors(source);
382 verify([source]);
383 CompilationUnit unit = resolveCompilationUnit(source, library);
384 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
385 InterfaceType typeA = classA.element.type;
386 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
387 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
388 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
389 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
390 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
391 }
392 void test_is_postIf() {
393 Source source = addSource(EngineTestCase.createSource([
394 "class A {}",
395 "A f(var p) {",
396 " if (p is A) {",
397 " A a = p;",
398 " } else {",
399 " return null;",
400 " }",
401 " return p;",
402 "}"]));
403 LibraryElement library = resolve(source);
404 assertNoErrors(source);
405 verify([source]);
406 CompilationUnit unit = resolveCompilationUnit(source, library);
407 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
408 InterfaceType typeA = classA.element.type;
409 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
410 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
411 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
412 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
413 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
414 }
415 void test_is_subclass() {
416 Source source = addSource(EngineTestCase.createSource([
417 "class A {}",
418 "class B extends A {",
419 " B m() => this;",
420 "}",
421 "A f(A p) {",
422 " if (p is B) {",
423 " return p.m();",
424 " }",
425 "}"]));
426 LibraryElement library = resolve(source);
427 assertNoErrors(source);
428 CompilationUnit unit = resolveCompilationUnit(source, library);
429 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration;
430 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
431 IfStatement ifStatement = body.block.statements[0] as IfStatement;
432 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
433 MethodInvocation invocation = statement.expression as MethodInvocation;
434 JUnitTestCase.assertNotNull(invocation.methodName.propagatedElement);
435 }
436 void test_is_while() {
437 Source source = addSource(EngineTestCase.createSource([
438 "class A {}",
439 "A f(var p) {",
440 " while (p is A) {",
441 " return p;",
442 " }",
443 "}"]));
444 LibraryElement library = resolve(source);
445 assertNoErrors(source);
446 verify([source]);
447 CompilationUnit unit = resolveCompilationUnit(source, library);
448 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
449 InterfaceType typeA = classA.element.type;
450 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
451 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
452 WhileStatement whileStatement = body.block.statements[0] as WhileStatement;
453 ReturnStatement statement = ((whileStatement.body as Block)).statements[0] a s ReturnStatement;
454 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
455 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
456 }
457 void test_isNot_conditional() {
458 Source source = addSource(EngineTestCase.createSource([
459 "class A {}",
460 "A f(var p) {",
461 " return (p is! A) ? null : p;",
462 "}"]));
463 LibraryElement library = resolve(source);
464 assertNoErrors(source);
465 verify([source]);
466 CompilationUnit unit = resolveCompilationUnit(source, library);
467 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
468 InterfaceType typeA = classA.element.type;
469 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
470 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
471 ReturnStatement statement = body.block.statements[0] as ReturnStatement;
472 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion;
473 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi er;
474 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
475 }
476 void test_isNot_if() {
477 Source source = addSource(EngineTestCase.createSource([
478 "class A {}",
479 "A f(var p) {",
480 " if (p is! A) {",
481 " return null;",
482 " } else {",
483 " return p;",
484 " }",
485 "}"]));
486 LibraryElement library = resolve(source);
487 assertNoErrors(source);
488 verify([source]);
489 CompilationUnit unit = resolveCompilationUnit(source, library);
490 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
491 InterfaceType typeA = classA.element.type;
492 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
493 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
494 IfStatement ifStatement = body.block.statements[0] as IfStatement;
495 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement;
496 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
497 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
498 }
499 void test_isNot_if_logicalOr() {
500 Source source = addSource(EngineTestCase.createSource([
501 "class A {}",
502 "A f(var p) {",
503 " if (p is! A || null == p) {",
504 " return null;",
505 " } else {",
506 " return p;",
507 " }",
508 "}"]));
509 LibraryElement library = resolve(source);
510 assertNoErrors(source);
511 CompilationUnit unit = resolveCompilationUnit(source, library);
512 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
513 InterfaceType typeA = classA.element.type;
514 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
515 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
516 IfStatement ifStatement = body.block.statements[0] as IfStatement;
517 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement;
518 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
519 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
520 }
521 void test_isNot_postConditional() {
522 Source source = addSource(EngineTestCase.createSource([
523 "class A {}",
524 "A f(var p) {",
525 " A a = (p is! A) ? throw null : p;",
526 " return p;",
527 "}"]));
528 LibraryElement library = resolve(source);
529 assertNoErrors(source);
530 verify([source]);
531 CompilationUnit unit = resolveCompilationUnit(source, library);
532 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
533 InterfaceType typeA = classA.element.type;
534 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
535 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
536 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
537 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
538 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
539 }
540 void test_isNot_postIf() {
541 Source source = addSource(EngineTestCase.createSource([
542 "class A {}",
543 "A f(var p) {",
544 " if (p is! A) {",
545 " return null;",
546 " }",
547 " return p;",
548 "}"]));
549 LibraryElement library = resolve(source);
550 assertNoErrors(source);
551 verify([source]);
552 CompilationUnit unit = resolveCompilationUnit(source, library);
553 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
554 InterfaceType typeA = classA.element.type;
555 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
556 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
557 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
558 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
559 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
560 }
561 void test_listLiteral_different() {
562 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [ 0, '1', 2];", " return v[2];", "}"]));
563 LibraryElement library = resolve(source);
564 assertNoErrors(source);
565 verify([source]);
566 CompilationUnit unit = resolveCompilationUnit(source, library);
567 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
568 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
569 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
570 IndexExpression indexExpression = statement.expression as IndexExpression;
571 JUnitTestCase.assertNull(indexExpression.propagatedType);
572 }
573 void test_listLiteral_same() {
574 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [ 0, 1, 2];", " return v[2];", "}"]));
575 LibraryElement library = resolve(source);
576 assertNoErrors(source);
577 verify([source]);
578 CompilationUnit unit = resolveCompilationUnit(source, library);
579 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
580 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
581 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
582 IndexExpression indexExpression = statement.expression as IndexExpression;
583 JUnitTestCase.assertSame(typeProvider.intType, indexExpression.propagatedTyp e);
584 }
585 void test_mapLiteral_different() {
586 Source source = addSource(EngineTestCase.createSource([
587 "f() {",
588 " var v = {'0' : 0, 1 : '1', '2' : 2};",
589 " return v;",
590 "}"]));
591 LibraryElement library = resolve(source);
592 assertNoErrors(source);
593 verify([source]);
594 CompilationUnit unit = resolveCompilationUnit(source, library);
595 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
596 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
597 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
598 SimpleIdentifier identifier = statement.expression as SimpleIdentifier;
599 InterfaceType propagatedType = identifier.propagatedType as InterfaceType;
600 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen t);
601 List<Type2> typeArguments = propagatedType.typeArguments;
602 EngineTestCase.assertLength(2, typeArguments);
603 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[0]);
604 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments[1]);
605 }
606 void test_mapLiteral_same() {
607 Source source = addSource(EngineTestCase.createSource([
608 "f() {",
609 " var v = {'a' : 0, 'b' : 1, 'c' : 2};",
610 " return v;",
611 "}"]));
612 LibraryElement library = resolve(source);
613 assertNoErrors(source);
614 verify([source]);
615 CompilationUnit unit = resolveCompilationUnit(source, library);
616 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
617 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
618 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
619 SimpleIdentifier identifier = statement.expression as SimpleIdentifier;
620 InterfaceType propagatedType = identifier.propagatedType as InterfaceType;
621 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen t);
622 List<Type2> typeArguments = propagatedType.typeArguments;
623 EngineTestCase.assertLength(2, typeArguments);
624 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments[0]);
625 JUnitTestCase.assertSame(typeProvider.intType, typeArguments[1]);
626 }
627 void test_propagatedReturnType_function_hasReturnType_returnsNull() {
628 String code = EngineTestCase.createSource(["String f() => null;", "main() {" , " var v = f();", "}"]);
629 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.stri ngType);
630 }
631 void test_propagatedReturnType_function_lessSpecificStaticReturnType() {
632 String code = EngineTestCase.createSource(["Object f() => 42;", "main() {", " var v = f();", "}"]);
633 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
634 }
635 void test_propagatedReturnType_function_moreSpecificStaticReturnType() {
636 String code = EngineTestCase.createSource([
637 "int f(v) => (v as num);",
638 "main() {",
639 " var v = f(3);",
640 "}"]);
641 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
642 }
643 void test_propagatedReturnType_function_noReturnTypeName_blockBody_multipleRet urns() {
644 String code = EngineTestCase.createSource([
645 "f() {",
646 " if (true) return 0;",
647 " return 1.0;",
648 "}",
649 "main() {",
650 " var v = f();",
651 "}"]);
652 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.numT ype);
653 }
654 void test_propagatedReturnType_function_noReturnTypeName_blockBody_oneReturn() {
655 String code = EngineTestCase.createSource([
656 "f() {",
657 " var z = 42;",
658 " return z;",
659 "}",
660 "main() {",
661 " var v = f();",
662 "}"]);
663 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
664 }
665 void test_propagatedReturnType_function_noReturnTypeName_expressionBody() {
666 String code = EngineTestCase.createSource(["f() => 42;", "main() {", " var v = f();", "}"]);
667 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
668 }
669 void test_propagatedReturnType_localFunction() {
670 String code = EngineTestCase.createSource(["main() {", " f() => 42;", " va r v = f();", "}"]);
671 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
672 }
673 void test_query() {
674 Source source = addSource(EngineTestCase.createSource([
675 "import 'dart:html';",
676 "",
677 "main() {",
678 " var v1 = query('a');",
679 " var v2 = query('A');",
680 " var v3 = query('body:active');",
681 " var v4 = query('button[foo=\"bar\"]');",
682 " var v5 = query('div.class');",
683 " var v6 = query('input#id');",
684 " var v7 = query('select#id');",
685 " // invocation of method",
686 " var m1 = document.query('div');",
687 " // unsupported currently",
688 " var b1 = query('noSuchTag');",
689 " var b2 = query('DART_EDITOR_NO_SUCH_TYPE');",
690 " var b3 = query('body div');",
691 " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];",
692 "}"]));
693 LibraryElement library = resolve(source);
694 assertNoErrors(source);
695 verify([source]);
696 CompilationUnit unit = resolveCompilationUnit(source, library);
697 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration;
698 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody;
699 ReturnStatement statement = body.block.statements[11] as ReturnStatement;
700 NodeList<Expression> elements = ((statement.expression as ListLiteral)).elem ents;
701 JUnitTestCase.assertEquals("AnchorElement", elements[0].propagatedType.name) ;
702 JUnitTestCase.assertEquals("AnchorElement", elements[1].propagatedType.name) ;
703 JUnitTestCase.assertEquals("BodyElement", elements[2].propagatedType.name);
704 JUnitTestCase.assertEquals("ButtonElement", elements[3].propagatedType.name) ;
705 JUnitTestCase.assertEquals("DivElement", elements[4].propagatedType.name);
706 JUnitTestCase.assertEquals("InputElement", elements[5].propagatedType.name);
707 JUnitTestCase.assertEquals("SelectElement", elements[6].propagatedType.name) ;
708 JUnitTestCase.assertEquals("DivElement", elements[7].propagatedType.name);
709 JUnitTestCase.assertEquals("Element", elements[8].propagatedType.name);
710 JUnitTestCase.assertEquals("Element", elements[9].propagatedType.name);
711 JUnitTestCase.assertEquals("Element", elements[10].propagatedType.name);
712 }
713
714 /**
715 * @param code the code that assigns the value to the variable "v", no matter how. We check that
716 * "v" has expected static and propagated type.
717 */
718 void check_propagatedReturnType(String code, Type2 expectedStaticType, Type2 e xpectedPropagatedType) {
719 Source source = addSource(code);
720 LibraryElement library = resolve(source);
721 assertNoErrors(source);
722 verify([source]);
723 CompilationUnit unit = resolveCompilationUnit(source, library);
724 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v = ", Si mpleIdentifier);
725 JUnitTestCase.assertSame(expectedStaticType, identifier.staticType);
726 JUnitTestCase.assertSame(expectedPropagatedType, identifier.propagatedType);
727 }
728 static dartSuite() {
729 _ut.group('TypePropagationTest', () {
730 _ut.test('test_Future_then', () {
731 final __test = new TypePropagationTest();
732 runJUnitTest(__test, __test.test_Future_then);
733 });
734 _ut.test('test_as', () {
735 final __test = new TypePropagationTest();
736 runJUnitTest(__test, __test.test_as);
737 });
738 _ut.test('test_assert', () {
739 final __test = new TypePropagationTest();
740 runJUnitTest(__test, __test.test_assert);
741 });
742 _ut.test('test_assignment', () {
743 final __test = new TypePropagationTest();
744 runJUnitTest(__test, __test.test_assignment);
745 });
746 _ut.test('test_assignment_afterInitializer', () {
747 final __test = new TypePropagationTest();
748 runJUnitTest(__test, __test.test_assignment_afterInitializer);
749 });
750 _ut.test('test_forEach', () {
751 final __test = new TypePropagationTest();
752 runJUnitTest(__test, __test.test_forEach);
753 });
754 _ut.test('test_functionExpression_asInvocationArgument', () {
755 final __test = new TypePropagationTest();
756 runJUnitTest(__test, __test.test_functionExpression_asInvocationArgument );
757 });
758 _ut.test('test_functionExpression_asInvocationArgument_fromInferredInvocat ion', () {
759 final __test = new TypePropagationTest();
760 runJUnitTest(__test, __test.test_functionExpression_asInvocationArgument _fromInferredInvocation);
761 });
762 _ut.test('test_functionExpression_asInvocationArgument_keepIfLessSpecific' , () {
763 final __test = new TypePropagationTest();
764 runJUnitTest(__test, __test.test_functionExpression_asInvocationArgument _keepIfLessSpecific);
765 });
766 _ut.test('test_functionExpression_asInvocationArgument_replaceIfMoreSpecif ic', () {
767 final __test = new TypePropagationTest();
768 runJUnitTest(__test, __test.test_functionExpression_asInvocationArgument _replaceIfMoreSpecific);
769 });
770 _ut.test('test_initializer', () {
771 final __test = new TypePropagationTest();
772 runJUnitTest(__test, __test.test_initializer);
773 });
774 _ut.test('test_initializer_dereference', () {
775 final __test = new TypePropagationTest();
776 runJUnitTest(__test, __test.test_initializer_dereference);
777 });
778 _ut.test('test_isNot_conditional', () {
779 final __test = new TypePropagationTest();
780 runJUnitTest(__test, __test.test_isNot_conditional);
781 });
782 _ut.test('test_isNot_if', () {
783 final __test = new TypePropagationTest();
784 runJUnitTest(__test, __test.test_isNot_if);
785 });
786 _ut.test('test_isNot_if_logicalOr', () {
787 final __test = new TypePropagationTest();
788 runJUnitTest(__test, __test.test_isNot_if_logicalOr);
789 });
790 _ut.test('test_isNot_postConditional', () {
791 final __test = new TypePropagationTest();
792 runJUnitTest(__test, __test.test_isNot_postConditional);
793 });
794 _ut.test('test_isNot_postIf', () {
795 final __test = new TypePropagationTest();
796 runJUnitTest(__test, __test.test_isNot_postIf);
797 });
798 _ut.test('test_is_conditional', () {
799 final __test = new TypePropagationTest();
800 runJUnitTest(__test, __test.test_is_conditional);
801 });
802 _ut.test('test_is_if', () {
803 final __test = new TypePropagationTest();
804 runJUnitTest(__test, __test.test_is_if);
805 });
806 _ut.test('test_is_if_lessSpecific', () {
807 final __test = new TypePropagationTest();
808 runJUnitTest(__test, __test.test_is_if_lessSpecific);
809 });
810 _ut.test('test_is_if_logicalAnd', () {
811 final __test = new TypePropagationTest();
812 runJUnitTest(__test, __test.test_is_if_logicalAnd);
813 });
814 _ut.test('test_is_postConditional', () {
815 final __test = new TypePropagationTest();
816 runJUnitTest(__test, __test.test_is_postConditional);
817 });
818 _ut.test('test_is_postIf', () {
819 final __test = new TypePropagationTest();
820 runJUnitTest(__test, __test.test_is_postIf);
821 });
822 _ut.test('test_is_subclass', () {
823 final __test = new TypePropagationTest();
824 runJUnitTest(__test, __test.test_is_subclass);
825 });
826 _ut.test('test_is_while', () {
827 final __test = new TypePropagationTest();
828 runJUnitTest(__test, __test.test_is_while);
829 });
830 _ut.test('test_listLiteral_different', () {
831 final __test = new TypePropagationTest();
832 runJUnitTest(__test, __test.test_listLiteral_different);
833 });
834 _ut.test('test_listLiteral_same', () {
835 final __test = new TypePropagationTest();
836 runJUnitTest(__test, __test.test_listLiteral_same);
837 });
838 _ut.test('test_mapLiteral_different', () {
839 final __test = new TypePropagationTest();
840 runJUnitTest(__test, __test.test_mapLiteral_different);
841 });
842 _ut.test('test_mapLiteral_same', () {
843 final __test = new TypePropagationTest();
844 runJUnitTest(__test, __test.test_mapLiteral_same);
845 });
846 _ut.test('test_propagatedReturnType_function_hasReturnType_returnsNull', ( ) {
847 final __test = new TypePropagationTest();
848 runJUnitTest(__test, __test.test_propagatedReturnType_function_hasReturn Type_returnsNull);
849 });
850 _ut.test('test_propagatedReturnType_function_lessSpecificStaticReturnType' , () {
851 final __test = new TypePropagationTest();
852 runJUnitTest(__test, __test.test_propagatedReturnType_function_lessSpeci ficStaticReturnType);
853 });
854 _ut.test('test_propagatedReturnType_function_moreSpecificStaticReturnType' , () {
855 final __test = new TypePropagationTest();
856 runJUnitTest(__test, __test.test_propagatedReturnType_function_moreSpeci ficStaticReturnType);
857 });
858 _ut.test('test_propagatedReturnType_function_noReturnTypeName_blockBody_mu ltipleReturns', () {
859 final __test = new TypePropagationTest();
860 runJUnitTest(__test, __test.test_propagatedReturnType_function_noReturnT ypeName_blockBody_multipleReturns);
861 });
862 _ut.test('test_propagatedReturnType_function_noReturnTypeName_blockBody_on eReturn', () {
863 final __test = new TypePropagationTest();
864 runJUnitTest(__test, __test.test_propagatedReturnType_function_noReturnT ypeName_blockBody_oneReturn);
865 });
866 _ut.test('test_propagatedReturnType_function_noReturnTypeName_expressionBo dy', () {
867 final __test = new TypePropagationTest();
868 runJUnitTest(__test, __test.test_propagatedReturnType_function_noReturnT ypeName_expressionBody);
869 });
870 _ut.test('test_propagatedReturnType_localFunction', () {
871 final __test = new TypePropagationTest();
872 runJUnitTest(__test, __test.test_propagatedReturnType_localFunction);
873 });
874 _ut.test('test_query', () {
875 final __test = new TypePropagationTest();
876 runJUnitTest(__test, __test.test_query);
877 });
878 });
879 }
880 }
881 class NonErrorResolverTest extends ResolverTestCase {
882 void test_ambiguousExport() {
883 Source source = addSource(EngineTestCase.createSource([
884 "library L;",
885 "export 'lib1.dart';",
886 "export 'lib2.dart';"]));
887 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s M {}"]));
888 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
889 resolve(source);
890 assertNoErrors(source);
891 verify([source]);
892 }
893 void test_ambiguousExport_combinators_hide() {
894 Source source = addSource(EngineTestCase.createSource([
895 "library L;",
896 "export 'lib1.dart';",
897 "export 'lib2.dart' hide B;"]));
898 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class A {}", "class B {}"]));
899 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class B {}", "class C {}"]));
900 resolve(source);
901 assertNoErrors(source);
902 verify([source]);
903 }
904 void test_ambiguousExport_combinators_show() {
905 Source source = addSource(EngineTestCase.createSource([
906 "library L;",
907 "export 'lib1.dart';",
908 "export 'lib2.dart' show C;"]));
909 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class A {}", "class B {}"]));
910 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class B {}", "class C {}"]));
911 resolve(source);
912 assertNoErrors(source);
913 verify([source]);
914 }
915 void test_argumentDefinitionTestNonParameter_formalParameter() {
916 Source source = addSource(EngineTestCase.createSource(["f(var v) {", " retu rn ?v;", "}"]));
917 resolve(source);
918 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]);
919 verify([source]);
920 }
921 void test_argumentDefinitionTestNonParameter_namedParameter() {
922 Source source = addSource(EngineTestCase.createSource(["f({var v : 0}) {", " return ?v;", "}"]));
923 resolve(source);
924 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]);
925 verify([source]);
926 }
927 void test_argumentDefinitionTestNonParameter_optionalParameter() {
928 Source source = addSource(EngineTestCase.createSource(["f([var v]) {", " re turn ?v;", "}"]));
929 resolve(source);
930 assertErrors(source, [ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST]);
931 verify([source]);
932 }
933 void test_argumentTypeNotAssignable_classWithCall_Function() {
934 Source source = addSource(EngineTestCase.createSource([
935 " caller(Function callee) {",
936 " callee();",
937 " }",
938 "",
939 " class CallMeBack {",
940 " call() => 0;",
941 " }",
942 "",
943 " main() {",
944 " caller(new CallMeBack());",
945 " }"]));
946 resolve(source);
947 assertNoErrors(source);
948 verify([source]);
949 }
950 void test_argumentTypeNotAssignable_fieldFormalParameterElement_member() {
951 Source source = addSource(EngineTestCase.createSource([
952 "class ObjectSink<T> {",
953 " void sink(T object) {",
954 " new TimestampedObject<T>(object);",
955 " }",
956 "}",
957 "class TimestampedObject<E> {",
958 " E object2;",
959 " TimestampedObject(this.object2);",
960 "}"]));
961 resolve(source);
962 assertNoErrors(source);
963 verify([source]);
964 }
965 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() {
966 Source source = addSource(EngineTestCase.createSource([
967 "class A<K> {",
968 " m(f(K k), K v) {",
969 " f(v);",
970 " }",
971 "}"]));
972 resolve(source);
973 assertNoErrors(source);
974 verify([source]);
975 }
976 void test_argumentTypeNotAssignable_invocation_typedef_generic() {
977 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);", "f(A<int> a) {", " a(1);", "}"]));
978 resolve(source);
979 assertNoErrors(source);
980 verify([source]);
981 }
982 void test_argumentTypeNotAssignable_Object_Function() {
983 Source source = addSource(EngineTestCase.createSource([
984 "main() {",
985 " process(() {});",
986 "}",
987 "process(Object x) {}"]));
988 resolve(source);
989 assertNoErrors(source);
990 verify([source]);
991 }
992 void test_argumentTypeNotAssignable_typedef_local() {
993 Source source = addSource(EngineTestCase.createSource([
994 "typedef A(int p1, String p2);",
995 "A getA() => null;",
996 "f() {",
997 " A a = getA();",
998 " a(1, '2');",
999 "}"]));
1000 resolve(source);
1001 assertNoErrors(source);
1002 verify([source]);
1003 }
1004 void test_argumentTypeNotAssignable_typedef_parameter() {
1005 Source source = addSource(EngineTestCase.createSource([
1006 "typedef A(int p1, String p2);",
1007 "f(A a) {",
1008 " a(1, '2');",
1009 "}"]));
1010 resolve(source);
1011 assertNoErrors(source);
1012 verify([source]);
1013 }
1014 void test_assignmentToFinal_prefixNegate() {
1015 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " -x;", "}"]));
1016 resolve(source);
1017 assertNoErrors(source);
1018 verify([source]);
1019 }
1020 void test_assignmentToFinals_importWithPrefix() {
1021 Source source = addSource(EngineTestCase.createSource([
1022 "library lib;",
1023 "import 'lib1.dart' as foo;",
1024 "main() {",
1025 " foo.x = true;",
1026 "}"]));
1027 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "bool x = false;"]));
1028 resolve(source);
1029 assertNoErrors(source);
1030 verify([source]);
1031 }
1032 void test_breakWithoutLabelInSwitch() {
1033 Source source = addSource(EngineTestCase.createSource([
1034 "class A {",
1035 " void m(int i) {",
1036 " switch (i) {",
1037 " case 0:",
1038 " break;",
1039 " }",
1040 " }",
1041 "}"]));
1042 resolve(source);
1043 assertNoErrors(source);
1044 verify([source]);
1045 }
1046 void test_builtInIdentifierAsType_dynamic() {
1047 Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x ;", "}"]));
1048 resolve(source);
1049 assertNoErrors(source);
1050 verify([source]);
1051 }
1052 void test_caseBlockNotTerminated() {
1053 Source source = addSource(EngineTestCase.createSource([
1054 "f(int p) {",
1055 " for (int i = 0; i < 10; i++) {",
1056 " switch (p) {",
1057 " case 0:",
1058 " break;",
1059 " case 1:",
1060 " continue;",
1061 " case 2:",
1062 " return;",
1063 " case 3:",
1064 " throw new Object();",
1065 " case 4:",
1066 " case 5:",
1067 " return;",
1068 " case 6:",
1069 " default:",
1070 " return;",
1071 " }",
1072 " }",
1073 "}"]));
1074 resolve(source);
1075 assertNoErrors(source);
1076 verify([source]);
1077 }
1078 void test_caseBlockNotTerminated_lastCase() {
1079 Source source = addSource(EngineTestCase.createSource([
1080 "f(int p) {",
1081 " switch (p) {",
1082 " case 0:",
1083 " p = p + 1;",
1084 " }",
1085 "}"]));
1086 resolve(source);
1087 assertNoErrors(source);
1088 verify([source]);
1089 }
1090 void test_caseExpressionTypeImplementsEquals_int() {
1091 Source source = addSource(EngineTestCase.createSource([
1092 "f(int i) {",
1093 " switch(i) {",
1094 " case(1) : return 1;",
1095 " default: return 0;",
1096 " }",
1097 "}"]));
1098 resolve(source);
1099 assertNoErrors(source);
1100 verify([source]);
1101 }
1102 void test_caseExpressionTypeImplementsEquals_Object() {
1103 Source source = addSource(EngineTestCase.createSource([
1104 "class IntWrapper {",
1105 " final int value;",
1106 " const IntWrapper(this.value);",
1107 "}",
1108 "",
1109 "f(IntWrapper intWrapper) {",
1110 " switch(intWrapper) {",
1111 " case(const IntWrapper(1)) : return 1;",
1112 " default: return 0;",
1113 " }",
1114 "}"]));
1115 resolve(source);
1116 assertNoErrors(source);
1117 verify([source]);
1118 }
1119 void test_caseExpressionTypeImplementsEquals_String() {
1120 Source source = addSource(EngineTestCase.createSource([
1121 "f(String s) {",
1122 " switch(s) {",
1123 " case('1') : return 1;",
1124 " default: return 0;",
1125 " }",
1126 "}"]));
1127 resolve(source);
1128 assertNoErrors(source);
1129 verify([source]);
1130 }
1131 void test_concreteClassWithAbstractMember() {
1132 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", "}"]));
1133 resolve(source);
1134 assertNoErrors(source);
1135 verify([source]);
1136 }
1137 void test_conflictingInstanceGetterAndSuperclassMember_instance() {
1138 Source source = addSource(EngineTestCase.createSource([
1139 "class A {",
1140 " get v => 0;",
1141 "}",
1142 "class B extends A {",
1143 " get v => 1;",
1144 "}"]));
1145 resolve(source);
1146 assertNoErrors(source);
1147 verify([source]);
1148 }
1149 void test_conflictingStaticGetterAndInstanceSetter_thisClass() {
1150 Source source = addSource(EngineTestCase.createSource([
1151 "class A {",
1152 " static get x => 0;",
1153 " static set x(int p) {}",
1154 "}"]));
1155 resolve(source);
1156 assertNoErrors(source);
1157 verify([source]);
1158 }
1159 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() {
1160 Source source = addSource(EngineTestCase.createSource([
1161 "class A {",
1162 " static x() {}",
1163 " static set x(int p) {}",
1164 "}"]));
1165 resolve(source);
1166 assertNoErrors(source);
1167 verify([source]);
1168 }
1169 void test_constConstructorWithNonConstSuper_redirectingFactory() {
1170 Source source = addSource(EngineTestCase.createSource([
1171 "class A {",
1172 " A();",
1173 "}",
1174 "class B implements C {",
1175 " const B();",
1176 "}",
1177 "class C extends A {",
1178 " const factory C() = B;",
1179 "}"]));
1180 resolve(source);
1181 assertNoErrors(source);
1182 verify([source]);
1183 }
1184 void test_constConstructorWithNonFinalField_finalInstanceVar() {
1185 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " const A();", "}"]));
1186 resolve(source);
1187 assertNoErrors(source);
1188 verify([source]);
1189 }
1190 void test_constConstructorWithNonFinalField_mixin() {
1191 Source source = addSource(EngineTestCase.createSource([
1192 "class A {",
1193 " a() {}",
1194 "}",
1195 "class B extends Object with A {",
1196 " const B();",
1197 "}"]));
1198 resolve(source);
1199 assertNoErrors(source);
1200 verify([source]);
1201 }
1202 void test_constConstructorWithNonFinalField_static() {
1203 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " const A();", "}"]));
1204 resolve(source);
1205 assertNoErrors(source);
1206 verify([source]);
1207 }
1208 void test_constConstructorWithNonFinalField_syntheticField() {
1209 Source source = addSource(EngineTestCase.createSource([
1210 "class A {",
1211 " const A();",
1212 " set x(value) {}",
1213 " get x {return 0;}",
1214 "}"]));
1215 resolve(source);
1216 assertNoErrors(source);
1217 verify([source]);
1218 }
1219 void test_constEval_propertyExtraction_fieldStatic_targetType() {
1220 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons t PI = 3.14;"]));
1221 Source source = addSource(EngineTestCase.createSource(["import 'math.dart' a s math;", "const C = math.PI;"]));
1222 resolve(source);
1223 assertNoErrors(source);
1224 verify([source]);
1225 }
1226 void test_constEval_propertyExtraction_methodStatic_targetType() {
1227 Source source = addSource(EngineTestCase.createSource([
1228 "class A {",
1229 " const A();",
1230 " static m() {}",
1231 "}",
1232 "const C = A.m;"]));
1233 resolve(source);
1234 assertNoErrors(source);
1235 verify([source]);
1236 }
1237 void test_constEval_symbol() {
1238 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons t PI = 3.14;"]));
1239 Source source = addSource(EngineTestCase.createSource(["const C = #foo;", "f oo() {}"]));
1240 resolve(source);
1241 assertNoErrors(source);
1242 verify([source]);
1243 }
1244 void test_constEvalTypeBoolNumString_equal() {
1245 Source source = addSource(EngineTestCase.createSource([
1246 "class A {",
1247 " const A();",
1248 "}",
1249 "class B {",
1250 " final v;",
1251 " const B.a1(bool p) : v = p == true;",
1252 " const B.a2(bool p) : v = p == false;",
1253 " const B.a3(bool p) : v = p == 0;",
1254 " const B.a4(bool p) : v = p == 0.0;",
1255 " const B.a5(bool p) : v = p == '';",
1256 " const B.b1(int p) : v = p == true;",
1257 " const B.b2(int p) : v = p == false;",
1258 " const B.b3(int p) : v = p == 0;",
1259 " const B.b4(int p) : v = p == 0.0;",
1260 " const B.b5(int p) : v = p == '';",
1261 " const B.c1(String p) : v = p == true;",
1262 " const B.c2(String p) : v = p == false;",
1263 " const B.c3(String p) : v = p == 0;",
1264 " const B.c4(String p) : v = p == 0.0;",
1265 " const B.c5(String p) : v = p == '';",
1266 " const B.n1(num p) : v = p == null;",
1267 " const B.n2(num p) : v = null == p;",
1268 "}"]));
1269 resolve(source);
1270 assertNoErrors(source);
1271 }
1272 void test_constEvalTypeBoolNumString_notEqual() {
1273 Source source = addSource(EngineTestCase.createSource([
1274 "class A {",
1275 " const A();",
1276 "}",
1277 "class B {",
1278 " final v;",
1279 " const B.a1(bool p) : v = p != true;",
1280 " const B.a2(bool p) : v = p != false;",
1281 " const B.a3(bool p) : v = p != 0;",
1282 " const B.a4(bool p) : v = p != 0.0;",
1283 " const B.a5(bool p) : v = p != '';",
1284 " const B.b1(int p) : v = p != true;",
1285 " const B.b2(int p) : v = p != false;",
1286 " const B.b3(int p) : v = p != 0;",
1287 " const B.b4(int p) : v = p != 0.0;",
1288 " const B.b5(int p) : v = p != '';",
1289 " const B.c1(String p) : v = p != true;",
1290 " const B.c2(String p) : v = p != false;",
1291 " const B.c3(String p) : v = p != 0;",
1292 " const B.c4(String p) : v = p != 0.0;",
1293 " const B.c5(String p) : v = p != '';",
1294 " const B.n1(num p) : v = p != null;",
1295 " const B.n2(num p) : v = null != p;",
1296 "}"]));
1297 resolve(source);
1298 assertNoErrors(source);
1299 verify([source]);
1300 }
1301 void test_constNotInitialized_field() {
1302 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c const int x = 0;", "}"]));
1303 resolve(source);
1304 assertNoErrors(source);
1305 verify([source]);
1306 }
1307 void test_constNotInitialized_local() {
1308 Source source = addSource(EngineTestCase.createSource(["main() {", " const int x = 0;", "}"]));
1309 resolve(source);
1310 assertNoErrors(source);
1311 verify([source]);
1312 }
1313 void test_constructorDeclaration_scope_signature() {
1314 Source source = addSource(EngineTestCase.createSource([
1315 "const app = 0;",
1316 "class A {",
1317 " A(@app int app) {}",
1318 "}"]));
1319 resolve(source);
1320 assertNoErrors(source);
1321 verify([source]);
1322 }
1323 void test_constWithNonConstantArgument_literals() {
1324 Source source = addSource(EngineTestCase.createSource([
1325 "class A {",
1326 " const A(a, b, c, d);",
1327 "}",
1328 "f() { return const A(true, 0, 1.0, '2'); }"]));
1329 resolve(source);
1330 assertNoErrors(source);
1331 verify([source]);
1332 }
1333 void test_constWithTypeParameters_direct() {
1334 Source source = addSource(EngineTestCase.createSource([
1335 "class A<T> {",
1336 " static const V = const A<int>();",
1337 " const A();",
1338 "}"]));
1339 resolve(source);
1340 assertNoErrors(source);
1341 verify([source]);
1342 }
1343 void test_constWithUndefinedConstructor() {
1344 Source source = addSource(EngineTestCase.createSource([
1345 "class A {",
1346 " const A.name();",
1347 "}",
1348 "f() {",
1349 " return const A.name();",
1350 "}"]));
1351 resolve(source);
1352 assertNoErrors(source);
1353 verify([source]);
1354 }
1355 void test_constWithUndefinedConstructorDefault() {
1356 Source source = addSource(EngineTestCase.createSource([
1357 "class A {",
1358 " const A();",
1359 "}",
1360 "f() {",
1361 " return const A();",
1362 "}"]));
1363 resolve(source);
1364 assertNoErrors(source);
1365 verify([source]);
1366 }
1367 void test_defaultValueInFunctionTypeAlias() {
1368 Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"]));
1369 resolve(source);
1370 assertNoErrors(source);
1371 verify([source]);
1372 }
1373 void test_defaultValueInFunctionTypedParameter_named() {
1374 Source source = addSource(EngineTestCase.createSource(["f(g({p})) {}"]));
1375 resolve(source);
1376 assertNoErrors(source);
1377 verify([source]);
1378 }
1379 void test_defaultValueInFunctionTypedParameter_optional() {
1380 Source source = addSource(EngineTestCase.createSource(["f(g([p])) {}"]));
1381 resolve(source);
1382 assertNoErrors(source);
1383 verify([source]);
1384 }
1385 void test_duplicateDefinition_emptyName() {
1386 Source source = addSource(EngineTestCase.createSource([
1387 "Map _globalMap = {",
1388 " 'a' : () {},",
1389 " 'b' : () {}",
1390 "};"]));
1391 resolve(source);
1392 assertNoErrors(source);
1393 verify([source]);
1394 }
1395 void test_duplicateDefinition_getter() {
1396 Source source = addSource(EngineTestCase.createSource(["bool get a => true;" ]));
1397 resolve(source);
1398 assertNoErrors(source);
1399 verify([source]);
1400 }
1401 void test_dynamicIdentifier() {
1402 Source source = addSource(EngineTestCase.createSource(["main() {", " var v = dynamic;", "}"]));
1403 resolve(source);
1404 assertNoErrors(source);
1405 verify([source]);
1406 }
1407 void test_expectedOneListTypeArgument() {
1408 Source source = addSource(EngineTestCase.createSource(["main() {", " <int> [];", "}"]));
1409 resolve(source);
1410 assertNoErrors(source);
1411 verify([source]);
1412 }
1413 void test_expectedTwoMapTypeArguments() {
1414 Source source = addSource(EngineTestCase.createSource(["main() {", " <int, int> {};", "}"]));
1415 resolve(source);
1416 assertNoErrors(source);
1417 verify([source]);
1418 }
1419 void test_exportOfNonLibrary_libraryDeclared() {
1420 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
1421 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
1422 resolve(source);
1423 assertNoErrors(source);
1424 verify([source]);
1425 }
1426 void test_exportOfNonLibrary_libraryNotDeclared() {
1427 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
1428 addSource2("/lib1.dart", EngineTestCase.createSource([""]));
1429 resolve(source);
1430 assertNoErrors(source);
1431 verify([source]);
1432 }
1433 void test_extraPositionalArguments_function() {
1434 Source source = addSource(EngineTestCase.createSource(["f(p1, p2) {}", "main () {", " f(1, 2);", "}"]));
1435 resolve(source);
1436 assertNoErrors(source);
1437 verify([source]);
1438 }
1439 void test_extraPositionalArguments_Function() {
1440 Source source = addSource(EngineTestCase.createSource(["f(Function a) {", " a(1, 2);", "}"]));
1441 resolve(source);
1442 assertNoErrors(source);
1443 verify([source]);
1444 }
1445 void test_extraPositionalArguments_typedef_local() {
1446 Source source = addSource(EngineTestCase.createSource([
1447 "typedef A(p1, p2);",
1448 "A getA() => null;",
1449 "f() {",
1450 " A a = getA();",
1451 " a(1, 2);",
1452 "}"]));
1453 resolve(source);
1454 assertNoErrors(source);
1455 verify([source]);
1456 }
1457 void test_extraPositionalArguments_typedef_parameter() {
1458 Source source = addSource(EngineTestCase.createSource(["typedef A(p1, p2);", "f(A a) {", " a(1, 2);", "}"]));
1459 resolve(source);
1460 assertNoErrors(source);
1461 verify([source]);
1462 }
1463 void test_fieldInitializedByMultipleInitializers() {
1464 Source source = addSource(EngineTestCase.createSource([
1465 "class A {",
1466 " int x;",
1467 " int y;",
1468 " A() : x = 0, y = 0 {}",
1469 "}"]));
1470 resolve(source);
1471 assertNoErrors(source);
1472 verify([source]);
1473 }
1474 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() {
1475 Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 0;", " A() : x = 1 {}", "}"]));
1476 resolve(source);
1477 assertNoErrors(source);
1478 verify([source]);
1479 }
1480 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() {
1481 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 1 {}", "}"]));
1482 resolve(source);
1483 assertNoErrors(source);
1484 verify([source]);
1485 }
1486 void test_fieldInitializerOutsideConstructor() {
1487 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"]));
1488 resolve(source);
1489 assertNoErrors(source);
1490 verify([source]);
1491 }
1492 void test_fieldInitializerOutsideConstructor_defaultParameters() {
1493 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A([this.x]) {}", "}"]));
1494 resolve(source);
1495 assertNoErrors(source);
1496 verify([source]);
1497 }
1498 void test_fieldInitializerRedirectingConstructor_super() {
1499 Source source = addSource(EngineTestCase.createSource([
1500 "class A {",
1501 " A() {}",
1502 "}",
1503 "class B extends A {",
1504 " int x;",
1505 " B(this.x) : super();",
1506 "}"]));
1507 resolve(source);
1508 assertNoErrors(source);
1509 verify([source]);
1510 }
1511 void test_finalInitializedInDeclarationAndConstructor_initializer() {
1512 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 1 {}", "}"]));
1513 resolve(source);
1514 assertNoErrors(source);
1515 verify([source]);
1516 }
1517 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
1518 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) {}", "}"]));
1519 resolve(source);
1520 assertNoErrors(source);
1521 verify([source]);
1522 }
1523 void test_finalNotInitialized_atDeclaration() {
1524 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"]));
1525 resolve(source);
1526 assertNoErrors(source);
1527 verify([source]);
1528 }
1529 void test_finalNotInitialized_fieldFormal() {
1530 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"]));
1531 resolve(source);
1532 assertNoErrors(source);
1533 verify([source]);
1534 }
1535 void test_finalNotInitialized_functionTypedFieldFormal() {
1536 Source source = addSource(EngineTestCase.createSource([
1537 "class A {",
1538 " final Function x;",
1539 " A(int this.x(int p)) {}",
1540 "}"]));
1541 resolve(source);
1542 assertNoErrors(source);
1543 verify([source]);
1544 }
1545 void test_finalNotInitialized_hasNativeClause_hasConstructor() {
1546 Source source = addSource(EngineTestCase.createSource([
1547 "class A native 'something' {",
1548 " final int x;",
1549 " A() {}",
1550 "}"]));
1551 resolve(source);
1552 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
1553 verify([source]);
1554 }
1555 void test_finalNotInitialized_hasNativeClause_noConstructor() {
1556 Source source = addSource(EngineTestCase.createSource(["class A native 'some thing' {", " final int x;", "}"]));
1557 resolve(source);
1558 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
1559 verify([source]);
1560 }
1561 void test_finalNotInitialized_initializer() {
1562 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 0 {}", "}"]));
1563 resolve(source);
1564 assertNoErrors(source);
1565 verify([source]);
1566 }
1567 void test_finalNotInitialized_redirectingConstructor() {
1568 Source source = addSource(EngineTestCase.createSource([
1569 "class A {",
1570 " final int x;",
1571 " A(this.x);",
1572 " A.named() : this (42);",
1573 "}"]));
1574 resolve(source);
1575 assertNoErrors(source);
1576 verify([source]);
1577 }
1578 void test_functionDeclaration_scope_returnType() {
1579 Source source = addSource(EngineTestCase.createSource(["int f(int) {}"]));
1580 resolve(source);
1581 assertNoErrors(source);
1582 verify([source]);
1583 }
1584 void test_functionDeclaration_scope_signature() {
1585 Source source = addSource(EngineTestCase.createSource(["const app = 0;", "f( @app int app) {}"]));
1586 resolve(source);
1587 assertNoErrors(source);
1588 verify([source]);
1589 }
1590 void test_functionTypeAlias_scope_returnType() {
1591 Source source = addSource(EngineTestCase.createSource(["typedef int f(int);" ]));
1592 resolve(source);
1593 assertNoErrors(source);
1594 verify([source]);
1595 }
1596 void test_functionTypeAlias_scope_signature() {
1597 Source source = addSource(EngineTestCase.createSource(["const app = 0;", "ty pedef int f(@app int app);"]));
1598 resolve(source);
1599 assertNoErrors(source);
1600 verify([source]);
1601 }
1602 void test_functionWithoutCall() {
1603 Source source = addSource(EngineTestCase.createSource([
1604 "abstract class A implements Function {",
1605 "}",
1606 "class B implements A {",
1607 " void call() {}",
1608 "}",
1609 "class C extends A {",
1610 " void call() {}",
1611 "}",
1612 "class D extends C {",
1613 "}"]));
1614 resolve(source);
1615 assertNoErrors(source);
1616 verify([source]);
1617 }
1618 void test_implicitThisReferenceInInitializer_constructorName() {
1619 Source source = addSource(EngineTestCase.createSource([
1620 "class A {",
1621 " A.named() {}",
1622 "}",
1623 "class B {",
1624 " var v;",
1625 " B() : v = new A.named();",
1626 "}"]));
1627 resolve(source);
1628 assertNoErrors(source);
1629 verify([source]);
1630 }
1631 void test_implicitThisReferenceInInitializer_prefixedIdentifier() {
1632 Source source = addSource(EngineTestCase.createSource([
1633 "class A {",
1634 " var f;",
1635 "}",
1636 "class B {",
1637 " var v;",
1638 " B(A a) : v = a.f;",
1639 "}"]));
1640 resolve(source);
1641 assertNoErrors(source);
1642 verify([source]);
1643 }
1644 void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() {
1645 Source source = addSource(EngineTestCase.createSource([
1646 "class A {",
1647 " f() {}",
1648 "}",
1649 "class B {",
1650 " var v;",
1651 " B() : v = new A().f();",
1652 "}"]));
1653 resolve(source);
1654 assertNoErrors(source);
1655 verify([source]);
1656 }
1657 void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() {
1658 Source source = addSource(EngineTestCase.createSource([
1659 "class A {",
1660 " var f;",
1661 "}",
1662 "class B {",
1663 " var v;",
1664 " B() : v = new A().f;",
1665 "}"]));
1666 resolve(source);
1667 assertNoErrors(source);
1668 verify([source]);
1669 }
1670 void test_implicitThisReferenceInInitializer_staticField_thisClass() {
1671 Source source = addSource(EngineTestCase.createSource([
1672 "class A {",
1673 " var v;",
1674 " A() : v = f;",
1675 " static var f;",
1676 "}"]));
1677 resolve(source);
1678 assertNoErrors(source);
1679 verify([source]);
1680 }
1681 void test_implicitThisReferenceInInitializer_staticGetter() {
1682 Source source = addSource(EngineTestCase.createSource([
1683 "class A {",
1684 " var v;",
1685 " A() : v = f;",
1686 " static get f => 42;",
1687 "}"]));
1688 resolve(source);
1689 assertNoErrors(source);
1690 verify([source]);
1691 }
1692 void test_implicitThisReferenceInInitializer_staticMethod() {
1693 Source source = addSource(EngineTestCase.createSource([
1694 "class A {",
1695 " var v;",
1696 " A() : v = f();",
1697 " static f() => 42;",
1698 "}"]));
1699 resolve(source);
1700 assertNoErrors(source);
1701 verify([source]);
1702 }
1703 void test_implicitThisReferenceInInitializer_topLevelField() {
1704 Source source = addSource(EngineTestCase.createSource([
1705 "class A {",
1706 " var v;",
1707 " A() : v = f;",
1708 "}",
1709 "var f = 42;"]));
1710 resolve(source);
1711 assertNoErrors(source);
1712 verify([source]);
1713 }
1714 void test_implicitThisReferenceInInitializer_topLevelFunction() {
1715 Source source = addSource(EngineTestCase.createSource([
1716 "class A {",
1717 " var v;",
1718 " A() : v = f();",
1719 "}",
1720 "f() => 42;"]));
1721 resolve(source);
1722 assertNoErrors(source);
1723 verify([source]);
1724 }
1725 void test_implicitThisReferenceInInitializer_topLevelGetter() {
1726 Source source = addSource(EngineTestCase.createSource([
1727 "class A {",
1728 " var v;",
1729 " A() : v = f;",
1730 "}",
1731 "get f => 42;"]));
1732 resolve(source);
1733 assertNoErrors(source);
1734 verify([source]);
1735 }
1736 void test_implicitThisReferenceInInitializer_typeParameter() {
1737 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va r v;", " A(p) : v = (p is T);", "}"]));
1738 resolve(source);
1739 assertNoErrors(source);
1740 verify([source]);
1741 }
1742 void test_importDuplicatedLibraryName() {
1743 Source source = addSource(EngineTestCase.createSource([
1744 "library test;",
1745 "import 'lib.dart';",
1746 "import 'lib.dart';"]));
1747 addSource2("/lib.dart", "library lib;");
1748 resolve(source);
1749 assertErrors(source, [
1750 HintCode.UNUSED_IMPORT,
1751 HintCode.UNUSED_IMPORT,
1752 HintCode.DUPLICATE_IMPORT]);
1753 verify([source]);
1754 }
1755 void test_importOfNonLibrary_libraryDeclared() {
1756 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';", "A a;"]));
1757 addSource2("/part.dart", EngineTestCase.createSource(["library lib1;", "clas s A {}"]));
1758 resolve(source);
1759 assertNoErrors(source);
1760 verify([source]);
1761 }
1762 void test_importOfNonLibrary_libraryNotDeclared() {
1763 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';", "A a;"]));
1764 addSource2("/part.dart", EngineTestCase.createSource(["class A {}"]));
1765 resolve(source);
1766 assertNoErrors(source);
1767 verify([source]);
1768 }
1769 void test_importPrefixes_withFirstLetterDifference() {
1770 Source source = addSource(EngineTestCase.createSource([
1771 "library L;",
1772 "import 'lib1.dart' as math;",
1773 "import 'lib2.dart' as path;",
1774 "main() {",
1775 " math.test1();",
1776 " path.test2();",
1777 "}"]));
1778 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "test 1() {}"]));
1779 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "test 2() {}"]));
1780 resolve(source);
1781 assertNoErrors(source);
1782 verify([source]);
1783 }
1784 void test_inconsistentCaseExpressionTypes() {
1785 Source source = addSource(EngineTestCase.createSource([
1786 "f(var p) {",
1787 " switch (p) {",
1788 " case 1:",
1789 " break;",
1790 " case 2:",
1791 " break;",
1792 " }",
1793 "}"]));
1794 resolve(source);
1795 assertNoErrors(source);
1796 verify([source]);
1797 }
1798 void test_inconsistentMethodInheritance_accessors_typeParameter2() {
1799 Source source = addSource(EngineTestCase.createSource([
1800 "abstract class A<E> {",
1801 " E get x {return 1;}",
1802 "}",
1803 "class B<E> {",
1804 " E get x {return 1;}",
1805 "}",
1806 "class C<E> extends A<E> implements B<E> {",
1807 "}"]));
1808 resolve(source);
1809 assertNoErrors(source);
1810 verify([source]);
1811 }
1812 void test_inconsistentMethodInheritance_accessors_typeParameters_diamond() {
1813 Source source = addSource(EngineTestCase.createSource([
1814 "abstract class F<E> extends B<E> {}",
1815 "class D<E> extends F<E> {",
1816 " external E get g;",
1817 "}",
1818 "abstract class C<E> {",
1819 " E get g;",
1820 "}",
1821 "abstract class B<E> implements C<E> {",
1822 " E get g { return null; }",
1823 "}",
1824 "class A<E> extends B<E> implements D<E> {",
1825 "}"]));
1826 resolve(source);
1827 assertNoErrors(source);
1828 verify([source]);
1829 }
1830 void test_inconsistentMethodInheritance_accessors_typeParameters1() {
1831 Source source = addSource(EngineTestCase.createSource([
1832 "abstract class A<E> {",
1833 " E get x;",
1834 "}",
1835 "abstract class B<E> {",
1836 " E get x;",
1837 "}",
1838 "class C<E> implements A<E>, B<E> {",
1839 " E get x => 1;",
1840 "}"]));
1841 resolve(source);
1842 assertNoErrors(source);
1843 verify([source]);
1844 }
1845 void test_inconsistentMethodInheritance_methods_typeParameter2() {
1846 Source source = addSource(EngineTestCase.createSource([
1847 "class A<E> {",
1848 " x(E e) {}",
1849 "}",
1850 "class B<E> {",
1851 " x(E e) {}",
1852 "}",
1853 "class C<E> extends A<E> implements B<E> {",
1854 " x(E e) {}",
1855 "}"]));
1856 resolve(source);
1857 assertNoErrors(source);
1858 verify([source]);
1859 }
1860 void test_inconsistentMethodInheritance_methods_typeParameters1() {
1861 Source source = addSource(EngineTestCase.createSource([
1862 "class A<E> {",
1863 " x(E e) {}",
1864 "}",
1865 "class B<E> {",
1866 " x(E e) {}",
1867 "}",
1868 "class C<E> implements A<E>, B<E> {",
1869 " x(E e) {}",
1870 "}"]));
1871 resolve(source);
1872 assertNoErrors(source);
1873 verify([source]);
1874 }
1875 void test_inconsistentMethodInheritance_simple() {
1876 Source source = addSource(EngineTestCase.createSource([
1877 "abstract class A {",
1878 " x();",
1879 "}",
1880 "abstract class B {",
1881 " x();",
1882 "}",
1883 "class C implements A, B {",
1884 " x() {}",
1885 "}"]));
1886 resolve(source);
1887 assertNoErrors(source);
1888 verify([source]);
1889 }
1890 void test_initializingFormalForNonExistantField() {
1891 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"]));
1892 resolve(source);
1893 assertNoErrors(source);
1894 verify([source]);
1895 }
1896 void test_instanceAccessToStaticMember_fromComment() {
1897 Source source = addSource(EngineTestCase.createSource([
1898 "class A {",
1899 " static m() {}",
1900 "}",
1901 "/// [A.m]",
1902 "main() {",
1903 "}"]));
1904 resolve(source);
1905 assertNoErrors(source);
1906 verify([source]);
1907 }
1908 void test_instanceAccessToStaticMember_topLevel() {
1909 Source source = addSource(EngineTestCase.createSource(["m() {}", "main() {", " m();", "}"]));
1910 resolve(source);
1911 assertNoErrors(source);
1912 verify([source]);
1913 }
1914 void test_instanceMemberAccessFromStatic_fromComment() {
1915 Source source = addSource(EngineTestCase.createSource([
1916 "class A {",
1917 " m() {}",
1918 " /// [m]",
1919 " static foo() {",
1920 " }",
1921 "}"]));
1922 resolve(source);
1923 assertNoErrors(source);
1924 verify([source]);
1925 }
1926 void test_instanceMethodNameCollidesWithSuperclassStatic_field() {
1927 Source source = addSource(EngineTestCase.createSource([
1928 "import 'lib.dart';",
1929 "class B extends A {",
1930 " _m() {}",
1931 "}"]));
1932 addSource2("/lib.dart", EngineTestCase.createSource(["library L;", "class A {", " static var _m;", "}"]));
1933 resolve(source);
1934 assertNoErrors(source);
1935 verify([source]);
1936 }
1937 void test_instanceMethodNameCollidesWithSuperclassStatic_method() {
1938 Source source = addSource(EngineTestCase.createSource([
1939 "import 'lib.dart';",
1940 "class B extends A {",
1941 " _m() {}",
1942 "}"]));
1943 addSource2("/lib.dart", EngineTestCase.createSource(["library L;", "class A {", " static _m() {}", "}"]));
1944 resolve(source);
1945 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]);
1946 verify([source]);
1947 }
1948 void test_invalidAnnotation_constantVariable() {
1949 Source source = addSource(EngineTestCase.createSource(["const C = 0;", "@C", "main() {", "}"]));
1950 resolve(source);
1951 assertNoErrors(source);
1952 verify([source]);
1953 }
1954 void test_invalidAnnotation_importWithPrefix_constantVariable() {
1955 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "const C = 0;"]));
1956 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as p;", "@p.C", "main() {", "}"]));
1957 resolve(source);
1958 assertNoErrors(source);
1959 verify([source]);
1960 }
1961 void test_invalidAnnotation_importWithPrefix_constConstructor() {
1962 addSource2("/lib.dart", EngineTestCase.createSource([
1963 "library lib;",
1964 "class A {",
1965 " const A.named(int p);",
1966 "}"]));
1967 Source source = addSource(EngineTestCase.createSource([
1968 "import 'lib.dart' as p;",
1969 "@p.A.named(42)",
1970 "main() {",
1971 "}"]));
1972 resolve(source);
1973 assertNoErrors(source);
1974 verify([source]);
1975 }
1976 void test_invalidAssignment() {
1977 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;", " var y;", " x = y;", "}"]));
1978 resolve(source);
1979 assertNoErrors(source);
1980 verify([source]);
1981 }
1982 void test_invalidAssignment_compoundAssignment() {
1983 Source source = addSource(EngineTestCase.createSource([
1984 "class byte {",
1985 " int _value;",
1986 " byte(this._value);",
1987 " byte operator +(int val) {}",
1988 "}",
1989 "",
1990 "void main() {",
1991 " byte b = new byte(52);",
1992 " b += 3;",
1993 "}"]));
1994 resolve(source);
1995 assertNoErrors(source);
1996 verify([source]);
1997 }
1998 void test_invalidAssignment_defaultValue_named() {
1999 Source source = addSource(EngineTestCase.createSource(["f({String x: '0'}) { ", "}"]));
2000 resolve(source);
2001 assertNoErrors(source);
2002 verify([source]);
2003 }
2004 void test_invalidAssignment_defaultValue_optional() {
2005 Source source = addSource(EngineTestCase.createSource(["f([String x = '0']) {", "}"]));
2006 resolve(source);
2007 assertNoErrors(source);
2008 verify([source]);
2009 }
2010 void test_invalidAssignment_toDynamic() {
2011 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g = () => 0;", "}"]));
2012 resolve(source);
2013 assertNoErrors(source);
2014 verify([source]);
2015 }
2016 void test_invalidFactoryNameNotAClass() {
2017 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}"]));
2018 resolve(source);
2019 assertNoErrors(source);
2020 verify([source]);
2021 }
2022 void test_invalidMethodOverrideNamedParamType() {
2023 Source source = addSource(EngineTestCase.createSource([
2024 "class A {",
2025 " m({int a}) {}",
2026 "}",
2027 "class B implements A {",
2028 " m({int a, int b}) {}",
2029 "}"]));
2030 resolve(source);
2031 assertNoErrors(source);
2032 verify([source]);
2033 }
2034 void test_invalidOverrideDifferentDefaultValues_named() {
2035 Source source = addSource(EngineTestCase.createSource([
2036 "class A {",
2037 " m({int p : 0}) {}",
2038 "}",
2039 "class B extends A {",
2040 " m({int p : 0}) {}",
2041 "}"]));
2042 resolve(source);
2043 assertNoErrors(source);
2044 verify([source]);
2045 }
2046 void test_invalidOverrideDifferentDefaultValues_positional() {
2047 Source source = addSource(EngineTestCase.createSource([
2048 "class A {",
2049 " m([int p = 0]) {}",
2050 "}",
2051 "class B extends A {",
2052 " m([int p = 0]) {}",
2053 "}"]));
2054 resolve(source);
2055 assertNoErrors(source);
2056 verify([source]);
2057 }
2058 void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() {
2059 Source source = addSource(EngineTestCase.createSource([
2060 "class A {",
2061 " m([int a = 0, String b = '0']) {}",
2062 "}",
2063 "class B extends A {",
2064 " m([int b = 0, String a = '0']) {}",
2065 "}"]));
2066 resolve(source);
2067 assertNoErrors(source);
2068 verify([source]);
2069 }
2070 void test_invalidOverrideNamed_unorderedNamedParameter() {
2071 Source source = addSource(EngineTestCase.createSource([
2072 "class A {",
2073 " m({a, b}) {}",
2074 "}",
2075 "class B extends A {",
2076 " m({b, a}) {}",
2077 "}"]));
2078 resolve(source);
2079 assertNoErrors(source);
2080 verify([source]);
2081 }
2082 void test_invalidOverrideRequired_less() {
2083 Source source = addSource(EngineTestCase.createSource([
2084 "class A {",
2085 " m(a, b) {}",
2086 "}",
2087 "class B extends A {",
2088 " m(a, [b]) {}",
2089 "}"]));
2090 resolve(source);
2091 assertNoErrors(source);
2092 verify([source]);
2093 }
2094 void test_invalidOverrideRequired_same() {
2095 Source source = addSource(EngineTestCase.createSource([
2096 "class A {",
2097 " m(a) {}",
2098 "}",
2099 "class B extends A {",
2100 " m(a) {}",
2101 "}"]));
2102 resolve(source);
2103 assertNoErrors(source);
2104 verify([source]);
2105 }
2106 void test_invalidOverrideReturnType_returnType_interface() {
2107 Source source = addSource2("/test.dart", EngineTestCase.createSource([
2108 "abstract class A {",
2109 " num m();",
2110 "}",
2111 "class B implements A {",
2112 " int m() { return 1; }",
2113 "}"]));
2114 resolve(source);
2115 assertNoErrors(source);
2116 verify([source]);
2117 }
2118 void test_invalidOverrideReturnType_returnType_interface2() {
2119 Source source = addSource2("/test.dart", EngineTestCase.createSource([
2120 "abstract class A {",
2121 " num m();",
2122 "}",
2123 "abstract class B implements A {",
2124 "}",
2125 "class C implements B {",
2126 " int m() { return 1; }",
2127 "}"]));
2128 resolve(source);
2129 assertNoErrors(source);
2130 verify([source]);
2131 }
2132 void test_invalidOverrideReturnType_returnType_mixin() {
2133 Source source = addSource2("/test.dart", EngineTestCase.createSource([
2134 "class A {",
2135 " num m() { return 0; }",
2136 "}",
2137 "class B extends Object with A {",
2138 " int m() { return 1; }",
2139 "}"]));
2140 resolve(source);
2141 assertNoErrors(source);
2142 verify([source]);
2143 }
2144 void test_invalidOverrideReturnType_returnType_parameterizedTypes() {
2145 Source source = addSource(EngineTestCase.createSource([
2146 "abstract class A<E> {",
2147 " List<E> m();",
2148 "}",
2149 "class B extends A<dynamic> {",
2150 " List<dynamic> m() { return new List<dynamic>(); }",
2151 "}"]));
2152 resolve(source);
2153 assertNoErrors(source);
2154 verify([source]);
2155 }
2156 void test_invalidOverrideReturnType_returnType_sameType() {
2157 Source source = addSource2("/test.dart", EngineTestCase.createSource([
2158 "class A {",
2159 " int m() { return 0; }",
2160 "}",
2161 "class B extends A {",
2162 " int m() { return 1; }",
2163 "}"]));
2164 resolve(source);
2165 assertNoErrors(source);
2166 verify([source]);
2167 }
2168 void test_invalidOverrideReturnType_returnType_superclass() {
2169 Source source = addSource2("/test.dart", EngineTestCase.createSource([
2170 "class A {",
2171 " num m() { return 0; }",
2172 "}",
2173 "class B extends A {",
2174 " int m() { return 1; }",
2175 "}"]));
2176 resolve(source);
2177 assertNoErrors(source);
2178 verify([source]);
2179 }
2180 void test_invalidOverrideReturnType_returnType_superclass2() {
2181 Source source = addSource2("/test.dart", EngineTestCase.createSource([
2182 "class A {",
2183 " num m() { return 0; }",
2184 "}",
2185 "class B extends A {",
2186 "}",
2187 "class C extends B {",
2188 " int m() { return 1; }",
2189 "}"]));
2190 resolve(source);
2191 assertNoErrors(source);
2192 verify([source]);
2193 }
2194 void test_invalidOverrideReturnType_returnType_void() {
2195 Source source = addSource(EngineTestCase.createSource([
2196 "class A {",
2197 " void m() {}",
2198 "}",
2199 "class B extends A {",
2200 " int m() {}",
2201 "}"]));
2202 resolve(source);
2203 assertNoErrors(source);
2204 verify([source]);
2205 }
2206 void test_invalidReferenceToThis_constructor() {
2207 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { ", " var v = this;", " }", "}"]));
2208 resolve(source);
2209 assertNoErrors(source);
2210 verify([source]);
2211 }
2212 void test_invalidReferenceToThis_instanceMethod() {
2213 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { ", " var v = this;", " }", "}"]));
2214 resolve(source);
2215 assertNoErrors(source);
2216 verify([source]);
2217 }
2218 void test_invalidTypeArgumentForKey() {
2219 Source source = addSource(EngineTestCase.createSource([
2220 "class A {",
2221 " m() {",
2222 " return const <int, int>{};",
2223 " }",
2224 "}"]));
2225 resolve(source);
2226 assertNoErrors(source);
2227 verify([source]);
2228 }
2229 void test_invalidTypeArgumentInConstList() {
2230 Source source = addSource(EngineTestCase.createSource([
2231 "class A<E> {",
2232 " m() {",
2233 " return <E>[];",
2234 " }",
2235 "}"]));
2236 resolve(source);
2237 assertNoErrors(source);
2238 verify([source]);
2239 }
2240 void test_invalidTypeArgumentInConstMap() {
2241 Source source = addSource(EngineTestCase.createSource([
2242 "class A<E> {",
2243 " m() {",
2244 " return <String, E>{};",
2245 " }",
2246 "}"]));
2247 resolve(source);
2248 assertNoErrors(source);
2249 verify([source]);
2250 }
2251 void test_invocationOfNonFunction_dynamic() {
2252 Source source = addSource(EngineTestCase.createSource([
2253 "class A {",
2254 " var f;",
2255 "}",
2256 "class B extends A {",
2257 " g() {",
2258 " f();",
2259 " }",
2260 "}"]));
2261 resolve(source);
2262 assertNoErrors(source);
2263 verify([source]);
2264 }
2265 void test_invocationOfNonFunction_getter() {
2266 Source source = addSource(EngineTestCase.createSource([
2267 "class A {",
2268 " var g;",
2269 "}",
2270 "f() {",
2271 " A a;",
2272 " a.g();",
2273 "}"]));
2274 resolve(source);
2275 assertNoErrors(source);
2276 verify([source]);
2277 }
2278 void test_invocationOfNonFunction_localVariable() {
2279 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g();", "}"]));
2280 resolve(source);
2281 assertNoErrors(source);
2282 verify([source]);
2283 }
2284 void test_invocationOfNonFunction_localVariable_dynamic() {
2285 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {", " var v = f;", " v();", "}"]));
2286 resolve(source);
2287 assertNoErrors(source);
2288 verify([source]);
2289 }
2290 void test_invocationOfNonFunction_localVariable_dynamic2() {
2291 Source source = addSource(EngineTestCase.createSource([
2292 "f() {}",
2293 "main() {",
2294 " var v = f;",
2295 " v = 1;",
2296 " v();",
2297 "}"]));
2298 resolve(source);
2299 assertNoErrors(source);
2300 verify([source]);
2301 }
2302 void test_invocationOfNonFunction_Object() {
2303 Source source = addSource(EngineTestCase.createSource(["main() {", " Object v = null;", " v();", "}"]));
2304 resolve(source);
2305 assertNoErrors(source);
2306 verify([source]);
2307 }
2308 void test_listElementTypeNotAssignable() {
2309 Source source = addSource(EngineTestCase.createSource(["var v1 = <int> [42]; ", "var v2 = const <int> [42];"]));
2310 resolve(source);
2311 assertNoErrors(source);
2312 verify([source]);
2313 }
2314 void test_mapKeyTypeNotAssignable() {
2315 Source source = addSource(EngineTestCase.createSource(["var v = <String, int > {'a' : 1};"]));
2316 resolve(source);
2317 assertNoErrors(source);
2318 verify([source]);
2319 }
2320 void test_memberWithClassName_setter() {
2321 Source source = addSource(EngineTestCase.createSource(["class A {", " set A (v) {}", "}"]));
2322 resolve(source);
2323 assertNoErrors(source);
2324 verify([source]);
2325 }
2326 void test_methodDeclaration_scope_signature() {
2327 Source source = addSource(EngineTestCase.createSource([
2328 "const app = 0;",
2329 "class A {",
2330 " foo(@app int app) {}",
2331 "}"]));
2332 resolve(source);
2333 assertNoErrors(source);
2334 verify([source]);
2335 }
2336 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() {
2337 Source source = addSource(EngineTestCase.createSource([
2338 "class C {",
2339 " int get x => 0;",
2340 " set x(int v) {}",
2341 "}"]));
2342 resolve(source);
2343 assertNoErrors(source);
2344 verify([source]);
2345 }
2346 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() {
2347 Source source = addSource(EngineTestCase.createSource(["class C {", " get x => 0;", " set x(String v) {}", "}"]));
2348 resolve(source);
2349 assertNoErrors(source);
2350 verify([source]);
2351 }
2352 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() {
2353 Source source = addSource(EngineTestCase.createSource(["class C {", " int g et x => 0;", " set x(v) {}", "}"]));
2354 resolve(source);
2355 assertNoErrors(source);
2356 verify([source]);
2357 }
2358 void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() {
2359 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s et x(int v) {}"]));
2360 resolve(source);
2361 assertNoErrors(source);
2362 verify([source]);
2363 }
2364 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() {
2365 Source source = addSource(EngineTestCase.createSource(["get x => 0;", "set x (String v) {}"]));
2366 resolve(source);
2367 assertNoErrors(source);
2368 verify([source]);
2369 }
2370 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() {
2371 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s et x(v) {}"]));
2372 resolve(source);
2373 assertNoErrors(source);
2374 verify([source]);
2375 }
2376 void test_mixedReturnTypes_differentScopes() {
2377 Source source = addSource(EngineTestCase.createSource([
2378 "class C {",
2379 " m(int x) {",
2380 " f(int y) {",
2381 " return;",
2382 " }",
2383 " f(x);",
2384 " return 0;",
2385 " }",
2386 "}"]));
2387 resolve(source);
2388 assertNoErrors(source);
2389 verify([source]);
2390 }
2391 void test_mixedReturnTypes_sameKind() {
2392 Source source = addSource(EngineTestCase.createSource([
2393 "class C {",
2394 " m(int x) {",
2395 " if (x < 0) {",
2396 " return 1;",
2397 " }",
2398 " return 0;",
2399 " }",
2400 "}"]));
2401 resolve(source);
2402 assertNoErrors(source);
2403 verify([source]);
2404 }
2405 void test_mixinDeclaresConstructor() {
2406 Source source = addSource(EngineTestCase.createSource([
2407 "class A {",
2408 " m() {}",
2409 "}",
2410 "class B extends Object with A {}"]));
2411 resolve(source);
2412 assertNoErrors(source);
2413 verify([source]);
2414 }
2415 void test_mixinDeclaresConstructor_factory() {
2416 Source source = addSource(EngineTestCase.createSource([
2417 "class A {",
2418 " factory A() {}",
2419 "}",
2420 "class B extends Object with A {}"]));
2421 resolve(source);
2422 assertNoErrors(source);
2423 verify([source]);
2424 }
2425 void test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias() {
2426 Source source = addSource(EngineTestCase.createSource([
2427 "class A {}",
2428 "class B = Object with A;",
2429 "class C extends Object with B {}"]));
2430 resolve(source);
2431 assertNoErrors(source);
2432 verify([source]);
2433 }
2434 void test_mixinInheritsFromNotObject_typedef_mixTypeAlias() {
2435 Source source = addSource(EngineTestCase.createSource([
2436 "class A {}",
2437 "class B = Object with A;",
2438 "class C = Object with B;"]));
2439 resolve(source);
2440 assertNoErrors(source);
2441 verify([source]);
2442 }
2443 void test_multipleSuperInitializers_no() {
2444 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B() {}", "}"]));
2445 resolve(source);
2446 assertNoErrors(source);
2447 verify([source]);
2448 }
2449 void test_multipleSuperInitializers_single() {
2450 Source source = addSource(EngineTestCase.createSource([
2451 "class A {}",
2452 "class B extends A {",
2453 " B() : super() {}",
2454 "}"]));
2455 resolve(source);
2456 assertNoErrors(source);
2457 verify([source]);
2458 }
2459 void test_newWithAbstractClass_factory() {
2460 Source source = addSource(EngineTestCase.createSource([
2461 "abstract class A {",
2462 " factory A() { return new B(); }",
2463 "}",
2464 "class B implements A {",
2465 " B() {}",
2466 "}",
2467 "A f() {",
2468 " return new A();",
2469 "}"]));
2470 resolve(source);
2471 assertNoErrors(source);
2472 verify([source]);
2473 }
2474 void test_newWithUndefinedConstructor() {
2475 Source source = addSource(EngineTestCase.createSource([
2476 "class A {",
2477 " A.name() {}",
2478 "}",
2479 "f() {",
2480 " new A.name();",
2481 "}"]));
2482 resolve(source);
2483 assertNoErrors(source);
2484 verify([source]);
2485 }
2486 void test_newWithUndefinedConstructorDefault() {
2487 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A();", "}"]));
2488 resolve(source);
2489 assertNoErrors(source);
2490 verify([source]);
2491 }
2492 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_ accessor() {
2493 Source source = addSource(EngineTestCase.createSource([
2494 "class A {",
2495 " int get g => 0;",
2496 "}",
2497 "abstract class B extends A {",
2498 " int get g;",
2499 "}",
2500 "class C extends B {",
2501 "}"]));
2502 resolve(source);
2503 assertNoErrors(source);
2504 verify([source]);
2505 }
2506 void test_nonAbstractClassInheritsAbstractMemberOne_abstractOverridesConcrete_ method() {
2507 Source source = addSource(EngineTestCase.createSource([
2508 "class A {",
2509 " m(p) {}",
2510 "}",
2511 "abstract class B extends A {",
2512 " m(p);",
2513 "}",
2514 "class C extends B {",
2515 "}"]));
2516 resolve(source);
2517 assertNoErrors(source);
2518 verify([source]);
2519 }
2520 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_accessor() {
2521 Source source = addSource(EngineTestCase.createSource([
2522 "abstract class A {",
2523 " int get g;",
2524 "}",
2525 "class B extends A {",
2526 " noSuchMethod(v) => '';",
2527 "}"]));
2528 resolve(source);
2529 assertNoErrors(source);
2530 verify([source]);
2531 }
2532 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_method() {
2533 Source source = addSource(EngineTestCase.createSource([
2534 "abstract class A {",
2535 " m(p);",
2536 "}",
2537 "class B extends A {",
2538 " noSuchMethod(v) => '';",
2539 "}"]));
2540 resolve(source);
2541 assertNoErrors(source);
2542 verify([source]);
2543 }
2544 void test_nonBoolExpression_functionType() {
2545 Source source = addSource(EngineTestCase.createSource([
2546 "bool makeAssertion() => true;",
2547 "f() {",
2548 " assert(makeAssertion);",
2549 "}"]));
2550 resolve(source);
2551 assertNoErrors(source);
2552 verify([source]);
2553 }
2554 void test_nonBoolExpression_interfaceType() {
2555 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr ue);", "}"]));
2556 resolve(source);
2557 assertNoErrors(source);
2558 verify([source]);
2559 }
2560 void test_nonConstantDefaultValue_function_named() {
2561 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"]) );
2562 resolve(source);
2563 assertNoErrors(source);
2564 verify([source]);
2565 }
2566 void test_nonConstantDefaultValue_function_positional() {
2567 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"]) );
2568 resolve(source);
2569 assertNoErrors(source);
2570 verify([source]);
2571 }
2572 void test_nonConstantDefaultValue_inConstructor_named() {
2573 Source source = addSource(EngineTestCase.createSource(["class A {", " A({x : 2 + 3}) {}", "}"]));
2574 resolve(source);
2575 assertNoErrors(source);
2576 verify([source]);
2577 }
2578 void test_nonConstantDefaultValue_inConstructor_positional() {
2579 Source source = addSource(EngineTestCase.createSource(["class A {", " A([x = 2 + 3]) {}", "}"]));
2580 resolve(source);
2581 assertNoErrors(source);
2582 verify([source]);
2583 }
2584 void test_nonConstantDefaultValue_method_named() {
2585 Source source = addSource(EngineTestCase.createSource(["class A {", " m({x : 2 + 3}) {}", "}"]));
2586 resolve(source);
2587 assertNoErrors(source);
2588 verify([source]);
2589 }
2590 void test_nonConstantDefaultValue_method_positional() {
2591 Source source = addSource(EngineTestCase.createSource(["class A {", " m([x = 2 + 3]) {}", "}"]));
2592 resolve(source);
2593 assertNoErrors(source);
2594 verify([source]);
2595 }
2596 void test_nonConstantValueInInitializer_namedArgument() {
2597 Source source = addSource(EngineTestCase.createSource([
2598 "class A {",
2599 " final a;",
2600 " const A({this.a});",
2601 "}",
2602 "class B extends A {",
2603 " const B({b}) : super(a: b);",
2604 "}"]));
2605 resolve(source);
2606 assertNoErrors(source);
2607 verify([source]);
2608 }
2609 void test_nonConstCaseExpression() {
2610 Source source = addSource(EngineTestCase.createSource([
2611 "f(Type t) {",
2612 " switch (t) {",
2613 " case bool:",
2614 " case int:",
2615 " return true;",
2616 " default:",
2617 " return false;",
2618 " }",
2619 "}"]));
2620 resolve(source);
2621 assertNoErrors(source);
2622 verify([source]);
2623 }
2624 void test_nonConstMapAsExpressionStatement_const() {
2625 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a ' : 0, 'b' : 1};", "}"]));
2626 resolve(source);
2627 assertNoErrors(source);
2628 verify([source]);
2629 }
2630 void test_nonConstMapAsExpressionStatement_notExpressionStatement() {
2631 Source source = addSource(EngineTestCase.createSource(["f() {", " var m = { 'a' : 0, 'b' : 1};", "}"]));
2632 resolve(source);
2633 assertNoErrors(source);
2634 verify([source]);
2635 }
2636 void test_nonConstMapAsExpressionStatement_typeArguments() {
2637 Source source = addSource(EngineTestCase.createSource(["f() {", " <String, int> {'a' : 0, 'b' : 1};", "}"]));
2638 resolve(source);
2639 assertNoErrors(source);
2640 verify([source]);
2641 }
2642 void test_nonConstValueInInitializer_binary_bool() {
2643 Source source = addSource(EngineTestCase.createSource([
2644 "class A {",
2645 " final v;",
2646 " const A.a1(bool p) : v = p && true;",
2647 " const A.a2(bool p) : v = true && p;",
2648 " const A.b1(bool p) : v = p || true;",
2649 " const A.b2(bool p) : v = true || p;",
2650 "}"]));
2651 resolve(source);
2652 assertErrors(source, [HintCode.DEAD_CODE]);
2653 verify([source]);
2654 }
2655 void test_nonConstValueInInitializer_binary_dynamic() {
2656 Source source = addSource(EngineTestCase.createSource([
2657 "class A {",
2658 " final v;",
2659 " const A.a1(p) : v = p + 5;",
2660 " const A.a2(p) : v = 5 + p;",
2661 " const A.b1(p) : v = p - 5;",
2662 " const A.b2(p) : v = 5 - p;",
2663 " const A.c1(p) : v = p * 5;",
2664 " const A.c2(p) : v = 5 * p;",
2665 " const A.d1(p) : v = p / 5;",
2666 " const A.d2(p) : v = 5 / p;",
2667 " const A.e1(p) : v = p ~/ 5;",
2668 " const A.e2(p) : v = 5 ~/ p;",
2669 " const A.f1(p) : v = p > 5;",
2670 " const A.f2(p) : v = 5 > p;",
2671 " const A.g1(p) : v = p < 5;",
2672 " const A.g2(p) : v = 5 < p;",
2673 " const A.h1(p) : v = p >= 5;",
2674 " const A.h2(p) : v = 5 >= p;",
2675 " const A.i1(p) : v = p <= 5;",
2676 " const A.i2(p) : v = 5 <= p;",
2677 " const A.j1(p) : v = p % 5;",
2678 " const A.j2(p) : v = 5 % p;",
2679 "}"]));
2680 resolve(source);
2681 assertNoErrors(source);
2682 }
2683 void test_nonConstValueInInitializer_binary_int() {
2684 Source source = addSource(EngineTestCase.createSource([
2685 "class A {",
2686 " final v;",
2687 " const A.a1(int p) : v = p ^ 5;",
2688 " const A.a2(int p) : v = 5 ^ p;",
2689 " const A.b1(int p) : v = p & 5;",
2690 " const A.b2(int p) : v = 5 & p;",
2691 " const A.c1(int p) : v = p | 5;",
2692 " const A.c2(int p) : v = 5 | p;",
2693 " const A.d1(int p) : v = p >> 5;",
2694 " const A.d2(int p) : v = 5 >> p;",
2695 " const A.e1(int p) : v = p << 5;",
2696 " const A.e2(int p) : v = 5 << p;",
2697 "}"]));
2698 resolve(source);
2699 assertNoErrors(source);
2700 verify([source]);
2701 }
2702 void test_nonConstValueInInitializer_binary_num() {
2703 Source source = addSource(EngineTestCase.createSource([
2704 "class A {",
2705 " final v;",
2706 " const A.a1(num p) : v = p + 5;",
2707 " const A.a2(num p) : v = 5 + p;",
2708 " const A.b1(num p) : v = p - 5;",
2709 " const A.b2(num p) : v = 5 - p;",
2710 " const A.c1(num p) : v = p * 5;",
2711 " const A.c2(num p) : v = 5 * p;",
2712 " const A.d1(num p) : v = p / 5;",
2713 " const A.d2(num p) : v = 5 / p;",
2714 " const A.e1(num p) : v = p ~/ 5;",
2715 " const A.e2(num p) : v = 5 ~/ p;",
2716 " const A.f1(num p) : v = p > 5;",
2717 " const A.f2(num p) : v = 5 > p;",
2718 " const A.g1(num p) : v = p < 5;",
2719 " const A.g2(num p) : v = 5 < p;",
2720 " const A.h1(num p) : v = p >= 5;",
2721 " const A.h2(num p) : v = 5 >= p;",
2722 " const A.i1(num p) : v = p <= 5;",
2723 " const A.i2(num p) : v = 5 <= p;",
2724 " const A.j1(num p) : v = p % 5;",
2725 " const A.j2(num p) : v = 5 % p;",
2726 "}"]));
2727 resolve(source);
2728 assertNoErrors(source);
2729 verify([source]);
2730 }
2731 void test_nonConstValueInInitializer_field() {
2732 Source source = addSource(EngineTestCase.createSource([
2733 "class A {",
2734 " final int a;",
2735 " const A() : a = 5;",
2736 "}"]));
2737 resolve(source);
2738 assertNoErrors(source);
2739 verify([source]);
2740 }
2741 void test_nonConstValueInInitializer_redirecting() {
2742 Source source = addSource(EngineTestCase.createSource([
2743 "class A {",
2744 " const A.named(p);",
2745 " const A() : this.named(42);",
2746 "}"]));
2747 resolve(source);
2748 assertNoErrors(source);
2749 verify([source]);
2750 }
2751 void test_nonConstValueInInitializer_super() {
2752 Source source = addSource(EngineTestCase.createSource([
2753 "class A {",
2754 " const A(p);",
2755 "}",
2756 "class B extends A {",
2757 " const B() : super(42);",
2758 "}"]));
2759 resolve(source);
2760 assertNoErrors(source);
2761 verify([source]);
2762 }
2763 void test_nonConstValueInInitializer_unary() {
2764 Source source = addSource(EngineTestCase.createSource([
2765 "class A {",
2766 " final v;",
2767 " const A.a(bool p) : v = !p;",
2768 " const A.b(int p) : v = ~p;",
2769 " const A.c(num p) : v = -p;",
2770 "}"]));
2771 resolve(source);
2772 assertNoErrors(source);
2773 verify([source]);
2774 }
2775 void test_nonGenerativeConstructor() {
2776 Source source = addSource(EngineTestCase.createSource([
2777 "class A {",
2778 " A.named() {}",
2779 " factory A() {}",
2780 "}",
2781 "class B extends A {",
2782 " B() : super.named();",
2783 "}"]));
2784 resolve(source);
2785 assertNoErrors(source);
2786 verify([source]);
2787 }
2788 void test_nonTypeInCatchClause_isClass() {
2789 Source source = addSource(EngineTestCase.createSource([
2790 "f() {",
2791 " try {",
2792 " } on String catch (e) {",
2793 " }",
2794 "}"]));
2795 resolve(source);
2796 assertNoErrors(source);
2797 verify([source]);
2798 }
2799 void test_nonTypeInCatchClause_isFunctionTypeAlias() {
2800 Source source = addSource(EngineTestCase.createSource([
2801 "typedef F();",
2802 "f() {",
2803 " try {",
2804 " } on F catch (e) {",
2805 " }",
2806 "}"]));
2807 resolve(source);
2808 assertNoErrors(source);
2809 verify([source]);
2810 }
2811 void test_nonTypeInCatchClause_isTypeParameter() {
2812 Source source = addSource(EngineTestCase.createSource([
2813 "class A<T> {",
2814 " f() {",
2815 " try {",
2816 " } on T catch (e) {",
2817 " }",
2818 " }",
2819 "}"]));
2820 resolve(source);
2821 assertNoErrors(source);
2822 verify([source]);
2823 }
2824 void test_nonTypeInCatchClause_noType() {
2825 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", " } catch (e) {", " }", "}"]));
2826 resolve(source);
2827 assertNoErrors(source);
2828 verify([source]);
2829 }
2830 void test_nonVoidReturnForOperator_no() {
2831 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor []=(a, b) {}", "}"]));
2832 resolve(source);
2833 assertNoErrors(source);
2834 verify([source]);
2835 }
2836 void test_nonVoidReturnForOperator_void() {
2837 Source source = addSource(EngineTestCase.createSource(["class A {", " void operator []=(a, b) {}", "}"]));
2838 resolve(source);
2839 assertNoErrors(source);
2840 verify([source]);
2841 }
2842 void test_nonVoidReturnForSetter_function_no() {
2843 Source source = addSource("set x(v) {}");
2844 resolve(source);
2845 assertNoErrors(source);
2846 verify([source]);
2847 }
2848 void test_nonVoidReturnForSetter_function_void() {
2849 Source source = addSource("void set x(v) {}");
2850 resolve(source);
2851 assertNoErrors(source);
2852 verify([source]);
2853 }
2854 void test_nonVoidReturnForSetter_method_no() {
2855 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (v) {}", "}"]));
2856 resolve(source);
2857 assertNoErrors(source);
2858 verify([source]);
2859 }
2860 void test_nonVoidReturnForSetter_method_void() {
2861 Source source = addSource(EngineTestCase.createSource(["class A {", " void set x(v) {}", "}"]));
2862 resolve(source);
2863 assertNoErrors(source);
2864 verify([source]);
2865 }
2866 void test_null_callMethod() {
2867 Source source = addSource(EngineTestCase.createSource(["main() {", " null.m ();", "}"]));
2868 resolve(source);
2869 assertNoErrors(source);
2870 }
2871 void test_null_callOperator() {
2872 Source source = addSource(EngineTestCase.createSource([
2873 "main() {",
2874 " null + 5;",
2875 " null == 5;",
2876 " null[0];",
2877 "}"]));
2878 resolve(source);
2879 assertNoErrors(source);
2880 }
2881 void test_optionalParameterInOperator_required() {
2882 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +(p) {}", "}"]));
2883 resolve(source);
2884 assertNoErrors(source);
2885 verify([source]);
2886 }
2887 void test_prefixCollidesWithTopLevelMembers() {
2888 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class A {}"]));
2889 Source source = addSource(EngineTestCase.createSource([
2890 "import 'lib.dart' as p;",
2891 "typedef P();",
2892 "p2() {}",
2893 "var p3;",
2894 "class p4 {}",
2895 "p.A a;"]));
2896 resolve(source);
2897 assertNoErrors(source);
2898 verify([source]);
2899 }
2900 void test_propagateTypeArgs_intoBounds() {
2901 Source source = addSource(EngineTestCase.createSource([
2902 "abstract class A<E> {}",
2903 "abstract class B<F> implements A<F>{}",
2904 "abstract class C<G, H extends A<G>> {}",
2905 "class D<I> extends C<I, B<I>> {}"]));
2906 resolve(source);
2907 assertNoErrors(source);
2908 verify([source]);
2909 }
2910 void test_propagateTypeArgs_intoSupertype() {
2911 Source source = addSource(EngineTestCase.createSource([
2912 "class A<T> {",
2913 " A(T p);",
2914 " A.named(T p);",
2915 "}",
2916 "class B<S> extends A<S> {",
2917 " B(S p) : super(p);",
2918 " B.named(S p) : super.named(p);",
2919 "}"]));
2920 resolve(source);
2921 assertNoErrors(source);
2922 verify([source]);
2923 }
2924 void test_proxy_annotation_prefixed() {
2925 Source source = addSource(EngineTestCase.createSource([
2926 "library L;",
2927 "import 'meta.dart';",
2928 "@proxy",
2929 "class A {}",
2930 "f(A a) {",
2931 " a.m();",
2932 " var x = a.g;",
2933 " a.s = 1;",
2934 " var y = a + a;",
2935 " a++;",
2936 " ++a;",
2937 "}"]));
2938 addSource2("/meta.dart", EngineTestCase.createSource([
2939 "library meta;",
2940 "const proxy = const _Proxy();",
2941 "class _Proxy { const _Proxy(); }"]));
2942 resolve(source);
2943 assertNoErrors(source);
2944 }
2945 void test_proxy_annotation_prefixed2() {
2946 Source source = addSource(EngineTestCase.createSource([
2947 "library L;",
2948 "import 'meta.dart';",
2949 "@proxy",
2950 "class A {}",
2951 "class B {",
2952 " f(A a) {",
2953 " a.m();",
2954 " var x = a.g;",
2955 " a.s = 1;",
2956 " var y = a + a;",
2957 " a++;",
2958 " ++a;",
2959 " }",
2960 "}"]));
2961 addSource2("/meta.dart", EngineTestCase.createSource([
2962 "library meta;",
2963 "const proxy = const _Proxy();",
2964 "class _Proxy { const _Proxy(); }"]));
2965 resolve(source);
2966 assertNoErrors(source);
2967 }
2968 void test_proxy_annotation_prefixed3() {
2969 Source source = addSource(EngineTestCase.createSource([
2970 "library L;",
2971 "import 'meta.dart';",
2972 "class B {",
2973 " f(A a) {",
2974 " a.m();",
2975 " var x = a.g;",
2976 " a.s = 1;",
2977 " var y = a + a;",
2978 " a++;",
2979 " ++a;",
2980 " }",
2981 "}",
2982 "@proxy",
2983 "class A {}"]));
2984 addSource2("/meta.dart", EngineTestCase.createSource([
2985 "library meta;",
2986 "const proxy = const _Proxy();",
2987 "class _Proxy { const _Proxy(); }"]));
2988 resolve(source);
2989 assertNoErrors(source);
2990 }
2991 void test_proxy_annotation_simple() {
2992 Source source = addSource(EngineTestCase.createSource([
2993 "library L;",
2994 "import 'meta.dart';",
2995 "@proxy",
2996 "class B {",
2997 " m() {",
2998 " n();",
2999 " var x = g;",
3000 " s = 1;",
3001 " var y = this + this;",
3002 " }",
3003 "}"]));
3004 addSource2("/meta.dart", EngineTestCase.createSource([
3005 "library meta;",
3006 "const proxy = const _Proxy();",
3007 "class _Proxy { const _Proxy(); }"]));
3008 resolve(source);
3009 assertNoErrors(source);
3010 }
3011 void test_recursiveConstructorRedirect() {
3012 Source source = addSource(EngineTestCase.createSource([
3013 "class A {",
3014 " A.a() : this.b();",
3015 " A.b() : this.c();",
3016 " A.c() {}",
3017 "}"]));
3018 resolve(source);
3019 assertNoErrors(source);
3020 verify([source]);
3021 }
3022 void test_recursiveFactoryRedirect() {
3023 Source source = addSource(EngineTestCase.createSource([
3024 "class A {",
3025 " factory A() = B;",
3026 "}",
3027 "class B implements A {",
3028 " factory B() = C;",
3029 "}",
3030 "class C implements B {",
3031 " factory C() {}",
3032 "}"]));
3033 resolve(source);
3034 assertNoErrors(source);
3035 verify([source]);
3036 }
3037 void test_redirectToInvalidFunctionType() {
3038 Source source = addSource(EngineTestCase.createSource([
3039 "class A implements B {",
3040 " A(int p) {}",
3041 "}",
3042 "class B {",
3043 " factory B(int p) = A;",
3044 "}"]));
3045 resolve(source);
3046 assertNoErrors(source);
3047 verify([source]);
3048 }
3049 void test_redirectToInvalidReturnType() {
3050 Source source = addSource(EngineTestCase.createSource([
3051 "class A {",
3052 " A() {}",
3053 "}",
3054 "class B extends A {",
3055 " factory B() = A;",
3056 "}"]));
3057 resolve(source);
3058 assertNoErrors(source);
3059 verify([source]);
3060 }
3061 void test_redirectToNonConstConstructor() {
3062 Source source = addSource(EngineTestCase.createSource([
3063 "class A {",
3064 " const A.a();",
3065 " const factory A.b() = A.a;",
3066 "}"]));
3067 resolve(source);
3068 assertNoErrors(source);
3069 verify([source]);
3070 }
3071 void test_referenceToDeclaredVariableInInitializer_constructorName() {
3072 Source source = addSource(EngineTestCase.createSource([
3073 "class A {",
3074 " A.x() {}",
3075 "}",
3076 "f() {",
3077 " var x = new A.x();",
3078 "}"]));
3079 resolve(source);
3080 assertNoErrors(source);
3081 verify([source]);
3082 }
3083 void test_referenceToDeclaredVariableInInitializer_methodName() {
3084 Source source = addSource(EngineTestCase.createSource([
3085 "class A {",
3086 " x() {}",
3087 "}",
3088 "f(A a) {",
3089 " var x = a.x();",
3090 "}"]));
3091 resolve(source);
3092 assertNoErrors(source);
3093 verify([source]);
3094 }
3095 void test_referenceToDeclaredVariableInInitializer_propertyName() {
3096 Source source = addSource(EngineTestCase.createSource([
3097 "class A {",
3098 " var x;",
3099 "}",
3100 "f(A a) {",
3101 " var x = a.x;",
3102 "}"]));
3103 resolve(source);
3104 assertNoErrors(source);
3105 verify([source]);
3106 }
3107 void test_rethrowOutsideCatch() {
3108 Source source = addSource(EngineTestCase.createSource([
3109 "class A {",
3110 " void m() {",
3111 " try {} catch (e) {rethrow;}",
3112 " }",
3113 "}"]));
3114 resolve(source);
3115 assertNoErrors(source);
3116 verify([source]);
3117 }
3118 void test_returnInGenerativeConstructor() {
3119 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { return; }", "}"]));
3120 resolve(source);
3121 assertNoErrors(source);
3122 verify([source]);
3123 }
3124 void test_returnOfInvalidType_dynamic() {
3125 Source source = addSource(EngineTestCase.createSource([
3126 "class TypeError {}",
3127 "class A {",
3128 " static void testLogicalOp() {",
3129 " testOr(a, b, onTypeError) {",
3130 " try {",
3131 " return a || b;",
3132 " } on TypeError catch (t) {",
3133 " return onTypeError;",
3134 " }",
3135 " }",
3136 " }",
3137 "}"]));
3138 resolve(source);
3139 assertNoErrors(source);
3140 verify([source]);
3141 }
3142 void test_returnOfInvalidType_dynamicAsTypeArgument() {
3143 Source source = addSource(EngineTestCase.createSource([
3144 "class I<T> {",
3145 " factory I() => new A<T>();",
3146 "}",
3147 "class A<T> implements I {",
3148 "}"]));
3149 resolve(source);
3150 assertNoErrors(source);
3151 verify([source]);
3152 }
3153 void test_returnOfInvalidType_subtype() {
3154 Source source = addSource(EngineTestCase.createSource([
3155 "class A {}",
3156 "class B extends A {}",
3157 "A f(B b) { return b; }"]));
3158 resolve(source);
3159 assertNoErrors(source);
3160 verify([source]);
3161 }
3162 void test_returnOfInvalidType_supertype() {
3163 Source source = addSource(EngineTestCase.createSource([
3164 "class A {}",
3165 "class B extends A {}",
3166 "B f(A a) { return a; }"]));
3167 resolve(source);
3168 assertNoErrors(source);
3169 verify([source]);
3170 }
3171 void test_returnOfInvalidType_void() {
3172 Source source = addSource(EngineTestCase.createSource([
3173 "void f1() {}",
3174 "void f2() { return; }",
3175 "void f3() { return null; }",
3176 "void f4() { return g1(); }",
3177 "void f5() { return g2(); }",
3178 "g1() {}",
3179 "void g2() {}",
3180 ""]));
3181 resolve(source);
3182 assertNoErrors(source);
3183 verify([source]);
3184 }
3185 void test_returnWithoutValue_noReturnType() {
3186 Source source = addSource(EngineTestCase.createSource(["f() { return; }"]));
3187 resolve(source);
3188 assertNoErrors(source);
3189 verify([source]);
3190 }
3191 void test_returnWithoutValue_void() {
3192 Source source = addSource(EngineTestCase.createSource(["void f() { return; } "]));
3193 resolve(source);
3194 assertNoErrors(source);
3195 verify([source]);
3196 }
3197 void test_staticAccessToInstanceMember_annotation() {
3198 Source source = addSource(EngineTestCase.createSource([
3199 "class A {",
3200 " const A.name();",
3201 "}",
3202 "@A.name()",
3203 "main() {",
3204 "}"]));
3205 resolve(source);
3206 assertNoErrors(source);
3207 verify([source]);
3208 }
3209 void test_staticAccessToInstanceMember_method() {
3210 Source source = addSource(EngineTestCase.createSource([
3211 "class A {",
3212 " static m() {}",
3213 "}",
3214 "main() {",
3215 " A.m;",
3216 " A.m();",
3217 "}"]));
3218 resolve(source);
3219 assertNoErrors(source);
3220 verify([source]);
3221 }
3222 void test_staticAccessToInstanceMember_propertyAccess_field() {
3223 Source source = addSource(EngineTestCase.createSource([
3224 "class A {",
3225 " static var f;",
3226 "}",
3227 "main() {",
3228 " A.f;",
3229 " A.f = 1;",
3230 "}"]));
3231 resolve(source);
3232 assertNoErrors(source);
3233 verify([source]);
3234 }
3235 void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() {
3236 Source source = addSource(EngineTestCase.createSource([
3237 "class A {",
3238 " static get f => 42;",
3239 " static set f(x) {}",
3240 "}",
3241 "main() {",
3242 " A.f;",
3243 " A.f = 1;",
3244 "}"]));
3245 resolve(source);
3246 assertNoErrors(source);
3247 verify([source]);
3248 }
3249 void test_superInInvalidContext() {
3250 Source source = addSource(EngineTestCase.createSource([
3251 "class A {",
3252 " m() {}",
3253 "}",
3254 "class B extends A {",
3255 " B() {",
3256 " var v = super.m();",
3257 " }",
3258 " n() {",
3259 " var v = super.m();",
3260 " }",
3261 "}"]));
3262 resolve(source);
3263 assertNoErrors(source);
3264 verify([source]);
3265 }
3266 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() {
3267 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "cl ass B {", " A a;", "}"]));
3268 resolve(source);
3269 assertNoErrors(source);
3270 verify([source]);
3271 }
3272 void test_typeArgumentNotMatchingBounds_const() {
3273 Source source = addSource(EngineTestCase.createSource([
3274 "class A {}",
3275 "class B extends A {}",
3276 "class G<E extends A> {",
3277 " const G();",
3278 "}",
3279 "f() { return const G<B>(); }"]));
3280 resolve(source);
3281 assertNoErrors(source);
3282 verify([source]);
3283 }
3284 void test_typeArgumentNotMatchingBounds_new() {
3285 Source source = addSource(EngineTestCase.createSource([
3286 "class A {}",
3287 "class B extends A {}",
3288 "class G<E extends A> {}",
3289 "f() { return new G<B>(); }"]));
3290 resolve(source);
3291 assertNoErrors(source);
3292 verify([source]);
3293 }
3294 void test_typeArgumentNotMatchingBounds_typeArgumentList_0() {
3295 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e xtends A>{}"]));
3296 resolve(source);
3297 assertNoErrors(source);
3298 verify([source]);
3299 }
3300 void test_typeArgumentNotMatchingBounds_typeArgumentList_1() {
3301 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e xtends A<A>>{}"]));
3302 resolve(source);
3303 assertNoErrors(source);
3304 verify([source]);
3305 }
3306 void test_typeArgumentNotMatchingBounds_typeArgumentList_20() {
3307 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e xtends A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A>>>>>>>>>>>>>>>>>>>>>{}"]));
3308 resolve(source);
3309 assertNoErrors(source);
3310 verify([source]);
3311 }
3312 void test_typePromotion_booleanAnd_useInRight() {
3313 Source source = addSource(EngineTestCase.createSource([
3314 "main(Object p) {",
3315 " p is String && p.length != 0;",
3316 "}"]));
3317 resolve(source);
3318 assertNoErrors(source);
3319 verify([source]);
3320 }
3321 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignm ent() {
3322 Source source = addSource(EngineTestCase.createSource([
3323 "callMe(f()) { f(); }",
3324 "main(Object p) {",
3325 " (p is String) && callMe(() { p.length; });",
3326 "}"]));
3327 resolve(source);
3328 assertNoErrors(source);
3329 verify([source]);
3330 }
3331 void test_typePromotion_conditional_useInThen() {
3332 Source source = addSource(EngineTestCase.createSource(["main(Object p) {", " p is String ? p.length : 0;", "}"]));
3333 resolve(source);
3334 assertNoErrors(source);
3335 verify([source]);
3336 }
3337 void test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() {
3338 Source source = addSource(EngineTestCase.createSource([
3339 "callMe(f()) { f(); }",
3340 "main(Object p) {",
3341 " p is String ? callMe(() { p.length; }) : 0;",
3342 "}"]));
3343 resolve(source);
3344 assertNoErrors(source);
3345 verify([source]);
3346 }
3347 void test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific() {
3348 Source source = addSource(EngineTestCase.createSource([
3349 "typedef FuncB(B b);",
3350 "typedef FuncA(A a);",
3351 "class A {}",
3352 "class B {}",
3353 "main(FuncA f) {",
3354 " if (f is FuncB) {",
3355 " f(new A());",
3356 " }",
3357 "}"]));
3358 resolve(source);
3359 assertNoErrors(source);
3360 verify([source]);
3361 }
3362 void test_typePromotion_functionType_return_ignoreIfNotMoreSpecific() {
3363 Source source = addSource(EngineTestCase.createSource([
3364 "typedef FuncDynToDyn(x);",
3365 "typedef void FuncDynToVoid(x);",
3366 "class A {}",
3367 "main(FuncDynToDyn f) {",
3368 " if (f is FuncDynToVoid) {",
3369 " A a = f(null);",
3370 " }",
3371 "}"]));
3372 resolve(source);
3373 assertNoErrors(source);
3374 verify([source]);
3375 }
3376 void test_typePromotion_functionType_return_voidToDynamic() {
3377 Source source = addSource(EngineTestCase.createSource([
3378 "typedef FuncDynToDyn(x);",
3379 "typedef void FuncDynToVoid(x);",
3380 "class A {}",
3381 "main(FuncDynToVoid f) {",
3382 " if (f is FuncDynToDyn) {",
3383 " A a = f(null);",
3384 " }",
3385 "}"]));
3386 resolve(source);
3387 assertNoErrors(source);
3388 verify([source]);
3389 }
3390 void test_typePromotion_if_accessedInClosure_noAssignment() {
3391 Source source = addSource(EngineTestCase.createSource([
3392 "callMe(f()) { f(); }",
3393 "main(Object p) {",
3394 " if (p is String) {",
3395 " callMe(() {",
3396 " p.length;",
3397 " });",
3398 " }",
3399 "}"]));
3400 resolve(source);
3401 assertNoErrors(source);
3402 verify([source]);
3403 }
3404 void test_typePromotion_if_hasAssignment_outsideAfter() {
3405 Source source = addSource(EngineTestCase.createSource([
3406 "main(Object p) {",
3407 " if (p is String) {",
3408 " p.length;",
3409 " }",
3410 " p = 0;",
3411 "}"]));
3412 resolve(source);
3413 assertNoErrors(source);
3414 verify([source]);
3415 }
3416 void test_typePromotion_if_hasAssignment_outsideBefore() {
3417 Source source = addSource(EngineTestCase.createSource([
3418 "main(Object p, Object p2) {",
3419 " p = p2;",
3420 " if (p is String) {",
3421 " p.length;",
3422 " }",
3423 "}"]));
3424 resolve(source);
3425 assertNoErrors(source);
3426 verify([source]);
3427 }
3428 void test_typePromotion_if_is_and_left() {
3429 Source source = addSource(EngineTestCase.createSource([
3430 "bool tt() => true;",
3431 "main(Object p) {",
3432 " if (p is String && tt()) {",
3433 " p.length;",
3434 " }",
3435 "}"]));
3436 resolve(source);
3437 assertNoErrors(source);
3438 verify([source]);
3439 }
3440 void test_typePromotion_if_is_and_right() {
3441 Source source = addSource(EngineTestCase.createSource([
3442 "bool tt() => true;",
3443 "main(Object p) {",
3444 " if (tt() && p is String) {",
3445 " p.length;",
3446 " }",
3447 "}"]));
3448 resolve(source);
3449 assertNoErrors(source);
3450 verify([source]);
3451 }
3452 void test_typePromotion_if_is_and_subThenSuper() {
3453 Source source = addSource(EngineTestCase.createSource([
3454 "class A {",
3455 " var a;",
3456 "}",
3457 "class B extends A {",
3458 " var b;",
3459 "}",
3460 "main(Object p) {",
3461 " if (p is B && p is A) {",
3462 " p.a;",
3463 " p.b;",
3464 " }",
3465 "}"]));
3466 resolve(source);
3467 assertNoErrors(source);
3468 verify([source]);
3469 }
3470 void test_typePromotion_if_is_parenthesized() {
3471 Source source = addSource(EngineTestCase.createSource([
3472 "main(Object p) {",
3473 " if ((p is String)) {",
3474 " p.length;",
3475 " }",
3476 "}"]));
3477 resolve(source);
3478 assertNoErrors(source);
3479 verify([source]);
3480 }
3481 void test_typePromotion_if_is_single() {
3482 Source source = addSource(EngineTestCase.createSource([
3483 "main(Object p) {",
3484 " if (p is String) {",
3485 " p.length;",
3486 " }",
3487 "}"]));
3488 resolve(source);
3489 assertNoErrors(source);
3490 verify([source]);
3491 }
3492 void test_undefinedConstructorInInitializer_explicit_named() {
3493 Source source = addSource(EngineTestCase.createSource([
3494 "class A {",
3495 " A.named() {}",
3496 "}",
3497 "class B extends A {",
3498 " B() : super.named();",
3499 "}"]));
3500 resolve(source);
3501 assertNoErrors(source);
3502 verify([source]);
3503 }
3504 void test_undefinedConstructorInInitializer_explicit_unnamed() {
3505 Source source = addSource(EngineTestCase.createSource([
3506 "class A {",
3507 " A() {}",
3508 "}",
3509 "class B extends A {",
3510 " B() : super();",
3511 "}"]));
3512 resolve(source);
3513 assertNoErrors(source);
3514 verify([source]);
3515 }
3516 void test_undefinedConstructorInInitializer_hasOptionalParameters() {
3517 Source source = addSource(EngineTestCase.createSource([
3518 "class A {",
3519 " A([p]) {}",
3520 "}",
3521 "class B extends A {",
3522 " B();",
3523 "}"]));
3524 resolve(source);
3525 assertNoErrors(source);
3526 verify([source]);
3527 }
3528 void test_undefinedConstructorInInitializer_implicit() {
3529 Source source = addSource(EngineTestCase.createSource([
3530 "class A {",
3531 " A() {}",
3532 "}",
3533 "class B extends A {",
3534 " B();",
3535 "}"]));
3536 resolve(source);
3537 assertNoErrors(source);
3538 verify([source]);
3539 }
3540 void test_undefinedConstructorInInitializer_implicit_typeAlias() {
3541 Source source = addSource(EngineTestCase.createSource([
3542 "class M {}",
3543 "class A = Object with M;",
3544 "class B extends A {",
3545 " B();",
3546 "}"]));
3547 resolve(source);
3548 assertNoErrors(source);
3549 verify([source]);
3550 }
3551 void test_undefinedConstructorInInitializer_redirecting() {
3552 Source source = addSource(EngineTestCase.createSource([
3553 "class Foo {",
3554 " Foo.ctor();",
3555 "}",
3556 "class Bar extends Foo {",
3557 " Bar() : this.ctor();",
3558 " Bar.ctor() : super.ctor();",
3559 "}"]));
3560 resolve(source);
3561 assertNoErrors(source);
3562 verify([source]);
3563 }
3564 void test_undefinedGetter_typeSubstitution() {
3565 Source source = addSource(EngineTestCase.createSource([
3566 "class A<E> {",
3567 " E element;",
3568 "}",
3569 "class B extends A<List> {",
3570 " m() {",
3571 " element.last;",
3572 " }",
3573 "}"]));
3574 resolve(source);
3575 assertNoErrors(source);
3576 verify([source]);
3577 }
3578 void test_undefinedIdentifier_hide() {
3579 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' hide a;"]));
3580 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
3581 resolve(source);
3582 assertNoErrors(source);
3583 verify([source]);
3584 }
3585 void test_undefinedIdentifier_show() {
3586 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' show a;"]));
3587 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
3588 resolve(source);
3589 assertNoErrors(source);
3590 verify([source]);
3591 }
3592 void test_undefinedMethod_functionExpression_callMethod() {
3593 Source source = addSource(EngineTestCase.createSource(["main() {", " (() => null).call();", "}"]));
3594 resolve(source);
3595 assertNoErrors(source);
3596 }
3597 void test_undefinedMethod_functionExpression_directCall() {
3598 Source source = addSource(EngineTestCase.createSource(["main() {", " (() => null)();", "}"]));
3599 resolve(source);
3600 assertNoErrors(source);
3601 }
3602 void test_undefinedOperator_index() {
3603 Source source = addSource(EngineTestCase.createSource([
3604 "class A {",
3605 " operator [](a) {}",
3606 " operator []=(a, b) {}",
3607 "}",
3608 "f(A a) {",
3609 " a[0];",
3610 " a[0] = 1;",
3611 "}"]));
3612 resolve(source);
3613 assertNoErrors(source);
3614 verify([source]);
3615 }
3616 void test_undefinedOperator_tilde() {
3617 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons t B = ~((1 << A) - 1);"]));
3618 resolve(source);
3619 assertNoErrors(source);
3620 verify([source]);
3621 }
3622 void test_undefinedSetter_importWithPrefix() {
3623 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "set y( int value) {}"]));
3624 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as x;", "main() {", " x.y = 0;", "}"]));
3625 resolve(source);
3626 assertNoErrors(source);
3627 verify([source]);
3628 }
3629 void test_undefinedSuperMethod_field() {
3630 Source source = addSource(EngineTestCase.createSource([
3631 "class A {",
3632 " var m;",
3633 "}",
3634 "class B extends A {",
3635 " f() {",
3636 " super.m();",
3637 " }",
3638 "}"]));
3639 resolve(source);
3640 assertNoErrors(source);
3641 verify([source]);
3642 }
3643 void test_undefinedSuperMethod_method() {
3644 Source source = addSource(EngineTestCase.createSource([
3645 "class A {",
3646 " m() {}",
3647 "}",
3648 "class B extends A {",
3649 " f() {",
3650 " super.m();",
3651 " }",
3652 "}"]));
3653 resolve(source);
3654 assertNoErrors(source);
3655 verify([source]);
3656 }
3657 void test_wrongNumberOfParametersForOperator_index() {
3658 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor []=(a, b) {}", "}"]));
3659 resolve(source);
3660 assertNoErrors(source);
3661 verify([source]);
3662 }
3663 void test_wrongNumberOfParametersForOperator_minus() {
3664 check_wrongNumberOfParametersForOperator("-", "");
3665 check_wrongNumberOfParametersForOperator("-", "a");
3666 }
3667 void test_wrongNumberOfParametersForOperator1() {
3668 check_wrongNumberOfParametersForOperator1("<");
3669 check_wrongNumberOfParametersForOperator1(">");
3670 check_wrongNumberOfParametersForOperator1("<=");
3671 check_wrongNumberOfParametersForOperator1(">=");
3672 check_wrongNumberOfParametersForOperator1("+");
3673 check_wrongNumberOfParametersForOperator1("/");
3674 check_wrongNumberOfParametersForOperator1("~/");
3675 check_wrongNumberOfParametersForOperator1("*");
3676 check_wrongNumberOfParametersForOperator1("%");
3677 check_wrongNumberOfParametersForOperator1("|");
3678 check_wrongNumberOfParametersForOperator1("^");
3679 check_wrongNumberOfParametersForOperator1("&");
3680 check_wrongNumberOfParametersForOperator1("<<");
3681 check_wrongNumberOfParametersForOperator1(">>");
3682 check_wrongNumberOfParametersForOperator1("[]");
3683 }
3684 void test_wrongNumberOfParametersForSetter() {
3685 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (a) {}", "}"]));
3686 resolve(source);
3687 assertNoErrors(source);
3688 verify([source]);
3689 }
3690 void check_wrongNumberOfParametersForOperator(String name, String parameters) {
3691 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor ${name}(${parameters}) {}", "}"]));
3692 resolve(source);
3693 assertNoErrors(source);
3694 verify([source]);
3695 reset();
3696 }
3697 void check_wrongNumberOfParametersForOperator1(String name) {
3698 check_wrongNumberOfParametersForOperator(name, "a");
3699 }
3700 static dartSuite() {
3701 _ut.group('NonErrorResolverTest', () {
3702 _ut.test('test_ambiguousExport', () {
3703 final __test = new NonErrorResolverTest();
3704 runJUnitTest(__test, __test.test_ambiguousExport);
3705 });
3706 _ut.test('test_ambiguousExport_combinators_hide', () {
3707 final __test = new NonErrorResolverTest();
3708 runJUnitTest(__test, __test.test_ambiguousExport_combinators_hide);
3709 });
3710 _ut.test('test_ambiguousExport_combinators_show', () {
3711 final __test = new NonErrorResolverTest();
3712 runJUnitTest(__test, __test.test_ambiguousExport_combinators_show);
3713 });
3714 _ut.test('test_argumentDefinitionTestNonParameter_formalParameter', () {
3715 final __test = new NonErrorResolverTest();
3716 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_form alParameter);
3717 });
3718 _ut.test('test_argumentDefinitionTestNonParameter_namedParameter', () {
3719 final __test = new NonErrorResolverTest();
3720 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_name dParameter);
3721 });
3722 _ut.test('test_argumentDefinitionTestNonParameter_optionalParameter', () {
3723 final __test = new NonErrorResolverTest();
3724 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_opti onalParameter);
3725 });
3726 _ut.test('test_argumentTypeNotAssignable_Object_Function', () {
3727 final __test = new NonErrorResolverTest();
3728 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_Object_Functi on);
3729 });
3730 _ut.test('test_argumentTypeNotAssignable_classWithCall_Function', () {
3731 final __test = new NonErrorResolverTest();
3732 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_classWithCall _Function);
3733 });
3734 _ut.test('test_argumentTypeNotAssignable_fieldFormalParameterElement_membe r', () {
3735 final __test = new NonErrorResolverTest();
3736 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_fieldFormalPa rameterElement_member);
3737 });
3738 _ut.test('test_argumentTypeNotAssignable_invocation_functionParameter_gene ric', () {
3739 final __test = new NonErrorResolverTest();
3740 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_fu nctionParameter_generic);
3741 });
3742 _ut.test('test_argumentTypeNotAssignable_invocation_typedef_generic', () {
3743 final __test = new NonErrorResolverTest();
3744 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ty pedef_generic);
3745 });
3746 _ut.test('test_argumentTypeNotAssignable_typedef_local', () {
3747 final __test = new NonErrorResolverTest();
3748 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_typedef_local );
3749 });
3750 _ut.test('test_argumentTypeNotAssignable_typedef_parameter', () {
3751 final __test = new NonErrorResolverTest();
3752 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_typedef_param eter);
3753 });
3754 _ut.test('test_assignmentToFinal_prefixNegate', () {
3755 final __test = new NonErrorResolverTest();
3756 runJUnitTest(__test, __test.test_assignmentToFinal_prefixNegate);
3757 });
3758 _ut.test('test_assignmentToFinals_importWithPrefix', () {
3759 final __test = new NonErrorResolverTest();
3760 runJUnitTest(__test, __test.test_assignmentToFinals_importWithPrefix);
3761 });
3762 _ut.test('test_breakWithoutLabelInSwitch', () {
3763 final __test = new NonErrorResolverTest();
3764 runJUnitTest(__test, __test.test_breakWithoutLabelInSwitch);
3765 });
3766 _ut.test('test_builtInIdentifierAsType_dynamic', () {
3767 final __test = new NonErrorResolverTest();
3768 runJUnitTest(__test, __test.test_builtInIdentifierAsType_dynamic);
3769 });
3770 _ut.test('test_caseBlockNotTerminated', () {
3771 final __test = new NonErrorResolverTest();
3772 runJUnitTest(__test, __test.test_caseBlockNotTerminated);
3773 });
3774 _ut.test('test_caseBlockNotTerminated_lastCase', () {
3775 final __test = new NonErrorResolverTest();
3776 runJUnitTest(__test, __test.test_caseBlockNotTerminated_lastCase);
3777 });
3778 _ut.test('test_caseExpressionTypeImplementsEquals_Object', () {
3779 final __test = new NonErrorResolverTest();
3780 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Obje ct);
3781 });
3782 _ut.test('test_caseExpressionTypeImplementsEquals_String', () {
3783 final __test = new NonErrorResolverTest();
3784 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Stri ng);
3785 });
3786 _ut.test('test_caseExpressionTypeImplementsEquals_int', () {
3787 final __test = new NonErrorResolverTest();
3788 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_int) ;
3789 });
3790 _ut.test('test_concreteClassWithAbstractMember', () {
3791 final __test = new NonErrorResolverTest();
3792 runJUnitTest(__test, __test.test_concreteClassWithAbstractMember);
3793 });
3794 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_instance', () {
3795 final __test = new NonErrorResolverTest();
3796 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_instance);
3797 });
3798 _ut.test('test_conflictingStaticGetterAndInstanceSetter_thisClass', () {
3799 final __test = new NonErrorResolverTest();
3800 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette r_thisClass);
3801 });
3802 _ut.test('test_conflictingStaticSetterAndInstanceMember_thisClass_method', () {
3803 final __test = new NonErrorResolverTest();
3804 runJUnitTest(__test, __test.test_conflictingStaticSetterAndInstanceMembe r_thisClass_method);
3805 });
3806 _ut.test('test_constConstructorWithNonConstSuper_redirectingFactory', () {
3807 final __test = new NonErrorResolverTest();
3808 runJUnitTest(__test, __test.test_constConstructorWithNonConstSuper_redir ectingFactory);
3809 });
3810 _ut.test('test_constConstructorWithNonFinalField_finalInstanceVar', () {
3811 final __test = new NonErrorResolverTest();
3812 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_final InstanceVar);
3813 });
3814 _ut.test('test_constConstructorWithNonFinalField_mixin', () {
3815 final __test = new NonErrorResolverTest();
3816 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_mixin );
3817 });
3818 _ut.test('test_constConstructorWithNonFinalField_static', () {
3819 final __test = new NonErrorResolverTest();
3820 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_stati c);
3821 });
3822 _ut.test('test_constConstructorWithNonFinalField_syntheticField', () {
3823 final __test = new NonErrorResolverTest();
3824 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField);
3825 });
3826 _ut.test('test_constEvalTypeBoolNumString_equal', () {
3827 final __test = new NonErrorResolverTest();
3828 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal);
3829 });
3830 _ut.test('test_constEvalTypeBoolNumString_notEqual', () {
3831 final __test = new NonErrorResolverTest();
3832 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual);
3833 });
3834 _ut.test('test_constEval_propertyExtraction_fieldStatic_targetType', () {
3835 final __test = new NonErrorResolverTest();
3836 runJUnitTest(__test, __test.test_constEval_propertyExtraction_fieldStati c_targetType);
3837 });
3838 _ut.test('test_constEval_propertyExtraction_methodStatic_targetType', () {
3839 final __test = new NonErrorResolverTest();
3840 runJUnitTest(__test, __test.test_constEval_propertyExtraction_methodStat ic_targetType);
3841 });
3842 _ut.test('test_constEval_symbol', () {
3843 final __test = new NonErrorResolverTest();
3844 runJUnitTest(__test, __test.test_constEval_symbol);
3845 });
3846 _ut.test('test_constNotInitialized_field', () {
3847 final __test = new NonErrorResolverTest();
3848 runJUnitTest(__test, __test.test_constNotInitialized_field);
3849 });
3850 _ut.test('test_constNotInitialized_local', () {
3851 final __test = new NonErrorResolverTest();
3852 runJUnitTest(__test, __test.test_constNotInitialized_local);
3853 });
3854 _ut.test('test_constWithNonConstantArgument_literals', () {
3855 final __test = new NonErrorResolverTest();
3856 runJUnitTest(__test, __test.test_constWithNonConstantArgument_literals);
3857 });
3858 _ut.test('test_constWithTypeParameters_direct', () {
3859 final __test = new NonErrorResolverTest();
3860 runJUnitTest(__test, __test.test_constWithTypeParameters_direct);
3861 });
3862 _ut.test('test_constWithUndefinedConstructor', () {
3863 final __test = new NonErrorResolverTest();
3864 runJUnitTest(__test, __test.test_constWithUndefinedConstructor);
3865 });
3866 _ut.test('test_constWithUndefinedConstructorDefault', () {
3867 final __test = new NonErrorResolverTest();
3868 runJUnitTest(__test, __test.test_constWithUndefinedConstructorDefault);
3869 });
3870 _ut.test('test_constructorDeclaration_scope_signature', () {
3871 final __test = new NonErrorResolverTest();
3872 runJUnitTest(__test, __test.test_constructorDeclaration_scope_signature) ;
3873 });
3874 _ut.test('test_defaultValueInFunctionTypeAlias', () {
3875 final __test = new NonErrorResolverTest();
3876 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
3877 });
3878 _ut.test('test_defaultValueInFunctionTypedParameter_named', () {
3879 final __test = new NonErrorResolverTest();
3880 runJUnitTest(__test, __test.test_defaultValueInFunctionTypedParameter_na med);
3881 });
3882 _ut.test('test_defaultValueInFunctionTypedParameter_optional', () {
3883 final __test = new NonErrorResolverTest();
3884 runJUnitTest(__test, __test.test_defaultValueInFunctionTypedParameter_op tional);
3885 });
3886 _ut.test('test_duplicateDefinition_emptyName', () {
3887 final __test = new NonErrorResolverTest();
3888 runJUnitTest(__test, __test.test_duplicateDefinition_emptyName);
3889 });
3890 _ut.test('test_duplicateDefinition_getter', () {
3891 final __test = new NonErrorResolverTest();
3892 runJUnitTest(__test, __test.test_duplicateDefinition_getter);
3893 });
3894 _ut.test('test_dynamicIdentifier', () {
3895 final __test = new NonErrorResolverTest();
3896 runJUnitTest(__test, __test.test_dynamicIdentifier);
3897 });
3898 _ut.test('test_expectedOneListTypeArgument', () {
3899 final __test = new NonErrorResolverTest();
3900 runJUnitTest(__test, __test.test_expectedOneListTypeArgument);
3901 });
3902 _ut.test('test_expectedTwoMapTypeArguments', () {
3903 final __test = new NonErrorResolverTest();
3904 runJUnitTest(__test, __test.test_expectedTwoMapTypeArguments);
3905 });
3906 _ut.test('test_exportOfNonLibrary_libraryDeclared', () {
3907 final __test = new NonErrorResolverTest();
3908 runJUnitTest(__test, __test.test_exportOfNonLibrary_libraryDeclared);
3909 });
3910 _ut.test('test_exportOfNonLibrary_libraryNotDeclared', () {
3911 final __test = new NonErrorResolverTest();
3912 runJUnitTest(__test, __test.test_exportOfNonLibrary_libraryNotDeclared);
3913 });
3914 _ut.test('test_extraPositionalArguments_Function', () {
3915 final __test = new NonErrorResolverTest();
3916 runJUnitTest(__test, __test.test_extraPositionalArguments_Function);
3917 });
3918 _ut.test('test_extraPositionalArguments_function', () {
3919 final __test = new NonErrorResolverTest();
3920 runJUnitTest(__test, __test.test_extraPositionalArguments_function);
3921 });
3922 _ut.test('test_extraPositionalArguments_typedef_local', () {
3923 final __test = new NonErrorResolverTest();
3924 runJUnitTest(__test, __test.test_extraPositionalArguments_typedef_local) ;
3925 });
3926 _ut.test('test_extraPositionalArguments_typedef_parameter', () {
3927 final __test = new NonErrorResolverTest();
3928 runJUnitTest(__test, __test.test_extraPositionalArguments_typedef_parame ter);
3929 });
3930 _ut.test('test_fieldInitializedByMultipleInitializers', () {
3931 final __test = new NonErrorResolverTest();
3932 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers) ;
3933 });
3934 _ut.test('test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal', () {
3935 final __test = new NonErrorResolverTest();
3936 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_fieldNotFinal);
3937 });
3938 _ut.test('test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSe t', () {
3939 final __test = new NonErrorResolverTest();
3940 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_finalFieldNotSet);
3941 });
3942 _ut.test('test_fieldInitializerOutsideConstructor', () {
3943 final __test = new NonErrorResolverTest();
3944 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor);
3945 });
3946 _ut.test('test_fieldInitializerOutsideConstructor_defaultParameters', () {
3947 final __test = new NonErrorResolverTest();
3948 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor_defa ultParameters);
3949 });
3950 _ut.test('test_fieldInitializerRedirectingConstructor_super', () {
3951 final __test = new NonErrorResolverTest();
3952 runJUnitTest(__test, __test.test_fieldInitializerRedirectingConstructor_ super);
3953 });
3954 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializer', ( ) {
3955 final __test = new NonErrorResolverTest();
3956 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializer);
3957 });
3958 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializingFor mal', () {
3959 final __test = new NonErrorResolverTest();
3960 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializingFormal);
3961 });
3962 _ut.test('test_finalNotInitialized_atDeclaration', () {
3963 final __test = new NonErrorResolverTest();
3964 runJUnitTest(__test, __test.test_finalNotInitialized_atDeclaration);
3965 });
3966 _ut.test('test_finalNotInitialized_fieldFormal', () {
3967 final __test = new NonErrorResolverTest();
3968 runJUnitTest(__test, __test.test_finalNotInitialized_fieldFormal);
3969 });
3970 _ut.test('test_finalNotInitialized_functionTypedFieldFormal', () {
3971 final __test = new NonErrorResolverTest();
3972 runJUnitTest(__test, __test.test_finalNotInitialized_functionTypedFieldF ormal);
3973 });
3974 _ut.test('test_finalNotInitialized_hasNativeClause_hasConstructor', () {
3975 final __test = new NonErrorResolverTest();
3976 runJUnitTest(__test, __test.test_finalNotInitialized_hasNativeClause_has Constructor);
3977 });
3978 _ut.test('test_finalNotInitialized_hasNativeClause_noConstructor', () {
3979 final __test = new NonErrorResolverTest();
3980 runJUnitTest(__test, __test.test_finalNotInitialized_hasNativeClause_noC onstructor);
3981 });
3982 _ut.test('test_finalNotInitialized_initializer', () {
3983 final __test = new NonErrorResolverTest();
3984 runJUnitTest(__test, __test.test_finalNotInitialized_initializer);
3985 });
3986 _ut.test('test_finalNotInitialized_redirectingConstructor', () {
3987 final __test = new NonErrorResolverTest();
3988 runJUnitTest(__test, __test.test_finalNotInitialized_redirectingConstruc tor);
3989 });
3990 _ut.test('test_functionDeclaration_scope_returnType', () {
3991 final __test = new NonErrorResolverTest();
3992 runJUnitTest(__test, __test.test_functionDeclaration_scope_returnType);
3993 });
3994 _ut.test('test_functionDeclaration_scope_signature', () {
3995 final __test = new NonErrorResolverTest();
3996 runJUnitTest(__test, __test.test_functionDeclaration_scope_signature);
3997 });
3998 _ut.test('test_functionTypeAlias_scope_returnType', () {
3999 final __test = new NonErrorResolverTest();
4000 runJUnitTest(__test, __test.test_functionTypeAlias_scope_returnType);
4001 });
4002 _ut.test('test_functionTypeAlias_scope_signature', () {
4003 final __test = new NonErrorResolverTest();
4004 runJUnitTest(__test, __test.test_functionTypeAlias_scope_signature);
4005 });
4006 _ut.test('test_functionWithoutCall', () {
4007 final __test = new NonErrorResolverTest();
4008 runJUnitTest(__test, __test.test_functionWithoutCall);
4009 });
4010 _ut.test('test_implicitThisReferenceInInitializer_constructorName', () {
4011 final __test = new NonErrorResolverTest();
4012 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_cons tructorName);
4013 });
4014 _ut.test('test_implicitThisReferenceInInitializer_prefixedIdentifier', () {
4015 final __test = new NonErrorResolverTest();
4016 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_pref ixedIdentifier);
4017 });
4018 _ut.test('test_implicitThisReferenceInInitializer_qualifiedMethodInvocatio n', () {
4019 final __test = new NonErrorResolverTest();
4020 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_qual ifiedMethodInvocation);
4021 });
4022 _ut.test('test_implicitThisReferenceInInitializer_qualifiedPropertyAccess' , () {
4023 final __test = new NonErrorResolverTest();
4024 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_qual ifiedPropertyAccess);
4025 });
4026 _ut.test('test_implicitThisReferenceInInitializer_staticField_thisClass', () {
4027 final __test = new NonErrorResolverTest();
4028 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_stat icField_thisClass);
4029 });
4030 _ut.test('test_implicitThisReferenceInInitializer_staticGetter', () {
4031 final __test = new NonErrorResolverTest();
4032 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_stat icGetter);
4033 });
4034 _ut.test('test_implicitThisReferenceInInitializer_staticMethod', () {
4035 final __test = new NonErrorResolverTest();
4036 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_stat icMethod);
4037 });
4038 _ut.test('test_implicitThisReferenceInInitializer_topLevelField', () {
4039 final __test = new NonErrorResolverTest();
4040 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL evelField);
4041 });
4042 _ut.test('test_implicitThisReferenceInInitializer_topLevelFunction', () {
4043 final __test = new NonErrorResolverTest();
4044 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL evelFunction);
4045 });
4046 _ut.test('test_implicitThisReferenceInInitializer_topLevelGetter', () {
4047 final __test = new NonErrorResolverTest();
4048 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL evelGetter);
4049 });
4050 _ut.test('test_implicitThisReferenceInInitializer_typeParameter', () {
4051 final __test = new NonErrorResolverTest();
4052 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_type Parameter);
4053 });
4054 _ut.test('test_importDuplicatedLibraryName', () {
4055 final __test = new NonErrorResolverTest();
4056 runJUnitTest(__test, __test.test_importDuplicatedLibraryName);
4057 });
4058 _ut.test('test_importOfNonLibrary_libraryDeclared', () {
4059 final __test = new NonErrorResolverTest();
4060 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryDeclared);
4061 });
4062 _ut.test('test_importOfNonLibrary_libraryNotDeclared', () {
4063 final __test = new NonErrorResolverTest();
4064 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared);
4065 });
4066 _ut.test('test_importPrefixes_withFirstLetterDifference', () {
4067 final __test = new NonErrorResolverTest();
4068 runJUnitTest(__test, __test.test_importPrefixes_withFirstLetterDifferenc e);
4069 });
4070 _ut.test('test_inconsistentCaseExpressionTypes', () {
4071 final __test = new NonErrorResolverTest();
4072 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes);
4073 });
4074 _ut.test('test_inconsistentMethodInheritance_accessors_typeParameter2', () {
4075 final __test = new NonErrorResolverTest();
4076 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors _typeParameter2);
4077 });
4078 _ut.test('test_inconsistentMethodInheritance_accessors_typeParameters1', ( ) {
4079 final __test = new NonErrorResolverTest();
4080 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors _typeParameters1);
4081 });
4082 _ut.test('test_inconsistentMethodInheritance_accessors_typeParameters_diam ond', () {
4083 final __test = new NonErrorResolverTest();
4084 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_accessors _typeParameters_diamond);
4085 });
4086 _ut.test('test_inconsistentMethodInheritance_methods_typeParameter2', () {
4087 final __test = new NonErrorResolverTest();
4088 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_methods_t ypeParameter2);
4089 });
4090 _ut.test('test_inconsistentMethodInheritance_methods_typeParameters1', () {
4091 final __test = new NonErrorResolverTest();
4092 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_methods_t ypeParameters1);
4093 });
4094 _ut.test('test_inconsistentMethodInheritance_simple', () {
4095 final __test = new NonErrorResolverTest();
4096 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_simple);
4097 });
4098 _ut.test('test_initializingFormalForNonExistantField', () {
4099 final __test = new NonErrorResolverTest();
4100 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField);
4101 });
4102 _ut.test('test_instanceAccessToStaticMember_fromComment', () {
4103 final __test = new NonErrorResolverTest();
4104 runJUnitTest(__test, __test.test_instanceAccessToStaticMember_fromCommen t);
4105 });
4106 _ut.test('test_instanceAccessToStaticMember_topLevel', () {
4107 final __test = new NonErrorResolverTest();
4108 runJUnitTest(__test, __test.test_instanceAccessToStaticMember_topLevel);
4109 });
4110 _ut.test('test_instanceMemberAccessFromStatic_fromComment', () {
4111 final __test = new NonErrorResolverTest();
4112 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_fromComm ent);
4113 });
4114 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_field', () {
4115 final __test = new NonErrorResolverTest();
4116 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_field);
4117 });
4118 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_method', () {
4119 final __test = new NonErrorResolverTest();
4120 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_method);
4121 });
4122 _ut.test('test_invalidAnnotation_constantVariable', () {
4123 final __test = new NonErrorResolverTest();
4124 runJUnitTest(__test, __test.test_invalidAnnotation_constantVariable);
4125 });
4126 _ut.test('test_invalidAnnotation_importWithPrefix_constConstructor', () {
4127 final __test = new NonErrorResolverTest();
4128 runJUnitTest(__test, __test.test_invalidAnnotation_importWithPrefix_cons tConstructor);
4129 });
4130 _ut.test('test_invalidAnnotation_importWithPrefix_constantVariable', () {
4131 final __test = new NonErrorResolverTest();
4132 runJUnitTest(__test, __test.test_invalidAnnotation_importWithPrefix_cons tantVariable);
4133 });
4134 _ut.test('test_invalidAssignment', () {
4135 final __test = new NonErrorResolverTest();
4136 runJUnitTest(__test, __test.test_invalidAssignment);
4137 });
4138 _ut.test('test_invalidAssignment_compoundAssignment', () {
4139 final __test = new NonErrorResolverTest();
4140 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment);
4141 });
4142 _ut.test('test_invalidAssignment_defaultValue_named', () {
4143 final __test = new NonErrorResolverTest();
4144 runJUnitTest(__test, __test.test_invalidAssignment_defaultValue_named);
4145 });
4146 _ut.test('test_invalidAssignment_defaultValue_optional', () {
4147 final __test = new NonErrorResolverTest();
4148 runJUnitTest(__test, __test.test_invalidAssignment_defaultValue_optional );
4149 });
4150 _ut.test('test_invalidAssignment_toDynamic', () {
4151 final __test = new NonErrorResolverTest();
4152 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic);
4153 });
4154 _ut.test('test_invalidFactoryNameNotAClass', () {
4155 final __test = new NonErrorResolverTest();
4156 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass);
4157 });
4158 _ut.test('test_invalidMethodOverrideNamedParamType', () {
4159 final __test = new NonErrorResolverTest();
4160 runJUnitTest(__test, __test.test_invalidMethodOverrideNamedParamType);
4161 });
4162 _ut.test('test_invalidOverrideDifferentDefaultValues_named', () {
4163 final __test = new NonErrorResolverTest();
4164 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_n amed);
4165 });
4166 _ut.test('test_invalidOverrideDifferentDefaultValues_positional', () {
4167 final __test = new NonErrorResolverTest();
4168 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p ositional);
4169 });
4170 _ut.test('test_invalidOverrideDifferentDefaultValues_positional_changedOrd er', () {
4171 final __test = new NonErrorResolverTest();
4172 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p ositional_changedOrder);
4173 });
4174 _ut.test('test_invalidOverrideNamed_unorderedNamedParameter', () {
4175 final __test = new NonErrorResolverTest();
4176 runJUnitTest(__test, __test.test_invalidOverrideNamed_unorderedNamedPara meter);
4177 });
4178 _ut.test('test_invalidOverrideRequired_less', () {
4179 final __test = new NonErrorResolverTest();
4180 runJUnitTest(__test, __test.test_invalidOverrideRequired_less);
4181 });
4182 _ut.test('test_invalidOverrideRequired_same', () {
4183 final __test = new NonErrorResolverTest();
4184 runJUnitTest(__test, __test.test_invalidOverrideRequired_same);
4185 });
4186 _ut.test('test_invalidOverrideReturnType_returnType_interface', () {
4187 final __test = new NonErrorResolverTest();
4188 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in terface);
4189 });
4190 _ut.test('test_invalidOverrideReturnType_returnType_interface2', () {
4191 final __test = new NonErrorResolverTest();
4192 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in terface2);
4193 });
4194 _ut.test('test_invalidOverrideReturnType_returnType_mixin', () {
4195 final __test = new NonErrorResolverTest();
4196 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_mi xin);
4197 });
4198 _ut.test('test_invalidOverrideReturnType_returnType_parameterizedTypes', ( ) {
4199 final __test = new NonErrorResolverTest();
4200 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_pa rameterizedTypes);
4201 });
4202 _ut.test('test_invalidOverrideReturnType_returnType_sameType', () {
4203 final __test = new NonErrorResolverTest();
4204 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_sa meType);
4205 });
4206 _ut.test('test_invalidOverrideReturnType_returnType_superclass', () {
4207 final __test = new NonErrorResolverTest();
4208 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_su perclass);
4209 });
4210 _ut.test('test_invalidOverrideReturnType_returnType_superclass2', () {
4211 final __test = new NonErrorResolverTest();
4212 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_su perclass2);
4213 });
4214 _ut.test('test_invalidOverrideReturnType_returnType_void', () {
4215 final __test = new NonErrorResolverTest();
4216 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_vo id);
4217 });
4218 _ut.test('test_invalidReferenceToThis_constructor', () {
4219 final __test = new NonErrorResolverTest();
4220 runJUnitTest(__test, __test.test_invalidReferenceToThis_constructor);
4221 });
4222 _ut.test('test_invalidReferenceToThis_instanceMethod', () {
4223 final __test = new NonErrorResolverTest();
4224 runJUnitTest(__test, __test.test_invalidReferenceToThis_instanceMethod);
4225 });
4226 _ut.test('test_invalidTypeArgumentForKey', () {
4227 final __test = new NonErrorResolverTest();
4228 runJUnitTest(__test, __test.test_invalidTypeArgumentForKey);
4229 });
4230 _ut.test('test_invalidTypeArgumentInConstList', () {
4231 final __test = new NonErrorResolverTest();
4232 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList);
4233 });
4234 _ut.test('test_invalidTypeArgumentInConstMap', () {
4235 final __test = new NonErrorResolverTest();
4236 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstMap);
4237 });
4238 _ut.test('test_invocationOfNonFunction_Object', () {
4239 final __test = new NonErrorResolverTest();
4240 runJUnitTest(__test, __test.test_invocationOfNonFunction_Object);
4241 });
4242 _ut.test('test_invocationOfNonFunction_dynamic', () {
4243 final __test = new NonErrorResolverTest();
4244 runJUnitTest(__test, __test.test_invocationOfNonFunction_dynamic);
4245 });
4246 _ut.test('test_invocationOfNonFunction_getter', () {
4247 final __test = new NonErrorResolverTest();
4248 runJUnitTest(__test, __test.test_invocationOfNonFunction_getter);
4249 });
4250 _ut.test('test_invocationOfNonFunction_localVariable', () {
4251 final __test = new NonErrorResolverTest();
4252 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable);
4253 });
4254 _ut.test('test_invocationOfNonFunction_localVariable_dynamic', () {
4255 final __test = new NonErrorResolverTest();
4256 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable_d ynamic);
4257 });
4258 _ut.test('test_invocationOfNonFunction_localVariable_dynamic2', () {
4259 final __test = new NonErrorResolverTest();
4260 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable_d ynamic2);
4261 });
4262 _ut.test('test_listElementTypeNotAssignable', () {
4263 final __test = new NonErrorResolverTest();
4264 runJUnitTest(__test, __test.test_listElementTypeNotAssignable);
4265 });
4266 _ut.test('test_mapKeyTypeNotAssignable', () {
4267 final __test = new NonErrorResolverTest();
4268 runJUnitTest(__test, __test.test_mapKeyTypeNotAssignable);
4269 });
4270 _ut.test('test_memberWithClassName_setter', () {
4271 final __test = new NonErrorResolverTest();
4272 runJUnitTest(__test, __test.test_memberWithClassName_setter);
4273 });
4274 _ut.test('test_methodDeclaration_scope_signature', () {
4275 final __test = new NonErrorResolverTest();
4276 runJUnitTest(__test, __test.test_methodDeclaration_scope_signature);
4277 });
4278 _ut.test('test_misMatchedGetterAndSetterTypes_instance_sameTypes', () {
4279 final __test = new NonErrorResolverTest();
4280 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance _sameTypes);
4281 });
4282 _ut.test('test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter', () {
4283 final __test = new NonErrorResolverTest();
4284 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance _unspecifiedGetter);
4285 });
4286 _ut.test('test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter', () {
4287 final __test = new NonErrorResolverTest();
4288 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance _unspecifiedSetter);
4289 });
4290 _ut.test('test_misMatchedGetterAndSetterTypes_topLevel_sameTypes', () {
4291 final __test = new NonErrorResolverTest();
4292 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel _sameTypes);
4293 });
4294 _ut.test('test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter', () {
4295 final __test = new NonErrorResolverTest();
4296 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel _unspecifiedGetter);
4297 });
4298 _ut.test('test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter', () {
4299 final __test = new NonErrorResolverTest();
4300 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel _unspecifiedSetter);
4301 });
4302 _ut.test('test_mixedReturnTypes_differentScopes', () {
4303 final __test = new NonErrorResolverTest();
4304 runJUnitTest(__test, __test.test_mixedReturnTypes_differentScopes);
4305 });
4306 _ut.test('test_mixedReturnTypes_sameKind', () {
4307 final __test = new NonErrorResolverTest();
4308 runJUnitTest(__test, __test.test_mixedReturnTypes_sameKind);
4309 });
4310 _ut.test('test_mixinDeclaresConstructor', () {
4311 final __test = new NonErrorResolverTest();
4312 runJUnitTest(__test, __test.test_mixinDeclaresConstructor);
4313 });
4314 _ut.test('test_mixinDeclaresConstructor_factory', () {
4315 final __test = new NonErrorResolverTest();
4316 runJUnitTest(__test, __test.test_mixinDeclaresConstructor_factory);
4317 });
4318 _ut.test('test_mixinInheritsFromNotObject_classDeclaration_mixTypeAlias', () {
4319 final __test = new NonErrorResolverTest();
4320 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_classDeclara tion_mixTypeAlias);
4321 });
4322 _ut.test('test_mixinInheritsFromNotObject_typedef_mixTypeAlias', () {
4323 final __test = new NonErrorResolverTest();
4324 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_typedef_mixT ypeAlias);
4325 });
4326 _ut.test('test_multipleSuperInitializers_no', () {
4327 final __test = new NonErrorResolverTest();
4328 runJUnitTest(__test, __test.test_multipleSuperInitializers_no);
4329 });
4330 _ut.test('test_multipleSuperInitializers_single', () {
4331 final __test = new NonErrorResolverTest();
4332 runJUnitTest(__test, __test.test_multipleSuperInitializers_single);
4333 });
4334 _ut.test('test_newWithAbstractClass_factory', () {
4335 final __test = new NonErrorResolverTest();
4336 runJUnitTest(__test, __test.test_newWithAbstractClass_factory);
4337 });
4338 _ut.test('test_newWithUndefinedConstructor', () {
4339 final __test = new NonErrorResolverTest();
4340 runJUnitTest(__test, __test.test_newWithUndefinedConstructor);
4341 });
4342 _ut.test('test_newWithUndefinedConstructorDefault', () {
4343 final __test = new NonErrorResolverTest();
4344 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault);
4345 });
4346 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_abstractOverrides Concrete_accessor', () {
4347 final __test = new NonErrorResolverTest();
4348 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_abstractOverridesConcrete_accessor);
4349 });
4350 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_abstractOverrides Concrete_method', () {
4351 final __test = new NonErrorResolverTest();
4352 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_abstractOverridesConcrete_method);
4353 });
4354 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_acce ssor', () {
4355 final __test = new NonErrorResolverTest();
4356 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_noSuchMethod_accessor);
4357 });
4358 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_meth od', () {
4359 final __test = new NonErrorResolverTest();
4360 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_noSuchMethod_method);
4361 });
4362 _ut.test('test_nonBoolExpression_functionType', () {
4363 final __test = new NonErrorResolverTest();
4364 runJUnitTest(__test, __test.test_nonBoolExpression_functionType);
4365 });
4366 _ut.test('test_nonBoolExpression_interfaceType', () {
4367 final __test = new NonErrorResolverTest();
4368 runJUnitTest(__test, __test.test_nonBoolExpression_interfaceType);
4369 });
4370 _ut.test('test_nonConstCaseExpression', () {
4371 final __test = new NonErrorResolverTest();
4372 runJUnitTest(__test, __test.test_nonConstCaseExpression);
4373 });
4374 _ut.test('test_nonConstMapAsExpressionStatement_const', () {
4375 final __test = new NonErrorResolverTest();
4376 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_const) ;
4377 });
4378 _ut.test('test_nonConstMapAsExpressionStatement_notExpressionStatement', ( ) {
4379 final __test = new NonErrorResolverTest();
4380 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_notExp ressionStatement);
4381 });
4382 _ut.test('test_nonConstMapAsExpressionStatement_typeArguments', () {
4383 final __test = new NonErrorResolverTest();
4384 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_typeAr guments);
4385 });
4386 _ut.test('test_nonConstValueInInitializer_binary_bool', () {
4387 final __test = new NonErrorResolverTest();
4388 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_bool) ;
4389 });
4390 _ut.test('test_nonConstValueInInitializer_binary_dynamic', () {
4391 final __test = new NonErrorResolverTest();
4392 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_dynam ic);
4393 });
4394 _ut.test('test_nonConstValueInInitializer_binary_int', () {
4395 final __test = new NonErrorResolverTest();
4396 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_int);
4397 });
4398 _ut.test('test_nonConstValueInInitializer_binary_num', () {
4399 final __test = new NonErrorResolverTest();
4400 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_num);
4401 });
4402 _ut.test('test_nonConstValueInInitializer_field', () {
4403 final __test = new NonErrorResolverTest();
4404 runJUnitTest(__test, __test.test_nonConstValueInInitializer_field);
4405 });
4406 _ut.test('test_nonConstValueInInitializer_redirecting', () {
4407 final __test = new NonErrorResolverTest();
4408 runJUnitTest(__test, __test.test_nonConstValueInInitializer_redirecting) ;
4409 });
4410 _ut.test('test_nonConstValueInInitializer_super', () {
4411 final __test = new NonErrorResolverTest();
4412 runJUnitTest(__test, __test.test_nonConstValueInInitializer_super);
4413 });
4414 _ut.test('test_nonConstValueInInitializer_unary', () {
4415 final __test = new NonErrorResolverTest();
4416 runJUnitTest(__test, __test.test_nonConstValueInInitializer_unary);
4417 });
4418 _ut.test('test_nonConstantDefaultValue_function_named', () {
4419 final __test = new NonErrorResolverTest();
4420 runJUnitTest(__test, __test.test_nonConstantDefaultValue_function_named) ;
4421 });
4422 _ut.test('test_nonConstantDefaultValue_function_positional', () {
4423 final __test = new NonErrorResolverTest();
4424 runJUnitTest(__test, __test.test_nonConstantDefaultValue_function_positi onal);
4425 });
4426 _ut.test('test_nonConstantDefaultValue_inConstructor_named', () {
4427 final __test = new NonErrorResolverTest();
4428 runJUnitTest(__test, __test.test_nonConstantDefaultValue_inConstructor_n amed);
4429 });
4430 _ut.test('test_nonConstantDefaultValue_inConstructor_positional', () {
4431 final __test = new NonErrorResolverTest();
4432 runJUnitTest(__test, __test.test_nonConstantDefaultValue_inConstructor_p ositional);
4433 });
4434 _ut.test('test_nonConstantDefaultValue_method_named', () {
4435 final __test = new NonErrorResolverTest();
4436 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_named);
4437 });
4438 _ut.test('test_nonConstantDefaultValue_method_positional', () {
4439 final __test = new NonErrorResolverTest();
4440 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_position al);
4441 });
4442 _ut.test('test_nonConstantValueInInitializer_namedArgument', () {
4443 final __test = new NonErrorResolverTest();
4444 runJUnitTest(__test, __test.test_nonConstantValueInInitializer_namedArgu ment);
4445 });
4446 _ut.test('test_nonGenerativeConstructor', () {
4447 final __test = new NonErrorResolverTest();
4448 runJUnitTest(__test, __test.test_nonGenerativeConstructor);
4449 });
4450 _ut.test('test_nonTypeInCatchClause_isClass', () {
4451 final __test = new NonErrorResolverTest();
4452 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isClass);
4453 });
4454 _ut.test('test_nonTypeInCatchClause_isFunctionTypeAlias', () {
4455 final __test = new NonErrorResolverTest();
4456 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isFunctionTypeAlia s);
4457 });
4458 _ut.test('test_nonTypeInCatchClause_isTypeParameter', () {
4459 final __test = new NonErrorResolverTest();
4460 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isTypeParameter);
4461 });
4462 _ut.test('test_nonTypeInCatchClause_noType', () {
4463 final __test = new NonErrorResolverTest();
4464 runJUnitTest(__test, __test.test_nonTypeInCatchClause_noType);
4465 });
4466 _ut.test('test_nonVoidReturnForOperator_no', () {
4467 final __test = new NonErrorResolverTest();
4468 runJUnitTest(__test, __test.test_nonVoidReturnForOperator_no);
4469 });
4470 _ut.test('test_nonVoidReturnForOperator_void', () {
4471 final __test = new NonErrorResolverTest();
4472 runJUnitTest(__test, __test.test_nonVoidReturnForOperator_void);
4473 });
4474 _ut.test('test_nonVoidReturnForSetter_function_no', () {
4475 final __test = new NonErrorResolverTest();
4476 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_function_no);
4477 });
4478 _ut.test('test_nonVoidReturnForSetter_function_void', () {
4479 final __test = new NonErrorResolverTest();
4480 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_function_void);
4481 });
4482 _ut.test('test_nonVoidReturnForSetter_method_no', () {
4483 final __test = new NonErrorResolverTest();
4484 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_method_no);
4485 });
4486 _ut.test('test_nonVoidReturnForSetter_method_void', () {
4487 final __test = new NonErrorResolverTest();
4488 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_method_void);
4489 });
4490 _ut.test('test_null_callMethod', () {
4491 final __test = new NonErrorResolverTest();
4492 runJUnitTest(__test, __test.test_null_callMethod);
4493 });
4494 _ut.test('test_null_callOperator', () {
4495 final __test = new NonErrorResolverTest();
4496 runJUnitTest(__test, __test.test_null_callOperator);
4497 });
4498 _ut.test('test_optionalParameterInOperator_required', () {
4499 final __test = new NonErrorResolverTest();
4500 runJUnitTest(__test, __test.test_optionalParameterInOperator_required);
4501 });
4502 _ut.test('test_prefixCollidesWithTopLevelMembers', () {
4503 final __test = new NonErrorResolverTest();
4504 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers);
4505 });
4506 _ut.test('test_propagateTypeArgs_intoBounds', () {
4507 final __test = new NonErrorResolverTest();
4508 runJUnitTest(__test, __test.test_propagateTypeArgs_intoBounds);
4509 });
4510 _ut.test('test_propagateTypeArgs_intoSupertype', () {
4511 final __test = new NonErrorResolverTest();
4512 runJUnitTest(__test, __test.test_propagateTypeArgs_intoSupertype);
4513 });
4514 _ut.test('test_proxy_annotation_prefixed', () {
4515 final __test = new NonErrorResolverTest();
4516 runJUnitTest(__test, __test.test_proxy_annotation_prefixed);
4517 });
4518 _ut.test('test_proxy_annotation_prefixed2', () {
4519 final __test = new NonErrorResolverTest();
4520 runJUnitTest(__test, __test.test_proxy_annotation_prefixed2);
4521 });
4522 _ut.test('test_proxy_annotation_prefixed3', () {
4523 final __test = new NonErrorResolverTest();
4524 runJUnitTest(__test, __test.test_proxy_annotation_prefixed3);
4525 });
4526 _ut.test('test_proxy_annotation_simple', () {
4527 final __test = new NonErrorResolverTest();
4528 runJUnitTest(__test, __test.test_proxy_annotation_simple);
4529 });
4530 _ut.test('test_recursiveConstructorRedirect', () {
4531 final __test = new NonErrorResolverTest();
4532 runJUnitTest(__test, __test.test_recursiveConstructorRedirect);
4533 });
4534 _ut.test('test_recursiveFactoryRedirect', () {
4535 final __test = new NonErrorResolverTest();
4536 runJUnitTest(__test, __test.test_recursiveFactoryRedirect);
4537 });
4538 _ut.test('test_redirectToInvalidFunctionType', () {
4539 final __test = new NonErrorResolverTest();
4540 runJUnitTest(__test, __test.test_redirectToInvalidFunctionType);
4541 });
4542 _ut.test('test_redirectToInvalidReturnType', () {
4543 final __test = new NonErrorResolverTest();
4544 runJUnitTest(__test, __test.test_redirectToInvalidReturnType);
4545 });
4546 _ut.test('test_redirectToNonConstConstructor', () {
4547 final __test = new NonErrorResolverTest();
4548 runJUnitTest(__test, __test.test_redirectToNonConstConstructor);
4549 });
4550 _ut.test('test_referenceToDeclaredVariableInInitializer_constructorName', () {
4551 final __test = new NonErrorResolverTest();
4552 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_constructorName);
4553 });
4554 _ut.test('test_referenceToDeclaredVariableInInitializer_methodName', () {
4555 final __test = new NonErrorResolverTest();
4556 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_methodName);
4557 });
4558 _ut.test('test_referenceToDeclaredVariableInInitializer_propertyName', () {
4559 final __test = new NonErrorResolverTest();
4560 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_propertyName);
4561 });
4562 _ut.test('test_rethrowOutsideCatch', () {
4563 final __test = new NonErrorResolverTest();
4564 runJUnitTest(__test, __test.test_rethrowOutsideCatch);
4565 });
4566 _ut.test('test_returnInGenerativeConstructor', () {
4567 final __test = new NonErrorResolverTest();
4568 runJUnitTest(__test, __test.test_returnInGenerativeConstructor);
4569 });
4570 _ut.test('test_returnOfInvalidType_dynamic', () {
4571 final __test = new NonErrorResolverTest();
4572 runJUnitTest(__test, __test.test_returnOfInvalidType_dynamic);
4573 });
4574 _ut.test('test_returnOfInvalidType_dynamicAsTypeArgument', () {
4575 final __test = new NonErrorResolverTest();
4576 runJUnitTest(__test, __test.test_returnOfInvalidType_dynamicAsTypeArgume nt);
4577 });
4578 _ut.test('test_returnOfInvalidType_subtype', () {
4579 final __test = new NonErrorResolverTest();
4580 runJUnitTest(__test, __test.test_returnOfInvalidType_subtype);
4581 });
4582 _ut.test('test_returnOfInvalidType_supertype', () {
4583 final __test = new NonErrorResolverTest();
4584 runJUnitTest(__test, __test.test_returnOfInvalidType_supertype);
4585 });
4586 _ut.test('test_returnOfInvalidType_void', () {
4587 final __test = new NonErrorResolverTest();
4588 runJUnitTest(__test, __test.test_returnOfInvalidType_void);
4589 });
4590 _ut.test('test_returnWithoutValue_noReturnType', () {
4591 final __test = new NonErrorResolverTest();
4592 runJUnitTest(__test, __test.test_returnWithoutValue_noReturnType);
4593 });
4594 _ut.test('test_returnWithoutValue_void', () {
4595 final __test = new NonErrorResolverTest();
4596 runJUnitTest(__test, __test.test_returnWithoutValue_void);
4597 });
4598 _ut.test('test_staticAccessToInstanceMember_annotation', () {
4599 final __test = new NonErrorResolverTest();
4600 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_annotation );
4601 });
4602 _ut.test('test_staticAccessToInstanceMember_method', () {
4603 final __test = new NonErrorResolverTest();
4604 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method);
4605 });
4606 _ut.test('test_staticAccessToInstanceMember_propertyAccess_field', () {
4607 final __test = new NonErrorResolverTest();
4608 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_field);
4609 });
4610 _ut.test('test_staticAccessToInstanceMember_propertyAccess_propertyAccesso r', () {
4611 final __test = new NonErrorResolverTest();
4612 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_propertyAccessor);
4613 });
4614 _ut.test('test_superInInvalidContext', () {
4615 final __test = new NonErrorResolverTest();
4616 runJUnitTest(__test, __test.test_superInInvalidContext);
4617 });
4618 _ut.test('test_typeAliasCannotReferenceItself_returnClass_withTypeAlias', () {
4619 final __test = new NonErrorResolverTest();
4620 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_returnCl ass_withTypeAlias);
4621 });
4622 _ut.test('test_typeArgumentNotMatchingBounds_const', () {
4623 final __test = new NonErrorResolverTest();
4624 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
4625 });
4626 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
4627 final __test = new NonErrorResolverTest();
4628 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
4629 });
4630 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList_0', () {
4631 final __test = new NonErrorResolverTest();
4632 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum entList_0);
4633 });
4634 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList_1', () {
4635 final __test = new NonErrorResolverTest();
4636 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum entList_1);
4637 });
4638 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList_20', () {
4639 final __test = new NonErrorResolverTest();
4640 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum entList_20);
4641 });
4642 _ut.test('test_typePromotion_booleanAnd_useInRight', () {
4643 final __test = new NonErrorResolverTest();
4644 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight);
4645 });
4646 _ut.test('test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_ noAssignment', () {
4647 final __test = new NonErrorResolverTest();
4648 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight_acc essedInClosureRight_noAssignment);
4649 });
4650 _ut.test('test_typePromotion_conditional_useInThen', () {
4651 final __test = new NonErrorResolverTest();
4652 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen);
4653 });
4654 _ut.test('test_typePromotion_conditional_useInThen_accessedInClosure_noAss ignment', () {
4655 final __test = new NonErrorResolverTest();
4656 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen_acc essedInClosure_noAssignment);
4657 });
4658 _ut.test('test_typePromotion_functionType_arg_ignoreIfNotMoreSpecific', () {
4659 final __test = new NonErrorResolverTest();
4660 runJUnitTest(__test, __test.test_typePromotion_functionType_arg_ignoreIf NotMoreSpecific);
4661 });
4662 _ut.test('test_typePromotion_functionType_return_ignoreIfNotMoreSpecific', () {
4663 final __test = new NonErrorResolverTest();
4664 runJUnitTest(__test, __test.test_typePromotion_functionType_return_ignor eIfNotMoreSpecific);
4665 });
4666 _ut.test('test_typePromotion_functionType_return_voidToDynamic', () {
4667 final __test = new NonErrorResolverTest();
4668 runJUnitTest(__test, __test.test_typePromotion_functionType_return_voidT oDynamic);
4669 });
4670 _ut.test('test_typePromotion_if_accessedInClosure_noAssignment', () {
4671 final __test = new NonErrorResolverTest();
4672 runJUnitTest(__test, __test.test_typePromotion_if_accessedInClosure_noAs signment);
4673 });
4674 _ut.test('test_typePromotion_if_hasAssignment_outsideAfter', () {
4675 final __test = new NonErrorResolverTest();
4676 runJUnitTest(__test, __test.test_typePromotion_if_hasAssignment_outsideA fter);
4677 });
4678 _ut.test('test_typePromotion_if_hasAssignment_outsideBefore', () {
4679 final __test = new NonErrorResolverTest();
4680 runJUnitTest(__test, __test.test_typePromotion_if_hasAssignment_outsideB efore);
4681 });
4682 _ut.test('test_typePromotion_if_is_and_left', () {
4683 final __test = new NonErrorResolverTest();
4684 runJUnitTest(__test, __test.test_typePromotion_if_is_and_left);
4685 });
4686 _ut.test('test_typePromotion_if_is_and_right', () {
4687 final __test = new NonErrorResolverTest();
4688 runJUnitTest(__test, __test.test_typePromotion_if_is_and_right);
4689 });
4690 _ut.test('test_typePromotion_if_is_and_subThenSuper', () {
4691 final __test = new NonErrorResolverTest();
4692 runJUnitTest(__test, __test.test_typePromotion_if_is_and_subThenSuper);
4693 });
4694 _ut.test('test_typePromotion_if_is_parenthesized', () {
4695 final __test = new NonErrorResolverTest();
4696 runJUnitTest(__test, __test.test_typePromotion_if_is_parenthesized);
4697 });
4698 _ut.test('test_typePromotion_if_is_single', () {
4699 final __test = new NonErrorResolverTest();
4700 runJUnitTest(__test, __test.test_typePromotion_if_is_single);
4701 });
4702 _ut.test('test_undefinedConstructorInInitializer_explicit_named', () {
4703 final __test = new NonErrorResolverTest();
4704 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_named);
4705 });
4706 _ut.test('test_undefinedConstructorInInitializer_explicit_unnamed', () {
4707 final __test = new NonErrorResolverTest();
4708 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_unnamed);
4709 });
4710 _ut.test('test_undefinedConstructorInInitializer_hasOptionalParameters', ( ) {
4711 final __test = new NonErrorResolverTest();
4712 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_hasOp tionalParameters);
4713 });
4714 _ut.test('test_undefinedConstructorInInitializer_implicit', () {
4715 final __test = new NonErrorResolverTest();
4716 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit);
4717 });
4718 _ut.test('test_undefinedConstructorInInitializer_implicit_typeAlias', () {
4719 final __test = new NonErrorResolverTest();
4720 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit_typeAlias);
4721 });
4722 _ut.test('test_undefinedConstructorInInitializer_redirecting', () {
4723 final __test = new NonErrorResolverTest();
4724 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_redir ecting);
4725 });
4726 _ut.test('test_undefinedGetter_typeSubstitution', () {
4727 final __test = new NonErrorResolverTest();
4728 runJUnitTest(__test, __test.test_undefinedGetter_typeSubstitution);
4729 });
4730 _ut.test('test_undefinedIdentifier_hide', () {
4731 final __test = new NonErrorResolverTest();
4732 runJUnitTest(__test, __test.test_undefinedIdentifier_hide);
4733 });
4734 _ut.test('test_undefinedIdentifier_show', () {
4735 final __test = new NonErrorResolverTest();
4736 runJUnitTest(__test, __test.test_undefinedIdentifier_show);
4737 });
4738 _ut.test('test_undefinedMethod_functionExpression_callMethod', () {
4739 final __test = new NonErrorResolverTest();
4740 runJUnitTest(__test, __test.test_undefinedMethod_functionExpression_call Method);
4741 });
4742 _ut.test('test_undefinedMethod_functionExpression_directCall', () {
4743 final __test = new NonErrorResolverTest();
4744 runJUnitTest(__test, __test.test_undefinedMethod_functionExpression_dire ctCall);
4745 });
4746 _ut.test('test_undefinedOperator_index', () {
4747 final __test = new NonErrorResolverTest();
4748 runJUnitTest(__test, __test.test_undefinedOperator_index);
4749 });
4750 _ut.test('test_undefinedOperator_tilde', () {
4751 final __test = new NonErrorResolverTest();
4752 runJUnitTest(__test, __test.test_undefinedOperator_tilde);
4753 });
4754 _ut.test('test_undefinedSetter_importWithPrefix', () {
4755 final __test = new NonErrorResolverTest();
4756 runJUnitTest(__test, __test.test_undefinedSetter_importWithPrefix);
4757 });
4758 _ut.test('test_undefinedSuperMethod_field', () {
4759 final __test = new NonErrorResolverTest();
4760 runJUnitTest(__test, __test.test_undefinedSuperMethod_field);
4761 });
4762 _ut.test('test_undefinedSuperMethod_method', () {
4763 final __test = new NonErrorResolverTest();
4764 runJUnitTest(__test, __test.test_undefinedSuperMethod_method);
4765 });
4766 _ut.test('test_wrongNumberOfParametersForOperator1', () {
4767 final __test = new NonErrorResolverTest();
4768 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator1);
4769 });
4770 _ut.test('test_wrongNumberOfParametersForOperator_index', () {
4771 final __test = new NonErrorResolverTest();
4772 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_inde x);
4773 });
4774 _ut.test('test_wrongNumberOfParametersForOperator_minus', () {
4775 final __test = new NonErrorResolverTest();
4776 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_minu s);
4777 });
4778 _ut.test('test_wrongNumberOfParametersForSetter', () {
4779 final __test = new NonErrorResolverTest();
4780 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter);
4781 });
4782 });
4783 }
4784 }
4785 class LibraryTest extends EngineTestCase {
4786
4787 /**
4788 * The error listener to which all errors will be reported.
4789 */
4790 GatheringErrorListener _errorListener;
4791
4792 /**
4793 * The source factory used to create libraries.
4794 */
4795 SourceFactory _sourceFactory;
4796
4797 /**
4798 * The analysis context to pass in to all libraries created by the tests.
4799 */
4800 AnalysisContextImpl _analysisContext;
4801
4802 /**
4803 * The library used by the tests.
4804 */
4805 Library _library5;
4806 void setUp() {
4807 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
4808 _analysisContext = new AnalysisContextImpl();
4809 _analysisContext.sourceFactory = _sourceFactory;
4810 _errorListener = new GatheringErrorListener();
4811 _library5 = library("/lib.dart");
4812 }
4813 void test_getExplicitlyImportsCore() {
4814 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore);
4815 _errorListener.assertNoErrors();
4816 }
4817 void test_getExports() {
4818 EngineTestCase.assertLength(0, _library5.exports);
4819 _errorListener.assertNoErrors();
4820 }
4821 void test_getImports() {
4822 EngineTestCase.assertLength(0, _library5.imports);
4823 _errorListener.assertNoErrors();
4824 }
4825 void test_getImportsAndExports() {
4826 _library5.importedLibraries = <Library> [library("/imported.dart")];
4827 _library5.exportedLibraries = <Library> [library("/exported.dart")];
4828 EngineTestCase.assertLength(2, _library5.importsAndExports);
4829 _errorListener.assertNoErrors();
4830 }
4831 void test_getLibraryScope() {
4832 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac tory.libraryIdentifier2(["lib"]));
4833 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart") ;
4834 _library5.libraryElement = element;
4835 JUnitTestCase.assertNotNull(_library5.libraryScope);
4836 _errorListener.assertNoErrors();
4837 }
4838 void test_getLibrarySource() {
4839 JUnitTestCase.assertNotNull(_library5.librarySource);
4840 }
4841 void test_setExplicitlyImportsCore() {
4842 _library5.explicitlyImportsCore = true;
4843 JUnitTestCase.assertTrue(_library5.explicitlyImportsCore);
4844 _errorListener.assertNoErrors();
4845 }
4846 void test_setExportedLibraries() {
4847 Library exportLibrary = library("/exported.dart");
4848 _library5.exportedLibraries = <Library> [exportLibrary];
4849 List<Library> exports = _library5.exports;
4850 EngineTestCase.assertLength(1, exports);
4851 JUnitTestCase.assertSame(exportLibrary, exports[0]);
4852 _errorListener.assertNoErrors();
4853 }
4854 void test_setImportedLibraries() {
4855 Library importLibrary = library("/imported.dart");
4856 _library5.importedLibraries = <Library> [importLibrary];
4857 List<Library> imports = _library5.imports;
4858 EngineTestCase.assertLength(1, imports);
4859 JUnitTestCase.assertSame(importLibrary, imports[0]);
4860 _errorListener.assertNoErrors();
4861 }
4862 void test_setLibraryElement() {
4863 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac tory.libraryIdentifier2(["lib"]));
4864 _library5.libraryElement = element;
4865 JUnitTestCase.assertSame(element, _library5.libraryElement);
4866 }
4867 Library library(String definingCompilationUnitPath) => new Library(_analysisCo ntext, _errorListener, new FileBasedSource.con1(_sourceFactory.contentCache, Fil eUtilities2.createFile(definingCompilationUnitPath)));
4868 static dartSuite() {
4869 _ut.group('LibraryTest', () {
4870 _ut.test('test_getExplicitlyImportsCore', () {
4871 final __test = new LibraryTest();
4872 runJUnitTest(__test, __test.test_getExplicitlyImportsCore);
4873 });
4874 _ut.test('test_getExports', () {
4875 final __test = new LibraryTest();
4876 runJUnitTest(__test, __test.test_getExports);
4877 });
4878 _ut.test('test_getImports', () {
4879 final __test = new LibraryTest();
4880 runJUnitTest(__test, __test.test_getImports);
4881 });
4882 _ut.test('test_getImportsAndExports', () {
4883 final __test = new LibraryTest();
4884 runJUnitTest(__test, __test.test_getImportsAndExports);
4885 });
4886 _ut.test('test_getLibraryScope', () {
4887 final __test = new LibraryTest();
4888 runJUnitTest(__test, __test.test_getLibraryScope);
4889 });
4890 _ut.test('test_getLibrarySource', () {
4891 final __test = new LibraryTest();
4892 runJUnitTest(__test, __test.test_getLibrarySource);
4893 });
4894 _ut.test('test_setExplicitlyImportsCore', () {
4895 final __test = new LibraryTest();
4896 runJUnitTest(__test, __test.test_setExplicitlyImportsCore);
4897 });
4898 _ut.test('test_setExportedLibraries', () {
4899 final __test = new LibraryTest();
4900 runJUnitTest(__test, __test.test_setExportedLibraries);
4901 });
4902 _ut.test('test_setImportedLibraries', () {
4903 final __test = new LibraryTest();
4904 runJUnitTest(__test, __test.test_setImportedLibraries);
4905 });
4906 _ut.test('test_setLibraryElement', () {
4907 final __test = new LibraryTest();
4908 runJUnitTest(__test, __test.test_setLibraryElement);
4909 });
4910 });
4911 }
4912 }
4913 class StaticTypeWarningCodeTest extends ResolverTestCase {
4914 void fail_inaccessibleSetter() {
4915 Source source = addSource(EngineTestCase.createSource([]));
4916 resolve(source);
4917 assertErrors(source, [StaticTypeWarningCode.INACCESSIBLE_SETTER]);
4918 verify([source]);
4919 }
4920 void test_expectedOneListTypeArgument() {
4921 Source source = addSource(EngineTestCase.createSource(["main() {", " <int, int> [];", "}"]));
4922 resolve(source);
4923 assertErrors(source, [StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS ]);
4924 verify([source]);
4925 }
4926 void test_expectedTwoMapTypeArguments_one() {
4927 Source source = addSource(EngineTestCase.createSource(["main() {", " <int> {};", "}"]));
4928 resolve(source);
4929 assertErrors(source, [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS] );
4930 verify([source]);
4931 }
4932 void test_expectedTwoMapTypeArguments_three() {
4933 Source source = addSource(EngineTestCase.createSource(["main() {", " <int, int, int> {};", "}"]));
4934 resolve(source);
4935 assertErrors(source, [StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS] );
4936 verify([source]);
4937 }
4938 void test_inconsistentMethodInheritance_paramCount() {
4939 Source source = addSource(EngineTestCase.createSource([
4940 "abstract class A {",
4941 " int x();",
4942 "}",
4943 "abstract class B {",
4944 " int x(int y);",
4945 "}",
4946 "class C implements A, B {",
4947 "}"]));
4948 resolve(source);
4949 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE] );
4950 verify([source]);
4951 }
4952 void test_inconsistentMethodInheritance_paramType() {
4953 Source source = addSource(EngineTestCase.createSource([
4954 "abstract class A {",
4955 " x(int i);",
4956 "}",
4957 "abstract class B {",
4958 " x(String s);",
4959 "}",
4960 "abstract class C implements A, B {}"]));
4961 resolve(source);
4962 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE] );
4963 verify([source]);
4964 }
4965 void test_inconsistentMethodInheritance_returnType() {
4966 Source source = addSource(EngineTestCase.createSource([
4967 "abstract class A {",
4968 " int x();",
4969 "}",
4970 "abstract class B {",
4971 " String x();",
4972 "}",
4973 "abstract class C implements A, B {}"]));
4974 resolve(source);
4975 assertErrors(source, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE] );
4976 verify([source]);
4977 }
4978 void test_instanceAccessToStaticMember_method_invocation() {
4979 Source source = addSource(EngineTestCase.createSource([
4980 "class A {",
4981 " static m() {}",
4982 "}",
4983 "main(A a) {",
4984 " a.m();",
4985 "}"]));
4986 resolve(source);
4987 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER ]);
4988 verify([source]);
4989 }
4990 void test_instanceAccessToStaticMember_method_reference() {
4991 Source source = addSource(EngineTestCase.createSource([
4992 "class A {",
4993 " static m() {}",
4994 "}",
4995 "main(A a) {",
4996 " a.m;",
4997 "}"]));
4998 resolve(source);
4999 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER ]);
5000 verify([source]);
5001 }
5002 void test_instanceAccessToStaticMember_propertyAccess_field() {
5003 Source source = addSource(EngineTestCase.createSource([
5004 "class A {",
5005 " static var f;",
5006 "}",
5007 "main(A a) {",
5008 " a.f;",
5009 "}"]));
5010 resolve(source);
5011 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER ]);
5012 verify([source]);
5013 }
5014 void test_instanceAccessToStaticMember_propertyAccess_getter() {
5015 Source source = addSource(EngineTestCase.createSource([
5016 "class A {",
5017 " static get f => 42;",
5018 "}",
5019 "main(A a) {",
5020 " a.f;",
5021 "}"]));
5022 resolve(source);
5023 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER ]);
5024 verify([source]);
5025 }
5026 void test_instanceAccessToStaticMember_propertyAccess_setter() {
5027 Source source = addSource(EngineTestCase.createSource([
5028 "class A {",
5029 " static set f(x) {}",
5030 "}",
5031 "main(A a) {",
5032 " a.f = 42;",
5033 "}"]));
5034 resolve(source);
5035 assertErrors(source, [StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER ]);
5036 verify([source]);
5037 }
5038 void test_invalidAssignment_compoundAssignment() {
5039 Source source = addSource(EngineTestCase.createSource([
5040 "class byte {",
5041 " int _value;",
5042 " byte(this._value);",
5043 " int operator +(int val) {}",
5044 "}",
5045 "",
5046 "void main() {",
5047 " byte b = new byte(52);",
5048 " b += 3;",
5049 "}"]));
5050 resolve(source);
5051 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
5052 verify([source]);
5053 }
5054 void test_invalidAssignment_defaultValue_named() {
5055 Source source = addSource(EngineTestCase.createSource(["f({String x: 0}) {", "}"]));
5056 resolve(source);
5057 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
5058 verify([source]);
5059 }
5060 void test_invalidAssignment_defaultValue_optional() {
5061 Source source = addSource(EngineTestCase.createSource(["f([String x = 0]) {" , "}"]));
5062 resolve(source);
5063 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
5064 verify([source]);
5065 }
5066 void test_invalidAssignment_instanceVariable() {
5067 Source source = addSource(EngineTestCase.createSource([
5068 "class A {",
5069 " int x;",
5070 "}",
5071 "f() {",
5072 " A a;",
5073 " a.x = '0';",
5074 "}"]));
5075 resolve(source);
5076 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
5077 verify([source]);
5078 }
5079 void test_invalidAssignment_localVariable() {
5080 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;", " x = '0';", "}"]));
5081 resolve(source);
5082 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
5083 verify([source]);
5084 }
5085 void test_invalidAssignment_staticVariable() {
5086 Source source = addSource(EngineTestCase.createSource([
5087 "class A {",
5088 " static int x;",
5089 "}",
5090 "f() {",
5091 " A.x = '0';",
5092 "}"]));
5093 resolve(source);
5094 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
5095 verify([source]);
5096 }
5097 void test_invalidAssignment_topLevelVariableDeclaration() {
5098 Source source = addSource(EngineTestCase.createSource(["int x = 'string';"]) );
5099 resolve(source);
5100 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
5101 verify([source]);
5102 }
5103 void test_invalidAssignment_variableDeclaration() {
5104 Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 'string';", "}"]));
5105 resolve(source);
5106 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
5107 verify([source]);
5108 }
5109 void test_invocationOfNonFunction_class() {
5110 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " A();", " }", "}"]));
5111 resolve(source);
5112 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
5113 }
5114 void test_invocationOfNonFunction_localVariable() {
5115 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;", " return x();", "}"]));
5116 resolve(source);
5117 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
5118 verify([source]);
5119 }
5120 void test_invocationOfNonFunction_ordinaryInvocation() {
5121 Source source = addSource(EngineTestCase.createSource([
5122 "class A {",
5123 " static int x;",
5124 "}",
5125 "class B {",
5126 " m() {",
5127 " A.x();",
5128 " }",
5129 "}"]));
5130 resolve(source);
5131 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
5132 }
5133 void test_invocationOfNonFunction_staticInvocation() {
5134 Source source = addSource(EngineTestCase.createSource([
5135 "class A {",
5136 " static int get g => 0;",
5137 " f() {",
5138 " A.g();",
5139 " }",
5140 "}"]));
5141 resolve(source);
5142 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
5143 }
5144 void test_invocationOfNonFunction_superExpression() {
5145 Source source = addSource(EngineTestCase.createSource([
5146 "class A {",
5147 " int get g => 0;",
5148 "}",
5149 "class B extends A {",
5150 " m() {",
5151 " var v = super.g();",
5152 " }",
5153 "}"]));
5154 resolve(source);
5155 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
5156 verify([source]);
5157 }
5158 void test_invocationOfNonFunctionExpression_literal() {
5159 Source source = addSource(EngineTestCase.createSource(["f() {", " 3(5);", " }"]));
5160 resolve(source);
5161 assertErrors(source, [StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRE SSION]);
5162 verify([source]);
5163 }
5164 void test_nonBoolCondition_conditional() {
5165 Source source = addSource(EngineTestCase.createSource(["f() { return 3 ? 2 : 1; }"]));
5166 resolve(source);
5167 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]);
5168 verify([source]);
5169 }
5170 void test_nonBoolCondition_do() {
5171 Source source = addSource(EngineTestCase.createSource(["f() {", " do {} whi le (3);", "}"]));
5172 resolve(source);
5173 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]);
5174 verify([source]);
5175 }
5176 void test_nonBoolCondition_if() {
5177 Source source = addSource(EngineTestCase.createSource(["f() {", " if (3) re turn 2; else return 1;", "}"]));
5178 resolve(source);
5179 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]);
5180 verify([source]);
5181 }
5182 void test_nonBoolCondition_while() {
5183 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3) {}", "}"]));
5184 resolve(source);
5185 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_CONDITION]);
5186 verify([source]);
5187 }
5188 void test_nonBoolExpression_functionType() {
5189 Source source = addSource(EngineTestCase.createSource([
5190 "int makeAssertion() => 1;",
5191 "f() {",
5192 " assert(makeAssertion);",
5193 "}"]));
5194 resolve(source);
5195 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
5196 verify([source]);
5197 }
5198 void test_nonBoolExpression_interfaceType() {
5199 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"]));
5200 resolve(source);
5201 assertErrors(source, [StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
5202 verify([source]);
5203 }
5204 void test_nonTypeAsTypeArgument_notAType() {
5205 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"]));
5206 resolve(source);
5207 assertErrors(source, [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
5208 verify([source]);
5209 }
5210 void test_nonTypeAsTypeArgument_undefinedIdentifier() {
5211 Source source = addSource(EngineTestCase.createSource(["class B<E> {}", "f(B <A> b) {}"]));
5212 resolve(source);
5213 assertErrors(source, [StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
5214 verify([source]);
5215 }
5216 void test_returnOfInvalidType_expressionFunctionBody_function() {
5217 Source source = addSource(EngineTestCase.createSource(["int f() => '0';"]));
5218 resolve(source);
5219 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5220 verify([source]);
5221 }
5222 void test_returnOfInvalidType_expressionFunctionBody_getter() {
5223 Source source = addSource(EngineTestCase.createSource(["int get g => '0';"]) );
5224 resolve(source);
5225 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5226 verify([source]);
5227 }
5228 void test_returnOfInvalidType_expressionFunctionBody_localFunction() {
5229 Source source = addSource(EngineTestCase.createSource([
5230 "class A {",
5231 " String m() {",
5232 " int f() => '0';",
5233 " }",
5234 "}"]));
5235 resolve(source);
5236 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5237 verify([source]);
5238 }
5239 void test_returnOfInvalidType_expressionFunctionBody_method() {
5240 Source source = addSource(EngineTestCase.createSource(["class A {", " int f () => '0';", "}"]));
5241 resolve(source);
5242 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5243 verify([source]);
5244 }
5245 void test_returnOfInvalidType_expressionFunctionBody_void() {
5246 Source source = addSource(EngineTestCase.createSource(["void f() => 42;"]));
5247 resolve(source);
5248 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5249 verify([source]);
5250 }
5251 void test_returnOfInvalidType_function() {
5252 Source source = addSource(EngineTestCase.createSource(["int f() { return '0' ; }"]));
5253 resolve(source);
5254 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5255 verify([source]);
5256 }
5257 void test_returnOfInvalidType_getter() {
5258 Source source = addSource(EngineTestCase.createSource(["int get g { return ' 0'; }"]));
5259 resolve(source);
5260 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5261 verify([source]);
5262 }
5263 void test_returnOfInvalidType_localFunction() {
5264 Source source = addSource(EngineTestCase.createSource([
5265 "class A {",
5266 " String m() {",
5267 " int f() { return '0'; }",
5268 " }",
5269 "}"]));
5270 resolve(source);
5271 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5272 verify([source]);
5273 }
5274 void test_returnOfInvalidType_method() {
5275 Source source = addSource(EngineTestCase.createSource(["class A {", " int f () { return '0'; }", "}"]));
5276 resolve(source);
5277 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5278 verify([source]);
5279 }
5280 void test_returnOfInvalidType_void() {
5281 Source source = addSource(EngineTestCase.createSource(["void f() { return 42 ; }"]));
5282 resolve(source);
5283 assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
5284 verify([source]);
5285 }
5286 void test_typeArgumentNotMatchingBounds_classTypeAlias() {
5287 Source source = addSource(EngineTestCase.createSource([
5288 "class A {}",
5289 "class B {}",
5290 "class C {}",
5291 "class G<E extends A> {}",
5292 "class D = G<B> with C;"]));
5293 resolve(source);
5294 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5295 verify([source]);
5296 }
5297 void test_typeArgumentNotMatchingBounds_extends() {
5298 Source source = addSource(EngineTestCase.createSource([
5299 "class A {}",
5300 "class B {}",
5301 "class G<E extends A> {}",
5302 "class C extends G<B>{}"]));
5303 resolve(source);
5304 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5305 verify([source]);
5306 }
5307 void test_typeArgumentNotMatchingBounds_fieldFormalParameter() {
5308 Source source = addSource(EngineTestCase.createSource([
5309 "class A {}",
5310 "class B {}",
5311 "class G<E extends A> {}",
5312 "class C {",
5313 " var f;",
5314 " C(G<B> this.f) {}",
5315 "}"]));
5316 resolve(source);
5317 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5318 verify([source]);
5319 }
5320 void test_typeArgumentNotMatchingBounds_functionReturnType() {
5321 Source source = addSource(EngineTestCase.createSource([
5322 "class A {}",
5323 "class B {}",
5324 "class G<E extends A> {}",
5325 "G<B> f() {}"]));
5326 resolve(source);
5327 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5328 verify([source]);
5329 }
5330 void test_typeArgumentNotMatchingBounds_functionTypeAlias() {
5331 Source source = addSource(EngineTestCase.createSource([
5332 "class A {}",
5333 "class B {}",
5334 "class G<E extends A> {}",
5335 "typedef G<B> f();"]));
5336 resolve(source);
5337 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5338 verify([source]);
5339 }
5340 void test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() {
5341 Source source = addSource(EngineTestCase.createSource([
5342 "class A {}",
5343 "class B {}",
5344 "class G<E extends A> {}",
5345 "f(G<B> h()) {}"]));
5346 resolve(source);
5347 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5348 verify([source]);
5349 }
5350 void test_typeArgumentNotMatchingBounds_implements() {
5351 Source source = addSource(EngineTestCase.createSource([
5352 "class A {}",
5353 "class B {}",
5354 "class G<E extends A> {}",
5355 "class C implements G<B>{}"]));
5356 resolve(source);
5357 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5358 verify([source]);
5359 }
5360 void test_typeArgumentNotMatchingBounds_is() {
5361 Source source = addSource(EngineTestCase.createSource([
5362 "class A {}",
5363 "class B {}",
5364 "class G<E extends A> {}",
5365 "var b = 1 is G<B>;"]));
5366 resolve(source);
5367 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5368 verify([source]);
5369 }
5370 void test_typeArgumentNotMatchingBounds_methodReturnType() {
5371 Source source = addSource(EngineTestCase.createSource([
5372 "class A {}",
5373 "class B {}",
5374 "class G<E extends A> {}",
5375 "class C {",
5376 " G<B> m() {}",
5377 "}"]));
5378 resolve(source);
5379 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5380 verify([source]);
5381 }
5382 void test_typeArgumentNotMatchingBounds_new() {
5383 Source source = addSource(EngineTestCase.createSource([
5384 "class A {}",
5385 "class B {}",
5386 "class G<E extends A> {}",
5387 "f() { return new G<B>(); }"]));
5388 resolve(source);
5389 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5390 verify([source]);
5391 }
5392 void test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() {
5393 Source source = addSource(EngineTestCase.createSource([
5394 "class A {}",
5395 "class B extends A {}",
5396 "class C extends B {}",
5397 "class G<E extends B> {}",
5398 "f() { return new G<A>(); }"]));
5399 resolve(source);
5400 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5401 verify([source]);
5402 }
5403 void test_typeArgumentNotMatchingBounds_parameter() {
5404 Source source = addSource(EngineTestCase.createSource([
5405 "class A {}",
5406 "class B {}",
5407 "class G<E extends A> {}",
5408 "f(G<B> g) {}"]));
5409 resolve(source);
5410 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5411 verify([source]);
5412 }
5413 void test_typeArgumentNotMatchingBounds_redirectingConstructor() {
5414 Source source = addSource(EngineTestCase.createSource([
5415 "class A {}",
5416 "class B {}",
5417 "class X<T extends A> {",
5418 " X(int x, int y) {}",
5419 " factory X.name(int x, int y) = X<B>;",
5420 "}"]));
5421 resolve(source);
5422 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5423 verify([source]);
5424 }
5425 void test_typeArgumentNotMatchingBounds_typeArgumentList() {
5426 Source source = addSource(EngineTestCase.createSource([
5427 "class A {}",
5428 "class B {}",
5429 "class C<E> {}",
5430 "class D<E extends A> {}",
5431 "C<D<B>> Var;"]));
5432 resolve(source);
5433 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5434 verify([source]);
5435 }
5436 void test_typeArgumentNotMatchingBounds_typeParameter() {
5437 Source source = addSource(EngineTestCase.createSource([
5438 "class A {}",
5439 "class B {}",
5440 "class C {}",
5441 "class G<E extends A> {}",
5442 "class D<F extends G<B>> {}"]));
5443 resolve(source);
5444 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5445 verify([source]);
5446 }
5447 void test_typeArgumentNotMatchingBounds_variableDeclaration() {
5448 Source source = addSource(EngineTestCase.createSource([
5449 "class A {}",
5450 "class B {}",
5451 "class G<E extends A> {}",
5452 "G<B> g;"]));
5453 resolve(source);
5454 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5455 verify([source]);
5456 }
5457 void test_typeArgumentNotMatchingBounds_with() {
5458 Source source = addSource(EngineTestCase.createSource([
5459 "class A {}",
5460 "class B {}",
5461 "class G<E extends A> {}",
5462 "class C extends Object with G<B>{}"]));
5463 resolve(source);
5464 assertErrors(source, [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUND S]);
5465 verify([source]);
5466 }
5467 void test_typeParameterSupertypeOfItsBound() {
5468 Source source = addSource(EngineTestCase.createSource(["class A<T extends T> {", "}"]));
5469 resolve(source);
5470 assertErrors(source, [StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_ BOUND]);
5471 verify([source]);
5472 }
5473 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_mutated() {
5474 Source source = addSource(EngineTestCase.createSource([
5475 "callMe(f()) { f(); }",
5476 "main(Object p) {",
5477 " (p is String) && callMe(() { p.length; });",
5478 " p = 0;",
5479 "}"]));
5480 resolve(source);
5481 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5482 }
5483 void test_typePromotion_booleanAnd_useInRight_mutatedInLeft() {
5484 Source source = addSource(EngineTestCase.createSource([
5485 "main(Object p) {",
5486 " ((p is String) && ((p = 42) == 42)) && p.length != 0;",
5487 "}"]));
5488 resolve(source);
5489 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5490 }
5491 void test_typePromotion_booleanAnd_useInRight_mutatedInRight() {
5492 Source source = addSource(EngineTestCase.createSource([
5493 "main(Object p) {",
5494 " (p is String) && (((p = 42) == 42) && p.length != 0);",
5495 "}"]));
5496 resolve(source);
5497 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5498 }
5499 void test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_ after() {
5500 Source source = addSource(EngineTestCase.createSource([
5501 "callMe(f()) { f(); }",
5502 "main(Object p) {",
5503 " p is String ? callMe(() { p.length; }) : 0;",
5504 " p = 42;",
5505 "}"]));
5506 resolve(source);
5507 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5508 }
5509 void test_typePromotion_conditional_useInThen_accessedInClosure_hasAssignment_ before() {
5510 Source source = addSource(EngineTestCase.createSource([
5511 "callMe(f()) { f(); }",
5512 "main(Object p) {",
5513 " p = 42;",
5514 " p is String ? callMe(() { p.length; }) : 0;",
5515 "}"]));
5516 resolve(source);
5517 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5518 }
5519 void test_typePromotion_conditional_useInThen_hasAssignment() {
5520 Source source = addSource(EngineTestCase.createSource([
5521 "main(Object p) {",
5522 " p is String ? (p.length + (p = 42)) : 0;",
5523 "}"]));
5524 resolve(source);
5525 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5526 }
5527 void test_typePromotion_if_accessedInClosure_hasAssignment() {
5528 Source source = addSource(EngineTestCase.createSource([
5529 "callMe(f()) { f(); }",
5530 "main(Object p) {",
5531 " if (p is String) {",
5532 " callMe(() {",
5533 " p.length;",
5534 " });",
5535 " }",
5536 " p = 0;",
5537 "}"]));
5538 resolve(source);
5539 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5540 }
5541 void test_typePromotion_if_and_right_hasAssignment() {
5542 Source source = addSource(EngineTestCase.createSource([
5543 "main(Object p) {",
5544 " if (p is String && (p = null) == null) {",
5545 " p.length;",
5546 " }",
5547 "}"]));
5548 resolve(source);
5549 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5550 }
5551 void test_typePromotion_if_hasAssignment_after() {
5552 Source source = addSource(EngineTestCase.createSource([
5553 "main(Object p) {",
5554 " if (p is String) {",
5555 " p.length;",
5556 " p = 0;",
5557 " }",
5558 "}"]));
5559 resolve(source);
5560 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5561 }
5562 void test_typePromotion_if_hasAssignment_before() {
5563 Source source = addSource(EngineTestCase.createSource([
5564 "main(Object p) {",
5565 " if (p is String) {",
5566 " p = 0;",
5567 " p.length;",
5568 " }",
5569 "}"]));
5570 resolve(source);
5571 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5572 }
5573 void test_undefinedGetter() {
5574 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e) { return e.m; }"]));
5575 resolve(source);
5576 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5577 }
5578 void test_undefinedGetter_static() {
5579 Source source = addSource(EngineTestCase.createSource(["class A {}", "var a = A.B;"]));
5580 resolve(source);
5581 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_GETTER]);
5582 }
5583 void test_undefinedMethod() {
5584 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " n();", " }", "}"]));
5585 resolve(source);
5586 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
5587 }
5588 void test_undefinedMethod_assignmentExpression() {
5589 Source source = addSource(EngineTestCase.createSource([
5590 "class A {}",
5591 "class B {",
5592 " f(A a) {",
5593 " A a2 = new A();",
5594 " a += a2;",
5595 " }",
5596 "}"]));
5597 resolve(source);
5598 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
5599 }
5600 void test_undefinedMethod_ignoreTypePropagation() {
5601 Source source = addSource(EngineTestCase.createSource([
5602 "class A {}",
5603 "class B extends A {",
5604 " m() {}",
5605 "}",
5606 "class C {",
5607 " f() {",
5608 " A a = new B();",
5609 " a.m();",
5610 " }",
5611 "}"]));
5612 resolve(source);
5613 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
5614 }
5615 void test_undefinedMethod_private() {
5616 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class A {", " _foo() {}", "}"]));
5617 Source source = addSource(EngineTestCase.createSource([
5618 "import 'lib.dart';",
5619 "class B extends A {",
5620 " test() {",
5621 " _foo();",
5622 " }",
5623 "}"]));
5624 resolve(source);
5625 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_METHOD]);
5626 }
5627 void test_undefinedOperator_indexBoth() {
5628 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a[0]++;", "}"]));
5629 resolve(source);
5630 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
5631 }
5632 void test_undefinedOperator_indexGetter() {
5633 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a[0];", "}"]));
5634 resolve(source);
5635 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
5636 }
5637 void test_undefinedOperator_indexSetter() {
5638 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a[0] = 1;", "}"]));
5639 resolve(source);
5640 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
5641 }
5642 void test_undefinedOperator_plus() {
5643 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a + 1;", "}"]));
5644 resolve(source);
5645 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
5646 }
5647 void test_undefinedOperator_postfixExpression() {
5648 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a++;", "}"]));
5649 resolve(source);
5650 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
5651 }
5652 void test_undefinedOperator_prefixExpression() {
5653 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " ++a;", "}"]));
5654 resolve(source);
5655 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
5656 }
5657 void test_undefinedSetter() {
5658 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e1 ) { e1.m = 0; }"]));
5659 resolve(source);
5660 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]);
5661 }
5662 void test_undefinedSetter_static() {
5663 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { A.B = 0;}"]));
5664 resolve(source);
5665 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SETTER]);
5666 }
5667 void test_undefinedSuperMethod() {
5668 Source source = addSource(EngineTestCase.createSource([
5669 "class A {}",
5670 "class B extends A {",
5671 " m() { return super.m(); }",
5672 "}"]));
5673 resolve(source);
5674 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]);
5675 }
5676 void test_unqualifiedReferenceToNonLocalStaticMember_getter() {
5677 Source source = addSource(EngineTestCase.createSource([
5678 "class A {",
5679 " static int get a => 0;",
5680 "}",
5681 "class B extends A {",
5682 " int b() {",
5683 " return a;",
5684 " }",
5685 "}"]));
5686 resolve(source);
5687 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC AL_STATIC_MEMBER]);
5688 verify([source]);
5689 }
5690 void test_unqualifiedReferenceToNonLocalStaticMember_method() {
5691 Source source = addSource(EngineTestCase.createSource([
5692 "class A {",
5693 " static void a() {}",
5694 "}",
5695 "class B extends A {",
5696 " void b() {",
5697 " a();",
5698 " }",
5699 "}"]));
5700 resolve(source);
5701 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC AL_STATIC_MEMBER]);
5702 verify([source]);
5703 }
5704 void test_unqualifiedReferenceToNonLocalStaticMember_setter() {
5705 Source source = addSource(EngineTestCase.createSource([
5706 "class A {",
5707 " static set a(x) {}",
5708 "}",
5709 "class B extends A {",
5710 " b(y) {",
5711 " a = y;",
5712 " }",
5713 "}"]));
5714 resolve(source);
5715 assertErrors(source, [StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOC AL_STATIC_MEMBER]);
5716 verify([source]);
5717 }
5718 void test_wrongNumberOfTypeArguments_tooFew() {
5719 Source source = addSource(EngineTestCase.createSource(["class A<E, F> {}", " A<A> a = null;"]));
5720 resolve(source);
5721 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]) ;
5722 verify([source]);
5723 }
5724 void test_wrongNumberOfTypeArguments_tooMany() {
5725 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A , A> a = null;"]));
5726 resolve(source);
5727 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]) ;
5728 verify([source]);
5729 }
5730 void test_wrongNumberOfTypeArguments_typeTest_tooFew() {
5731 Source source = addSource(EngineTestCase.createSource([
5732 "class A {}",
5733 "class C<K, V> {}",
5734 "f(p) {",
5735 " return p is C<A>;",
5736 "}"]));
5737 resolve(source);
5738 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]) ;
5739 verify([source]);
5740 }
5741 void test_wrongNumberOfTypeArguments_typeTest_tooMany() {
5742 Source source = addSource(EngineTestCase.createSource([
5743 "class A {}",
5744 "class C<E> {}",
5745 "f(p) {",
5746 " return p is C<A, A>;",
5747 "}"]));
5748 resolve(source);
5749 assertErrors(source, [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]) ;
5750 verify([source]);
5751 }
5752 static dartSuite() {
5753 _ut.group('StaticTypeWarningCodeTest', () {
5754 _ut.test('test_expectedOneListTypeArgument', () {
5755 final __test = new StaticTypeWarningCodeTest();
5756 runJUnitTest(__test, __test.test_expectedOneListTypeArgument);
5757 });
5758 _ut.test('test_expectedTwoMapTypeArguments_one', () {
5759 final __test = new StaticTypeWarningCodeTest();
5760 runJUnitTest(__test, __test.test_expectedTwoMapTypeArguments_one);
5761 });
5762 _ut.test('test_expectedTwoMapTypeArguments_three', () {
5763 final __test = new StaticTypeWarningCodeTest();
5764 runJUnitTest(__test, __test.test_expectedTwoMapTypeArguments_three);
5765 });
5766 _ut.test('test_inconsistentMethodInheritance_paramCount', () {
5767 final __test = new StaticTypeWarningCodeTest();
5768 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_paramCoun t);
5769 });
5770 _ut.test('test_inconsistentMethodInheritance_paramType', () {
5771 final __test = new StaticTypeWarningCodeTest();
5772 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_paramType );
5773 });
5774 _ut.test('test_inconsistentMethodInheritance_returnType', () {
5775 final __test = new StaticTypeWarningCodeTest();
5776 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_returnTyp e);
5777 });
5778 _ut.test('test_instanceAccessToStaticMember_method_invocation', () {
5779 final __test = new StaticTypeWarningCodeTest();
5780 runJUnitTest(__test, __test.test_instanceAccessToStaticMember_method_inv ocation);
5781 });
5782 _ut.test('test_instanceAccessToStaticMember_method_reference', () {
5783 final __test = new StaticTypeWarningCodeTest();
5784 runJUnitTest(__test, __test.test_instanceAccessToStaticMember_method_ref erence);
5785 });
5786 _ut.test('test_instanceAccessToStaticMember_propertyAccess_field', () {
5787 final __test = new StaticTypeWarningCodeTest();
5788 runJUnitTest(__test, __test.test_instanceAccessToStaticMember_propertyAc cess_field);
5789 });
5790 _ut.test('test_instanceAccessToStaticMember_propertyAccess_getter', () {
5791 final __test = new StaticTypeWarningCodeTest();
5792 runJUnitTest(__test, __test.test_instanceAccessToStaticMember_propertyAc cess_getter);
5793 });
5794 _ut.test('test_instanceAccessToStaticMember_propertyAccess_setter', () {
5795 final __test = new StaticTypeWarningCodeTest();
5796 runJUnitTest(__test, __test.test_instanceAccessToStaticMember_propertyAc cess_setter);
5797 });
5798 _ut.test('test_invalidAssignment_compoundAssignment', () {
5799 final __test = new StaticTypeWarningCodeTest();
5800 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment);
5801 });
5802 _ut.test('test_invalidAssignment_defaultValue_named', () {
5803 final __test = new StaticTypeWarningCodeTest();
5804 runJUnitTest(__test, __test.test_invalidAssignment_defaultValue_named);
5805 });
5806 _ut.test('test_invalidAssignment_defaultValue_optional', () {
5807 final __test = new StaticTypeWarningCodeTest();
5808 runJUnitTest(__test, __test.test_invalidAssignment_defaultValue_optional );
5809 });
5810 _ut.test('test_invalidAssignment_instanceVariable', () {
5811 final __test = new StaticTypeWarningCodeTest();
5812 runJUnitTest(__test, __test.test_invalidAssignment_instanceVariable);
5813 });
5814 _ut.test('test_invalidAssignment_localVariable', () {
5815 final __test = new StaticTypeWarningCodeTest();
5816 runJUnitTest(__test, __test.test_invalidAssignment_localVariable);
5817 });
5818 _ut.test('test_invalidAssignment_staticVariable', () {
5819 final __test = new StaticTypeWarningCodeTest();
5820 runJUnitTest(__test, __test.test_invalidAssignment_staticVariable);
5821 });
5822 _ut.test('test_invalidAssignment_topLevelVariableDeclaration', () {
5823 final __test = new StaticTypeWarningCodeTest();
5824 runJUnitTest(__test, __test.test_invalidAssignment_topLevelVariableDecla ration);
5825 });
5826 _ut.test('test_invalidAssignment_variableDeclaration', () {
5827 final __test = new StaticTypeWarningCodeTest();
5828 runJUnitTest(__test, __test.test_invalidAssignment_variableDeclaration);
5829 });
5830 _ut.test('test_invocationOfNonFunctionExpression_literal', () {
5831 final __test = new StaticTypeWarningCodeTest();
5832 runJUnitTest(__test, __test.test_invocationOfNonFunctionExpression_liter al);
5833 });
5834 _ut.test('test_invocationOfNonFunction_class', () {
5835 final __test = new StaticTypeWarningCodeTest();
5836 runJUnitTest(__test, __test.test_invocationOfNonFunction_class);
5837 });
5838 _ut.test('test_invocationOfNonFunction_localVariable', () {
5839 final __test = new StaticTypeWarningCodeTest();
5840 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable);
5841 });
5842 _ut.test('test_invocationOfNonFunction_ordinaryInvocation', () {
5843 final __test = new StaticTypeWarningCodeTest();
5844 runJUnitTest(__test, __test.test_invocationOfNonFunction_ordinaryInvocat ion);
5845 });
5846 _ut.test('test_invocationOfNonFunction_staticInvocation', () {
5847 final __test = new StaticTypeWarningCodeTest();
5848 runJUnitTest(__test, __test.test_invocationOfNonFunction_staticInvocatio n);
5849 });
5850 _ut.test('test_invocationOfNonFunction_superExpression', () {
5851 final __test = new StaticTypeWarningCodeTest();
5852 runJUnitTest(__test, __test.test_invocationOfNonFunction_superExpression );
5853 });
5854 _ut.test('test_nonBoolCondition_conditional', () {
5855 final __test = new StaticTypeWarningCodeTest();
5856 runJUnitTest(__test, __test.test_nonBoolCondition_conditional);
5857 });
5858 _ut.test('test_nonBoolCondition_do', () {
5859 final __test = new StaticTypeWarningCodeTest();
5860 runJUnitTest(__test, __test.test_nonBoolCondition_do);
5861 });
5862 _ut.test('test_nonBoolCondition_if', () {
5863 final __test = new StaticTypeWarningCodeTest();
5864 runJUnitTest(__test, __test.test_nonBoolCondition_if);
5865 });
5866 _ut.test('test_nonBoolCondition_while', () {
5867 final __test = new StaticTypeWarningCodeTest();
5868 runJUnitTest(__test, __test.test_nonBoolCondition_while);
5869 });
5870 _ut.test('test_nonBoolExpression_functionType', () {
5871 final __test = new StaticTypeWarningCodeTest();
5872 runJUnitTest(__test, __test.test_nonBoolExpression_functionType);
5873 });
5874 _ut.test('test_nonBoolExpression_interfaceType', () {
5875 final __test = new StaticTypeWarningCodeTest();
5876 runJUnitTest(__test, __test.test_nonBoolExpression_interfaceType);
5877 });
5878 _ut.test('test_nonTypeAsTypeArgument_notAType', () {
5879 final __test = new StaticTypeWarningCodeTest();
5880 runJUnitTest(__test, __test.test_nonTypeAsTypeArgument_notAType);
5881 });
5882 _ut.test('test_nonTypeAsTypeArgument_undefinedIdentifier', () {
5883 final __test = new StaticTypeWarningCodeTest();
5884 runJUnitTest(__test, __test.test_nonTypeAsTypeArgument_undefinedIdentifi er);
5885 });
5886 _ut.test('test_returnOfInvalidType_expressionFunctionBody_function', () {
5887 final __test = new StaticTypeWarningCodeTest();
5888 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_function);
5889 });
5890 _ut.test('test_returnOfInvalidType_expressionFunctionBody_getter', () {
5891 final __test = new StaticTypeWarningCodeTest();
5892 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_getter);
5893 });
5894 _ut.test('test_returnOfInvalidType_expressionFunctionBody_localFunction', () {
5895 final __test = new StaticTypeWarningCodeTest();
5896 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_localFunction);
5897 });
5898 _ut.test('test_returnOfInvalidType_expressionFunctionBody_method', () {
5899 final __test = new StaticTypeWarningCodeTest();
5900 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_method);
5901 });
5902 _ut.test('test_returnOfInvalidType_expressionFunctionBody_void', () {
5903 final __test = new StaticTypeWarningCodeTest();
5904 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_void);
5905 });
5906 _ut.test('test_returnOfInvalidType_function', () {
5907 final __test = new StaticTypeWarningCodeTest();
5908 runJUnitTest(__test, __test.test_returnOfInvalidType_function);
5909 });
5910 _ut.test('test_returnOfInvalidType_getter', () {
5911 final __test = new StaticTypeWarningCodeTest();
5912 runJUnitTest(__test, __test.test_returnOfInvalidType_getter);
5913 });
5914 _ut.test('test_returnOfInvalidType_localFunction', () {
5915 final __test = new StaticTypeWarningCodeTest();
5916 runJUnitTest(__test, __test.test_returnOfInvalidType_localFunction);
5917 });
5918 _ut.test('test_returnOfInvalidType_method', () {
5919 final __test = new StaticTypeWarningCodeTest();
5920 runJUnitTest(__test, __test.test_returnOfInvalidType_method);
5921 });
5922 _ut.test('test_returnOfInvalidType_void', () {
5923 final __test = new StaticTypeWarningCodeTest();
5924 runJUnitTest(__test, __test.test_returnOfInvalidType_void);
5925 });
5926 _ut.test('test_typeArgumentNotMatchingBounds_classTypeAlias', () {
5927 final __test = new StaticTypeWarningCodeTest();
5928 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_classType Alias);
5929 });
5930 _ut.test('test_typeArgumentNotMatchingBounds_extends', () {
5931 final __test = new StaticTypeWarningCodeTest();
5932 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_extends);
5933 });
5934 _ut.test('test_typeArgumentNotMatchingBounds_fieldFormalParameter', () {
5935 final __test = new StaticTypeWarningCodeTest();
5936 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_fieldForm alParameter);
5937 });
5938 _ut.test('test_typeArgumentNotMatchingBounds_functionReturnType', () {
5939 final __test = new StaticTypeWarningCodeTest();
5940 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_functionR eturnType);
5941 });
5942 _ut.test('test_typeArgumentNotMatchingBounds_functionTypeAlias', () {
5943 final __test = new StaticTypeWarningCodeTest();
5944 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_functionT ypeAlias);
5945 });
5946 _ut.test('test_typeArgumentNotMatchingBounds_functionTypedFormalParameter' , () {
5947 final __test = new StaticTypeWarningCodeTest();
5948 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_functionT ypedFormalParameter);
5949 });
5950 _ut.test('test_typeArgumentNotMatchingBounds_implements', () {
5951 final __test = new StaticTypeWarningCodeTest();
5952 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_implement s);
5953 });
5954 _ut.test('test_typeArgumentNotMatchingBounds_is', () {
5955 final __test = new StaticTypeWarningCodeTest();
5956 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_is);
5957 });
5958 _ut.test('test_typeArgumentNotMatchingBounds_methodReturnType', () {
5959 final __test = new StaticTypeWarningCodeTest();
5960 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_methodRet urnType);
5961 });
5962 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
5963 final __test = new StaticTypeWarningCodeTest();
5964 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
5965 });
5966 _ut.test('test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound', ( ) {
5967 final __test = new StaticTypeWarningCodeTest();
5968 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new_super TypeOfUpperBound);
5969 });
5970 _ut.test('test_typeArgumentNotMatchingBounds_parameter', () {
5971 final __test = new StaticTypeWarningCodeTest();
5972 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_parameter );
5973 });
5974 _ut.test('test_typeArgumentNotMatchingBounds_redirectingConstructor', () {
5975 final __test = new StaticTypeWarningCodeTest();
5976 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_redirecti ngConstructor);
5977 });
5978 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList', () {
5979 final __test = new StaticTypeWarningCodeTest();
5980 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum entList);
5981 });
5982 _ut.test('test_typeArgumentNotMatchingBounds_typeParameter', () {
5983 final __test = new StaticTypeWarningCodeTest();
5984 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeParam eter);
5985 });
5986 _ut.test('test_typeArgumentNotMatchingBounds_variableDeclaration', () {
5987 final __test = new StaticTypeWarningCodeTest();
5988 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_variableD eclaration);
5989 });
5990 _ut.test('test_typeArgumentNotMatchingBounds_with', () {
5991 final __test = new StaticTypeWarningCodeTest();
5992 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_with);
5993 });
5994 _ut.test('test_typeParameterSupertypeOfItsBound', () {
5995 final __test = new StaticTypeWarningCodeTest();
5996 runJUnitTest(__test, __test.test_typeParameterSupertypeOfItsBound);
5997 });
5998 _ut.test('test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_ mutated', () {
5999 final __test = new StaticTypeWarningCodeTest();
6000 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight_acc essedInClosureRight_mutated);
6001 });
6002 _ut.test('test_typePromotion_booleanAnd_useInRight_mutatedInLeft', () {
6003 final __test = new StaticTypeWarningCodeTest();
6004 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight_mut atedInLeft);
6005 });
6006 _ut.test('test_typePromotion_booleanAnd_useInRight_mutatedInRight', () {
6007 final __test = new StaticTypeWarningCodeTest();
6008 runJUnitTest(__test, __test.test_typePromotion_booleanAnd_useInRight_mut atedInRight);
6009 });
6010 _ut.test('test_typePromotion_conditional_useInThen_accessedInClosure_hasAs signment_after', () {
6011 final __test = new StaticTypeWarningCodeTest();
6012 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen_acc essedInClosure_hasAssignment_after);
6013 });
6014 _ut.test('test_typePromotion_conditional_useInThen_accessedInClosure_hasAs signment_before', () {
6015 final __test = new StaticTypeWarningCodeTest();
6016 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen_acc essedInClosure_hasAssignment_before);
6017 });
6018 _ut.test('test_typePromotion_conditional_useInThen_hasAssignment', () {
6019 final __test = new StaticTypeWarningCodeTest();
6020 runJUnitTest(__test, __test.test_typePromotion_conditional_useInThen_has Assignment);
6021 });
6022 _ut.test('test_typePromotion_if_accessedInClosure_hasAssignment', () {
6023 final __test = new StaticTypeWarningCodeTest();
6024 runJUnitTest(__test, __test.test_typePromotion_if_accessedInClosure_hasA ssignment);
6025 });
6026 _ut.test('test_typePromotion_if_and_right_hasAssignment', () {
6027 final __test = new StaticTypeWarningCodeTest();
6028 runJUnitTest(__test, __test.test_typePromotion_if_and_right_hasAssignmen t);
6029 });
6030 _ut.test('test_typePromotion_if_hasAssignment_after', () {
6031 final __test = new StaticTypeWarningCodeTest();
6032 runJUnitTest(__test, __test.test_typePromotion_if_hasAssignment_after);
6033 });
6034 _ut.test('test_typePromotion_if_hasAssignment_before', () {
6035 final __test = new StaticTypeWarningCodeTest();
6036 runJUnitTest(__test, __test.test_typePromotion_if_hasAssignment_before);
6037 });
6038 _ut.test('test_undefinedGetter', () {
6039 final __test = new StaticTypeWarningCodeTest();
6040 runJUnitTest(__test, __test.test_undefinedGetter);
6041 });
6042 _ut.test('test_undefinedGetter_static', () {
6043 final __test = new StaticTypeWarningCodeTest();
6044 runJUnitTest(__test, __test.test_undefinedGetter_static);
6045 });
6046 _ut.test('test_undefinedMethod', () {
6047 final __test = new StaticTypeWarningCodeTest();
6048 runJUnitTest(__test, __test.test_undefinedMethod);
6049 });
6050 _ut.test('test_undefinedMethod_assignmentExpression', () {
6051 final __test = new StaticTypeWarningCodeTest();
6052 runJUnitTest(__test, __test.test_undefinedMethod_assignmentExpression);
6053 });
6054 _ut.test('test_undefinedMethod_ignoreTypePropagation', () {
6055 final __test = new StaticTypeWarningCodeTest();
6056 runJUnitTest(__test, __test.test_undefinedMethod_ignoreTypePropagation);
6057 });
6058 _ut.test('test_undefinedMethod_private', () {
6059 final __test = new StaticTypeWarningCodeTest();
6060 runJUnitTest(__test, __test.test_undefinedMethod_private);
6061 });
6062 _ut.test('test_undefinedOperator_indexBoth', () {
6063 final __test = new StaticTypeWarningCodeTest();
6064 runJUnitTest(__test, __test.test_undefinedOperator_indexBoth);
6065 });
6066 _ut.test('test_undefinedOperator_indexGetter', () {
6067 final __test = new StaticTypeWarningCodeTest();
6068 runJUnitTest(__test, __test.test_undefinedOperator_indexGetter);
6069 });
6070 _ut.test('test_undefinedOperator_indexSetter', () {
6071 final __test = new StaticTypeWarningCodeTest();
6072 runJUnitTest(__test, __test.test_undefinedOperator_indexSetter);
6073 });
6074 _ut.test('test_undefinedOperator_plus', () {
6075 final __test = new StaticTypeWarningCodeTest();
6076 runJUnitTest(__test, __test.test_undefinedOperator_plus);
6077 });
6078 _ut.test('test_undefinedOperator_postfixExpression', () {
6079 final __test = new StaticTypeWarningCodeTest();
6080 runJUnitTest(__test, __test.test_undefinedOperator_postfixExpression);
6081 });
6082 _ut.test('test_undefinedOperator_prefixExpression', () {
6083 final __test = new StaticTypeWarningCodeTest();
6084 runJUnitTest(__test, __test.test_undefinedOperator_prefixExpression);
6085 });
6086 _ut.test('test_undefinedSetter', () {
6087 final __test = new StaticTypeWarningCodeTest();
6088 runJUnitTest(__test, __test.test_undefinedSetter);
6089 });
6090 _ut.test('test_undefinedSetter_static', () {
6091 final __test = new StaticTypeWarningCodeTest();
6092 runJUnitTest(__test, __test.test_undefinedSetter_static);
6093 });
6094 _ut.test('test_undefinedSuperMethod', () {
6095 final __test = new StaticTypeWarningCodeTest();
6096 runJUnitTest(__test, __test.test_undefinedSuperMethod);
6097 });
6098 _ut.test('test_unqualifiedReferenceToNonLocalStaticMember_getter', () {
6099 final __test = new StaticTypeWarningCodeTest();
6100 runJUnitTest(__test, __test.test_unqualifiedReferenceToNonLocalStaticMem ber_getter);
6101 });
6102 _ut.test('test_unqualifiedReferenceToNonLocalStaticMember_method', () {
6103 final __test = new StaticTypeWarningCodeTest();
6104 runJUnitTest(__test, __test.test_unqualifiedReferenceToNonLocalStaticMem ber_method);
6105 });
6106 _ut.test('test_unqualifiedReferenceToNonLocalStaticMember_setter', () {
6107 final __test = new StaticTypeWarningCodeTest();
6108 runJUnitTest(__test, __test.test_unqualifiedReferenceToNonLocalStaticMem ber_setter);
6109 });
6110 _ut.test('test_wrongNumberOfTypeArguments_tooFew', () {
6111 final __test = new StaticTypeWarningCodeTest();
6112 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooFew);
6113 });
6114 _ut.test('test_wrongNumberOfTypeArguments_tooMany', () {
6115 final __test = new StaticTypeWarningCodeTest();
6116 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooMany);
6117 });
6118 _ut.test('test_wrongNumberOfTypeArguments_typeTest_tooFew', () {
6119 final __test = new StaticTypeWarningCodeTest();
6120 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too Few);
6121 });
6122 _ut.test('test_wrongNumberOfTypeArguments_typeTest_tooMany', () {
6123 final __test = new StaticTypeWarningCodeTest();
6124 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too Many);
6125 });
6126 });
6127 }
6128 }
6129 class HintCodeTest extends ResolverTestCase {
6130 void fail_isInt() {
6131 Source source = addSource(EngineTestCase.createSource(["var v = 1 is int;"]) );
6132 resolve(source);
6133 assertErrors(source, [HintCode.IS_INT]);
6134 verify([source]);
6135 }
6136 void fail_isNotInt() {
6137 Source source = addSource(EngineTestCase.createSource(["var v = 1 is! int;"] ));
6138 resolve(source);
6139 assertErrors(source, [HintCode.IS_NOT_INT]);
6140 verify([source]);
6141 }
6142 void fail_overrideEqualsButNotHashCode() {
6143 Source source = addSource(EngineTestCase.createSource(["class A {", " bool operator ==(x) {}", "}"]));
6144 resolve(source);
6145 assertErrors(source, [HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE]);
6146 verify([source]);
6147 }
6148 void test_deadCode_deadBlock_conditionalElse() {
6149 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? 1 : 2;", "}"]));
6150 resolve(source);
6151 assertErrors(source, [HintCode.DEAD_CODE]);
6152 verify([source]);
6153 }
6154 void test_deadCode_deadBlock_conditionalElse_nested() {
6155 Source source = addSource(EngineTestCase.createSource(["f() {", " true ? tr ue : false && false;", "}"]));
6156 resolve(source);
6157 assertErrors(source, [HintCode.DEAD_CODE]);
6158 verify([source]);
6159 }
6160 void test_deadCode_deadBlock_conditionalIf() {
6161 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? 1 : 2;", "}"]));
6162 resolve(source);
6163 assertErrors(source, [HintCode.DEAD_CODE]);
6164 verify([source]);
6165 }
6166 void test_deadCode_deadBlock_conditionalIf_nested() {
6167 Source source = addSource(EngineTestCase.createSource(["f() {", " false ? f alse && false : true;", "}"]));
6168 resolve(source);
6169 assertErrors(source, [HintCode.DEAD_CODE]);
6170 verify([source]);
6171 }
6172 void test_deadCode_deadBlock_else() {
6173 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true) {} else {}", "}"]));
6174 resolve(source);
6175 assertErrors(source, [HintCode.DEAD_CODE]);
6176 verify([source]);
6177 }
6178 void test_deadCode_deadBlock_else_nested() {
6179 Source source = addSource(EngineTestCase.createSource(["f() {", " if(true) {} else {if (false) {}}", "}"]));
6180 resolve(source);
6181 assertErrors(source, [HintCode.DEAD_CODE]);
6182 verify([source]);
6183 }
6184 void test_deadCode_deadBlock_if() {
6185 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false) {}", "}"]));
6186 resolve(source);
6187 assertErrors(source, [HintCode.DEAD_CODE]);
6188 verify([source]);
6189 }
6190 void test_deadCode_deadBlock_if_nested() {
6191 Source source = addSource(EngineTestCase.createSource(["f() {", " if(false) {if(false) {}}", "}"]));
6192 resolve(source);
6193 assertErrors(source, [HintCode.DEAD_CODE]);
6194 verify([source]);
6195 }
6196 void test_deadCode_deadBlock_while() {
6197 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal se) {}", "}"]));
6198 resolve(source);
6199 assertErrors(source, [HintCode.DEAD_CODE]);
6200 verify([source]);
6201 }
6202 void test_deadCode_deadBlock_while_nested() {
6203 Source source = addSource(EngineTestCase.createSource(["f() {", " while(fal se) {if(false) {}}", "}"]));
6204 resolve(source);
6205 assertErrors(source, [HintCode.DEAD_CODE]);
6206 verify([source]);
6207 }
6208 void test_deadCode_deadCatch_catchFollowingCatch() {
6209 Source source = addSource(EngineTestCase.createSource([
6210 "class A {}",
6211 "f() {",
6212 " try {} catch (e) {} catch (e) {}",
6213 "}"]));
6214 resolve(source);
6215 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]);
6216 verify([source]);
6217 }
6218 void test_deadCode_deadCatch_catchFollowingCatch_nested() {
6219 Source source = addSource(EngineTestCase.createSource([
6220 "class A {}",
6221 "f() {",
6222 " try {} catch (e) {} catch (e) {if(false) {}}",
6223 "}"]));
6224 resolve(source);
6225 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]);
6226 verify([source]);
6227 }
6228 void test_deadCode_deadCatch_catchFollowingCatch_object() {
6229 Source source = addSource(EngineTestCase.createSource([
6230 "f() {",
6231 " try {} on Object catch (e) {} catch (e) {}",
6232 "}"]));
6233 resolve(source);
6234 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]);
6235 verify([source]);
6236 }
6237 void test_deadCode_deadCatch_catchFollowingCatch_object_nested() {
6238 Source source = addSource(EngineTestCase.createSource([
6239 "f() {",
6240 " try {} on Object catch (e) {} catch (e) {if(false) {}}",
6241 "}"]));
6242 resolve(source);
6243 assertErrors(source, [HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH]);
6244 verify([source]);
6245 }
6246 void test_deadCode_deadCatch_onCatchSubtype() {
6247 Source source = addSource(EngineTestCase.createSource([
6248 "class A {}",
6249 "class B extends A {}",
6250 "f() {",
6251 " try {} on A catch (e) {} on B catch (e) {}",
6252 "}"]));
6253 resolve(source);
6254 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]);
6255 verify([source]);
6256 }
6257 void test_deadCode_deadCatch_onCatchSubtype_nested() {
6258 Source source = addSource(EngineTestCase.createSource([
6259 "class A {}",
6260 "class B extends A {}",
6261 "f() {",
6262 " try {} on A catch (e) {} on B catch (e) {if(false) {}}",
6263 "}"]));
6264 resolve(source);
6265 assertErrors(source, [HintCode.DEAD_CODE_ON_CATCH_SUBTYPE]);
6266 verify([source]);
6267 }
6268 void test_deadCode_deadOperandLHS_and() {
6269 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b = false && false;", "}"]));
6270 resolve(source);
6271 assertErrors(source, [HintCode.DEAD_CODE]);
6272 verify([source]);
6273 }
6274 void test_deadCode_deadOperandLHS_and_nested() {
6275 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b = false && (false && false);", "}"]));
6276 resolve(source);
6277 assertErrors(source, [HintCode.DEAD_CODE]);
6278 verify([source]);
6279 }
6280 void test_deadCode_deadOperandLHS_or() {
6281 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b = true || true;", "}"]));
6282 resolve(source);
6283 assertErrors(source, [HintCode.DEAD_CODE]);
6284 verify([source]);
6285 }
6286 void test_deadCode_deadOperandLHS_or_nested() {
6287 Source source = addSource(EngineTestCase.createSource(["f() {", " bool b = true || (false && false);", "}"]));
6288 resolve(source);
6289 assertErrors(source, [HintCode.DEAD_CODE]);
6290 verify([source]);
6291 }
6292 void test_deadCode_statementAfterReturn_function() {
6293 Source source = addSource(EngineTestCase.createSource([
6294 "f() {",
6295 " var one = 1;",
6296 " return;",
6297 " var two = 2;",
6298 "}"]));
6299 resolve(source);
6300 assertErrors(source, [HintCode.DEAD_CODE]);
6301 verify([source]);
6302 }
6303 void test_deadCode_statementAfterReturn_ifStatement() {
6304 Source source = addSource(EngineTestCase.createSource([
6305 "f(bool b) {",
6306 " if(b) {",
6307 " var one = 1;",
6308 " return;",
6309 " var two = 2;",
6310 " }",
6311 "}"]));
6312 resolve(source);
6313 assertErrors(source, [HintCode.DEAD_CODE]);
6314 verify([source]);
6315 }
6316 void test_deadCode_statementAfterReturn_method() {
6317 Source source = addSource(EngineTestCase.createSource([
6318 "class A {",
6319 " m() {",
6320 " var one = 1;",
6321 " return;",
6322 " var two = 2;",
6323 " }",
6324 "}"]));
6325 resolve(source);
6326 assertErrors(source, [HintCode.DEAD_CODE]);
6327 verify([source]);
6328 }
6329 void test_deadCode_statementAfterReturn_nested() {
6330 Source source = addSource(EngineTestCase.createSource([
6331 "f() {",
6332 " var one = 1;",
6333 " return;",
6334 " if(false) {}",
6335 "}"]));
6336 resolve(source);
6337 assertErrors(source, [HintCode.DEAD_CODE]);
6338 verify([source]);
6339 }
6340 void test_deadCode_statementAfterReturn_twoReturns() {
6341 Source source = addSource(EngineTestCase.createSource([
6342 "f() {",
6343 " var one = 1;",
6344 " return;",
6345 " var two = 2;",
6346 " return;",
6347 " var three = 3;",
6348 "}"]));
6349 resolve(source);
6350 assertErrors(source, [HintCode.DEAD_CODE]);
6351 verify([source]);
6352 }
6353 void test_divisionOptimization_double() {
6354 Source source = addSource(EngineTestCase.createSource([
6355 "f(double x, double y) {",
6356 " var v = (x / y).toInt();",
6357 "}"]));
6358 resolve(source);
6359 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
6360 verify([source]);
6361 }
6362 void test_divisionOptimization_int() {
6363 Source source = addSource(EngineTestCase.createSource(["f(int x, int y) {", " var v = (x / y).toInt();", "}"]));
6364 resolve(source);
6365 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
6366 verify([source]);
6367 }
6368 void test_divisionOptimization_propagatedType() {
6369 Source source = addSource(EngineTestCase.createSource([
6370 "f(x, y) {",
6371 " x = 1;",
6372 " y = 1;",
6373 " var v = (x / y).toInt();",
6374 "}"]));
6375 resolve(source);
6376 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
6377 verify([source]);
6378 }
6379 void test_divisionOptimization_wrappedBinaryExpression() {
6380 Source source = addSource(EngineTestCase.createSource([
6381 "f(int x, int y) {",
6382 " var v = (((x / y))).toInt();",
6383 "}"]));
6384 resolve(source);
6385 assertErrors(source, [HintCode.DIVISION_OPTIMIZATION]);
6386 verify([source]);
6387 }
6388 void test_duplicateImport() {
6389 Source source = addSource(EngineTestCase.createSource([
6390 "library L;",
6391 "import 'lib1.dart';",
6392 "import 'lib1.dart';",
6393 "A a;"]));
6394 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s A {}"]));
6395 resolve(source);
6396 assertErrors(source, [HintCode.DUPLICATE_IMPORT]);
6397 verify([source]);
6398 }
6399 void test_duplicateImport2() {
6400 Source source = addSource(EngineTestCase.createSource([
6401 "library L;",
6402 "import 'lib1.dart';",
6403 "import 'lib1.dart';",
6404 "import 'lib1.dart';",
6405 "A a;"]));
6406 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s A {}"]));
6407 resolve(source);
6408 assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.DUPLICATE_IMPORT]) ;
6409 verify([source]);
6410 }
6411 void test_duplicateImport3() {
6412 Source source = addSource(EngineTestCase.createSource([
6413 "library L;",
6414 "import 'lib1.dart' as M show A hide B;",
6415 "import 'lib1.dart' as M show A hide B;",
6416 "M.A a;"]));
6417 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s A {}", "class B {}"]));
6418 resolve(source);
6419 assertErrors(source, [HintCode.DUPLICATE_IMPORT, HintCode.UNUSED_IMPORT]);
6420 verify([source]);
6421 }
6422 void test_isDouble() {
6423 Source source = addSource(EngineTestCase.createSource(["var v = 1 is double; "]));
6424 resolve(source);
6425 assertErrors(source, [HintCode.IS_DOUBLE]);
6426 verify([source]);
6427 }
6428 void test_isNotDouble() {
6429 Source source = addSource(EngineTestCase.createSource(["var v = 1 is! double ;"]));
6430 resolve(source);
6431 assertErrors(source, [HintCode.IS_NOT_DOUBLE]);
6432 verify([source]);
6433 }
6434 void test_overriddingPrivateMember_getter() {
6435 Source source = addSource(EngineTestCase.createSource([
6436 "import 'lib1.dart';",
6437 "class B extends A {",
6438 " get _g => 0;",
6439 "}"]));
6440 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;", "class A {", " get _g => 0;", "}"]));
6441 resolve(source);
6442 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]);
6443 verify([source, source2]);
6444 }
6445 void test_overriddingPrivateMember_method() {
6446 Source source = addSource(EngineTestCase.createSource([
6447 "import 'lib1.dart';",
6448 "class B extends A {",
6449 " _m(int x) => 0;",
6450 "}"]));
6451 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;", "class A {", " _m(int x) => 0;", "}"]));
6452 resolve(source);
6453 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]);
6454 verify([source, source2]);
6455 }
6456 void test_overriddingPrivateMember_method2() {
6457 Source source = addSource(EngineTestCase.createSource([
6458 "import 'lib1.dart';",
6459 "class B extends A {}",
6460 "class C extends B {",
6461 " _m(int x) => 0;",
6462 "}"]));
6463 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;", "class A {", " _m(int x) => 0;", "}"]));
6464 resolve(source);
6465 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]);
6466 verify([source, source2]);
6467 }
6468 void test_overriddingPrivateMember_setter() {
6469 Source source = addSource(EngineTestCase.createSource([
6470 "import 'lib1.dart';",
6471 "class B extends A {",
6472 " set _s(int x) {}",
6473 "}"]));
6474 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;", "class A {", " set _s(int x) {}", "}"]));
6475 resolve(source);
6476 assertErrors(source, [HintCode.OVERRIDDING_PRIVATE_MEMBER]);
6477 verify([source, source2]);
6478 }
6479 void test_typeCheck_type_is_Null() {
6480 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b = i is Null;", "}"]));
6481 resolve(source);
6482 assertErrors(source, [HintCode.TYPE_CHECK_IS_NULL]);
6483 verify([source]);
6484 }
6485 void test_typeCheck_type_not_Null() {
6486 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b = i is! Null;", "}"]));
6487 resolve(source);
6488 assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]);
6489 verify([source]);
6490 }
6491 void test_undefinedGetter() {
6492 Source source = addSource(EngineTestCase.createSource([
6493 "class A {}",
6494 "f(var a) {",
6495 " if(a is A) {",
6496 " return a.m;",
6497 " }",
6498 "}"]));
6499 resolve(source);
6500 assertErrors(source, [HintCode.UNDEFINED_GETTER]);
6501 }
6502 void test_undefinedGetter_message() {
6503 JUnitTestCase.assertEquals(StaticTypeWarningCode.UNDEFINED_GETTER.message, S taticWarningCode.UNDEFINED_GETTER.message);
6504 }
6505 void test_undefinedMethod() {
6506 Source source = addSource(EngineTestCase.createSource([
6507 "f() {",
6508 " var a = 'str';",
6509 " a.notAMethodOnString();",
6510 "}"]));
6511 resolve(source);
6512 assertErrors(source, [HintCode.UNDEFINED_METHOD]);
6513 }
6514 void test_undefinedMethod_assignmentExpression() {
6515 Source source = addSource(EngineTestCase.createSource([
6516 "class A {}",
6517 "class B {",
6518 " f(var a, var a2) {",
6519 " a = new A();",
6520 " a2 = new A();",
6521 " a += a2;",
6522 " }",
6523 "}"]));
6524 resolve(source);
6525 assertErrors(source, [HintCode.UNDEFINED_METHOD]);
6526 }
6527 void test_undefinedOperator_binaryExpression() {
6528 Source source = addSource(EngineTestCase.createSource([
6529 "class A {}",
6530 "f(var a) {",
6531 " if(a is A) {",
6532 " a + 1;",
6533 " }",
6534 "}"]));
6535 resolve(source);
6536 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
6537 }
6538 void test_undefinedOperator_indexBoth() {
6539 Source source = addSource(EngineTestCase.createSource([
6540 "class A {}",
6541 "f(var a) {",
6542 " if(a is A) {",
6543 " a[0]++;",
6544 " }",
6545 "}"]));
6546 resolve(source);
6547 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
6548 }
6549 void test_undefinedOperator_indexGetter() {
6550 Source source = addSource(EngineTestCase.createSource([
6551 "class A {}",
6552 "f(var a) {",
6553 " if(a is A) {",
6554 " a[0];",
6555 " }",
6556 "}"]));
6557 resolve(source);
6558 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
6559 }
6560 void test_undefinedOperator_indexSetter() {
6561 Source source = addSource(EngineTestCase.createSource([
6562 "class A {}",
6563 "f(var a) {",
6564 " if(a is A) {",
6565 " a[0] = 1;",
6566 " }",
6567 "}"]));
6568 resolve(source);
6569 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
6570 }
6571 void test_undefinedOperator_postfixExpression() {
6572 Source source = addSource(EngineTestCase.createSource([
6573 "class A {}",
6574 "f(var a) {",
6575 " if(a is A) {",
6576 " a++;",
6577 " }",
6578 "}"]));
6579 resolve(source);
6580 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
6581 }
6582 void test_undefinedOperator_prefixExpression() {
6583 Source source = addSource(EngineTestCase.createSource([
6584 "class A {}",
6585 "f(var a) {",
6586 " if(a is A) {",
6587 " ++a;",
6588 " }",
6589 "}"]));
6590 resolve(source);
6591 assertErrors(source, [HintCode.UNDEFINED_OPERATOR]);
6592 }
6593 void test_undefinedSetter() {
6594 Source source = addSource(EngineTestCase.createSource([
6595 "class A {}",
6596 "f(var a) {",
6597 " if(a is A) {",
6598 " a.m = 0;",
6599 " }",
6600 "}"]));
6601 resolve(source);
6602 assertErrors(source, [HintCode.UNDEFINED_SETTER]);
6603 }
6604 void test_undefinedSetter_message() {
6605 JUnitTestCase.assertEquals(StaticTypeWarningCode.UNDEFINED_SETTER.message, S taticWarningCode.UNDEFINED_SETTER.message);
6606 }
6607 void test_unnecessaryCast_type_supertype() {
6608 Source source = addSource(EngineTestCase.createSource(["m(int i) {", " var b = i as Object;", "}"]));
6609 resolve(source);
6610 assertErrors(source, [HintCode.UNNECESSARY_CAST]);
6611 verify([source]);
6612 }
6613 void test_unnecessaryCast_type_type() {
6614 Source source = addSource(EngineTestCase.createSource(["m(num i) {", " var b = i as num;", "}"]));
6615 resolve(source);
6616 assertErrors(source, [HintCode.UNNECESSARY_CAST]);
6617 verify([source]);
6618 }
6619 void test_unnecessaryTypeCheck_null_is_Null() {
6620 Source source = addSource(EngineTestCase.createSource(["bool b = null is Nul l;"]));
6621 resolve(source);
6622 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
6623 verify([source]);
6624 }
6625 void test_unnecessaryTypeCheck_null_not_Null() {
6626 Source source = addSource(EngineTestCase.createSource(["bool b = null is! Nu ll;"]));
6627 resolve(source);
6628 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
6629 verify([source]);
6630 }
6631 void test_unnecessaryTypeCheck_type_is_dynamic() {
6632 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b = i is dynamic;", "}"]));
6633 resolve(source);
6634 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
6635 verify([source]);
6636 }
6637 void test_unnecessaryTypeCheck_type_is_object() {
6638 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b = i is Object;", "}"]));
6639 resolve(source);
6640 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_TRUE]);
6641 verify([source]);
6642 }
6643 void test_unnecessaryTypeCheck_type_not_dynamic() {
6644 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b = i is! dynamic;", "}"]));
6645 resolve(source);
6646 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
6647 verify([source]);
6648 }
6649 void test_unnecessaryTypeCheck_type_not_object() {
6650 Source source = addSource(EngineTestCase.createSource(["m(i) {", " bool b = i is! Object;", "}"]));
6651 resolve(source);
6652 assertErrors(source, [HintCode.UNNECESSARY_TYPE_CHECK_FALSE]);
6653 verify([source]);
6654 }
6655 void test_unusedImport() {
6656 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';"]));
6657 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;"]));
6658 resolve(source);
6659 assertErrors(source, [HintCode.UNUSED_IMPORT]);
6660 assertNoErrors(source2);
6661 verify([source, source2]);
6662 }
6663 void test_unusedImport_as() {
6664 Source source = addSource(EngineTestCase.createSource([
6665 "library L;",
6666 "import 'lib1.dart';",
6667 "import 'lib1.dart' as one;",
6668 "one.A a;"]));
6669 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;", "class A {}"]));
6670 resolve(source);
6671 assertErrors(source, [HintCode.UNUSED_IMPORT]);
6672 assertNoErrors(source2);
6673 verify([source, source2]);
6674 }
6675 void test_unusedImport_hide() {
6676 Source source = addSource(EngineTestCase.createSource([
6677 "library L;",
6678 "import 'lib1.dart';",
6679 "import 'lib1.dart' hide A;",
6680 "A a;"]));
6681 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;", "class A {}"]));
6682 resolve(source);
6683 assertErrors(source, [HintCode.UNUSED_IMPORT]);
6684 assertNoErrors(source2);
6685 verify([source, source2]);
6686 }
6687 void test_unusedImport_show() {
6688 Source source = addSource(EngineTestCase.createSource([
6689 "library L;",
6690 "import 'lib1.dart' show A;",
6691 "import 'lib1.dart' show B;",
6692 "A a;"]));
6693 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;", "class A {}", "class B {}"]));
6694 resolve(source);
6695 assertErrors(source, [HintCode.UNUSED_IMPORT]);
6696 assertNoErrors(source2);
6697 verify([source, source2]);
6698 }
6699 static dartSuite() {
6700 _ut.group('HintCodeTest', () {
6701 _ut.test('test_deadCode_deadBlock_conditionalElse', () {
6702 final __test = new HintCodeTest();
6703 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse);
6704 });
6705 _ut.test('test_deadCode_deadBlock_conditionalElse_nested', () {
6706 final __test = new HintCodeTest();
6707 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_nest ed);
6708 });
6709 _ut.test('test_deadCode_deadBlock_conditionalIf', () {
6710 final __test = new HintCodeTest();
6711 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalIf);
6712 });
6713 _ut.test('test_deadCode_deadBlock_conditionalIf_nested', () {
6714 final __test = new HintCodeTest();
6715 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalIf_nested );
6716 });
6717 _ut.test('test_deadCode_deadBlock_else', () {
6718 final __test = new HintCodeTest();
6719 runJUnitTest(__test, __test.test_deadCode_deadBlock_else);
6720 });
6721 _ut.test('test_deadCode_deadBlock_else_nested', () {
6722 final __test = new HintCodeTest();
6723 runJUnitTest(__test, __test.test_deadCode_deadBlock_else_nested);
6724 });
6725 _ut.test('test_deadCode_deadBlock_if', () {
6726 final __test = new HintCodeTest();
6727 runJUnitTest(__test, __test.test_deadCode_deadBlock_if);
6728 });
6729 _ut.test('test_deadCode_deadBlock_if_nested', () {
6730 final __test = new HintCodeTest();
6731 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_nested);
6732 });
6733 _ut.test('test_deadCode_deadBlock_while', () {
6734 final __test = new HintCodeTest();
6735 runJUnitTest(__test, __test.test_deadCode_deadBlock_while);
6736 });
6737 _ut.test('test_deadCode_deadBlock_while_nested', () {
6738 final __test = new HintCodeTest();
6739 runJUnitTest(__test, __test.test_deadCode_deadBlock_while_nested);
6740 });
6741 _ut.test('test_deadCode_deadCatch_catchFollowingCatch', () {
6742 final __test = new HintCodeTest();
6743 runJUnitTest(__test, __test.test_deadCode_deadCatch_catchFollowingCatch) ;
6744 });
6745 _ut.test('test_deadCode_deadCatch_catchFollowingCatch_nested', () {
6746 final __test = new HintCodeTest();
6747 runJUnitTest(__test, __test.test_deadCode_deadCatch_catchFollowingCatch_ nested);
6748 });
6749 _ut.test('test_deadCode_deadCatch_catchFollowingCatch_object', () {
6750 final __test = new HintCodeTest();
6751 runJUnitTest(__test, __test.test_deadCode_deadCatch_catchFollowingCatch_ object);
6752 });
6753 _ut.test('test_deadCode_deadCatch_catchFollowingCatch_object_nested', () {
6754 final __test = new HintCodeTest();
6755 runJUnitTest(__test, __test.test_deadCode_deadCatch_catchFollowingCatch_ object_nested);
6756 });
6757 _ut.test('test_deadCode_deadCatch_onCatchSubtype', () {
6758 final __test = new HintCodeTest();
6759 runJUnitTest(__test, __test.test_deadCode_deadCatch_onCatchSubtype);
6760 });
6761 _ut.test('test_deadCode_deadCatch_onCatchSubtype_nested', () {
6762 final __test = new HintCodeTest();
6763 runJUnitTest(__test, __test.test_deadCode_deadCatch_onCatchSubtype_neste d);
6764 });
6765 _ut.test('test_deadCode_deadOperandLHS_and', () {
6766 final __test = new HintCodeTest();
6767 runJUnitTest(__test, __test.test_deadCode_deadOperandLHS_and);
6768 });
6769 _ut.test('test_deadCode_deadOperandLHS_and_nested', () {
6770 final __test = new HintCodeTest();
6771 runJUnitTest(__test, __test.test_deadCode_deadOperandLHS_and_nested);
6772 });
6773 _ut.test('test_deadCode_deadOperandLHS_or', () {
6774 final __test = new HintCodeTest();
6775 runJUnitTest(__test, __test.test_deadCode_deadOperandLHS_or);
6776 });
6777 _ut.test('test_deadCode_deadOperandLHS_or_nested', () {
6778 final __test = new HintCodeTest();
6779 runJUnitTest(__test, __test.test_deadCode_deadOperandLHS_or_nested);
6780 });
6781 _ut.test('test_deadCode_statementAfterReturn_function', () {
6782 final __test = new HintCodeTest();
6783 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_function) ;
6784 });
6785 _ut.test('test_deadCode_statementAfterReturn_ifStatement', () {
6786 final __test = new HintCodeTest();
6787 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_ifStateme nt);
6788 });
6789 _ut.test('test_deadCode_statementAfterReturn_method', () {
6790 final __test = new HintCodeTest();
6791 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_method);
6792 });
6793 _ut.test('test_deadCode_statementAfterReturn_nested', () {
6794 final __test = new HintCodeTest();
6795 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_nested);
6796 });
6797 _ut.test('test_deadCode_statementAfterReturn_twoReturns', () {
6798 final __test = new HintCodeTest();
6799 runJUnitTest(__test, __test.test_deadCode_statementAfterReturn_twoReturn s);
6800 });
6801 _ut.test('test_divisionOptimization_double', () {
6802 final __test = new HintCodeTest();
6803 runJUnitTest(__test, __test.test_divisionOptimization_double);
6804 });
6805 _ut.test('test_divisionOptimization_int', () {
6806 final __test = new HintCodeTest();
6807 runJUnitTest(__test, __test.test_divisionOptimization_int);
6808 });
6809 _ut.test('test_divisionOptimization_propagatedType', () {
6810 final __test = new HintCodeTest();
6811 runJUnitTest(__test, __test.test_divisionOptimization_propagatedType);
6812 });
6813 _ut.test('test_divisionOptimization_wrappedBinaryExpression', () {
6814 final __test = new HintCodeTest();
6815 runJUnitTest(__test, __test.test_divisionOptimization_wrappedBinaryExpre ssion);
6816 });
6817 _ut.test('test_duplicateImport', () {
6818 final __test = new HintCodeTest();
6819 runJUnitTest(__test, __test.test_duplicateImport);
6820 });
6821 _ut.test('test_duplicateImport2', () {
6822 final __test = new HintCodeTest();
6823 runJUnitTest(__test, __test.test_duplicateImport2);
6824 });
6825 _ut.test('test_duplicateImport3', () {
6826 final __test = new HintCodeTest();
6827 runJUnitTest(__test, __test.test_duplicateImport3);
6828 });
6829 _ut.test('test_isDouble', () {
6830 final __test = new HintCodeTest();
6831 runJUnitTest(__test, __test.test_isDouble);
6832 });
6833 _ut.test('test_isNotDouble', () {
6834 final __test = new HintCodeTest();
6835 runJUnitTest(__test, __test.test_isNotDouble);
6836 });
6837 _ut.test('test_overriddingPrivateMember_getter', () {
6838 final __test = new HintCodeTest();
6839 runJUnitTest(__test, __test.test_overriddingPrivateMember_getter);
6840 });
6841 _ut.test('test_overriddingPrivateMember_method', () {
6842 final __test = new HintCodeTest();
6843 runJUnitTest(__test, __test.test_overriddingPrivateMember_method);
6844 });
6845 _ut.test('test_overriddingPrivateMember_method2', () {
6846 final __test = new HintCodeTest();
6847 runJUnitTest(__test, __test.test_overriddingPrivateMember_method2);
6848 });
6849 _ut.test('test_overriddingPrivateMember_setter', () {
6850 final __test = new HintCodeTest();
6851 runJUnitTest(__test, __test.test_overriddingPrivateMember_setter);
6852 });
6853 _ut.test('test_typeCheck_type_is_Null', () {
6854 final __test = new HintCodeTest();
6855 runJUnitTest(__test, __test.test_typeCheck_type_is_Null);
6856 });
6857 _ut.test('test_typeCheck_type_not_Null', () {
6858 final __test = new HintCodeTest();
6859 runJUnitTest(__test, __test.test_typeCheck_type_not_Null);
6860 });
6861 _ut.test('test_undefinedGetter', () {
6862 final __test = new HintCodeTest();
6863 runJUnitTest(__test, __test.test_undefinedGetter);
6864 });
6865 _ut.test('test_undefinedGetter_message', () {
6866 final __test = new HintCodeTest();
6867 runJUnitTest(__test, __test.test_undefinedGetter_message);
6868 });
6869 _ut.test('test_undefinedMethod', () {
6870 final __test = new HintCodeTest();
6871 runJUnitTest(__test, __test.test_undefinedMethod);
6872 });
6873 _ut.test('test_undefinedMethod_assignmentExpression', () {
6874 final __test = new HintCodeTest();
6875 runJUnitTest(__test, __test.test_undefinedMethod_assignmentExpression);
6876 });
6877 _ut.test('test_undefinedOperator_binaryExpression', () {
6878 final __test = new HintCodeTest();
6879 runJUnitTest(__test, __test.test_undefinedOperator_binaryExpression);
6880 });
6881 _ut.test('test_undefinedOperator_indexBoth', () {
6882 final __test = new HintCodeTest();
6883 runJUnitTest(__test, __test.test_undefinedOperator_indexBoth);
6884 });
6885 _ut.test('test_undefinedOperator_indexGetter', () {
6886 final __test = new HintCodeTest();
6887 runJUnitTest(__test, __test.test_undefinedOperator_indexGetter);
6888 });
6889 _ut.test('test_undefinedOperator_indexSetter', () {
6890 final __test = new HintCodeTest();
6891 runJUnitTest(__test, __test.test_undefinedOperator_indexSetter);
6892 });
6893 _ut.test('test_undefinedOperator_postfixExpression', () {
6894 final __test = new HintCodeTest();
6895 runJUnitTest(__test, __test.test_undefinedOperator_postfixExpression);
6896 });
6897 _ut.test('test_undefinedOperator_prefixExpression', () {
6898 final __test = new HintCodeTest();
6899 runJUnitTest(__test, __test.test_undefinedOperator_prefixExpression);
6900 });
6901 _ut.test('test_undefinedSetter', () {
6902 final __test = new HintCodeTest();
6903 runJUnitTest(__test, __test.test_undefinedSetter);
6904 });
6905 _ut.test('test_undefinedSetter_message', () {
6906 final __test = new HintCodeTest();
6907 runJUnitTest(__test, __test.test_undefinedSetter_message);
6908 });
6909 _ut.test('test_unnecessaryCast_type_supertype', () {
6910 final __test = new HintCodeTest();
6911 runJUnitTest(__test, __test.test_unnecessaryCast_type_supertype);
6912 });
6913 _ut.test('test_unnecessaryCast_type_type', () {
6914 final __test = new HintCodeTest();
6915 runJUnitTest(__test, __test.test_unnecessaryCast_type_type);
6916 });
6917 _ut.test('test_unnecessaryTypeCheck_null_is_Null', () {
6918 final __test = new HintCodeTest();
6919 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_null_is_Null);
6920 });
6921 _ut.test('test_unnecessaryTypeCheck_null_not_Null', () {
6922 final __test = new HintCodeTest();
6923 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_null_not_Null);
6924 });
6925 _ut.test('test_unnecessaryTypeCheck_type_is_dynamic', () {
6926 final __test = new HintCodeTest();
6927 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_type_is_dynamic);
6928 });
6929 _ut.test('test_unnecessaryTypeCheck_type_is_object', () {
6930 final __test = new HintCodeTest();
6931 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_type_is_object);
6932 });
6933 _ut.test('test_unnecessaryTypeCheck_type_not_dynamic', () {
6934 final __test = new HintCodeTest();
6935 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_type_not_dynamic);
6936 });
6937 _ut.test('test_unnecessaryTypeCheck_type_not_object', () {
6938 final __test = new HintCodeTest();
6939 runJUnitTest(__test, __test.test_unnecessaryTypeCheck_type_not_object);
6940 });
6941 _ut.test('test_unusedImport', () {
6942 final __test = new HintCodeTest();
6943 runJUnitTest(__test, __test.test_unusedImport);
6944 });
6945 _ut.test('test_unusedImport_as', () {
6946 final __test = new HintCodeTest();
6947 runJUnitTest(__test, __test.test_unusedImport_as);
6948 });
6949 _ut.test('test_unusedImport_hide', () {
6950 final __test = new HintCodeTest();
6951 runJUnitTest(__test, __test.test_unusedImport_hide);
6952 });
6953 _ut.test('test_unusedImport_show', () {
6954 final __test = new HintCodeTest();
6955 runJUnitTest(__test, __test.test_unusedImport_show);
6956 });
6957 });
6958 }
6959 }
6960 class TypeResolverVisitorTest extends EngineTestCase {
6961
6962 /**
6963 * The error listener to which errors will be reported.
6964 */
6965 GatheringErrorListener _listener;
6966
6967 /**
6968 * The object representing the information about the library in which the type s are being
6969 * resolved.
6970 */
6971 Library _library;
6972
6973 /**
6974 * The type provider used to access the types.
6975 */
6976 TestTypeProvider _typeProvider;
6977
6978 /**
6979 * The visitor used to resolve types needed to form the type hierarchy.
6980 */
6981 TypeResolverVisitor _visitor;
6982 void fail_visitConstructorDeclaration() {
6983 JUnitTestCase.fail("Not yet tested");
6984 _listener.assertNoErrors();
6985 }
6986 void fail_visitFunctionDeclaration() {
6987 JUnitTestCase.fail("Not yet tested");
6988 _listener.assertNoErrors();
6989 }
6990 void fail_visitFunctionTypeAlias() {
6991 JUnitTestCase.fail("Not yet tested");
6992 _listener.assertNoErrors();
6993 }
6994 void fail_visitFunctionTypedFormalParameter() {
6995 JUnitTestCase.fail("Not yet tested");
6996 _listener.assertNoErrors();
6997 }
6998 void fail_visitMethodDeclaration() {
6999 JUnitTestCase.fail("Not yet tested");
7000 _listener.assertNoErrors();
7001 }
7002 void fail_visitVariableDeclaration() {
7003 JUnitTestCase.fail("Not yet tested");
7004 ClassElement type = ElementFactory.classElement2("A", []);
7005 VariableDeclaration node = ASTFactory.variableDeclaration("a");
7006 ASTFactory.variableDeclarationList(null, ASTFactory.typeName(type, []), [nod e]);
7007 JUnitTestCase.assertSame(type.type, node.name.staticType);
7008 _listener.assertNoErrors();
7009 }
7010 void setUp() {
7011 _listener = new GatheringErrorListener();
7012 SourceFactory factory = new SourceFactory.con2([new FileUriResolver()]);
7013 AnalysisContextImpl context = new AnalysisContextImpl();
7014 context.sourceFactory = factory;
7015 Source librarySource = new FileBasedSource.con1(factory.contentCache, FileUt ilities2.createFile("/lib.dart"));
7016 _library = new Library(context, _listener, librarySource);
7017 LibraryElementImpl element = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["lib"]));
7018 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart") ;
7019 _library.libraryElement = element;
7020 _typeProvider = new TestTypeProvider();
7021 _visitor = new TypeResolverVisitor.con1(_library, librarySource, _typeProvid er);
7022 }
7023 void test_visitCatchClause_exception() {
7024 CatchClause clause = ASTFactory.catchClause("e", []);
7025 SimpleIdentifier exceptionParameter = clause.exceptionParameter;
7026 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar ameter);
7027 resolve(clause, _typeProvider.dynamicType, null, []);
7028 _listener.assertNoErrors();
7029 }
7030 void test_visitCatchClause_exception_stackTrace() {
7031 CatchClause clause = ASTFactory.catchClause2("e", "s", []);
7032 SimpleIdentifier exceptionParameter = clause.exceptionParameter;
7033 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar ameter);
7034 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter;
7035 stackTraceParameter.staticElement = new LocalVariableElementImpl(stackTraceP arameter);
7036 resolve(clause, _typeProvider.dynamicType, _typeProvider.stackTraceType, []) ;
7037 _listener.assertNoErrors();
7038 }
7039 void test_visitCatchClause_on_exception() {
7040 ClassElement exceptionElement = ElementFactory.classElement2("E", []);
7041 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []);
7042 CatchClause clause = ASTFactory.catchClause4(exceptionType, "e", []);
7043 SimpleIdentifier exceptionParameter = clause.exceptionParameter;
7044 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar ameter);
7045 resolve(clause, exceptionElement.type, null, [exceptionElement]);
7046 _listener.assertNoErrors();
7047 }
7048 void test_visitCatchClause_on_exception_stackTrace() {
7049 ClassElement exceptionElement = ElementFactory.classElement2("E", []);
7050 TypeName exceptionType = ASTFactory.typeName(exceptionElement, []);
7051 ((exceptionType.name as SimpleIdentifier)).staticElement = exceptionElement;
7052 CatchClause clause = ASTFactory.catchClause5(exceptionType, "e", "s", []);
7053 SimpleIdentifier exceptionParameter = clause.exceptionParameter;
7054 exceptionParameter.staticElement = new LocalVariableElementImpl(exceptionPar ameter);
7055 SimpleIdentifier stackTraceParameter = clause.stackTraceParameter;
7056 stackTraceParameter.staticElement = new LocalVariableElementImpl(stackTraceP arameter);
7057 resolve(clause, exceptionElement.type, _typeProvider.stackTraceType, [except ionElement]);
7058 _listener.assertNoErrors();
7059 }
7060 void test_visitClassDeclaration() {
7061 ClassElement elementA = ElementFactory.classElement2("A", []);
7062 ClassElement elementB = ElementFactory.classElement2("B", []);
7063 ClassElement elementC = ElementFactory.classElement2("C", []);
7064 ClassElement elementD = ElementFactory.classElement2("D", []);
7065 ExtendsClause extendsClause = ASTFactory.extendsClause(ASTFactory.typeName(e lementB, []));
7066 WithClause withClause = ASTFactory.withClause([ASTFactory.typeName(elementC, [])]);
7067 ImplementsClause implementsClause = ASTFactory.implementsClause([ASTFactory. typeName(elementD, [])]);
7068 ClassDeclaration declaration = ASTFactory.classDeclaration(null, "A", null, extendsClause, withClause, implementsClause, []);
7069 declaration.name.staticElement = elementA;
7070 resolveNode(declaration, [elementA, elementB, elementC, elementD]);
7071 JUnitTestCase.assertSame(elementB.type, elementA.supertype);
7072 List<InterfaceType> mixins = elementA.mixins;
7073 EngineTestCase.assertLength(1, mixins);
7074 JUnitTestCase.assertSame(elementC.type, mixins[0]);
7075 List<InterfaceType> interfaces = elementA.interfaces;
7076 EngineTestCase.assertLength(1, interfaces);
7077 JUnitTestCase.assertSame(elementD.type, interfaces[0]);
7078 _listener.assertNoErrors();
7079 }
7080 void test_visitClassTypeAlias() {
7081 ClassElement elementA = ElementFactory.classElement2("A", []);
7082 ClassElement elementB = ElementFactory.classElement2("B", []);
7083 ClassElement elementC = ElementFactory.classElement2("C", []);
7084 ClassElement elementD = ElementFactory.classElement2("D", []);
7085 WithClause withClause = ASTFactory.withClause([ASTFactory.typeName(elementC, [])]);
7086 ImplementsClause implementsClause = ASTFactory.implementsClause([ASTFactory. typeName(elementD, [])]);
7087 ClassTypeAlias alias = ASTFactory.classTypeAlias("A", null, null, ASTFactory .typeName(elementB, []), withClause, implementsClause);
7088 alias.name.staticElement = elementA;
7089 resolveNode(alias, [elementA, elementB, elementC, elementD]);
7090 JUnitTestCase.assertSame(elementB.type, elementA.supertype);
7091 List<InterfaceType> mixins = elementA.mixins;
7092 EngineTestCase.assertLength(1, mixins);
7093 JUnitTestCase.assertSame(elementC.type, mixins[0]);
7094 List<InterfaceType> interfaces = elementA.interfaces;
7095 EngineTestCase.assertLength(1, interfaces);
7096 JUnitTestCase.assertSame(elementD.type, interfaces[0]);
7097 _listener.assertNoErrors();
7098 }
7099 void test_visitFieldFormalParameter_functionType() {
7100 InterfaceType intType = _typeProvider.intType;
7101 TypeName intTypeName = ASTFactory.typeName4("int", []);
7102 String innerParameterName = "a";
7103 SimpleFormalParameter parameter = ASTFactory.simpleFormalParameter3(innerPar ameterName);
7104 parameter.identifier.staticElement = ElementFactory.requiredParameter(innerP arameterName);
7105 String outerParameterName = "p";
7106 FormalParameter node = ASTFactory.fieldFormalParameter2(null, intTypeName, o uterParameterName, ASTFactory.formalParameterList([parameter]));
7107 node.identifier.staticElement = ElementFactory.requiredParameter(outerParame terName);
7108 Type2 parameterType = resolve6(node, [intType.element]);
7109 EngineTestCase.assertInstanceOf(FunctionType, parameterType);
7110 FunctionType functionType = parameterType as FunctionType;
7111 JUnitTestCase.assertSame(intType, functionType.returnType);
7112 EngineTestCase.assertLength(1, functionType.parameters);
7113 _listener.assertNoErrors();
7114 }
7115 void test_visitFieldFormalParameter_noType() {
7116 String parameterName = "p";
7117 FormalParameter node = ASTFactory.fieldFormalParameter(Keyword.VAR, null, pa rameterName);
7118 node.identifier.staticElement = ElementFactory.requiredParameter(parameterNa me);
7119 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, []));
7120 _listener.assertNoErrors();
7121 }
7122 void test_visitFieldFormalParameter_type() {
7123 InterfaceType intType = _typeProvider.intType;
7124 TypeName intTypeName = ASTFactory.typeName4("int", []);
7125 String parameterName = "p";
7126 FormalParameter node = ASTFactory.fieldFormalParameter(null, intTypeName, pa rameterName);
7127 node.identifier.staticElement = ElementFactory.requiredParameter(parameterNa me);
7128 JUnitTestCase.assertSame(intType, resolve6(node, [intType.element]));
7129 _listener.assertNoErrors();
7130 }
7131 void test_visitSimpleFormalParameter_noType() {
7132 FormalParameter node = ASTFactory.simpleFormalParameter3("p");
7133 node.identifier.staticElement = new ParameterElementImpl.con1(ASTFactory.ide ntifier3("p"));
7134 JUnitTestCase.assertSame(_typeProvider.dynamicType, resolve6(node, []));
7135 _listener.assertNoErrors();
7136 }
7137 void test_visitSimpleFormalParameter_type() {
7138 InterfaceType intType = _typeProvider.intType;
7139 ClassElement intElement = intType.element;
7140 FormalParameter node = ASTFactory.simpleFormalParameter4(ASTFactory.typeName (intElement, []), "p");
7141 SimpleIdentifier identifier = node.identifier;
7142 ParameterElementImpl element = new ParameterElementImpl.con1(identifier);
7143 identifier.staticElement = element;
7144 JUnitTestCase.assertSame(intType, resolve6(node, [intElement]));
7145 _listener.assertNoErrors();
7146 }
7147 void test_visitTypeName_noParameters_noArguments() {
7148 ClassElement classA = ElementFactory.classElement2("A", []);
7149 TypeName typeName = ASTFactory.typeName(classA, []);
7150 typeName.type = null;
7151 resolveNode(typeName, [classA]);
7152 JUnitTestCase.assertSame(classA.type, typeName.type);
7153 _listener.assertNoErrors();
7154 }
7155 void test_visitTypeName_parameters_arguments() {
7156 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
7157 ClassElement classB = ElementFactory.classElement2("B", []);
7158 TypeName typeName = ASTFactory.typeName(classA, [ASTFactory.typeName(classB, [])]);
7159 typeName.type = null;
7160 resolveNode(typeName, [classA, classB]);
7161 InterfaceType resultType = typeName.type as InterfaceType;
7162 JUnitTestCase.assertSame(classA, resultType.element);
7163 List<Type2> resultArguments = resultType.typeArguments;
7164 EngineTestCase.assertLength(1, resultArguments);
7165 JUnitTestCase.assertSame(classB.type, resultArguments[0]);
7166 _listener.assertNoErrors();
7167 }
7168 void test_visitTypeName_parameters_noArguments() {
7169 ClassElement classA = ElementFactory.classElement2("A", ["E"]);
7170 TypeName typeName = ASTFactory.typeName(classA, []);
7171 typeName.type = null;
7172 resolveNode(typeName, [classA]);
7173 InterfaceType resultType = typeName.type as InterfaceType;
7174 JUnitTestCase.assertSame(classA, resultType.element);
7175 List<Type2> resultArguments = resultType.typeArguments;
7176 EngineTestCase.assertLength(1, resultArguments);
7177 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]);
7178 _listener.assertNoErrors();
7179 }
7180 void test_visitTypeName_void() {
7181 ClassElement classA = ElementFactory.classElement2("A", []);
7182 TypeName typeName = ASTFactory.typeName4("void", []);
7183 resolveNode(typeName, [classA]);
7184 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type);
7185 _listener.assertNoErrors();
7186 }
7187
7188 /**
7189 * Analyze the given catch clause and assert that the types of the parameters have been set to the
7190 * given types. The types can be null if the catch clause does not have the co rresponding
7191 * parameter.
7192 *
7193 * @param node the catch clause to be analyzed
7194 * @param exceptionType the expected type of the exception parameter
7195 * @param stackTraceType the expected type of the stack trace parameter
7196 * @param definedElements the elements that are to be defined in the scope in which the element is
7197 * being resolved
7198 */
7199 void resolve(CatchClause node, Type2 exceptionType, InterfaceType stackTraceTy pe, List<Element> definedElements) {
7200 resolveNode(node, definedElements);
7201 SimpleIdentifier exceptionParameter = node.exceptionParameter;
7202 if (exceptionParameter != null) {
7203 JUnitTestCase.assertSame(exceptionType, exceptionParameter.staticType);
7204 }
7205 SimpleIdentifier stackTraceParameter = node.stackTraceParameter;
7206 if (stackTraceParameter != null) {
7207 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter.staticType);
7208 }
7209 }
7210
7211 /**
7212 * Return the type associated with the given parameter after the static type a nalyzer has computed
7213 * a type for it.
7214 *
7215 * @param node the parameter with which the type is associated
7216 * @param definedElements the elements that are to be defined in the scope in which the element is
7217 * being resolved
7218 * @return the type associated with the parameter
7219 */
7220 Type2 resolve6(FormalParameter node, List<Element> definedElements) {
7221 resolveNode(node, definedElements);
7222 return ((node.identifier.staticElement as ParameterElement)).type;
7223 }
7224
7225 /**
7226 * Return the element associated with the given identifier after the resolver has resolved the
7227 * identifier.
7228 *
7229 * @param node the expression to be resolved
7230 * @param definedElements the elements that are to be defined in the scope in which the element is
7231 * being resolved
7232 * @return the element to which the expression was resolved
7233 */
7234 void resolveNode(ASTNode node, List<Element> definedElements) {
7235 for (Element element in definedElements) {
7236 _library.libraryScope.define(element);
7237 }
7238 node.accept(_visitor);
7239 }
7240 static dartSuite() {
7241 _ut.group('TypeResolverVisitorTest', () {
7242 _ut.test('test_visitCatchClause_exception', () {
7243 final __test = new TypeResolverVisitorTest();
7244 runJUnitTest(__test, __test.test_visitCatchClause_exception);
7245 });
7246 _ut.test('test_visitCatchClause_exception_stackTrace', () {
7247 final __test = new TypeResolverVisitorTest();
7248 runJUnitTest(__test, __test.test_visitCatchClause_exception_stackTrace);
7249 });
7250 _ut.test('test_visitCatchClause_on_exception', () {
7251 final __test = new TypeResolverVisitorTest();
7252 runJUnitTest(__test, __test.test_visitCatchClause_on_exception);
7253 });
7254 _ut.test('test_visitCatchClause_on_exception_stackTrace', () {
7255 final __test = new TypeResolverVisitorTest();
7256 runJUnitTest(__test, __test.test_visitCatchClause_on_exception_stackTrac e);
7257 });
7258 _ut.test('test_visitClassDeclaration', () {
7259 final __test = new TypeResolverVisitorTest();
7260 runJUnitTest(__test, __test.test_visitClassDeclaration);
7261 });
7262 _ut.test('test_visitClassTypeAlias', () {
7263 final __test = new TypeResolverVisitorTest();
7264 runJUnitTest(__test, __test.test_visitClassTypeAlias);
7265 });
7266 _ut.test('test_visitFieldFormalParameter_functionType', () {
7267 final __test = new TypeResolverVisitorTest();
7268 runJUnitTest(__test, __test.test_visitFieldFormalParameter_functionType) ;
7269 });
7270 _ut.test('test_visitFieldFormalParameter_noType', () {
7271 final __test = new TypeResolverVisitorTest();
7272 runJUnitTest(__test, __test.test_visitFieldFormalParameter_noType);
7273 });
7274 _ut.test('test_visitFieldFormalParameter_type', () {
7275 final __test = new TypeResolverVisitorTest();
7276 runJUnitTest(__test, __test.test_visitFieldFormalParameter_type);
7277 });
7278 _ut.test('test_visitSimpleFormalParameter_noType', () {
7279 final __test = new TypeResolverVisitorTest();
7280 runJUnitTest(__test, __test.test_visitSimpleFormalParameter_noType);
7281 });
7282 _ut.test('test_visitSimpleFormalParameter_type', () {
7283 final __test = new TypeResolverVisitorTest();
7284 runJUnitTest(__test, __test.test_visitSimpleFormalParameter_type);
7285 });
7286 _ut.test('test_visitTypeName_noParameters_noArguments', () {
7287 final __test = new TypeResolverVisitorTest();
7288 runJUnitTest(__test, __test.test_visitTypeName_noParameters_noArguments) ;
7289 });
7290 _ut.test('test_visitTypeName_parameters_arguments', () {
7291 final __test = new TypeResolverVisitorTest();
7292 runJUnitTest(__test, __test.test_visitTypeName_parameters_arguments);
7293 });
7294 _ut.test('test_visitTypeName_parameters_noArguments', () {
7295 final __test = new TypeResolverVisitorTest();
7296 runJUnitTest(__test, __test.test_visitTypeName_parameters_noArguments);
7297 });
7298 _ut.test('test_visitTypeName_void', () {
7299 final __test = new TypeResolverVisitorTest();
7300 runJUnitTest(__test, __test.test_visitTypeName_void);
7301 });
7302 });
7303 }
7304 }
7305 class ResolverTestCase extends EngineTestCase {
7306
7307 /**
7308 * The source factory used to create [Source].
7309 */
7310 SourceFactory sourceFactory;
7311
7312 /**
7313 * The analysis context used to parse the compilation units being resolved.
7314 */
7315 AnalysisContextImpl analysisContext;
7316 void setUp() {
7317 reset();
7318 }
7319
7320 /**
7321 * Add a source file to the content provider.
7322 *
7323 * @param contents the contents to be returned by the content provider for the specified file
7324 * @return the source object representing the added file
7325 */
7326 Source addSource(String contents) => addSource2("/test.dart", contents);
7327
7328 /**
7329 * Add a source file to the content provider. The file path should be absolute .
7330 *
7331 * @param filePath the path of the file being added
7332 * @param contents the contents to be returned by the content provider for the specified file
7333 * @return the source object representing the added file
7334 */
7335 Source addSource2(String filePath, String contents) {
7336 Source source = cacheSource(filePath, contents);
7337 ChangeSet changeSet = new ChangeSet();
7338 changeSet.added(source);
7339 analysisContext.applyChanges(changeSet);
7340 return source;
7341 }
7342
7343 /**
7344 * Assert that the number of errors reported against the given source matches the number of errors
7345 * that are given and that they have the expected error codes. The order in wh ich the errors were
7346 * gathered is ignored.
7347 *
7348 * @param source the source against which the errors should have been reported
7349 * @param expectedErrorCodes the error codes of the errors that should have be en reported
7350 * @throws AnalysisException if the reported errors could not be computed
7351 * @throws AssertionFailedError if a different number of errors have been repo rted than were
7352 * expected
7353 */
7354 void assertErrors(Source source, List<ErrorCode> expectedErrorCodes) {
7355 GatheringErrorListener errorListener = new GatheringErrorListener();
7356 for (AnalysisError error in analysisContext.computeErrors(source)) {
7357 errorListener.onError(error);
7358 }
7359 errorListener.assertErrors2(expectedErrorCodes);
7360 }
7361
7362 /**
7363 * Assert that no errors have been reported against the given source.
7364 *
7365 * @param source the source against which no errors should have been reported
7366 * @throws AnalysisException if the reported errors could not be computed
7367 * @throws AssertionFailedError if any errors have been reported
7368 */
7369 void assertNoErrors(Source source) {
7370 assertErrors(source, []);
7371 }
7372
7373 /**
7374 * Cache the source file content in the source factory but don't add the sourc e to the analysis
7375 * context. The file path should be absolute.
7376 *
7377 * @param filePath the path of the file being cached
7378 * @param contents the contents to be returned by the content provider for the specified file
7379 * @return the source object representing the cached file
7380 */
7381 Source cacheSource(String filePath, String contents) {
7382 Source source = new FileBasedSource.con1(sourceFactory.contentCache, FileUti lities2.createFile(filePath));
7383 sourceFactory.setContents(source, contents);
7384 return source;
7385 }
7386
7387 /**
7388 * Create a library element that represents a library named `"test"` containin g a single
7389 * empty compilation unit.
7390 *
7391 * @return the library element that was created
7392 */
7393 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []);
7394
7395 /**
7396 * Create a library element that represents a library with the given name cont aining a single
7397 * empty compilation unit.
7398 *
7399 * @param libraryName the name of the library to be created
7400 * @return the library element that was created
7401 */
7402 LibraryElementImpl createTestLibrary2(AnalysisContext context, String libraryN ame, List<String> typeNames) {
7403 int count = typeNames.length;
7404 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat ionUnitElementImpl>(count);
7405 for (int i = 0; i < count; i++) {
7406 String typeName = typeNames[i];
7407 ClassElementImpl type = new ClassElementImpl(ASTFactory.identifier3(typeNa me));
7408 String fileName = "${typeName}.dart";
7409 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImp l(fileName);
7410 compilationUnit.source = createSource2(fileName);
7411 compilationUnit.types = <ClassElement> [type];
7412 sourcedCompilationUnits[i] = compilationUnit;
7413 }
7414 String fileName = "${libraryName}.dart";
7415 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName);
7416 compilationUnit.source = createSource2(fileName);
7417 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName]));
7418 library.definingCompilationUnit = compilationUnit;
7419 library.parts = sourcedCompilationUnits;
7420 return library;
7421 }
7422
7423 /**
7424 * Return a type provider that can be used to test the results of resolution.
7425 *
7426 * @return a type provider
7427 */
7428 TypeProvider get typeProvider {
7429 Source coreSource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE);
7430 LibraryElement coreElement = analysisContext.getLibraryElement(coreSource);
7431 return new TypeProviderImpl(coreElement);
7432 }
7433
7434 /**
7435 * In the rare cases we want to group several tests into single "test_" method , so need a way to
7436 * reset test instance to reuse it.
7437 */
7438 void reset() {
7439 analysisContext = AnalysisContextFactory.contextWithCore();
7440 sourceFactory = analysisContext.sourceFactory;
7441 }
7442
7443 /**
7444 * Given a library and all of its parts, resolve the contents of the library a nd the contents of
7445 * the parts. This assumes that the sources for the library and its parts have already been added
7446 * to the content provider using the method [addSource].
7447 *
7448 * @param librarySource the source for the compilation unit that defines the l ibrary
7449 * @return the element representing the resolved library
7450 * @throws AnalysisException if the analysis could not be performed
7451 */
7452 LibraryElement resolve(Source librarySource) => analysisContext.computeLibrary Element(librarySource);
7453
7454 /**
7455 * Return the resolved compilation unit corresponding to the given source in t he given library.
7456 *
7457 * @param source the source of the compilation unit to be returned
7458 * @param library the library in which the compilation unit is to be resolved
7459 * @return the resolved compilation unit
7460 * @throws Exception if the compilation unit could not be resolved
7461 */
7462 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) => analysisContext.resolveCompilationUnit(source, library);
7463
7464 /**
7465 * Verify that all of the identifiers in the compilation units associated with the given sources
7466 * have been resolved.
7467 *
7468 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element
7469 * to which they were resolved
7470 * @param sources the sources identifying the compilation units to be verified
7471 * @throws Exception if the contents of the compilation unit cannot be accesse d
7472 */
7473 void verify(List<Source> sources) {
7474 ResolutionVerifier verifier = new ResolutionVerifier();
7475 for (Source source in sources) {
7476 analysisContext.parseCompilationUnit(source).accept(verifier);
7477 }
7478 verifier.assertResolved();
7479 }
7480
7481 /**
7482 * Create a source object representing a file with the given name and give it an empty content.
7483 *
7484 * @param fileName the name of the file for which a source is to be created
7485 * @return the source that was created
7486 */
7487 FileBasedSource createSource2(String fileName) {
7488 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache , FileUtilities2.createFile(fileName));
7489 sourceFactory.setContents(source, "");
7490 return source;
7491 }
7492 static dartSuite() {
7493 _ut.group('ResolverTestCase', () {
7494 });
7495 }
7496 }
7497 class TypeProviderImplTest extends EngineTestCase {
7498 void test_creation() {
7499 InterfaceType objectType = classElement("Object", null, []).type;
7500 InterfaceType boolType = classElement("bool", objectType, []).type;
7501 InterfaceType numType = classElement("num", objectType, []).type;
7502 InterfaceType doubleType = classElement("double", numType, []).type;
7503 InterfaceType functionType = classElement("Function", objectType, []).type;
7504 InterfaceType intType = classElement("int", numType, []).type;
7505 InterfaceType listType = classElement("List", objectType, ["E"]).type;
7506 InterfaceType mapType = classElement("Map", objectType, ["K", "V"]).type;
7507 InterfaceType stackTraceType = classElement("StackTrace", objectType, []).ty pe;
7508 InterfaceType stringType = classElement("String", objectType, []).type;
7509 InterfaceType symbolType = classElement("Symbol", objectType, []).type;
7510 InterfaceType typeType = classElement("Type", objectType, []).type;
7511 CompilationUnitElementImpl unit = new CompilationUnitElementImpl("lib.dart") ;
7512 unit.types = <ClassElement> [
7513 boolType.element,
7514 doubleType.element,
7515 functionType.element,
7516 intType.element,
7517 listType.element,
7518 mapType.element,
7519 objectType.element,
7520 stackTraceType.element,
7521 stringType.element,
7522 symbolType.element,
7523 typeType.element];
7524 LibraryElementImpl library = new LibraryElementImpl(new AnalysisContextImpl( ), ASTFactory.libraryIdentifier2(["lib"]));
7525 library.definingCompilationUnit = unit;
7526 TypeProviderImpl provider = new TypeProviderImpl(library);
7527 JUnitTestCase.assertSame(boolType, provider.boolType);
7528 JUnitTestCase.assertNotNull(provider.bottomType);
7529 JUnitTestCase.assertSame(doubleType, provider.doubleType);
7530 JUnitTestCase.assertNotNull(provider.dynamicType);
7531 JUnitTestCase.assertSame(functionType, provider.functionType);
7532 JUnitTestCase.assertSame(intType, provider.intType);
7533 JUnitTestCase.assertSame(listType, provider.listType);
7534 JUnitTestCase.assertSame(mapType, provider.mapType);
7535 JUnitTestCase.assertSame(objectType, provider.objectType);
7536 JUnitTestCase.assertSame(stackTraceType, provider.stackTraceType);
7537 JUnitTestCase.assertSame(stringType, provider.stringType);
7538 JUnitTestCase.assertSame(symbolType, provider.symbolType);
7539 JUnitTestCase.assertSame(typeType, provider.typeType);
7540 }
7541 ClassElement classElement(String typeName, InterfaceType superclassType, List< String> parameterNames) {
7542 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN ame));
7543 element.supertype = superclassType;
7544 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element);
7545 element.type = type;
7546 int count = parameterNames.length;
7547 if (count > 0) {
7548 List<TypeParameterElementImpl> typeParameters = new List<TypeParameterElem entImpl>(count);
7549 List<TypeParameterTypeImpl> typeArguments = new List<TypeParameterTypeImpl >(count);
7550 for (int i = 0; i < count; i++) {
7551 TypeParameterElementImpl typeParameter = new TypeParameterElementImpl(AS TFactory.identifier3(parameterNames[i]));
7552 typeParameters[i] = typeParameter;
7553 typeArguments[i] = new TypeParameterTypeImpl(typeParameter);
7554 typeParameter.type = typeArguments[i];
7555 }
7556 element.typeParameters = typeParameters;
7557 type.typeArguments = typeArguments;
7558 }
7559 return element;
7560 }
7561 static dartSuite() {
7562 _ut.group('TypeProviderImplTest', () {
7563 _ut.test('test_creation', () {
7564 final __test = new TypeProviderImplTest();
7565 runJUnitTest(__test, __test.test_creation);
7566 });
7567 });
7568 }
7569 }
7570 class InheritanceManagerTest extends EngineTestCase {
7571
7572 /**
7573 * The type provider used to access the types.
7574 */
7575 TestTypeProvider _typeProvider;
7576
7577 /**
7578 * The library containing the code being resolved.
7579 */
7580 LibraryElementImpl _definingLibrary;
7581
7582 /**
7583 * The inheritance manager being tested.
7584 */
7585 InheritanceManager _inheritanceManager;
7586
7587 /**
7588 * The number of members that Object implements (as determined by [TestTypePro vider]).
7589 */
7590 int _numOfMembersInObject = 0;
7591 void setUp() {
7592 _typeProvider = new TestTypeProvider();
7593 _inheritanceManager = createInheritanceManager();
7594 InterfaceType objectType = _typeProvider.objectType;
7595 _numOfMembersInObject = objectType.methods.length + objectType.accessors.len gth;
7596 }
7597 void test_getMapOfMembersInheritedFromClasses_accessor_extends() {
7598 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7599 String getterName = "g";
7600 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7601 classA.accessors = <PropertyAccessorElement> [getterG];
7602 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
7603 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssB);
7604 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssA);
7605 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7606 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7607 JUnitTestCase.assertSame(getterG, mapB.get(getterName));
7608 assertNoErrors(classA);
7609 assertNoErrors(classB);
7610 }
7611 void test_getMapOfMembersInheritedFromClasses_accessor_implements() {
7612 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7613 String getterName = "g";
7614 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7615 classA.accessors = <PropertyAccessorElement> [getterG];
7616 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7617 classB.interfaces = <InterfaceType> [classA.type];
7618 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssB);
7619 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssA);
7620 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7621 JUnitTestCase.assertEquals(_numOfMembersInObject, mapB.size);
7622 JUnitTestCase.assertNull(mapB.get(getterName));
7623 assertNoErrors(classA);
7624 assertNoErrors(classB);
7625 }
7626 void test_getMapOfMembersInheritedFromClasses_accessor_with() {
7627 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7628 String getterName = "g";
7629 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7630 classA.accessors = <PropertyAccessorElement> [getterG];
7631 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7632 classB.mixins = <InterfaceType> [classA.type];
7633 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssB);
7634 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssA);
7635 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7636 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7637 JUnitTestCase.assertSame(getterG, mapB.get(getterName));
7638 assertNoErrors(classA);
7639 assertNoErrors(classB);
7640 }
7641 void test_getMapOfMembersInheritedFromClasses_method_extends() {
7642 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7643 String methodName = "m";
7644 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7645 classA.methods = <MethodElement> [methodM];
7646 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7647 classB.supertype = classA.type;
7648 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssB);
7649 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssA);
7650 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7651 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7652 JUnitTestCase.assertSame(methodM, mapB.get(methodName));
7653 assertNoErrors(classA);
7654 assertNoErrors(classB);
7655 }
7656 void test_getMapOfMembersInheritedFromClasses_method_implements() {
7657 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7658 String methodName = "m";
7659 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7660 classA.methods = <MethodElement> [methodM];
7661 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7662 classB.interfaces = <InterfaceType> [classA.type];
7663 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssB);
7664 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssA);
7665 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7666 JUnitTestCase.assertEquals(_numOfMembersInObject, mapB.size);
7667 JUnitTestCase.assertNull(mapB.get(methodName));
7668 assertNoErrors(classA);
7669 assertNoErrors(classB);
7670 }
7671 void test_getMapOfMembersInheritedFromClasses_method_with() {
7672 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7673 String methodName = "m";
7674 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7675 classA.methods = <MethodElement> [methodM];
7676 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7677 classB.mixins = <InterfaceType> [classA.type];
7678 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssB);
7679 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromClasses(cla ssA);
7680 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7681 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7682 JUnitTestCase.assertSame(methodM, mapB.get(methodName));
7683 assertNoErrors(classA);
7684 assertNoErrors(classB);
7685 }
7686 void test_getMapOfMembersInheritedFromInterfaces_accessor_extends() {
7687 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7688 String getterName = "g";
7689 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7690 classA.accessors = <PropertyAccessorElement> [getterG];
7691 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
7692 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classB);
7693 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classA);
7694 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7695 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7696 JUnitTestCase.assertSame(getterG, mapB.get(getterName));
7697 assertNoErrors(classA);
7698 assertNoErrors(classB);
7699 }
7700 void test_getMapOfMembersInheritedFromInterfaces_accessor_implements() {
7701 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7702 String getterName = "g";
7703 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7704 classA.accessors = <PropertyAccessorElement> [getterG];
7705 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7706 classB.interfaces = <InterfaceType> [classA.type];
7707 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classB);
7708 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classA);
7709 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7710 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7711 JUnitTestCase.assertSame(getterG, mapB.get(getterName));
7712 assertNoErrors(classA);
7713 assertNoErrors(classB);
7714 }
7715 void test_getMapOfMembersInheritedFromInterfaces_accessor_with() {
7716 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7717 String getterName = "g";
7718 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7719 classA.accessors = <PropertyAccessorElement> [getterG];
7720 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7721 classB.mixins = <InterfaceType> [classA.type];
7722 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classB);
7723 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classA);
7724 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7725 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7726 JUnitTestCase.assertSame(getterG, mapB.get(getterName));
7727 assertNoErrors(classA);
7728 assertNoErrors(classB);
7729 }
7730 void test_getMapOfMembersInheritedFromInterfaces_method_extends() {
7731 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7732 String methodName = "m";
7733 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7734 classA.methods = <MethodElement> [methodM];
7735 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
7736 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classB);
7737 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classA);
7738 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7739 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7740 JUnitTestCase.assertSame(methodM, mapB.get(methodName));
7741 assertNoErrors(classA);
7742 assertNoErrors(classB);
7743 }
7744 void test_getMapOfMembersInheritedFromInterfaces_method_implements() {
7745 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7746 String methodName = "m";
7747 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7748 classA.methods = <MethodElement> [methodM];
7749 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7750 classB.interfaces = <InterfaceType> [classA.type];
7751 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classB);
7752 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classA);
7753 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7754 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7755 JUnitTestCase.assertSame(methodM, mapB.get(methodName));
7756 assertNoErrors(classA);
7757 assertNoErrors(classB);
7758 }
7759 void test_getMapOfMembersInheritedFromInterfaces_method_with() {
7760 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7761 String methodName = "m";
7762 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7763 classA.methods = <MethodElement> [methodM];
7764 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7765 classB.mixins = <InterfaceType> [classA.type];
7766 MemberMap mapB = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classB);
7767 MemberMap mapA = _inheritanceManager.getMapOfMembersInheritedFromInterfaces( classA);
7768 JUnitTestCase.assertEquals(_numOfMembersInObject, mapA.size);
7769 JUnitTestCase.assertEquals(_numOfMembersInObject + 1, mapB.size);
7770 JUnitTestCase.assertSame(methodM, mapB.get(methodName));
7771 assertNoErrors(classA);
7772 assertNoErrors(classB);
7773 }
7774 void test_lookupInheritance_interface_getter() {
7775 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7776 String getterName = "g";
7777 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7778 classA.accessors = <PropertyAccessorElement> [getterG];
7779 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7780 classB.interfaces = <InterfaceType> [classA.type];
7781 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas sB, getterName));
7782 assertNoErrors(classA);
7783 assertNoErrors(classB);
7784 }
7785 void test_lookupInheritance_interface_method() {
7786 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7787 String methodName = "m";
7788 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7789 classA.methods = <MethodElement> [methodM];
7790 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7791 classB.interfaces = <InterfaceType> [classA.type];
7792 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas sB, methodName));
7793 assertNoErrors(classA);
7794 assertNoErrors(classB);
7795 }
7796 void test_lookupInheritance_interface_setter() {
7797 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7798 String setterName = "s";
7799 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, _typeProvider.intType);
7800 classA.accessors = <PropertyAccessorElement> [setterS];
7801 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7802 classB.interfaces = <InterfaceType> [classA.type];
7803 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas sB, "${setterName}="));
7804 assertNoErrors(classA);
7805 assertNoErrors(classB);
7806 }
7807 void test_lookupInheritance_interface_staticMember() {
7808 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7809 String methodName = "m";
7810 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7811 ((methodM as MethodElementImpl)).static = true;
7812 classA.methods = <MethodElement> [methodM];
7813 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7814 classB.interfaces = <InterfaceType> [classA.type];
7815 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho dName));
7816 assertNoErrors(classA);
7817 assertNoErrors(classB);
7818 }
7819 void test_lookupInheritance_interfaces_infiniteLoop() {
7820 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7821 classA.interfaces = <InterfaceType> [classA.type];
7822 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name "));
7823 assertNoErrors(classA);
7824 }
7825 void test_lookupInheritance_interfaces_infiniteLoop2() {
7826 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7827 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7828 classA.interfaces = <InterfaceType> [classB.type];
7829 classB.interfaces = <InterfaceType> [classA.type];
7830 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name "));
7831 assertNoErrors(classA);
7832 assertNoErrors(classB);
7833 }
7834 void test_lookupInheritance_interfaces_STWC_inconsistentMethodInheritance() {
7835 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []);
7836 String methodName = "m";
7837 MethodElement methodM1 = ElementFactory.methodElement(methodName, null, [_ty peProvider.intType]);
7838 classI1.methods = <MethodElement> [methodM1];
7839 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []);
7840 MethodElement methodM2 = ElementFactory.methodElement(methodName, null, [_ty peProvider.stringType]);
7841 classI2.methods = <MethodElement> [methodM2];
7842 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7843 classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
7844 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, metho dName));
7845 assertNoErrors(classI1);
7846 assertNoErrors(classI2);
7847 assertErrors(classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE] );
7848 }
7849 void test_lookupInheritance_interfaces_SWC_inconsistentMethodInheritance() {
7850 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []);
7851 String methodName = "m";
7852 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7853 classI1.methods = <MethodElement> [methodM];
7854 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []);
7855 PropertyAccessorElement getter = ElementFactory.getterElement(methodName, fa lse, _typeProvider.intType);
7856 classI2.accessors = <PropertyAccessorElement> [getter];
7857 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7858 classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
7859 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, metho dName));
7860 assertNoErrors(classI1);
7861 assertNoErrors(classI2);
7862 assertErrors(classA, [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETT ER_AND_METHOD]);
7863 }
7864 void test_lookupInheritance_interfaces_union1() {
7865 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []);
7866 String methodName1 = "m1";
7867 MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProv ider.intType, []);
7868 classI1.methods = <MethodElement> [methodM1];
7869 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []);
7870 String methodName2 = "m2";
7871 MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProv ider.intType, []);
7872 classI2.methods = <MethodElement> [methodM2];
7873 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7874 classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
7875 JUnitTestCase.assertSame(methodM1, _inheritanceManager.lookupInheritance(cla ssA, methodName1));
7876 JUnitTestCase.assertSame(methodM2, _inheritanceManager.lookupInheritance(cla ssA, methodName2));
7877 assertNoErrors(classI1);
7878 assertNoErrors(classI2);
7879 assertNoErrors(classA);
7880 }
7881 void test_lookupInheritance_interfaces_union2() {
7882 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []);
7883 String methodName1 = "m1";
7884 MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProv ider.intType, []);
7885 classI1.methods = <MethodElement> [methodM1];
7886 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []);
7887 String methodName2 = "m2";
7888 MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProv ider.intType, []);
7889 classI2.methods = <MethodElement> [methodM2];
7890 classI2.interfaces = <InterfaceType> [classI1.type];
7891 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7892 classA.interfaces = <InterfaceType> [classI2.type];
7893 JUnitTestCase.assertSame(methodM1, _inheritanceManager.lookupInheritance(cla ssA, methodName1));
7894 JUnitTestCase.assertSame(methodM2, _inheritanceManager.lookupInheritance(cla ssA, methodName2));
7895 assertNoErrors(classI1);
7896 assertNoErrors(classI2);
7897 assertNoErrors(classA);
7898 }
7899 void test_lookupInheritance_mixin_getter() {
7900 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7901 String getterName = "g";
7902 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7903 classA.accessors = <PropertyAccessorElement> [getterG];
7904 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7905 classB.mixins = <InterfaceType> [classA.type];
7906 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas sB, getterName));
7907 assertNoErrors(classA);
7908 assertNoErrors(classB);
7909 }
7910 void test_lookupInheritance_mixin_method() {
7911 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7912 String methodName = "m";
7913 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7914 classA.methods = <MethodElement> [methodM];
7915 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7916 classB.mixins = <InterfaceType> [classA.type];
7917 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas sB, methodName));
7918 assertNoErrors(classA);
7919 assertNoErrors(classB);
7920 }
7921 void test_lookupInheritance_mixin_setter() {
7922 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7923 String setterName = "s";
7924 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, _typeProvider.intType);
7925 classA.accessors = <PropertyAccessorElement> [setterS];
7926 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7927 classB.mixins = <InterfaceType> [classA.type];
7928 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas sB, "${setterName}="));
7929 assertNoErrors(classA);
7930 assertNoErrors(classB);
7931 }
7932 void test_lookupInheritance_mixin_staticMember() {
7933 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7934 String methodName = "m";
7935 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7936 ((methodM as MethodElementImpl)).static = true;
7937 classA.methods = <MethodElement> [methodM];
7938 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7939 classB.mixins = <InterfaceType> [classA.type];
7940 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho dName));
7941 assertNoErrors(classA);
7942 assertNoErrors(classB);
7943 }
7944 void test_lookupInheritance_noMember() {
7945 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7946 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "a")) ;
7947 assertNoErrors(classA);
7948 }
7949 void test_lookupInheritance_superclass_getter() {
7950 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7951 String getterName = "g";
7952 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
7953 classA.accessors = <PropertyAccessorElement> [getterG];
7954 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
7955 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas sB, getterName));
7956 assertNoErrors(classA);
7957 assertNoErrors(classB);
7958 }
7959 void test_lookupInheritance_superclass_infiniteLoop() {
7960 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7961 classA.supertype = classA.type;
7962 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name "));
7963 assertNoErrors(classA);
7964 }
7965 void test_lookupInheritance_superclass_infiniteLoop2() {
7966 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7967 ClassElementImpl classB = ElementFactory.classElement2("B", []);
7968 classA.supertype = classB.type;
7969 classB.supertype = classA.type;
7970 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name "));
7971 assertNoErrors(classA);
7972 assertNoErrors(classB);
7973 }
7974 void test_lookupInheritance_superclass_method() {
7975 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7976 String methodName = "m";
7977 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7978 classA.methods = <MethodElement> [methodM];
7979 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
7980 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas sB, methodName));
7981 assertNoErrors(classA);
7982 assertNoErrors(classB);
7983 }
7984 void test_lookupInheritance_superclass_setter() {
7985 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7986 String setterName = "s";
7987 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, _typeProvider.intType);
7988 classA.accessors = <PropertyAccessorElement> [setterS];
7989 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
7990 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas sB, "${setterName}="));
7991 assertNoErrors(classA);
7992 assertNoErrors(classB);
7993 }
7994 void test_lookupInheritance_superclass_staticMember() {
7995 ClassElementImpl classA = ElementFactory.classElement2("A", []);
7996 String methodName = "m";
7997 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
7998 ((methodM as MethodElementImpl)).static = true;
7999 classA.methods = <MethodElement> [methodM];
8000 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
8001 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho dName));
8002 assertNoErrors(classA);
8003 assertNoErrors(classB);
8004 }
8005 void test_lookupMember_getter() {
8006 ClassElementImpl classA = ElementFactory.classElement2("A", []);
8007 String getterName = "g";
8008 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
8009 classA.accessors = <PropertyAccessorElement> [getterG];
8010 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupMember(classA, g etterName));
8011 assertNoErrors(classA);
8012 }
8013 void test_lookupMember_getter_static() {
8014 ClassElementImpl classA = ElementFactory.classElement2("A", []);
8015 String getterName = "g";
8016 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, t rue, _typeProvider.intType);
8017 classA.accessors = <PropertyAccessorElement> [getterG];
8018 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, getterName ));
8019 assertNoErrors(classA);
8020 }
8021 void test_lookupMember_method() {
8022 ClassElementImpl classA = ElementFactory.classElement2("A", []);
8023 String methodName = "m";
8024 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
8025 classA.methods = <MethodElement> [methodM];
8026 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupMember(classA, m ethodName));
8027 assertNoErrors(classA);
8028 }
8029 void test_lookupMember_method_static() {
8030 ClassElementImpl classA = ElementFactory.classElement2("A", []);
8031 String methodName = "m";
8032 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
8033 ((methodM as MethodElementImpl)).static = true;
8034 classA.methods = <MethodElement> [methodM];
8035 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, methodName ));
8036 assertNoErrors(classA);
8037 }
8038 void test_lookupMember_noMember() {
8039 ClassElementImpl classA = ElementFactory.classElement2("A", []);
8040 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, "a"));
8041 assertNoErrors(classA);
8042 }
8043 void test_lookupMember_setter() {
8044 ClassElementImpl classA = ElementFactory.classElement2("A", []);
8045 String setterName = "s";
8046 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, _typeProvider.intType);
8047 classA.accessors = <PropertyAccessorElement> [setterS];
8048 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupMember(classA, " ${setterName}="));
8049 assertNoErrors(classA);
8050 }
8051 void test_lookupMember_setter_static() {
8052 ClassElementImpl classA = ElementFactory.classElement2("A", []);
8053 String setterName = "s";
8054 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, t rue, _typeProvider.intType);
8055 classA.accessors = <PropertyAccessorElement> [setterS];
8056 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, setterName ));
8057 assertNoErrors(classA);
8058 }
8059 void assertErrors(ClassElement classElt, List<ErrorCode> expectedErrorCodes) {
8060 GatheringErrorListener errorListener = new GatheringErrorListener();
8061 Set<AnalysisError> actualErrors = _inheritanceManager.getErrors(classElt);
8062 if (actualErrors != null) {
8063 for (AnalysisError error in actualErrors) {
8064 errorListener.onError(error);
8065 }
8066 }
8067 errorListener.assertErrors2(expectedErrorCodes);
8068 }
8069 void assertNoErrors(ClassElement classElt) {
8070 assertErrors(classElt, []);
8071 }
8072
8073 /**
8074 * Create the inheritance manager used by the tests.
8075 *
8076 * @return the inheritance manager that was created
8077 */
8078 InheritanceManager createInheritanceManager() {
8079 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
8080 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt ilities2.createFile("/test.dart"));
8081 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart");
8082 definingCompilationUnit.source = source;
8083 _definingLibrary = ElementFactory.library(context, "test");
8084 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
8085 return new InheritanceManager(_definingLibrary);
8086 }
8087 static dartSuite() {
8088 _ut.group('InheritanceManagerTest', () {
8089 _ut.test('test_getMapOfMembersInheritedFromClasses_accessor_extends', () {
8090 final __test = new InheritanceManagerTest();
8091 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_acc essor_extends);
8092 });
8093 _ut.test('test_getMapOfMembersInheritedFromClasses_accessor_implements', ( ) {
8094 final __test = new InheritanceManagerTest();
8095 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_acc essor_implements);
8096 });
8097 _ut.test('test_getMapOfMembersInheritedFromClasses_accessor_with', () {
8098 final __test = new InheritanceManagerTest();
8099 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_acc essor_with);
8100 });
8101 _ut.test('test_getMapOfMembersInheritedFromClasses_method_extends', () {
8102 final __test = new InheritanceManagerTest();
8103 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_met hod_extends);
8104 });
8105 _ut.test('test_getMapOfMembersInheritedFromClasses_method_implements', () {
8106 final __test = new InheritanceManagerTest();
8107 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_met hod_implements);
8108 });
8109 _ut.test('test_getMapOfMembersInheritedFromClasses_method_with', () {
8110 final __test = new InheritanceManagerTest();
8111 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromClasses_met hod_with);
8112 });
8113 _ut.test('test_getMapOfMembersInheritedFromInterfaces_accessor_extends', ( ) {
8114 final __test = new InheritanceManagerTest();
8115 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromInterfaces_ accessor_extends);
8116 });
8117 _ut.test('test_getMapOfMembersInheritedFromInterfaces_accessor_implements' , () {
8118 final __test = new InheritanceManagerTest();
8119 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromInterfaces_ accessor_implements);
8120 });
8121 _ut.test('test_getMapOfMembersInheritedFromInterfaces_accessor_with', () {
8122 final __test = new InheritanceManagerTest();
8123 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromInterfaces_ accessor_with);
8124 });
8125 _ut.test('test_getMapOfMembersInheritedFromInterfaces_method_extends', () {
8126 final __test = new InheritanceManagerTest();
8127 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromInterfaces_ method_extends);
8128 });
8129 _ut.test('test_getMapOfMembersInheritedFromInterfaces_method_implements', () {
8130 final __test = new InheritanceManagerTest();
8131 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromInterfaces_ method_implements);
8132 });
8133 _ut.test('test_getMapOfMembersInheritedFromInterfaces_method_with', () {
8134 final __test = new InheritanceManagerTest();
8135 runJUnitTest(__test, __test.test_getMapOfMembersInheritedFromInterfaces_ method_with);
8136 });
8137 _ut.test('test_lookupInheritance_interface_getter', () {
8138 final __test = new InheritanceManagerTest();
8139 runJUnitTest(__test, __test.test_lookupInheritance_interface_getter);
8140 });
8141 _ut.test('test_lookupInheritance_interface_method', () {
8142 final __test = new InheritanceManagerTest();
8143 runJUnitTest(__test, __test.test_lookupInheritance_interface_method);
8144 });
8145 _ut.test('test_lookupInheritance_interface_setter', () {
8146 final __test = new InheritanceManagerTest();
8147 runJUnitTest(__test, __test.test_lookupInheritance_interface_setter);
8148 });
8149 _ut.test('test_lookupInheritance_interface_staticMember', () {
8150 final __test = new InheritanceManagerTest();
8151 runJUnitTest(__test, __test.test_lookupInheritance_interface_staticMembe r);
8152 });
8153 _ut.test('test_lookupInheritance_interfaces_STWC_inconsistentMethodInherit ance', () {
8154 final __test = new InheritanceManagerTest();
8155 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_STWC_incon sistentMethodInheritance);
8156 });
8157 _ut.test('test_lookupInheritance_interfaces_SWC_inconsistentMethodInherita nce', () {
8158 final __test = new InheritanceManagerTest();
8159 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_SWC_incons istentMethodInheritance);
8160 });
8161 _ut.test('test_lookupInheritance_interfaces_infiniteLoop', () {
8162 final __test = new InheritanceManagerTest();
8163 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_infiniteLo op);
8164 });
8165 _ut.test('test_lookupInheritance_interfaces_infiniteLoop2', () {
8166 final __test = new InheritanceManagerTest();
8167 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_infiniteLo op2);
8168 });
8169 _ut.test('test_lookupInheritance_interfaces_union1', () {
8170 final __test = new InheritanceManagerTest();
8171 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_union1);
8172 });
8173 _ut.test('test_lookupInheritance_interfaces_union2', () {
8174 final __test = new InheritanceManagerTest();
8175 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_union2);
8176 });
8177 _ut.test('test_lookupInheritance_mixin_getter', () {
8178 final __test = new InheritanceManagerTest();
8179 runJUnitTest(__test, __test.test_lookupInheritance_mixin_getter);
8180 });
8181 _ut.test('test_lookupInheritance_mixin_method', () {
8182 final __test = new InheritanceManagerTest();
8183 runJUnitTest(__test, __test.test_lookupInheritance_mixin_method);
8184 });
8185 _ut.test('test_lookupInheritance_mixin_setter', () {
8186 final __test = new InheritanceManagerTest();
8187 runJUnitTest(__test, __test.test_lookupInheritance_mixin_setter);
8188 });
8189 _ut.test('test_lookupInheritance_mixin_staticMember', () {
8190 final __test = new InheritanceManagerTest();
8191 runJUnitTest(__test, __test.test_lookupInheritance_mixin_staticMember);
8192 });
8193 _ut.test('test_lookupInheritance_noMember', () {
8194 final __test = new InheritanceManagerTest();
8195 runJUnitTest(__test, __test.test_lookupInheritance_noMember);
8196 });
8197 _ut.test('test_lookupInheritance_superclass_getter', () {
8198 final __test = new InheritanceManagerTest();
8199 runJUnitTest(__test, __test.test_lookupInheritance_superclass_getter);
8200 });
8201 _ut.test('test_lookupInheritance_superclass_infiniteLoop', () {
8202 final __test = new InheritanceManagerTest();
8203 runJUnitTest(__test, __test.test_lookupInheritance_superclass_infiniteLo op);
8204 });
8205 _ut.test('test_lookupInheritance_superclass_infiniteLoop2', () {
8206 final __test = new InheritanceManagerTest();
8207 runJUnitTest(__test, __test.test_lookupInheritance_superclass_infiniteLo op2);
8208 });
8209 _ut.test('test_lookupInheritance_superclass_method', () {
8210 final __test = new InheritanceManagerTest();
8211 runJUnitTest(__test, __test.test_lookupInheritance_superclass_method);
8212 });
8213 _ut.test('test_lookupInheritance_superclass_setter', () {
8214 final __test = new InheritanceManagerTest();
8215 runJUnitTest(__test, __test.test_lookupInheritance_superclass_setter);
8216 });
8217 _ut.test('test_lookupInheritance_superclass_staticMember', () {
8218 final __test = new InheritanceManagerTest();
8219 runJUnitTest(__test, __test.test_lookupInheritance_superclass_staticMemb er);
8220 });
8221 _ut.test('test_lookupMember_getter', () {
8222 final __test = new InheritanceManagerTest();
8223 runJUnitTest(__test, __test.test_lookupMember_getter);
8224 });
8225 _ut.test('test_lookupMember_getter_static', () {
8226 final __test = new InheritanceManagerTest();
8227 runJUnitTest(__test, __test.test_lookupMember_getter_static);
8228 });
8229 _ut.test('test_lookupMember_method', () {
8230 final __test = new InheritanceManagerTest();
8231 runJUnitTest(__test, __test.test_lookupMember_method);
8232 });
8233 _ut.test('test_lookupMember_method_static', () {
8234 final __test = new InheritanceManagerTest();
8235 runJUnitTest(__test, __test.test_lookupMember_method_static);
8236 });
8237 _ut.test('test_lookupMember_noMember', () {
8238 final __test = new InheritanceManagerTest();
8239 runJUnitTest(__test, __test.test_lookupMember_noMember);
8240 });
8241 _ut.test('test_lookupMember_setter', () {
8242 final __test = new InheritanceManagerTest();
8243 runJUnitTest(__test, __test.test_lookupMember_setter);
8244 });
8245 _ut.test('test_lookupMember_setter_static', () {
8246 final __test = new InheritanceManagerTest();
8247 runJUnitTest(__test, __test.test_lookupMember_setter_static);
8248 });
8249 });
8250 }
8251 }
8252 class CompileTimeErrorCodeTest extends ResolverTestCase {
8253 void fail_compileTimeConstantRaisesException() {
8254 Source source = addSource(EngineTestCase.createSource([]));
8255 resolve(source);
8256 assertErrors(source, [CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCE PTION]);
8257 verify([source]);
8258 }
8259 void fail_constEvalThrowsException() {
8260 Source source = addSource(EngineTestCase.createSource([
8261 "class C {",
8262 " const C();",
8263 "}",
8264 "f() { return const C(); }"]));
8265 resolve(source);
8266 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTIO N]);
8267 verify([source]);
8268 }
8269 void fail_mixinDeclaresConstructor() {
8270 Source source = addSource(EngineTestCase.createSource([
8271 "class A {",
8272 " A() {}",
8273 "}",
8274 "class B extends Object mixin A {}"]));
8275 resolve(source);
8276 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
8277 verify([source]);
8278 }
8279 void fail_mixinOfNonClass() {
8280 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex tends Object mixin A {}"]));
8281 resolve(source);
8282 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
8283 verify([source]);
8284 }
8285 void fail_objectCannotExtendAnotherClass() {
8286 Source source = addSource(EngineTestCase.createSource([]));
8287 resolve(source);
8288 assertErrors(source, [CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLAS S]);
8289 verify([source]);
8290 }
8291 void fail_recursiveCompileTimeConstant() {
8292 Source source = addSource(EngineTestCase.createSource([
8293 "class A {",
8294 " const A();",
8295 " final m = const A();",
8296 "}"]));
8297 resolve(source);
8298 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]) ;
8299 verify([source]);
8300 }
8301 void fail_recursiveCompileTimeConstant_cycle() {
8302 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", " const y = x + 1;"]));
8303 resolve(source);
8304 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]) ;
8305 verify([source]);
8306 }
8307 void fail_superInitializerInObject() {
8308 Source source = addSource(EngineTestCase.createSource([]));
8309 resolve(source);
8310 assertErrors(source, [CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]);
8311 verify([source]);
8312 }
8313 void test_ambiguousExport() {
8314 Source source = addSource(EngineTestCase.createSource([
8315 "library L;",
8316 "export 'lib1.dart';",
8317 "export 'lib2.dart';"]));
8318 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
8319 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
8320 resolve(source);
8321 assertErrors(source, [CompileTimeErrorCode.AMBIGUOUS_EXPORT]);
8322 verify([source]);
8323 }
8324 void test_ambiguousImport_function() {
8325 Source source = addSource(EngineTestCase.createSource([
8326 "import 'lib1.dart';",
8327 "import 'lib2.dart';",
8328 "g() { return f(); }"]));
8329 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "f() {}"]));
8330 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "f() {}"]));
8331 resolve(source);
8332 assertErrors(source, [
8333 StaticWarningCode.AMBIGUOUS_IMPORT,
8334 CompileTimeErrorCode.UNDEFINED_FUNCTION]);
8335 }
8336 void test_argumentDefinitionTestNonParameter() {
8337 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0; ", " return ?v;", "}"]));
8338 resolve(source);
8339 assertErrors(source, [
8340 ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST,
8341 CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER]);
8342 verify([source]);
8343 }
8344 void test_builtInIdentifierAsMixinName_classTypeAlias() {
8345 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class as = A with B;"]));
8346 resolve(source);
8347 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NA ME]);
8348 verify([source]);
8349 }
8350 void test_builtInIdentifierAsType_formalParameter_field() {
8351 Source source = addSource(EngineTestCase.createSource(["class A {", " var x ;", " A(static this.x);", "}"]));
8352 resolve(source);
8353 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
8354 verify([source]);
8355 }
8356 void test_builtInIdentifierAsType_formalParameter_simple() {
8357 Source source = addSource(EngineTestCase.createSource(["f(static x) {", "}"] ));
8358 resolve(source);
8359 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
8360 verify([source]);
8361 }
8362 void test_builtInIdentifierAsType_variableDeclaration() {
8363 Source source = addSource(EngineTestCase.createSource(["f() {", " typedef x ;", "}"]));
8364 resolve(source);
8365 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE]);
8366 verify([source]);
8367 }
8368 void test_builtInIdentifierAsTypedefName_functionTypeAlias() {
8369 Source source = addSource(EngineTestCase.createSource(["typedef bool as();"] ));
8370 resolve(source);
8371 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NA ME]);
8372 verify([source]);
8373 }
8374 void test_builtInIdentifierAsTypeName() {
8375 Source source = addSource(EngineTestCase.createSource(["class as {}"]));
8376 resolve(source);
8377 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME] );
8378 verify([source]);
8379 }
8380 void test_builtInIdentifierAsTypeParameterName() {
8381 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"]));
8382 resolve(source);
8383 assertErrors(source, [CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAM ETER_NAME]);
8384 verify([source]);
8385 }
8386 void test_caseExpressionTypeImplementsEquals() {
8387 Source source = addSource(EngineTestCase.createSource([
8388 "class IntWrapper {",
8389 " final int value;",
8390 " const IntWrapper(this.value);",
8391 " bool operator ==(IntWrapper x) {",
8392 " return value == x.value;",
8393 " }",
8394 " get hashCode => value;",
8395 "}",
8396 "",
8397 "f(var a) {",
8398 " switch(a) {",
8399 " case(const IntWrapper(1)) : return 1;",
8400 " default: return 0;",
8401 " }",
8402 "}"]));
8403 resolve(source);
8404 assertErrors(source, [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_E QUALS]);
8405 verify([source]);
8406 }
8407 void test_conflictingConstructorNameAndMember_field() {
8408 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.x() {}", "}"]));
8409 resolve(source);
8410 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_ FIELD]);
8411 verify([source]);
8412 }
8413 void test_conflictingConstructorNameAndMember_method() {
8414 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.x();", " void x() {}", "}"]));
8415 resolve(source);
8416 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_ METHOD]);
8417 verify([source]);
8418 }
8419 void test_conflictingGetterAndMethod_field_method() {
8420 Source source = addSource(EngineTestCase.createSource([
8421 "class A {",
8422 " int m;",
8423 "}",
8424 "class B extends A {",
8425 " m() {}",
8426 "}"]));
8427 resolve(source);
8428 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]);
8429 verify([source]);
8430 }
8431 void test_conflictingGetterAndMethod_getter_method() {
8432 Source source = addSource(EngineTestCase.createSource([
8433 "class A {",
8434 " get m => 0;",
8435 "}",
8436 "class B extends A {",
8437 " m() {}",
8438 "}"]));
8439 resolve(source);
8440 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]);
8441 verify([source]);
8442 }
8443 void test_conflictingGetterAndMethod_method_field() {
8444 Source source = addSource(EngineTestCase.createSource([
8445 "class A {",
8446 " m() {}",
8447 "}",
8448 "class B extends A {",
8449 " int m;",
8450 "}"]));
8451 resolve(source);
8452 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]);
8453 verify([source]);
8454 }
8455 void test_conflictingGetterAndMethod_method_getter() {
8456 Source source = addSource(EngineTestCase.createSource([
8457 "class A {",
8458 " m() {}",
8459 "}",
8460 "class B extends A {",
8461 " get m => 0;",
8462 "}"]));
8463 resolve(source);
8464 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]);
8465 verify([source]);
8466 }
8467 void test_conflictingTypeVariableAndClass() {
8468 Source source = addSource(EngineTestCase.createSource(["class T<T> {", "}"]) );
8469 resolve(source);
8470 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLA SS]);
8471 verify([source]);
8472 }
8473 void test_conflictingTypeVariableAndMember_field() {
8474 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va r T;", "}"]));
8475 resolve(source);
8476 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM BER]);
8477 verify([source]);
8478 }
8479 void test_conflictingTypeVariableAndMember_getter() {
8480 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " ge t T => null;", "}"]));
8481 resolve(source);
8482 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM BER]);
8483 verify([source]);
8484 }
8485 void test_conflictingTypeVariableAndMember_method() {
8486 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " T( ) {}", "}"]));
8487 resolve(source);
8488 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM BER]);
8489 verify([source]);
8490 }
8491 void test_conflictingTypeVariableAndMember_method_static() {
8492 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " st atic T() {}", "}"]));
8493 resolve(source);
8494 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM BER]);
8495 verify([source]);
8496 }
8497 void test_conflictingTypeVariableAndMember_setter() {
8498 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " se t T(x) {}", "}"]));
8499 resolve(source);
8500 assertErrors(source, [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEM BER]);
8501 verify([source]);
8502 }
8503 void test_constConstructorWithNonConstSuper_explicit() {
8504 Source source = addSource(EngineTestCase.createSource([
8505 "class A {",
8506 " A();",
8507 "}",
8508 "class B extends A {",
8509 " const B(): super();",
8510 "}"]));
8511 resolve(source);
8512 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_ SUPER]);
8513 verify([source]);
8514 }
8515 void test_constConstructorWithNonConstSuper_implicit() {
8516 Source source = addSource(EngineTestCase.createSource([
8517 "class A {",
8518 " A();",
8519 "}",
8520 "class B extends A {",
8521 " const B();",
8522 "}"]));
8523 resolve(source);
8524 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_ SUPER]);
8525 verify([source]);
8526 }
8527 void test_constConstructorWithNonFinalField_mixin() {
8528 Source source = addSource(EngineTestCase.createSource([
8529 "class A {",
8530 " var a;",
8531 "}",
8532 "class B extends Object with A {",
8533 " const B();",
8534 "}"]));
8535 resolve(source);
8536 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_ FIELD]);
8537 verify([source]);
8538 }
8539 void test_constConstructorWithNonFinalField_super() {
8540 Source source = addSource(EngineTestCase.createSource([
8541 "class A {",
8542 " var a;",
8543 "}",
8544 "class B extends A {",
8545 " const B();",
8546 "}"]));
8547 resolve(source);
8548 assertErrors(source, [
8549 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD,
8550 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER]);
8551 verify([source]);
8552 }
8553 void test_constConstructorWithNonFinalField_this() {
8554 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " const A();", "}"]));
8555 resolve(source);
8556 assertErrors(source, [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_ FIELD]);
8557 verify([source]);
8558 }
8559 void test_constEval_newInstance_constConstructor() {
8560 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "const a = new A();"]));
8561 resolve(source);
8562 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA NT_VALUE]);
8563 verify([source]);
8564 }
8565 void test_constEval_propertyExtraction_targetNotConst() {
8566 Source source = addSource(EngineTestCase.createSource([
8567 "class A {",
8568 " const A();",
8569 " m() {}",
8570 "}",
8571 "final a = const A();",
8572 "const C = a.m;"]));
8573 resolve(source);
8574 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA NT_VALUE]);
8575 verify([source]);
8576 }
8577 void test_constEvalThrowsException_binaryMinus_null() {
8578 check_constEvalThrowsException_binary_null("null - 5", false);
8579 check_constEvalThrowsException_binary_null("5 - null", true);
8580 }
8581 void test_constEvalThrowsException_binaryPlus_null() {
8582 check_constEvalThrowsException_binary_null("null + 5", false);
8583 check_constEvalThrowsException_binary_null("5 + null", true);
8584 }
8585 void test_constEvalThrowsException_divisionByZero() {
8586 Source source = addSource("const C = 1 ~/ 0;");
8587 resolve(source);
8588 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]);
8589 verify([source]);
8590 }
8591 void test_constEvalThrowsException_unaryBitNot_null() {
8592 Source source = addSource("const C = ~null;");
8593 resolve(source);
8594 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
8595 }
8596 void test_constEvalThrowsException_unaryNegated_null() {
8597 Source source = addSource("const C = -null;");
8598 resolve(source);
8599 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
8600 }
8601 void test_constEvalThrowsException_unaryNot_null() {
8602 Source source = addSource("const C = !null;");
8603 resolve(source);
8604 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
8605 verify([source]);
8606 }
8607 void test_constEvalTypeBool_binary() {
8608 check_constEvalTypeBool_withParameter_binary("p && ''");
8609 check_constEvalTypeBool_withParameter_binary("p || ''");
8610 }
8611 void test_constEvalTypeBool_binary_leftTrue() {
8612 Source source = addSource("const C = (true || 0);");
8613 resolve(source);
8614 assertErrors(source, [
8615 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
8616 HintCode.DEAD_CODE]);
8617 verify([source]);
8618 }
8619 void test_constEvalTypeBoolNumString_equal() {
8620 Source source = addSource(EngineTestCase.createSource([
8621 "class A {",
8622 " const A();",
8623 "}",
8624 "class B {",
8625 " final a;",
8626 " const B(num p) : a = p == const A();",
8627 "}"]));
8628 resolve(source);
8629 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]) ;
8630 verify([source]);
8631 }
8632 void test_constEvalTypeBoolNumString_notEqual() {
8633 Source source = addSource(EngineTestCase.createSource([
8634 "class A {",
8635 " const A();",
8636 "}",
8637 "class B {",
8638 " final a;",
8639 " const B(String p) : a = p != const A();",
8640 "}"]));
8641 resolve(source);
8642 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]) ;
8643 verify([source]);
8644 }
8645 void test_constEvalTypeInt_binary() {
8646 check_constEvalTypeInt_withParameter_binary("p ^ ''");
8647 check_constEvalTypeInt_withParameter_binary("p & ''");
8648 check_constEvalTypeInt_withParameter_binary("p | ''");
8649 check_constEvalTypeInt_withParameter_binary("p >> ''");
8650 check_constEvalTypeInt_withParameter_binary("p << ''");
8651 }
8652 void test_constEvalTypeNum_binary() {
8653 check_constEvalTypeNum_withParameter_binary("p + ''");
8654 check_constEvalTypeNum_withParameter_binary("p - ''");
8655 check_constEvalTypeNum_withParameter_binary("p * ''");
8656 check_constEvalTypeNum_withParameter_binary("p / ''");
8657 check_constEvalTypeNum_withParameter_binary("p ~/ ''");
8658 check_constEvalTypeNum_withParameter_binary("p > ''");
8659 check_constEvalTypeNum_withParameter_binary("p < ''");
8660 check_constEvalTypeNum_withParameter_binary("p >= ''");
8661 check_constEvalTypeNum_withParameter_binary("p <= ''");
8662 check_constEvalTypeNum_withParameter_binary("p % ''");
8663 }
8664 void test_constEvalTypeNum_plus_String() {
8665 Source source = addSource("const C = 'a' + 'b';");
8666 resolve(source);
8667 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_NUM]);
8668 verify([source]);
8669 }
8670 void test_constFormalParameter_fieldFormalParameter() {
8671 Source source = addSource(EngineTestCase.createSource(["class A {", " var x ;", " A(const this.x) {}", "}"]));
8672 resolve(source);
8673 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
8674 verify([source]);
8675 }
8676 void test_constFormalParameter_simpleFormalParameter() {
8677 Source source = addSource(EngineTestCase.createSource(["f(const x) {}"]));
8678 resolve(source);
8679 assertErrors(source, [CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
8680 verify([source]);
8681 }
8682 void test_constInitializedWithNonConstValue() {
8683 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C = p;", "}"]));
8684 resolve(source);
8685 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA NT_VALUE]);
8686 verify([source]);
8687 }
8688 void test_constInitializedWithNonConstValue_missingConstInListLiteral() {
8689 Source source = addSource("const List L = [0];");
8690 resolve(source);
8691 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA NT_VALUE]);
8692 verify([source]);
8693 }
8694 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() {
8695 Source source = addSource("const Map M = {'a' : 0};");
8696 resolve(source);
8697 assertErrors(source, [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTA NT_VALUE]);
8698 verify([source]);
8699 }
8700 void test_constInstanceField() {
8701 Source source = addSource(EngineTestCase.createSource(["class C {", " const int f = 0;", "}"]));
8702 resolve(source);
8703 assertErrors(source, [CompileTimeErrorCode.CONST_INSTANCE_FIELD]);
8704 verify([source]);
8705 }
8706 void test_constMapKeyTypeImplementsEquals_direct() {
8707 Source source = addSource(EngineTestCase.createSource([
8708 "class A {",
8709 " const A();",
8710 " operator ==(other) => false;",
8711 "}",
8712 "main() {",
8713 " const {const A() : 0};",
8714 "}"]));
8715 resolve(source);
8716 assertErrors(source, [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMP LEMENTS_EQUALS]);
8717 verify([source]);
8718 }
8719 void test_constMapKeyTypeImplementsEquals_super() {
8720 Source source = addSource(EngineTestCase.createSource([
8721 "class A {",
8722 " const A();",
8723 " operator ==(other) => false;",
8724 "}",
8725 "class B extends A {",
8726 " const B();",
8727 "}",
8728 "main() {",
8729 " const {const B() : 0};",
8730 "}"]));
8731 resolve(source);
8732 assertErrors(source, [CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMP LEMENTS_EQUALS]);
8733 verify([source]);
8734 }
8735 void test_constWithInvalidTypeParameters() {
8736 Source source = addSource(EngineTestCase.createSource([
8737 "class A {",
8738 " const A();",
8739 "}",
8740 "f() { return const A<A>(); }"]));
8741 resolve(source);
8742 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER S]);
8743 verify([source]);
8744 }
8745 void test_constWithInvalidTypeParameters_tooFew() {
8746 Source source = addSource(EngineTestCase.createSource([
8747 "class A {}",
8748 "class C<K, V> {",
8749 " const C();",
8750 "}",
8751 "f(p) {",
8752 " return const C<A>();",
8753 "}"]));
8754 resolve(source);
8755 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER S]);
8756 verify([source]);
8757 }
8758 void test_constWithInvalidTypeParameters_tooMany() {
8759 Source source = addSource(EngineTestCase.createSource([
8760 "class A {}",
8761 "class C<E> {",
8762 " const C();",
8763 "}",
8764 "f(p) {",
8765 " return const C<A, A>();",
8766 "}"]));
8767 resolve(source);
8768 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETER S]);
8769 verify([source]);
8770 }
8771 void test_constWithNonConst() {
8772 Source source = addSource(EngineTestCase.createSource([
8773 "class T {",
8774 " T(a, b, {c, d}) {}",
8775 "}",
8776 "f() { return const T(0, 1, c: 2, d: 3); }"]));
8777 resolve(source);
8778 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONST]);
8779 verify([source]);
8780 }
8781 void test_constWithNonConstantArgument_annotation() {
8782 Source source = addSource(EngineTestCase.createSource([
8783 "class A {",
8784 " const A(int p);",
8785 "}",
8786 "var v = 42;",
8787 "@A(v)",
8788 "main() {",
8789 "}"]));
8790 resolve(source);
8791 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT] );
8792 verify([source]);
8793 }
8794 void test_constWithNonConstantArgument_instanceCreation() {
8795 Source source = addSource(EngineTestCase.createSource([
8796 "class A {",
8797 " const A(a);",
8798 "}",
8799 "f(p) { return const A(p); }"]));
8800 resolve(source);
8801 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT] );
8802 verify([source]);
8803 }
8804 void test_constWithNonType() {
8805 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", " return const A();", "}"]));
8806 resolve(source);
8807 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
8808 verify([source]);
8809 }
8810 void test_constWithNonType_fromLibrary() {
8811 Source source1 = addSource2("lib.dart", "");
8812 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([
8813 "import 'lib.dart' as lib;",
8814 "void f() {",
8815 " const lib.A();",
8816 "}"]));
8817 resolve(source1);
8818 resolve(source2);
8819 assertErrors(source2, [CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
8820 verify([source1]);
8821 }
8822 void test_constWithTypeParameters_direct() {
8823 Source source = addSource(EngineTestCase.createSource([
8824 "class A<T> {",
8825 " static const V = const A<T>();",
8826 " const A();",
8827 "}"]));
8828 resolve(source);
8829 assertErrors(source, [
8830 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
8831 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
8832 verify([source]);
8833 }
8834 void test_constWithTypeParameters_indirect() {
8835 Source source = addSource(EngineTestCase.createSource([
8836 "class A<T> {",
8837 " static const V = const A<List<T>>();",
8838 " const A();",
8839 "}"]));
8840 resolve(source);
8841 assertErrors(source, [
8842 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
8843 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC]);
8844 verify([source]);
8845 }
8846 void test_constWithUndefinedConstructor() {
8847 Source source = addSource(EngineTestCase.createSource([
8848 "class A {",
8849 " const A();",
8850 "}",
8851 "f() {",
8852 " return const A.noSuchConstructor();",
8853 "}"]));
8854 resolve(source);
8855 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR] );
8856 }
8857 void test_constWithUndefinedConstructorDefault() {
8858 Source source = addSource(EngineTestCase.createSource([
8859 "class A {",
8860 " const A.name();",
8861 "}",
8862 "f() {",
8863 " return const A();",
8864 "}"]));
8865 resolve(source);
8866 assertErrors(source, [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_ DEFAULT]);
8867 verify([source]);
8868 }
8869 void test_defaultValueInFunctionTypeAlias() {
8870 Source source = addSource(EngineTestCase.createSource(["typedef F([x = 0]);" ]));
8871 resolve(source);
8872 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_AL IAS]);
8873 verify([source]);
8874 }
8875 void test_defaultValueInFunctionTypedParameter_named() {
8876 Source source = addSource(EngineTestCase.createSource(["f(g({p: null})) {}"] ));
8877 resolve(source);
8878 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_P ARAMETER]);
8879 verify([source]);
8880 }
8881 void test_defaultValueInFunctionTypedParameter_optional() {
8882 Source source = addSource(EngineTestCase.createSource(["f(g([p = null])) {}" ]));
8883 resolve(source);
8884 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_P ARAMETER]);
8885 verify([source]);
8886 }
8887 void test_defaultValueInRedirectingFactoryConstructor() {
8888 Source source = addSource(EngineTestCase.createSource([
8889 "class A {",
8890 " factory A([int x = 0]) = B;",
8891 "}",
8892 "",
8893 "class B implements A {",
8894 " B([int x = 1]) {}",
8895 "}"]));
8896 resolve(source);
8897 assertErrors(source, [CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACT ORY_CONSTRUCTOR]);
8898 verify([source]);
8899 }
8900 void test_duplicateConstructorName_named() {
8901 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a() {}", " A.a() {}", "}"]));
8902 resolve(source);
8903 assertErrors(source, [
8904 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME,
8905 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME]);
8906 verify([source]);
8907 }
8908 void test_duplicateConstructorName_unnamed() {
8909 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", " A() {}", "}"]));
8910 resolve(source);
8911 assertErrors(source, [
8912 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT,
8913 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT]);
8914 verify([source]);
8915 }
8916 void test_duplicateDefinition() {
8917 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0 ;", " m(a) {}", "}"]));
8918 resolve(source);
8919 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
8920 verify([source]);
8921 }
8922 void test_duplicateDefinition_acrossLibraries() {
8923 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([ "library lib;", "", "part 'a.dart';", "part 'b.dart';"]));
8924 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
8925 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
8926 resolve(librarySource);
8927 assertErrors(sourceB, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
8928 verify([librarySource, sourceA, sourceB]);
8929 }
8930 void test_duplicateDefinition_classMembers_fields() {
8931 Source source = addSource(EngineTestCase.createSource(["class A {", " int a ;", " int a;", "}"]));
8932 resolve(source);
8933 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
8934 verify([source]);
8935 }
8936 void test_duplicateDefinition_classMembers_fields_oneStatic() {
8937 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " static int x;", "}"]));
8938 resolve(source);
8939 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
8940 verify([source]);
8941 }
8942 void test_duplicateDefinition_classMembers_methods() {
8943 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", " m() {}", "}"]));
8944 resolve(source);
8945 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
8946 verify([source]);
8947 }
8948 void test_duplicateDefinition_localFields() {
8949 Source source = addSource(EngineTestCase.createSource([
8950 "class A {",
8951 " m() {",
8952 " int a;",
8953 " int a;",
8954 " }",
8955 "}"]));
8956 resolve(source);
8957 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
8958 verify([source]);
8959 }
8960 void test_duplicateDefinition_parameterWithFunctionName_local() {
8961 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) { }", "}"]));
8962 resolve(source);
8963 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
8964 verify([source]);
8965 }
8966 void test_duplicateDefinition_parameterWithFunctionName_topLevel() {
8967 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) { }", "}"]));
8968 resolve(source);
8969 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION]);
8970 verify([source]);
8971 }
8972 void test_duplicateDefinitionInheritance_instanceGetter_staticGetter() {
8973 Source source = addSource(EngineTestCase.createSource([
8974 "class A {",
8975 " int get x => 0;",
8976 "}",
8977 "class B extends A {",
8978 " static int get x => 0;",
8979 "}"]));
8980 resolve(source);
8981 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE] );
8982 verify([source]);
8983 }
8984 void test_duplicateDefinitionInheritance_instanceGetterAbstract_staticGetter() {
8985 Source source = addSource(EngineTestCase.createSource([
8986 "abstract class A {",
8987 " int get x;",
8988 "}",
8989 "class B extends A {",
8990 " static int get x => 0;",
8991 "}"]));
8992 resolve(source);
8993 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE] );
8994 verify([source]);
8995 }
8996 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() {
8997 Source source = addSource(EngineTestCase.createSource([
8998 "class A {",
8999 " x() {}",
9000 "}",
9001 "class B extends A {",
9002 " static x() {}",
9003 "}"]));
9004 resolve(source);
9005 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE] );
9006 verify([source]);
9007 }
9008 void test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() {
9009 Source source = addSource(EngineTestCase.createSource([
9010 "abstract class A {",
9011 " x();",
9012 "}",
9013 "abstract class B extends A {",
9014 " static x() {}",
9015 "}"]));
9016 resolve(source);
9017 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE] );
9018 verify([source]);
9019 }
9020 void test_duplicateDefinitionInheritance_instanceSetter_staticSetter() {
9021 Source source = addSource(EngineTestCase.createSource([
9022 "class A {",
9023 " set x(value) {}",
9024 "}",
9025 "class B extends A {",
9026 " static set x(value) {}",
9027 "}"]));
9028 resolve(source);
9029 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE] );
9030 verify([source]);
9031 }
9032 void test_duplicateDefinitionInheritance_instanceSetterAbstract_staticSetter() {
9033 Source source = addSource(EngineTestCase.createSource([
9034 "abstract class A {",
9035 " set x(value);",
9036 "}",
9037 "class B extends A {",
9038 " static set x(value) {}",
9039 "}"]));
9040 resolve(source);
9041 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE] );
9042 verify([source]);
9043 }
9044 void test_duplicateNamedArgument() {
9045 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main () {", " f(a: 1, a: 2);", "}"]));
9046 resolve(source);
9047 assertErrors(source, [CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]);
9048 verify([source]);
9049 }
9050 void test_exportInternalLibrary() {
9051 Source source = addSource(EngineTestCase.createSource(["export 'dart:_interc eptors';"]));
9052 resolve(source);
9053 assertErrors(source, [CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]);
9054 verify([source]);
9055 }
9056 void test_exportOfNonLibrary() {
9057 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
9058 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"]));
9059 resolve(source);
9060 assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]);
9061 verify([source]);
9062 }
9063 void test_extendsDisallowedClass_bool() {
9064 Source source = addSource(EngineTestCase.createSource(["class A extends bool {}"]));
9065 resolve(source);
9066 assertErrors(source, [
9067 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
9068 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
9069 verify([source]);
9070 }
9071 void test_extendsDisallowedClass_double() {
9072 Source source = addSource(EngineTestCase.createSource(["class A extends doub le {}"]));
9073 resolve(source);
9074 assertErrors(source, [
9075 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
9076 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
9077 verify([source]);
9078 }
9079 void test_extendsDisallowedClass_int() {
9080 Source source = addSource(EngineTestCase.createSource(["class A extends int {}"]));
9081 resolve(source);
9082 assertErrors(source, [
9083 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
9084 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
9085 verify([source]);
9086 }
9087 void test_extendsDisallowedClass_Null() {
9088 Source source = addSource(EngineTestCase.createSource(["class A extends Null {}"]));
9089 resolve(source);
9090 assertErrors(source, [
9091 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
9092 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
9093 verify([source]);
9094 }
9095 void test_extendsDisallowedClass_num() {
9096 Source source = addSource(EngineTestCase.createSource(["class A extends num {}"]));
9097 resolve(source);
9098 assertErrors(source, [
9099 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
9100 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
9101 verify([source]);
9102 }
9103 void test_extendsDisallowedClass_String() {
9104 Source source = addSource(EngineTestCase.createSource(["class A extends Stri ng {}"]));
9105 resolve(source);
9106 assertErrors(source, [
9107 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
9108 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
9109 verify([source]);
9110 }
9111 void test_extendsNonClass_class() {
9112 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends A {}"]));
9113 resolve(source);
9114 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]);
9115 verify([source]);
9116 }
9117 void test_extendsNonClass_dynamic() {
9118 Source source = addSource(EngineTestCase.createSource(["class B extends dyna mic {}"]));
9119 resolve(source);
9120 assertErrors(source, [CompileTimeErrorCode.EXTENDS_NON_CLASS]);
9121 verify([source]);
9122 }
9123 void test_extraPositionalArguments_const() {
9124 Source source = addSource(EngineTestCase.createSource([
9125 "class A {",
9126 " const A();",
9127 "}",
9128 "main() {",
9129 " const A(0);",
9130 "}"]));
9131 resolve(source);
9132 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]);
9133 verify([source]);
9134 }
9135 void test_extraPositionalArguments_const_super() {
9136 Source source = addSource(EngineTestCase.createSource([
9137 "class A {",
9138 " const A();",
9139 "}",
9140 "class B extends A {",
9141 " const B() : super(0);",
9142 "}"]));
9143 resolve(source);
9144 assertErrors(source, [CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]);
9145 verify([source]);
9146 }
9147 void test_fieldInitializedByMultipleInitializers() {
9148 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A() : x = 0, x = 1 {}", "}"]));
9149 resolve(source);
9150 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INI TIALIZERS]);
9151 verify([source]);
9152 }
9153 void test_fieldInitializedByMultipleInitializers_multipleInits() {
9154 Source source = addSource(EngineTestCase.createSource([
9155 "class A {",
9156 " int x;",
9157 " A() : x = 0, x = 1, x = 2 {}",
9158 "}"]));
9159 resolve(source);
9160 assertErrors(source, [
9161 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS,
9162 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
9163 verify([source]);
9164 }
9165 void test_fieldInitializedByMultipleInitializers_multipleNames() {
9166 Source source = addSource(EngineTestCase.createSource([
9167 "class A {",
9168 " int x;",
9169 " int y;",
9170 " A() : x = 0, x = 1, y = 0, y = 1 {}",
9171 "}"]));
9172 resolve(source);
9173 assertErrors(source, [
9174 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS,
9175 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
9176 verify([source]);
9177 }
9178 void test_fieldInitializedInParameterAndInitializer() {
9179 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) : x = 1 {}", "}"]));
9180 resolve(source);
9181 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AN D_INITIALIZER]);
9182 verify([source]);
9183 }
9184 void test_fieldInitializerFactoryConstructor() {
9185 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " factory A(this.x) {}", "}"]));
9186 resolve(source);
9187 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRU CTOR]);
9188 verify([source]);
9189 }
9190 void test_fieldInitializerNotAssignable() {
9191 Source source = addSource(EngineTestCase.createSource([
9192 "class A {",
9193 " final int x;",
9194 " const A() : x = '';",
9195 "}"]));
9196 resolve(source);
9197 assertErrors(source, [CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIG NABLE]);
9198 verify([source]);
9199 }
9200 void test_fieldInitializerOutsideConstructor() {
9201 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " m(this.x) {}", "}"]));
9202 resolve(source);
9203 assertErrors(source, [
9204 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR,
9205 CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
9206 verify([source]);
9207 }
9208 void test_fieldInitializerOutsideConstructor_defaultParameter() {
9209 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " m([this.x]) {}", "}"]));
9210 resolve(source);
9211 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRU CTOR]);
9212 verify([source]);
9213 }
9214 void test_fieldInitializerRedirectingConstructor_afterRedirection() {
9215 Source source = addSource(EngineTestCase.createSource([
9216 "class A {",
9217 " int x;",
9218 " A.named() {}",
9219 " A() : this.named(), x = 42;",
9220 "}"]));
9221 resolve(source);
9222 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON STRUCTOR]);
9223 verify([source]);
9224 }
9225 void test_fieldInitializerRedirectingConstructor_beforeRedirection() {
9226 Source source = addSource(EngineTestCase.createSource([
9227 "class A {",
9228 " int x;",
9229 " A.named() {}",
9230 " A() : x = 42, this.named();",
9231 "}"]));
9232 resolve(source);
9233 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON STRUCTOR]);
9234 verify([source]);
9235 }
9236 void test_fieldInitializingFormalRedirectingConstructor() {
9237 Source source = addSource(EngineTestCase.createSource([
9238 "class A {",
9239 " int x;",
9240 " A.named() {}",
9241 " A(this.x) : this.named();",
9242 "}"]));
9243 resolve(source);
9244 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CON STRUCTOR]);
9245 verify([source]);
9246 }
9247 void test_finalInitializedMultipleTimes_initializers() {
9248 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 0, x = 0 {}", "}"]));
9249 resolve(source);
9250 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INI TIALIZERS]);
9251 verify([source]);
9252 }
9253
9254 /**
9255 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests the
9256 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided here to show
9257 * coverage over all of the permutations of initializers in constructor declar ations.
9258 *
9259 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of
9260 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code
9261 */
9262 void test_finalInitializedMultipleTimes_initializingFormal_initializer() {
9263 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) : x = 0 {}", "}"]));
9264 resolve(source);
9265 assertErrors(source, [CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AN D_INITIALIZER]);
9266 verify([source]);
9267 }
9268 void test_finalInitializedMultipleTimes_initializingFormals() {
9269 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x, this.x) {}", "}"]));
9270 resolve(source);
9271 assertErrors(source, [CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES] );
9272 verify([source]);
9273 }
9274 void test_finalNotInitialized_instanceField_const_static() {
9275 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c const F;", "}"]));
9276 resolve(source);
9277 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
9278 verify([source]);
9279 }
9280 void test_finalNotInitialized_library_const() {
9281 Source source = addSource(EngineTestCase.createSource(["const F;"]));
9282 resolve(source);
9283 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
9284 verify([source]);
9285 }
9286 void test_finalNotInitialized_local_const() {
9287 Source source = addSource(EngineTestCase.createSource(["f() {", " const int x;", "}"]));
9288 resolve(source);
9289 assertErrors(source, [CompileTimeErrorCode.CONST_NOT_INITIALIZED]);
9290 verify([source]);
9291 }
9292 void test_getterAndMethodWithSameName() {
9293 Source source = addSource(EngineTestCase.createSource(["class A {", " x(y) {}", " get x => 0;", "}"]));
9294 resolve(source);
9295 assertErrors(source, [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME] );
9296 verify([source]);
9297 }
9298 void test_implementsDisallowedClass_bool() {
9299 Source source = addSource(EngineTestCase.createSource(["class A implements b ool {}"]));
9300 resolve(source);
9301 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
9302 verify([source]);
9303 }
9304 void test_implementsDisallowedClass_double() {
9305 Source source = addSource(EngineTestCase.createSource(["class A implements d ouble {}"]));
9306 resolve(source);
9307 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
9308 verify([source]);
9309 }
9310 void test_implementsDisallowedClass_int() {
9311 Source source = addSource(EngineTestCase.createSource(["class A implements i nt {}"]));
9312 resolve(source);
9313 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
9314 verify([source]);
9315 }
9316 void test_implementsDisallowedClass_Null() {
9317 Source source = addSource(EngineTestCase.createSource(["class A implements N ull {}"]));
9318 resolve(source);
9319 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
9320 verify([source]);
9321 }
9322 void test_implementsDisallowedClass_num() {
9323 Source source = addSource(EngineTestCase.createSource(["class A implements n um {}"]));
9324 resolve(source);
9325 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
9326 verify([source]);
9327 }
9328 void test_implementsDisallowedClass_String() {
9329 Source source = addSource(EngineTestCase.createSource(["class A implements S tring {}"]));
9330 resolve(source);
9331 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
9332 verify([source]);
9333 }
9334 void test_implementsDynamic() {
9335 Source source = addSource(EngineTestCase.createSource(["class A implements d ynamic {}"]));
9336 resolve(source);
9337 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]);
9338 verify([source]);
9339 }
9340 void test_implementsNonClass_class() {
9341 Source source = addSource(EngineTestCase.createSource(["int A;", "class B im plements A {}"]));
9342 resolve(source);
9343 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
9344 verify([source]);
9345 }
9346 void test_implementsNonClass_typeAlias() {
9347 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B; ", "class C = A implements B;"]));
9348 resolve(source);
9349 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
9350 verify([source]);
9351 }
9352 void test_implementsRepeated() {
9353 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B implements A, A {}"]));
9354 resolve(source);
9355 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
9356 verify([source]);
9357 }
9358 void test_implementsRepeated_3times() {
9359 Source source = addSource(EngineTestCase.createSource([
9360 "class A {} class C{}",
9361 "class B implements A, A, A, A {}"]));
9362 resolve(source);
9363 assertErrors(source, [
9364 CompileTimeErrorCode.IMPLEMENTS_REPEATED,
9365 CompileTimeErrorCode.IMPLEMENTS_REPEATED,
9366 CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
9367 verify([source]);
9368 }
9369 void test_implementsSuperClass() {
9370 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A implements A {}"]));
9371 resolve(source);
9372 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
9373 verify([source]);
9374 }
9375 void test_implementsSuperClass_Object() {
9376 Source source = addSource(EngineTestCase.createSource(["class A implements O bject {}"]));
9377 resolve(source);
9378 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS]);
9379 verify([source]);
9380 }
9381 void test_implicitThisReferenceInInitializer_field() {
9382 Source source = addSource(EngineTestCase.createSource([
9383 "class A {",
9384 " var v;",
9385 " A() : v = f;",
9386 " var f;",
9387 "}"]));
9388 resolve(source);
9389 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA LIZER]);
9390 verify([source]);
9391 }
9392 void test_implicitThisReferenceInInitializer_field2() {
9393 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " final y = x;", "}"]));
9394 resolve(source);
9395 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA LIZER]);
9396 verify([source]);
9397 }
9398 void test_implicitThisReferenceInInitializer_invocation() {
9399 Source source = addSource(EngineTestCase.createSource([
9400 "class A {",
9401 " var v;",
9402 " A() : v = f();",
9403 " f() {}",
9404 "}"]));
9405 resolve(source);
9406 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA LIZER]);
9407 verify([source]);
9408 }
9409 void test_implicitThisReferenceInInitializer_invocationInStatic() {
9410 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c var F = m();", " m() {}", "}"]));
9411 resolve(source);
9412 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA LIZER]);
9413 verify([source]);
9414 }
9415 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation( ) {
9416 Source source = addSource(EngineTestCase.createSource([
9417 "class A {",
9418 " A(p) {}",
9419 " A.named() : this(f);",
9420 " var f;",
9421 "}"]));
9422 resolve(source);
9423 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA LIZER]);
9424 verify([source]);
9425 }
9426 void test_implicitThisReferenceInInitializer_superConstructorInvocation() {
9427 Source source = addSource(EngineTestCase.createSource([
9428 "class A {",
9429 " A(p) {}",
9430 "}",
9431 "class B extends A {",
9432 " B() : super(f);",
9433 " var f;",
9434 "}"]));
9435 resolve(source);
9436 assertErrors(source, [CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIA LIZER]);
9437 verify([source]);
9438 }
9439 void test_importInternalLibrary() {
9440 Source source = addSource(EngineTestCase.createSource(["import 'dart:_interc eptors';"]));
9441 resolve(source);
9442 assertErrors(source, [
9443 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY,
9444 HintCode.UNUSED_IMPORT]);
9445 verify([source]);
9446 }
9447 void test_importInternalLibrary_collection() {
9448 Source source = addSource(EngineTestCase.createSource(["import 'dart:_collec tion-dev';"]));
9449 resolve(source);
9450 assertErrors(source, [
9451 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY,
9452 HintCode.UNUSED_IMPORT]);
9453 verify([source]);
9454 }
9455 void test_importOfNonLibrary() {
9456 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';", "A a;"]));
9457 addSource2("/part.dart", EngineTestCase.createSource(["part of lib;", "class A{}"]));
9458 resolve(source);
9459 assertErrors(source, [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]);
9460 verify([source]);
9461 }
9462 void test_inconsistentCaseExpressionTypes() {
9463 Source source = addSource(EngineTestCase.createSource([
9464 "f(var p) {",
9465 " switch (p) {",
9466 " case 1:",
9467 " break;",
9468 " case 'a':",
9469 " break;",
9470 " }",
9471 "}"]));
9472 resolve(source);
9473 assertErrors(source, [CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPE S]);
9474 verify([source]);
9475 }
9476 void test_inconsistentCaseExpressionTypes_repeated() {
9477 Source source = addSource(EngineTestCase.createSource([
9478 "f(var p) {",
9479 " switch (p) {",
9480 " case 1:",
9481 " break;",
9482 " case 'a':",
9483 " break;",
9484 " case 'b':",
9485 " break;",
9486 " }",
9487 "}"]));
9488 resolve(source);
9489 assertErrors(source, [
9490 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
9491 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
9492 verify([source]);
9493 }
9494 void test_initializerForNonExistant_initializer() {
9495 Source source = addSource(EngineTestCase.createSource(["class A {", " A() : x = 0 {}", "}"]));
9496 resolve(source);
9497 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIEL D]);
9498 }
9499 void test_initializerForStaticField() {
9500 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " A() : x = 0 {}", "}"]));
9501 resolve(source);
9502 assertErrors(source, [CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]);
9503 verify([source]);
9504 }
9505 void test_initializingFormalForNonExistantField() {
9506 Source source = addSource(EngineTestCase.createSource(["class A {", " A(thi s.x) {}", "}"]));
9507 resolve(source);
9508 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST ANT_FIELD]);
9509 verify([source]);
9510 }
9511 void test_initializingFormalForNonExistantField_notInEnclosingClass() {
9512 Source source = addSource(EngineTestCase.createSource([
9513 "class A {",
9514 "int x;",
9515 "}",
9516 "class B extends A {",
9517 " B(this.x) {}",
9518 "}"]));
9519 resolve(source);
9520 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST ANT_FIELD]);
9521 verify([source]);
9522 }
9523 void test_initializingFormalForNonExistantField_optional() {
9524 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th is.x]) {}", "}"]));
9525 resolve(source);
9526 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST ANT_FIELD]);
9527 verify([source]);
9528 }
9529 void test_initializingFormalForNonExistantField_synthetic() {
9530 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et x => 1;", " A(this.x) {}", "}"]));
9531 resolve(source);
9532 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXIST ANT_FIELD]);
9533 verify([source]);
9534 }
9535 void test_initializingFormalForStaticField() {
9536 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " A([this.x]) {}", "}"]));
9537 resolve(source);
9538 assertErrors(source, [CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FI ELD]);
9539 verify([source]);
9540 }
9541 void test_instanceMemberAccessFromStatic_field() {
9542 Source source = addSource(EngineTestCase.createSource([
9543 "class A {",
9544 " int f;",
9545 " static foo() {",
9546 " f;",
9547 " }",
9548 "}"]));
9549 resolve(source);
9550 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI C]);
9551 verify([source]);
9552 }
9553 void test_instanceMemberAccessFromStatic_getter() {
9554 Source source = addSource(EngineTestCase.createSource([
9555 "class A {",
9556 " get g => null;",
9557 " static foo() {",
9558 " g;",
9559 " }",
9560 "}"]));
9561 resolve(source);
9562 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI C]);
9563 verify([source]);
9564 }
9565 void test_instanceMemberAccessFromStatic_method() {
9566 Source source = addSource(EngineTestCase.createSource([
9567 "class A {",
9568 " m() {}",
9569 " static foo() {",
9570 " m();",
9571 " }",
9572 "}"]));
9573 resolve(source);
9574 assertErrors(source, [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATI C]);
9575 verify([source]);
9576 }
9577 void test_invalidAnnotation_getter() {
9578 Source source = addSource(EngineTestCase.createSource(["get V => 0;", "@V", "main() {", "}"]));
9579 resolve(source);
9580 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
9581 verify([source]);
9582 }
9583 void test_invalidAnnotation_importWithPrefix_getter() {
9584 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "get V => 0;"]));
9585 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as p;", "@p.V", "main() {", "}"]));
9586 resolve(source);
9587 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
9588 verify([source]);
9589 }
9590 void test_invalidAnnotation_importWithPrefix_notConstantVariable() {
9591 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "final V = 0;"]));
9592 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as p;", "@p.V", "main() {", "}"]));
9593 resolve(source);
9594 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
9595 verify([source]);
9596 }
9597 void test_invalidAnnotation_importWithPrefix_notVariableOrConstructorInvocatio n() {
9598 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "typede f V();"]));
9599 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as p;", "@p.V", "main() {", "}"]));
9600 resolve(source);
9601 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
9602 verify([source]);
9603 }
9604 void test_invalidAnnotation_notConstantVariable() {
9605 Source source = addSource(EngineTestCase.createSource(["final V = 0;", "@V", "main() {", "}"]));
9606 resolve(source);
9607 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
9608 verify([source]);
9609 }
9610 void test_invalidAnnotation_notVariableOrConstructorInvocation() {
9611 Source source = addSource(EngineTestCase.createSource(["typedef V();", "@V", "main() {", "}"]));
9612 resolve(source);
9613 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
9614 verify([source]);
9615 }
9616 void test_invalidAnnotation_staticMethodReference() {
9617 Source source = addSource(EngineTestCase.createSource([
9618 "class A {",
9619 " static f() {}",
9620 "}",
9621 "@A.f",
9622 "main() {",
9623 "}"]));
9624 resolve(source);
9625 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
9626 verify([source]);
9627 }
9628 void test_invalidConstructorName_notEnclosingClassName_defined() {
9629 Source source = addSource(EngineTestCase.createSource(["class A {", " B() : super();", "}", "class B {}"]));
9630 resolve(source);
9631 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
9632 }
9633 void test_invalidConstructorName_notEnclosingClassName_undefined() {
9634 Source source = addSource(EngineTestCase.createSource(["class A {", " B() : super();", "}"]));
9635 resolve(source);
9636 assertErrors(source, [CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
9637 }
9638 void test_invalidFactoryNameNotAClass_notClassName() {
9639 Source source = addSource(EngineTestCase.createSource(["int B;", "class A {" , " factory B() {}", "}"]));
9640 resolve(source);
9641 assertErrors(source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS] );
9642 verify([source]);
9643 }
9644 void test_invalidFactoryNameNotAClass_notEnclosingClassName() {
9645 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry B() {}", "}"]));
9646 resolve(source);
9647 assertErrors(source, [CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS] );
9648 }
9649 void test_invalidReferenceToThis_factoryConstructor() {
9650 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() { return this; }", "}"]));
9651 resolve(source);
9652 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
9653 verify([source]);
9654 }
9655 void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() {
9656 Source source = addSource(EngineTestCase.createSource(["class A {", " var f ;", " A() : f = this;", "}"]));
9657 resolve(source);
9658 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
9659 verify([source]);
9660 }
9661 void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() {
9662 Source source = addSource(EngineTestCase.createSource(["class A {", " var f = this;", "}"]));
9663 resolve(source);
9664 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
9665 verify([source]);
9666 }
9667 void test_invalidReferenceToThis_staticMethod() {
9668 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c m() { return this; }", "}"]));
9669 resolve(source);
9670 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
9671 verify([source]);
9672 }
9673 void test_invalidReferenceToThis_staticVariableInitializer() {
9674 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c A f = this;", "}"]));
9675 resolve(source);
9676 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
9677 verify([source]);
9678 }
9679 void test_invalidReferenceToThis_superInitializer() {
9680 Source source = addSource(EngineTestCase.createSource([
9681 "class A {",
9682 " A(var x) {}",
9683 "}",
9684 "class B extends A {",
9685 " B() : super(this);",
9686 "}"]));
9687 resolve(source);
9688 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
9689 verify([source]);
9690 }
9691 void test_invalidReferenceToThis_topLevelFunction() {
9692 Source source = addSource("f() { return this; }");
9693 resolve(source);
9694 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
9695 verify([source]);
9696 }
9697 void test_invalidReferenceToThis_variableInitializer() {
9698 Source source = addSource("int x = this;");
9699 resolve(source);
9700 assertErrors(source, [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
9701 verify([source]);
9702 }
9703 void test_invalidTypeArgumentInConstList() {
9704 Source source = addSource(EngineTestCase.createSource([
9705 "class A<E> {",
9706 " m() {",
9707 " return const <E>[];",
9708 " }",
9709 "}"]));
9710 resolve(source);
9711 assertErrors(source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LI ST]);
9712 verify([source]);
9713 }
9714 void test_invalidTypeArgumentInConstMap() {
9715 Source source = addSource(EngineTestCase.createSource([
9716 "class A<E> {",
9717 " m() {",
9718 " return const <String, E>{};",
9719 " }",
9720 "}"]));
9721 resolve(source);
9722 assertErrors(source, [CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MA P]);
9723 verify([source]);
9724 }
9725 void test_invalidUri_export() {
9726 Source source = addSource(EngineTestCase.createSource(["export 'ht:';"]));
9727 resolve(source);
9728 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
9729 }
9730 void test_invalidUri_import() {
9731 Source source = addSource(EngineTestCase.createSource(["import 'ht:';"]));
9732 resolve(source);
9733 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
9734 }
9735 void test_invalidUri_part() {
9736 Source source = addSource(EngineTestCase.createSource(["part 'ht:';"]));
9737 resolve(source);
9738 assertErrors(source, [CompileTimeErrorCode.INVALID_URI]);
9739 }
9740 void test_labelInOuterScope() {
9741 Source source = addSource(EngineTestCase.createSource([
9742 "class A {",
9743 " void m(int i) {",
9744 " l: while (i > 0) {",
9745 " void f() {",
9746 " break l;",
9747 " };",
9748 " }",
9749 " }",
9750 "}"]));
9751 resolve(source);
9752 assertErrors(source, [CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]);
9753 }
9754 void test_labelUndefined_break() {
9755 Source source = addSource(EngineTestCase.createSource([
9756 "f() {",
9757 " x: while (true) {",
9758 " break y;",
9759 " }",
9760 "}"]));
9761 resolve(source);
9762 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]);
9763 }
9764 void test_labelUndefined_continue() {
9765 Source source = addSource(EngineTestCase.createSource([
9766 "f() {",
9767 " x: while (true) {",
9768 " continue y;",
9769 " }",
9770 "}"]));
9771 resolve(source);
9772 assertErrors(source, [CompileTimeErrorCode.LABEL_UNDEFINED]);
9773 }
9774 void test_listElementTypeNotAssignable() {
9775 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin g> [42];"]));
9776 resolve(source);
9777 assertErrors(source, [CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE] );
9778 verify([source]);
9779 }
9780 void test_mapKeyTypeNotAssignable() {
9781 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin g, int > {1 : 2};"]));
9782 resolve(source);
9783 assertErrors(source, [CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
9784 verify([source]);
9785 }
9786 void test_mapValueTypeNotAssignable() {
9787 Source source = addSource(EngineTestCase.createSource(["var v = const <Strin g, String> {'a' : 2};"]));
9788 resolve(source);
9789 assertErrors(source, [CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
9790 verify([source]);
9791 }
9792 void test_memberWithClassName_field() {
9793 Source source = addSource(EngineTestCase.createSource(["class A {", " int A = 0;", "}"]));
9794 resolve(source);
9795 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
9796 verify([source]);
9797 }
9798 void test_memberWithClassName_field2() {
9799 Source source = addSource(EngineTestCase.createSource(["class A {", " int z , A, b = 0;", "}"]));
9800 resolve(source);
9801 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
9802 verify([source]);
9803 }
9804 void test_memberWithClassName_getter() {
9805 Source source = addSource(EngineTestCase.createSource(["class A {", " get A => 0;", "}"]));
9806 resolve(source);
9807 assertErrors(source, [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
9808 verify([source]);
9809 }
9810 void test_memberWithClassName_method() {
9811 }
9812 void test_methodAndGetterWithSameName() {
9813 Source source = addSource(EngineTestCase.createSource(["class A {", " get x => 0;", " x(y) {}", "}"]));
9814 resolve(source);
9815 assertErrors(source, [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME] );
9816 verify([source]);
9817 }
9818 void test_mixinDeclaresConstructor_classDeclaration() {
9819 Source source = addSource(EngineTestCase.createSource([
9820 "class A {",
9821 " A() {}",
9822 "}",
9823 "class B extends Object with A {}"]));
9824 resolve(source);
9825 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
9826 verify([source]);
9827 }
9828 void test_mixinDeclaresConstructor_typeAlias() {
9829 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B = Object with A;"]));
9830 resolve(source);
9831 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
9832 verify([source]);
9833 }
9834 void test_mixinInheritsFromNotObject_classDeclaration_extends() {
9835 Source source = addSource(EngineTestCase.createSource([
9836 "class A {}",
9837 "class B extends A {}",
9838 "class C extends Object with B {}"]));
9839 resolve(source);
9840 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
9841 verify([source]);
9842 }
9843 void test_mixinInheritsFromNotObject_classDeclaration_with() {
9844 Source source = addSource(EngineTestCase.createSource([
9845 "class A {}",
9846 "class B extends Object with A {}",
9847 "class C extends Object with B {}"]));
9848 resolve(source);
9849 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
9850 verify([source]);
9851 }
9852 void test_mixinInheritsFromNotObject_typeAlias_extends() {
9853 Source source = addSource(EngineTestCase.createSource([
9854 "class A {}",
9855 "class B extends A {}",
9856 "class C = Object with B;"]));
9857 resolve(source);
9858 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
9859 verify([source]);
9860 }
9861 void test_mixinInheritsFromNotObject_typeAlias_with() {
9862 Source source = addSource(EngineTestCase.createSource([
9863 "class A {}",
9864 "class B extends Object with A {}",
9865 "class C = Object with B;"]));
9866 resolve(source);
9867 assertErrors(source, [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
9868 verify([source]);
9869 }
9870 void test_mixinOfDisallowedClass_bool() {
9871 Source source = addSource(EngineTestCase.createSource(["class A extends Obje ct with bool {}"]));
9872 resolve(source);
9873 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
9874 verify([source]);
9875 }
9876 void test_mixinOfDisallowedClass_double() {
9877 Source source = addSource(EngineTestCase.createSource(["class A extends Obje ct with double {}"]));
9878 resolve(source);
9879 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
9880 verify([source]);
9881 }
9882 void test_mixinOfDisallowedClass_int() {
9883 Source source = addSource(EngineTestCase.createSource(["class A extends Obje ct with int {}"]));
9884 resolve(source);
9885 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
9886 verify([source]);
9887 }
9888 void test_mixinOfDisallowedClass_Null() {
9889 Source source = addSource(EngineTestCase.createSource(["class A extends Obje ct with Null {}"]));
9890 resolve(source);
9891 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
9892 verify([source]);
9893 }
9894 void test_mixinOfDisallowedClass_num() {
9895 Source source = addSource(EngineTestCase.createSource(["class A extends Obje ct with num {}"]));
9896 resolve(source);
9897 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
9898 verify([source]);
9899 }
9900 void test_mixinOfDisallowedClass_String() {
9901 Source source = addSource(EngineTestCase.createSource(["class A extends Obje ct with String {}"]));
9902 resolve(source);
9903 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
9904 verify([source]);
9905 }
9906 void test_mixinOfNonClass_class() {
9907 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends Object with A {}"]));
9908 resolve(source);
9909 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
9910 verify([source]);
9911 }
9912 void test_mixinOfNonClass_typeAlias() {
9913 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B; ", "class C = A with B;"]));
9914 resolve(source);
9915 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
9916 verify([source]);
9917 }
9918 void test_mixinReferencesSuper() {
9919 Source source = addSource(EngineTestCase.createSource([
9920 "class A {",
9921 " toString() => super.toString();",
9922 "}",
9923 "class B extends Object with A {}"]));
9924 resolve(source);
9925 assertErrors(source, [CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]);
9926 verify([source]);
9927 }
9928 void test_mixinWithNonClassSuperclass_class() {
9929 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {} ", "class C extends A with B {}"]));
9930 resolve(source);
9931 assertErrors(source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]) ;
9932 verify([source]);
9933 }
9934 void test_mixinWithNonClassSuperclass_typeAlias() {
9935 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {} ", "class C = A with B;"]));
9936 resolve(source);
9937 assertErrors(source, [CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]) ;
9938 verify([source]);
9939 }
9940 void test_multipleRedirectingConstructorInvocations() {
9941 Source source = addSource(EngineTestCase.createSource([
9942 "class A {",
9943 " A() : this.a(), this.b();",
9944 " A.a() {}",
9945 " A.b() {}",
9946 "}"]));
9947 resolve(source);
9948 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_ INVOCATIONS]);
9949 verify([source]);
9950 }
9951 void test_multipleSuperInitializers() {
9952 Source source = addSource(EngineTestCase.createSource([
9953 "class A {}",
9954 "class B extends A {",
9955 " B() : super(), super() {}",
9956 "}"]));
9957 resolve(source);
9958 assertErrors(source, [CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]);
9959 verify([source]);
9960 }
9961 void test_nativeClauseInNonSDKCode() {
9962 Source source = addSource(EngineTestCase.createSource(["class A native 'stri ng' {}"]));
9963 resolve(source);
9964 assertErrors(source, [ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE]);
9965 verify([source]);
9966 }
9967 void test_nativeFunctionBodyInNonSDKCode_function() {
9968 Source source = addSource(EngineTestCase.createSource(["int m(a) native 'str ing';"]));
9969 resolve(source);
9970 assertErrors(source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]) ;
9971 verify([source]);
9972 }
9973 void test_nativeFunctionBodyInNonSDKCode_method() {
9974 Source source = addSource(EngineTestCase.createSource(["class A{", " static int m(a) native 'string';", "}"]));
9975 resolve(source);
9976 assertErrors(source, [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]) ;
9977 verify([source]);
9978 }
9979 void test_noAnnotationConstructorArguments() {
9980 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "@A", "main() {", "}"]));
9981 resolve(source);
9982 assertErrors(source, [CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMEN TS]);
9983 verify([source]);
9984 }
9985 void test_noDefaultSuperConstructorExplicit() {
9986 Source source = addSource(EngineTestCase.createSource([
9987 "class A {",
9988 " A(p);",
9989 "}",
9990 "class B extends A {",
9991 " B() {}",
9992 "}"]));
9993 resolve(source);
9994 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPL ICIT]);
9995 verify([source]);
9996 }
9997 void test_noDefaultSuperConstructorImplicit_superHasParameters() {
9998 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p); ", "}", "class B extends A {", "}"]));
9999 resolve(source);
10000 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPL ICIT]);
10001 verify([source]);
10002 }
10003 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() {
10004 Source source = addSource(EngineTestCase.createSource(["class A { A.named() {} }", "class B extends A {}"]));
10005 resolve(source);
10006 assertErrors(source, [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPL ICIT]);
10007 verify([source]);
10008 }
10009 void test_nonConstantAnnotationConstructor_named() {
10010 Source source = addSource(EngineTestCase.createSource([
10011 "class A {",
10012 " A.fromInt() {}",
10013 "}",
10014 "@A.fromInt()",
10015 "main() {",
10016 "}"]));
10017 resolve(source);
10018 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCT OR]);
10019 verify([source]);
10020 }
10021 void test_nonConstantAnnotationConstructor_unnamed() {
10022 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "@A()", "main() {", "}"]));
10023 resolve(source);
10024 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCT OR]);
10025 verify([source]);
10026 }
10027 void test_nonConstantDefaultValue_function_named() {
10028 Source source = addSource(EngineTestCase.createSource(["int y;", "f({x : y}) {}"]));
10029 resolve(source);
10030 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
10031 verify([source]);
10032 }
10033 void test_nonConstantDefaultValue_function_positional() {
10034 Source source = addSource(EngineTestCase.createSource(["int y;", "f([x = y]) {}"]));
10035 resolve(source);
10036 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
10037 verify([source]);
10038 }
10039 void test_nonConstantDefaultValue_inConstructor_named() {
10040 Source source = addSource(EngineTestCase.createSource(["class A {", " int y ;", " A({x : y}) {}", "}"]));
10041 resolve(source);
10042 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
10043 verify([source]);
10044 }
10045 void test_nonConstantDefaultValue_inConstructor_positional() {
10046 Source source = addSource(EngineTestCase.createSource(["class A {", " int y ;", " A([x = y]) {}", "}"]));
10047 resolve(source);
10048 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
10049 verify([source]);
10050 }
10051 void test_nonConstantDefaultValue_method_named() {
10052 Source source = addSource(EngineTestCase.createSource(["class A {", " int y ;", " m({x : y}) {}", "}"]));
10053 resolve(source);
10054 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
10055 verify([source]);
10056 }
10057 void test_nonConstantDefaultValue_method_positional() {
10058 Source source = addSource(EngineTestCase.createSource(["class A {", " int y ;", " m([x = y]) {}", "}"]));
10059 resolve(source);
10060 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
10061 verify([source]);
10062 }
10063 void test_nonConstCaseExpression() {
10064 Source source = addSource(EngineTestCase.createSource([
10065 "f(int p, int q) {",
10066 " switch (p) {",
10067 " case 3 + q:",
10068 " break;",
10069 " }",
10070 "}"]));
10071 resolve(source);
10072 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]);
10073 verify([source]);
10074 }
10075 void test_nonConstListElement() {
10076 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst [a];", "}"]));
10077 resolve(source);
10078 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
10079 verify([source]);
10080 }
10081 void test_nonConstMapAsExpressionStatement_begin() {
10082 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0, 'b' : 1}.length;", "}"]));
10083 resolve(source);
10084 assertErrors(source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATE MENT]);
10085 verify([source]);
10086 }
10087 void test_nonConstMapAsExpressionStatement_only() {
10088 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0, 'b' : 1};", "}"]));
10089 resolve(source);
10090 assertErrors(source, [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATE MENT]);
10091 verify([source]);
10092 }
10093 void test_nonConstMapKey() {
10094 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst {a : 0};", "}"]));
10095 resolve(source);
10096 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
10097 verify([source]);
10098 }
10099 void test_nonConstMapValue() {
10100 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst {'a' : a};", "}"]));
10101 resolve(source);
10102 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
10103 verify([source]);
10104 }
10105 void test_nonConstValueInInitializer_binary_notBool_left() {
10106 Source source = addSource(EngineTestCase.createSource([
10107 "class A {",
10108 " final bool a;",
10109 " const A(String p) : a = p && true;",
10110 "}"]));
10111 resolve(source);
10112 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]);
10113 verify([source]);
10114 }
10115 void test_nonConstValueInInitializer_binary_notBool_right() {
10116 Source source = addSource(EngineTestCase.createSource([
10117 "class A {",
10118 " final bool a;",
10119 " const A(String p) : a = true && p;",
10120 "}"]));
10121 resolve(source);
10122 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]);
10123 verify([source]);
10124 }
10125 void test_nonConstValueInInitializer_binary_notInt() {
10126 Source source = addSource(EngineTestCase.createSource([
10127 "class A {",
10128 " final int a;",
10129 " const A(String p) : a = 5 & p;",
10130 "}"]));
10131 resolve(source);
10132 assertErrors(source, [
10133 CompileTimeErrorCode.CONST_EVAL_TYPE_INT,
10134 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
10135 verify([source]);
10136 }
10137 void test_nonConstValueInInitializer_binary_notNum() {
10138 Source source = addSource(EngineTestCase.createSource([
10139 "class A {",
10140 " final int a;",
10141 " const A(String p) : a = 5 + p;",
10142 "}"]));
10143 resolve(source);
10144 assertErrors(source, [
10145 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM,
10146 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
10147 verify([source]);
10148 }
10149 void test_nonConstValueInInitializer_field() {
10150 Source source = addSource(EngineTestCase.createSource([
10151 "class A {",
10152 " static int C;",
10153 " final int a;",
10154 " const A() : a = C;",
10155 "}"]));
10156 resolve(source);
10157 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER ]);
10158 verify([source]);
10159 }
10160 void test_nonConstValueInInitializer_redirecting() {
10161 Source source = addSource(EngineTestCase.createSource([
10162 "class A {",
10163 " static var C;",
10164 " const A.named(p);",
10165 " const A() : this.named(C);",
10166 "}"]));
10167 resolve(source);
10168 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER ]);
10169 verify([source]);
10170 }
10171 void test_nonConstValueInInitializer_super() {
10172 Source source = addSource(EngineTestCase.createSource([
10173 "class A {",
10174 " const A(p);",
10175 "}",
10176 "class B extends A {",
10177 " static var C;",
10178 " const B() : super(C);",
10179 "}"]));
10180 resolve(source);
10181 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER ]);
10182 verify([source]);
10183 }
10184 void test_nonGenerativeConstructor_explicit() {
10185 Source source = addSource(EngineTestCase.createSource([
10186 "class A {",
10187 " factory A.named() {}",
10188 "}",
10189 "class B extends A {",
10190 " B() : super.named();",
10191 "}"]));
10192 resolve(source);
10193 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
10194 verify([source]);
10195 }
10196 void test_nonGenerativeConstructor_implicit() {
10197 Source source = addSource(EngineTestCase.createSource([
10198 "class A {",
10199 " factory A() {}",
10200 "}",
10201 "class B extends A {",
10202 " B();",
10203 "}"]));
10204 resolve(source);
10205 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
10206 verify([source]);
10207 }
10208 void test_nonGenerativeConstructor_implicit2() {
10209 Source source = addSource(EngineTestCase.createSource([
10210 "class A {",
10211 " factory A() {}",
10212 "}",
10213 "class B extends A {",
10214 "}"]));
10215 resolve(source);
10216 assertErrors(source, [CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
10217 verify([source]);
10218 }
10219 void test_notEnoughRequiredArguments_const() {
10220 Source source = addSource(EngineTestCase.createSource([
10221 "class A {",
10222 " const A(int p);",
10223 "}",
10224 "main() {",
10225 " const A();",
10226 "}"]));
10227 resolve(source);
10228 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
10229 verify([source]);
10230 }
10231 void test_notEnoughRequiredArguments_const_super() {
10232 Source source = addSource(EngineTestCase.createSource([
10233 "class A {",
10234 " const A(int p);",
10235 "}",
10236 "class B extends A {",
10237 " const B() : super();",
10238 "}"]));
10239 resolve(source);
10240 assertErrors(source, [CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
10241 verify([source]);
10242 }
10243 void test_optionalParameterInOperator_named() {
10244 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +({p}) {}", "}"]));
10245 resolve(source);
10246 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
10247 verify([source]);
10248 }
10249 void test_optionalParameterInOperator_positional() {
10250 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +([p]) {}", "}"]));
10251 resolve(source);
10252 assertErrors(source, [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
10253 verify([source]);
10254 }
10255 void test_partOfNonPart() {
10256 Source source = addSource(EngineTestCase.createSource(["library l1;", "part 'l2.dart';"]));
10257 addSource2("/l2.dart", EngineTestCase.createSource(["library l2;"]));
10258 resolve(source);
10259 assertErrors(source, [CompileTimeErrorCode.PART_OF_NON_PART]);
10260 verify([source]);
10261 }
10262 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() {
10263 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class A{}"]));
10264 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as p;", "typedef p();", "p.A a;"]));
10265 resolve(source);
10266 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME MBER]);
10267 verify([source]);
10268 }
10269 void test_prefixCollidesWithTopLevelMembers_topLevelFunction() {
10270 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class A{}"]));
10271 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as p;", "p() {}", "p.A a;"]));
10272 resolve(source);
10273 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME MBER]);
10274 verify([source]);
10275 }
10276 void test_prefixCollidesWithTopLevelMembers_topLevelVariable() {
10277 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class A{}"]));
10278 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as p;", "var p = null;", "p.A a;"]));
10279 resolve(source);
10280 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME MBER]);
10281 verify([source]);
10282 }
10283 void test_prefixCollidesWithTopLevelMembers_type() {
10284 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class A{}"]));
10285 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as p;", "class p {}", "p.A a;"]));
10286 resolve(source);
10287 assertErrors(source, [CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_ME MBER]);
10288 verify([source]);
10289 }
10290 void test_privateOptionalParameter() {
10291 Source source = addSource(EngineTestCase.createSource(["f({var _p}) {}"]));
10292 resolve(source);
10293 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
10294 verify([source]);
10295 }
10296 void test_privateOptionalParameter_fieldFormal() {
10297 Source source = addSource(EngineTestCase.createSource(["class A {", " var _ p;", " A({this._p: 0});", "}"]));
10298 resolve(source);
10299 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
10300 verify([source]);
10301 }
10302 void test_privateOptionalParameter_withDefaultValue() {
10303 Source source = addSource(EngineTestCase.createSource(["f({_p : 0}) {}"]));
10304 resolve(source);
10305 assertErrors(source, [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
10306 verify([source]);
10307 }
10308 void test_recursiveConstructorRedirect() {
10309 Source source = addSource(EngineTestCase.createSource([
10310 "class A {",
10311 " A.a() : this.b();",
10312 " A.b() : this.a();",
10313 "}"]));
10314 resolve(source);
10315 assertErrors(source, [
10316 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT,
10317 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]);
10318 verify([source]);
10319 }
10320 void test_recursiveConstructorRedirect_directSelfReference() {
10321 Source source = addSource(EngineTestCase.createSource(["class A {", " A() : this();", "}"]));
10322 resolve(source);
10323 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]);
10324 verify([source]);
10325 }
10326 void test_recursiveFactoryRedirect() {
10327 Source source = addSource(EngineTestCase.createSource([
10328 "class A implements B {",
10329 " factory A() = C;",
10330 "}",
10331 "class B implements C {",
10332 " factory B() = A;",
10333 "}",
10334 "class C implements A {",
10335 " factory C() = B;",
10336 "}"]));
10337 resolve(source);
10338 assertErrors(source, [
10339 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10340 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10341 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10342 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10343 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10344 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10345 verify([source]);
10346 }
10347 void test_recursiveFactoryRedirect_directSelfReference() {
10348 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() = A;", "}"]));
10349 resolve(source);
10350 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]);
10351 verify([source]);
10352 }
10353 void test_recursiveFactoryRedirect_generic() {
10354 Source source = addSource(EngineTestCase.createSource([
10355 "class A<T> implements B<T> {",
10356 " factory A() = C;",
10357 "}",
10358 "class B<T> implements C<T> {",
10359 " factory B() = A;",
10360 "}",
10361 "class C<T> implements A<T> {",
10362 " factory C() = B;",
10363 "}"]));
10364 resolve(source);
10365 assertErrors(source, [
10366 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10367 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10368 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10369 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10370 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10371 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10372 verify([source]);
10373 }
10374 void test_recursiveFactoryRedirect_named() {
10375 Source source = addSource(EngineTestCase.createSource([
10376 "class A implements B {",
10377 " factory A.nameA() = C.nameC;",
10378 "}",
10379 "class B implements C {",
10380 " factory B.nameB() = A.nameA;",
10381 "}",
10382 "class C implements A {",
10383 " factory C.nameC() = B.nameB;",
10384 "}"]));
10385 resolve(source);
10386 assertErrors(source, [
10387 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10388 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10389 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10390 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10391 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10392 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10393 verify([source]);
10394 }
10395
10396 /**
10397 * "A" references "C" which has cycle with "B". But we should not report probl em for "A" - it is
10398 * not the part of a cycle.
10399 */
10400 void test_recursiveFactoryRedirect_outsideCycle() {
10401 Source source = addSource(EngineTestCase.createSource([
10402 "class A {",
10403 " factory A() = C;",
10404 "}",
10405 "class B implements C {",
10406 " factory B() = C;",
10407 "}",
10408 "class C implements A, B {",
10409 " factory C() = B;",
10410 "}"]));
10411 resolve(source);
10412 assertErrors(source, [
10413 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10414 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
10415 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10416 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10417 verify([source]);
10418 }
10419 void test_recursiveInterfaceInheritance_extends() {
10420 Source source = addSource(EngineTestCase.createSource(["class A extends B {} ", "class B extends A {}"]));
10421 resolve(source);
10422 assertErrors(source, [
10423 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10424 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10425 verify([source]);
10426 }
10427 void test_recursiveInterfaceInheritance_extends_implements() {
10428 Source source = addSource(EngineTestCase.createSource(["class A extends B {} ", "class B implements A {}"]));
10429 resolve(source);
10430 assertErrors(source, [
10431 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10432 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10433 verify([source]);
10434 }
10435 void test_recursiveInterfaceInheritance_implements() {
10436 Source source = addSource(EngineTestCase.createSource(["class A implements B {}", "class B implements A {}"]));
10437 resolve(source);
10438 assertErrors(source, [
10439 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10440 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10441 verify([source]);
10442 }
10443 void test_recursiveInterfaceInheritance_tail() {
10444 Source source = addSource(EngineTestCase.createSource([
10445 "abstract class A implements A {}",
10446 "class B implements A {}"]));
10447 resolve(source);
10448 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B ASE_CASE_IMPLEMENTS]);
10449 verify([source]);
10450 }
10451 void test_recursiveInterfaceInheritance_tail2() {
10452 Source source = addSource(EngineTestCase.createSource([
10453 "abstract class A implements B {}",
10454 "abstract class B implements A {}",
10455 "class C implements A {}"]));
10456 resolve(source);
10457 assertErrors(source, [
10458 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10459 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10460 verify([source]);
10461 }
10462 void test_recursiveInterfaceInheritance_tail3() {
10463 Source source = addSource(EngineTestCase.createSource([
10464 "abstract class A implements B {}",
10465 "abstract class B implements C {}",
10466 "abstract class C implements A {}",
10467 "class D implements A {}"]));
10468 resolve(source);
10469 assertErrors(source, [
10470 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10471 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
10472 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
10473 verify([source]);
10474 }
10475 void test_recursiveInterfaceInheritanceBaseCaseExtends() {
10476 Source source = addSource(EngineTestCase.createSource(["class A extends A {} "]));
10477 resolve(source);
10478 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B ASE_CASE_EXTENDS]);
10479 verify([source]);
10480 }
10481 void test_recursiveInterfaceInheritanceBaseCaseImplements() {
10482 Source source = addSource(EngineTestCase.createSource(["class A implements A {}"]));
10483 resolve(source);
10484 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B ASE_CASE_IMPLEMENTS]);
10485 verify([source]);
10486 }
10487 void test_recursiveInterfaceInheritanceBaseCaseImplements_typeAlias() {
10488 Source source = addSource(EngineTestCase.createSource([
10489 "class A {}",
10490 "class M {}",
10491 "class B = A with M implements B;"]));
10492 resolve(source);
10493 assertErrors(source, [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_B ASE_CASE_IMPLEMENTS]);
10494 verify([source]);
10495 }
10496 void test_redirectToNonConstConstructor() {
10497 Source source = addSource(EngineTestCase.createSource([
10498 "class A {",
10499 " A.a() {}",
10500 " const factory A.b() = A.a;",
10501 "}"]));
10502 resolve(source);
10503 assertErrors(source, [CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR ]);
10504 verify([source]);
10505 }
10506 void test_referencedBeforeDeclaration_hideInBlock_function() {
10507 Source source = addSource(EngineTestCase.createSource([
10508 "var v = 1;",
10509 "main() {",
10510 " print(v);",
10511 " v() {}",
10512 "}",
10513 "print(x) {}"]));
10514 resolve(source);
10515 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
10516 }
10517 void test_referencedBeforeDeclaration_hideInBlock_local() {
10518 Source source = addSource(EngineTestCase.createSource([
10519 "var v = 1;",
10520 "main() {",
10521 " print(v);",
10522 " var v = 2;",
10523 "}",
10524 "print(x) {}"]));
10525 resolve(source);
10526 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
10527 }
10528 void test_referencedBeforeDeclaration_hideInBlock_subBlock() {
10529 Source source = addSource(EngineTestCase.createSource([
10530 "var v = 1;",
10531 "main() {",
10532 " {",
10533 " print(v);",
10534 " }",
10535 " var v = 2;",
10536 "}",
10537 "print(x) {}"]));
10538 resolve(source);
10539 assertErrors(source, [CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION]);
10540 }
10541 void test_referenceToDeclaredVariableInInitializer_closure() {
10542 Source source = addSource(EngineTestCase.createSource(["f() {", " var x = ( x) {};", "}"]));
10543 resolve(source);
10544 assertErrors(source, [CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN _INITIALIZER]);
10545 verify([source]);
10546 }
10547 void test_referenceToDeclaredVariableInInitializer_getter() {
10548 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x + 1;", "}"]));
10549 resolve(source);
10550 assertErrors(source, [CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN _INITIALIZER]);
10551 verify([source]);
10552 }
10553 void test_referenceToDeclaredVariableInInitializer_setter() {
10554 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x ++;", "}"]));
10555 resolve(source);
10556 assertErrors(source, [CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN _INITIALIZER]);
10557 verify([source]);
10558 }
10559 void test_referenceToDeclaredVariableInInitializer_unqualifiedInvocation() {
10560 Source source = addSource(EngineTestCase.createSource(["f() {", " var x = x ();", "}"]));
10561 resolve(source);
10562 assertErrors(source, [CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN _INITIALIZER]);
10563 verify([source]);
10564 }
10565 void test_rethrowOutsideCatch() {
10566 Source source = addSource(EngineTestCase.createSource(["f() {", " rethrow;" , "}"]));
10567 resolve(source);
10568 assertErrors(source, [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]);
10569 verify([source]);
10570 }
10571 void test_returnInGenerativeConstructor() {
10572 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { return 0; }", "}"]));
10573 resolve(source);
10574 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR] );
10575 verify([source]);
10576 }
10577 void test_returnInGenerativeConstructor_expressionFunctionBody() {
10578 Source source = addSource(EngineTestCase.createSource(["class A {", " A() = > null;", "}"]));
10579 resolve(source);
10580 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR] );
10581 verify([source]);
10582 }
10583 void test_superInInvalidContext_binaryExpression() {
10584 Source source = addSource(EngineTestCase.createSource(["var v = super + 0;"] ));
10585 resolve(source);
10586 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
10587 }
10588 void test_superInInvalidContext_constructorFieldInitializer() {
10589 Source source = addSource(EngineTestCase.createSource([
10590 "class A {",
10591 " m() {}",
10592 "}",
10593 "class B extends A {",
10594 " var f;",
10595 " B() : f = super.m();",
10596 "}"]));
10597 resolve(source);
10598 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
10599 }
10600 void test_superInInvalidContext_factoryConstructor() {
10601 Source source = addSource(EngineTestCase.createSource([
10602 "class A {",
10603 " m() {}",
10604 "}",
10605 "class B extends A {",
10606 " factory B() {",
10607 " super.m();",
10608 " }",
10609 "}"]));
10610 resolve(source);
10611 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
10612 }
10613 void test_superInInvalidContext_instanceVariableInitializer() {
10614 Source source = addSource(EngineTestCase.createSource([
10615 "class A {",
10616 " var a;",
10617 "}",
10618 "class B extends A {",
10619 " var b = super.a;",
10620 "}"]));
10621 resolve(source);
10622 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
10623 }
10624 void test_superInInvalidContext_staticMethod() {
10625 Source source = addSource(EngineTestCase.createSource([
10626 "class A {",
10627 " static m() {}",
10628 "}",
10629 "class B extends A {",
10630 " static n() { return super.m(); }",
10631 "}"]));
10632 resolve(source);
10633 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
10634 }
10635 void test_superInInvalidContext_staticVariableInitializer() {
10636 Source source = addSource(EngineTestCase.createSource([
10637 "class A {",
10638 " static int a = 0;",
10639 "}",
10640 "class B extends A {",
10641 " static int b = super.a;",
10642 "}"]));
10643 resolve(source);
10644 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
10645 }
10646 void test_superInInvalidContext_topLevelFunction() {
10647 Source source = addSource(EngineTestCase.createSource(["f() {", " super.f() ;", "}"]));
10648 resolve(source);
10649 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
10650 }
10651 void test_superInInvalidContext_topLevelVariableInitializer() {
10652 Source source = addSource(EngineTestCase.createSource(["var v = super.y;"])) ;
10653 resolve(source);
10654 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
10655 }
10656 void test_superInRedirectingConstructor_redirectionSuper() {
10657 Source source = addSource(EngineTestCase.createSource([
10658 "class A {}",
10659 "class B {",
10660 " B() : this.name(), super();",
10661 " B.name() {}",
10662 "}"]));
10663 resolve(source);
10664 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR] );
10665 verify([source]);
10666 }
10667 void test_superInRedirectingConstructor_superRedirection() {
10668 Source source = addSource(EngineTestCase.createSource([
10669 "class A {}",
10670 "class B {",
10671 " B() : super(), this.name();",
10672 " B.name() {}",
10673 "}"]));
10674 resolve(source);
10675 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR] );
10676 verify([source]);
10677 }
10678 void test_typeAliasCannotReferenceItself_parameterType_named() {
10679 Source source = addSource(EngineTestCase.createSource(["typedef A({A a});"]) );
10680 resolve(source);
10681 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
10682 verify([source]);
10683 }
10684 void test_typeAliasCannotReferenceItself_parameterType_positional() {
10685 Source source = addSource(EngineTestCase.createSource(["typedef A([A a]);"]) );
10686 resolve(source);
10687 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
10688 verify([source]);
10689 }
10690 void test_typeAliasCannotReferenceItself_parameterType_required() {
10691 Source source = addSource(EngineTestCase.createSource(["typedef A(A a);"]));
10692 resolve(source);
10693 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
10694 verify([source]);
10695 }
10696 void test_typeAliasCannotReferenceItself_parameterType_typeArgument() {
10697 Source source = addSource(EngineTestCase.createSource(["typedef A(List<A> a) ;"]));
10698 resolve(source);
10699 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
10700 verify([source]);
10701 }
10702 void test_typeAliasCannotReferenceItself_returnClass_withTypeAlias() {
10703 Source source = addSource(EngineTestCase.createSource([
10704 "typedef C A();",
10705 "typedef A B();",
10706 "class C {",
10707 " B a;",
10708 "}"]));
10709 resolve(source);
10710 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
10711 verify([source]);
10712 }
10713 void test_typeAliasCannotReferenceItself_returnType() {
10714 Source source = addSource(EngineTestCase.createSource(["typedef A A();"]));
10715 resolve(source);
10716 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
10717 verify([source]);
10718 }
10719 void test_typeAliasCannotReferenceItself_returnType_indirect() {
10720 Source source = addSource(EngineTestCase.createSource(["typedef B A();", "ty pedef A B();"]));
10721 resolve(source);
10722 assertErrors(source, [
10723 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
10724 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
10725 verify([source]);
10726 }
10727 void test_typeAliasCannotReferenceItself_typeVariableBounds() {
10728 Source source = addSource(EngineTestCase.createSource(["typedef A<T extends A>();"]));
10729 resolve(source);
10730 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
10731 verify([source]);
10732 }
10733 void test_typeAliasCannotRereferenceItself_mixin_direct() {
10734 Source source = addSource(EngineTestCase.createSource(["class M = Object wit h M;"]));
10735 resolve(source);
10736 assertErrors(source, [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSEL F]);
10737 verify([source]);
10738 }
10739 void test_typeAliasCannotRereferenceItself_mixin_indirect() {
10740 Source source = addSource(EngineTestCase.createSource([
10741 "class M1 = Object with M2;",
10742 "class M2 = Object with M1;"]));
10743 resolve(source);
10744 assertErrors(source, [
10745 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF,
10746 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF]);
10747 verify([source]);
10748 }
10749 void test_typeArgumentNotMatchingBounds_const() {
10750 Source source = addSource(EngineTestCase.createSource([
10751 "class A {}",
10752 "class B {}",
10753 "class G<E extends A> {",
10754 " const G();",
10755 "}",
10756 "f() { return const G<B>(); }"]));
10757 resolve(source);
10758 assertErrors(source, [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS ]);
10759 verify([source]);
10760 }
10761 void test_undefinedClass_const() {
10762 Source source = addSource(EngineTestCase.createSource(["f() {", " return co nst A();", "}"]));
10763 resolve(source);
10764 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CLASS]);
10765 verify([source]);
10766 }
10767 void test_undefinedConstructorInInitializer_explicit_named() {
10768 Source source = addSource(EngineTestCase.createSource([
10769 "class A {}",
10770 "class B extends A {",
10771 " B() : super.named();",
10772 "}"]));
10773 resolve(source);
10774 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI ZER]);
10775 }
10776 void test_undefinedConstructorInInitializer_explicit_unnamed() {
10777 Source source = addSource(EngineTestCase.createSource([
10778 "class A {",
10779 " A.named() {}",
10780 "}",
10781 "class B extends A {",
10782 " B() : super();",
10783 "}"]));
10784 resolve(source);
10785 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI ZER_DEFAULT]);
10786 verify([source]);
10787 }
10788 void test_undefinedConstructorInInitializer_implicit() {
10789 Source source = addSource(EngineTestCase.createSource([
10790 "class A {",
10791 " A.named() {}",
10792 "}",
10793 "class B extends A {",
10794 " B();",
10795 "}"]));
10796 resolve(source);
10797 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALI ZER_DEFAULT]);
10798 verify([source]);
10799 }
10800 void test_undefinedFunction() {
10801 Source source = addSource(EngineTestCase.createSource(["void f() {", " g(); ", "}"]));
10802 resolve(source);
10803 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]);
10804 }
10805 void test_undefinedFunction_hasImportPrefix() {
10806 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as f;", "main() { return f(); }"]));
10807 addSource2("/lib.dart", "library lib;");
10808 resolve(source);
10809 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]);
10810 }
10811 void test_undefinedFunction_inCatch() {
10812 Source source = addSource(EngineTestCase.createSource([
10813 "void f() {",
10814 " try {",
10815 " } on Object {",
10816 " g();",
10817 " }",
10818 "}"]));
10819 resolve(source);
10820 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_FUNCTION]);
10821 }
10822 void test_undefinedNamedParameter() {
10823 Source source = addSource(EngineTestCase.createSource([
10824 "class A {",
10825 " const A();",
10826 "}",
10827 "main() {",
10828 " const A(p: 0);",
10829 "}"]));
10830 resolve(source);
10831 assertErrors(source, [CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]);
10832 }
10833 void test_uriDoesNotExist_export() {
10834 Source source = addSource(EngineTestCase.createSource(["export 'unknown.dart ';"]));
10835 resolve(source);
10836 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
10837 }
10838 void test_uriDoesNotExist_import() {
10839 Source source = addSource(EngineTestCase.createSource(["import 'unknown.dart ';"]));
10840 resolve(source);
10841 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
10842 }
10843 void test_uriDoesNotExist_part() {
10844 Source source = addSource(EngineTestCase.createSource(["part 'unknown.dart'; "]));
10845 resolve(source);
10846 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
10847 }
10848 void test_uriWithInterpolation_constant() {
10849 Source source = addSource(EngineTestCase.createSource(["import 'stuff_\$plat form.dart';"]));
10850 resolve(source);
10851 assertErrors(source, [
10852 CompileTimeErrorCode.URI_WITH_INTERPOLATION,
10853 StaticWarningCode.UNDEFINED_IDENTIFIER]);
10854 }
10855 void test_uriWithInterpolation_nonConstant() {
10856 Source source = addSource(EngineTestCase.createSource(["library lib;", "part '\${'a'}.dart';"]));
10857 resolve(source);
10858 assertErrors(source, [CompileTimeErrorCode.URI_WITH_INTERPOLATION]);
10859 }
10860 void test_wrongNumberOfParametersForOperator_minus() {
10861 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor -(a, b) {}", "}"]));
10862 resolve(source);
10863 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OP ERATOR_MINUS]);
10864 verify([source]);
10865 reset();
10866 }
10867 void test_wrongNumberOfParametersForOperator_tilde() {
10868 check_wrongNumberOfParametersForOperator("~", "a");
10869 check_wrongNumberOfParametersForOperator("~", "a, b");
10870 }
10871 void test_wrongNumberOfParametersForOperator1() {
10872 check_wrongNumberOfParametersForOperator1("<");
10873 check_wrongNumberOfParametersForOperator1(">");
10874 check_wrongNumberOfParametersForOperator1("<=");
10875 check_wrongNumberOfParametersForOperator1(">=");
10876 check_wrongNumberOfParametersForOperator1("+");
10877 check_wrongNumberOfParametersForOperator1("/");
10878 check_wrongNumberOfParametersForOperator1("~/");
10879 check_wrongNumberOfParametersForOperator1("*");
10880 check_wrongNumberOfParametersForOperator1("%");
10881 check_wrongNumberOfParametersForOperator1("|");
10882 check_wrongNumberOfParametersForOperator1("^");
10883 check_wrongNumberOfParametersForOperator1("&");
10884 check_wrongNumberOfParametersForOperator1("<<");
10885 check_wrongNumberOfParametersForOperator1(">>");
10886 check_wrongNumberOfParametersForOperator1("[]");
10887 }
10888 void test_wrongNumberOfParametersForSetter_function_named() {
10889 Source source = addSource("set x({p}) {}");
10890 resolve(source);
10891 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE TTER]);
10892 verify([source]);
10893 }
10894 void test_wrongNumberOfParametersForSetter_function_optional() {
10895 Source source = addSource("set x([p]) {}");
10896 resolve(source);
10897 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE TTER]);
10898 verify([source]);
10899 }
10900 void test_wrongNumberOfParametersForSetter_function_tooFew() {
10901 Source source = addSource("set x() {}");
10902 resolve(source);
10903 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE TTER]);
10904 verify([source]);
10905 }
10906 void test_wrongNumberOfParametersForSetter_function_tooMany() {
10907 Source source = addSource("set x(a, b) {}");
10908 resolve(source);
10909 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE TTER]);
10910 verify([source]);
10911 }
10912 void test_wrongNumberOfParametersForSetter_method_named() {
10913 Source source = addSource(EngineTestCase.createSource(["class A {", " set x ({p}) {}", "}"]));
10914 resolve(source);
10915 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE TTER]);
10916 verify([source]);
10917 }
10918 void test_wrongNumberOfParametersForSetter_method_optional() {
10919 Source source = addSource(EngineTestCase.createSource(["class A {", " set x ([p]) {}", "}"]));
10920 resolve(source);
10921 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE TTER]);
10922 verify([source]);
10923 }
10924 void test_wrongNumberOfParametersForSetter_method_tooFew() {
10925 Source source = addSource(EngineTestCase.createSource(["class A {", " set x () {}", "}"]));
10926 resolve(source);
10927 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE TTER]);
10928 verify([source]);
10929 }
10930 void test_wrongNumberOfParametersForSetter_method_tooMany() {
10931 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (a, b) {}", "}"]));
10932 resolve(source);
10933 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SE TTER]);
10934 verify([source]);
10935 }
10936 void check_constEvalThrowsException_binary_null(String expr, bool resolved) {
10937 Source source = addSource("const C = ${expr};");
10938 resolve(source);
10939 if (resolved) {
10940 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
10941 verify([source]);
10942 } else {
10943 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
10944 }
10945 reset();
10946 }
10947 void check_constEvalTypeBool_withParameter_binary(String expr) {
10948 Source source = addSource(EngineTestCase.createSource([
10949 "class A {",
10950 " final a;",
10951 " const A(bool p) : a = ${expr};",
10952 "}"]));
10953 resolve(source);
10954 assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]);
10955 verify([source]);
10956 reset();
10957 }
10958 void check_constEvalTypeInt_withParameter_binary(String expr) {
10959 Source source = addSource(EngineTestCase.createSource([
10960 "class A {",
10961 " final a;",
10962 " const A(int p) : a = ${expr};",
10963 "}"]));
10964 resolve(source);
10965 assertErrors(source, [
10966 CompileTimeErrorCode.CONST_EVAL_TYPE_INT,
10967 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
10968 verify([source]);
10969 reset();
10970 }
10971 void check_constEvalTypeNum_withParameter_binary(String expr) {
10972 Source source = addSource(EngineTestCase.createSource([
10973 "class A {",
10974 " final a;",
10975 " const A(num p) : a = ${expr};",
10976 "}"]));
10977 resolve(source);
10978 assertErrors(source, [
10979 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM,
10980 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
10981 verify([source]);
10982 reset();
10983 }
10984 void check_wrongNumberOfParametersForOperator(String name, String parameters) {
10985 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor ${name}(${parameters}) {}", "}"]));
10986 resolve(source);
10987 assertErrors(source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OP ERATOR]);
10988 verify([source]);
10989 reset();
10990 }
10991 void check_wrongNumberOfParametersForOperator1(String name) {
10992 check_wrongNumberOfParametersForOperator(name, "");
10993 check_wrongNumberOfParametersForOperator(name, "a, b");
10994 }
10995 static dartSuite() {
10996 _ut.group('CompileTimeErrorCodeTest', () {
10997 _ut.test('test_ambiguousExport', () {
10998 final __test = new CompileTimeErrorCodeTest();
10999 runJUnitTest(__test, __test.test_ambiguousExport);
11000 });
11001 _ut.test('test_ambiguousImport_function', () {
11002 final __test = new CompileTimeErrorCodeTest();
11003 runJUnitTest(__test, __test.test_ambiguousImport_function);
11004 });
11005 _ut.test('test_argumentDefinitionTestNonParameter', () {
11006 final __test = new CompileTimeErrorCodeTest();
11007 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter);
11008 });
11009 _ut.test('test_builtInIdentifierAsMixinName_classTypeAlias', () {
11010 final __test = new CompileTimeErrorCodeTest();
11011 runJUnitTest(__test, __test.test_builtInIdentifierAsMixinName_classTypeA lias);
11012 });
11013 _ut.test('test_builtInIdentifierAsTypeName', () {
11014 final __test = new CompileTimeErrorCodeTest();
11015 runJUnitTest(__test, __test.test_builtInIdentifierAsTypeName);
11016 });
11017 _ut.test('test_builtInIdentifierAsTypeParameterName', () {
11018 final __test = new CompileTimeErrorCodeTest();
11019 runJUnitTest(__test, __test.test_builtInIdentifierAsTypeParameterName);
11020 });
11021 _ut.test('test_builtInIdentifierAsType_formalParameter_field', () {
11022 final __test = new CompileTimeErrorCodeTest();
11023 runJUnitTest(__test, __test.test_builtInIdentifierAsType_formalParameter _field);
11024 });
11025 _ut.test('test_builtInIdentifierAsType_formalParameter_simple', () {
11026 final __test = new CompileTimeErrorCodeTest();
11027 runJUnitTest(__test, __test.test_builtInIdentifierAsType_formalParameter _simple);
11028 });
11029 _ut.test('test_builtInIdentifierAsType_variableDeclaration', () {
11030 final __test = new CompileTimeErrorCodeTest();
11031 runJUnitTest(__test, __test.test_builtInIdentifierAsType_variableDeclara tion);
11032 });
11033 _ut.test('test_builtInIdentifierAsTypedefName_functionTypeAlias', () {
11034 final __test = new CompileTimeErrorCodeTest();
11035 runJUnitTest(__test, __test.test_builtInIdentifierAsTypedefName_function TypeAlias);
11036 });
11037 _ut.test('test_caseExpressionTypeImplementsEquals', () {
11038 final __test = new CompileTimeErrorCodeTest();
11039 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals);
11040 });
11041 _ut.test('test_conflictingConstructorNameAndMember_field', () {
11042 final __test = new CompileTimeErrorCodeTest();
11043 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_fie ld);
11044 });
11045 _ut.test('test_conflictingConstructorNameAndMember_method', () {
11046 final __test = new CompileTimeErrorCodeTest();
11047 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_met hod);
11048 });
11049 _ut.test('test_conflictingGetterAndMethod_field_method', () {
11050 final __test = new CompileTimeErrorCodeTest();
11051 runJUnitTest(__test, __test.test_conflictingGetterAndMethod_field_method );
11052 });
11053 _ut.test('test_conflictingGetterAndMethod_getter_method', () {
11054 final __test = new CompileTimeErrorCodeTest();
11055 runJUnitTest(__test, __test.test_conflictingGetterAndMethod_getter_metho d);
11056 });
11057 _ut.test('test_conflictingGetterAndMethod_method_field', () {
11058 final __test = new CompileTimeErrorCodeTest();
11059 runJUnitTest(__test, __test.test_conflictingGetterAndMethod_method_field );
11060 });
11061 _ut.test('test_conflictingGetterAndMethod_method_getter', () {
11062 final __test = new CompileTimeErrorCodeTest();
11063 runJUnitTest(__test, __test.test_conflictingGetterAndMethod_method_gette r);
11064 });
11065 _ut.test('test_conflictingTypeVariableAndClass', () {
11066 final __test = new CompileTimeErrorCodeTest();
11067 runJUnitTest(__test, __test.test_conflictingTypeVariableAndClass);
11068 });
11069 _ut.test('test_conflictingTypeVariableAndMember_field', () {
11070 final __test = new CompileTimeErrorCodeTest();
11071 runJUnitTest(__test, __test.test_conflictingTypeVariableAndMember_field) ;
11072 });
11073 _ut.test('test_conflictingTypeVariableAndMember_getter', () {
11074 final __test = new CompileTimeErrorCodeTest();
11075 runJUnitTest(__test, __test.test_conflictingTypeVariableAndMember_getter );
11076 });
11077 _ut.test('test_conflictingTypeVariableAndMember_method', () {
11078 final __test = new CompileTimeErrorCodeTest();
11079 runJUnitTest(__test, __test.test_conflictingTypeVariableAndMember_method );
11080 });
11081 _ut.test('test_conflictingTypeVariableAndMember_method_static', () {
11082 final __test = new CompileTimeErrorCodeTest();
11083 runJUnitTest(__test, __test.test_conflictingTypeVariableAndMember_method _static);
11084 });
11085 _ut.test('test_conflictingTypeVariableAndMember_setter', () {
11086 final __test = new CompileTimeErrorCodeTest();
11087 runJUnitTest(__test, __test.test_conflictingTypeVariableAndMember_setter );
11088 });
11089 _ut.test('test_constConstructorWithNonConstSuper_explicit', () {
11090 final __test = new CompileTimeErrorCodeTest();
11091 runJUnitTest(__test, __test.test_constConstructorWithNonConstSuper_expli cit);
11092 });
11093 _ut.test('test_constConstructorWithNonConstSuper_implicit', () {
11094 final __test = new CompileTimeErrorCodeTest();
11095 runJUnitTest(__test, __test.test_constConstructorWithNonConstSuper_impli cit);
11096 });
11097 _ut.test('test_constConstructorWithNonFinalField_mixin', () {
11098 final __test = new CompileTimeErrorCodeTest();
11099 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_mixin );
11100 });
11101 _ut.test('test_constConstructorWithNonFinalField_super', () {
11102 final __test = new CompileTimeErrorCodeTest();
11103 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_super );
11104 });
11105 _ut.test('test_constConstructorWithNonFinalField_this', () {
11106 final __test = new CompileTimeErrorCodeTest();
11107 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_this) ;
11108 });
11109 _ut.test('test_constEvalThrowsException_binaryMinus_null', () {
11110 final __test = new CompileTimeErrorCodeTest();
11111 runJUnitTest(__test, __test.test_constEvalThrowsException_binaryMinus_nu ll);
11112 });
11113 _ut.test('test_constEvalThrowsException_binaryPlus_null', () {
11114 final __test = new CompileTimeErrorCodeTest();
11115 runJUnitTest(__test, __test.test_constEvalThrowsException_binaryPlus_nul l);
11116 });
11117 _ut.test('test_constEvalThrowsException_divisionByZero', () {
11118 final __test = new CompileTimeErrorCodeTest();
11119 runJUnitTest(__test, __test.test_constEvalThrowsException_divisionByZero );
11120 });
11121 _ut.test('test_constEvalThrowsException_unaryBitNot_null', () {
11122 final __test = new CompileTimeErrorCodeTest();
11123 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryBitNot_nu ll);
11124 });
11125 _ut.test('test_constEvalThrowsException_unaryNegated_null', () {
11126 final __test = new CompileTimeErrorCodeTest();
11127 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryNegated_n ull);
11128 });
11129 _ut.test('test_constEvalThrowsException_unaryNot_null', () {
11130 final __test = new CompileTimeErrorCodeTest();
11131 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryNot_null) ;
11132 });
11133 _ut.test('test_constEvalTypeBoolNumString_equal', () {
11134 final __test = new CompileTimeErrorCodeTest();
11135 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal);
11136 });
11137 _ut.test('test_constEvalTypeBoolNumString_notEqual', () {
11138 final __test = new CompileTimeErrorCodeTest();
11139 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual);
11140 });
11141 _ut.test('test_constEvalTypeBool_binary', () {
11142 final __test = new CompileTimeErrorCodeTest();
11143 runJUnitTest(__test, __test.test_constEvalTypeBool_binary);
11144 });
11145 _ut.test('test_constEvalTypeBool_binary_leftTrue', () {
11146 final __test = new CompileTimeErrorCodeTest();
11147 runJUnitTest(__test, __test.test_constEvalTypeBool_binary_leftTrue);
11148 });
11149 _ut.test('test_constEvalTypeInt_binary', () {
11150 final __test = new CompileTimeErrorCodeTest();
11151 runJUnitTest(__test, __test.test_constEvalTypeInt_binary);
11152 });
11153 _ut.test('test_constEvalTypeNum_binary', () {
11154 final __test = new CompileTimeErrorCodeTest();
11155 runJUnitTest(__test, __test.test_constEvalTypeNum_binary);
11156 });
11157 _ut.test('test_constEvalTypeNum_plus_String', () {
11158 final __test = new CompileTimeErrorCodeTest();
11159 runJUnitTest(__test, __test.test_constEvalTypeNum_plus_String);
11160 });
11161 _ut.test('test_constEval_newInstance_constConstructor', () {
11162 final __test = new CompileTimeErrorCodeTest();
11163 runJUnitTest(__test, __test.test_constEval_newInstance_constConstructor) ;
11164 });
11165 _ut.test('test_constEval_propertyExtraction_targetNotConst', () {
11166 final __test = new CompileTimeErrorCodeTest();
11167 runJUnitTest(__test, __test.test_constEval_propertyExtraction_targetNotC onst);
11168 });
11169 _ut.test('test_constFormalParameter_fieldFormalParameter', () {
11170 final __test = new CompileTimeErrorCodeTest();
11171 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er);
11172 });
11173 _ut.test('test_constFormalParameter_simpleFormalParameter', () {
11174 final __test = new CompileTimeErrorCodeTest();
11175 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter);
11176 });
11177 _ut.test('test_constInitializedWithNonConstValue', () {
11178 final __test = new CompileTimeErrorCodeTest();
11179 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue);
11180 });
11181 _ut.test('test_constInitializedWithNonConstValue_missingConstInListLiteral ', () {
11182 final __test = new CompileTimeErrorCodeTest();
11183 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue_missi ngConstInListLiteral);
11184 });
11185 _ut.test('test_constInitializedWithNonConstValue_missingConstInMapLiteral' , () {
11186 final __test = new CompileTimeErrorCodeTest();
11187 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue_missi ngConstInMapLiteral);
11188 });
11189 _ut.test('test_constInstanceField', () {
11190 final __test = new CompileTimeErrorCodeTest();
11191 runJUnitTest(__test, __test.test_constInstanceField);
11192 });
11193 _ut.test('test_constMapKeyTypeImplementsEquals_direct', () {
11194 final __test = new CompileTimeErrorCodeTest();
11195 runJUnitTest(__test, __test.test_constMapKeyTypeImplementsEquals_direct) ;
11196 });
11197 _ut.test('test_constMapKeyTypeImplementsEquals_super', () {
11198 final __test = new CompileTimeErrorCodeTest();
11199 runJUnitTest(__test, __test.test_constMapKeyTypeImplementsEquals_super);
11200 });
11201 _ut.test('test_constWithInvalidTypeParameters', () {
11202 final __test = new CompileTimeErrorCodeTest();
11203 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters);
11204 });
11205 _ut.test('test_constWithInvalidTypeParameters_tooFew', () {
11206 final __test = new CompileTimeErrorCodeTest();
11207 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters_tooFew);
11208 });
11209 _ut.test('test_constWithInvalidTypeParameters_tooMany', () {
11210 final __test = new CompileTimeErrorCodeTest();
11211 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters_tooMany) ;
11212 });
11213 _ut.test('test_constWithNonConst', () {
11214 final __test = new CompileTimeErrorCodeTest();
11215 runJUnitTest(__test, __test.test_constWithNonConst);
11216 });
11217 _ut.test('test_constWithNonConstantArgument_annotation', () {
11218 final __test = new CompileTimeErrorCodeTest();
11219 runJUnitTest(__test, __test.test_constWithNonConstantArgument_annotation );
11220 });
11221 _ut.test('test_constWithNonConstantArgument_instanceCreation', () {
11222 final __test = new CompileTimeErrorCodeTest();
11223 runJUnitTest(__test, __test.test_constWithNonConstantArgument_instanceCr eation);
11224 });
11225 _ut.test('test_constWithNonType', () {
11226 final __test = new CompileTimeErrorCodeTest();
11227 runJUnitTest(__test, __test.test_constWithNonType);
11228 });
11229 _ut.test('test_constWithNonType_fromLibrary', () {
11230 final __test = new CompileTimeErrorCodeTest();
11231 runJUnitTest(__test, __test.test_constWithNonType_fromLibrary);
11232 });
11233 _ut.test('test_constWithTypeParameters_direct', () {
11234 final __test = new CompileTimeErrorCodeTest();
11235 runJUnitTest(__test, __test.test_constWithTypeParameters_direct);
11236 });
11237 _ut.test('test_constWithTypeParameters_indirect', () {
11238 final __test = new CompileTimeErrorCodeTest();
11239 runJUnitTest(__test, __test.test_constWithTypeParameters_indirect);
11240 });
11241 _ut.test('test_constWithUndefinedConstructor', () {
11242 final __test = new CompileTimeErrorCodeTest();
11243 runJUnitTest(__test, __test.test_constWithUndefinedConstructor);
11244 });
11245 _ut.test('test_constWithUndefinedConstructorDefault', () {
11246 final __test = new CompileTimeErrorCodeTest();
11247 runJUnitTest(__test, __test.test_constWithUndefinedConstructorDefault);
11248 });
11249 _ut.test('test_defaultValueInFunctionTypeAlias', () {
11250 final __test = new CompileTimeErrorCodeTest();
11251 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
11252 });
11253 _ut.test('test_defaultValueInFunctionTypedParameter_named', () {
11254 final __test = new CompileTimeErrorCodeTest();
11255 runJUnitTest(__test, __test.test_defaultValueInFunctionTypedParameter_na med);
11256 });
11257 _ut.test('test_defaultValueInFunctionTypedParameter_optional', () {
11258 final __test = new CompileTimeErrorCodeTest();
11259 runJUnitTest(__test, __test.test_defaultValueInFunctionTypedParameter_op tional);
11260 });
11261 _ut.test('test_defaultValueInRedirectingFactoryConstructor', () {
11262 final __test = new CompileTimeErrorCodeTest();
11263 runJUnitTest(__test, __test.test_defaultValueInRedirectingFactoryConstru ctor);
11264 });
11265 _ut.test('test_duplicateConstructorName_named', () {
11266 final __test = new CompileTimeErrorCodeTest();
11267 runJUnitTest(__test, __test.test_duplicateConstructorName_named);
11268 });
11269 _ut.test('test_duplicateConstructorName_unnamed', () {
11270 final __test = new CompileTimeErrorCodeTest();
11271 runJUnitTest(__test, __test.test_duplicateConstructorName_unnamed);
11272 });
11273 _ut.test('test_duplicateDefinition', () {
11274 final __test = new CompileTimeErrorCodeTest();
11275 runJUnitTest(__test, __test.test_duplicateDefinition);
11276 });
11277 _ut.test('test_duplicateDefinitionInheritance_instanceGetterAbstract_stati cGetter', () {
11278 final __test = new CompileTimeErrorCodeTest();
11279 runJUnitTest(__test, __test.test_duplicateDefinitionInheritance_instance GetterAbstract_staticGetter);
11280 });
11281 _ut.test('test_duplicateDefinitionInheritance_instanceGetter_staticGetter' , () {
11282 final __test = new CompileTimeErrorCodeTest();
11283 runJUnitTest(__test, __test.test_duplicateDefinitionInheritance_instance Getter_staticGetter);
11284 });
11285 _ut.test('test_duplicateDefinitionInheritance_instanceMethodAbstract_stati cMethod', () {
11286 final __test = new CompileTimeErrorCodeTest();
11287 runJUnitTest(__test, __test.test_duplicateDefinitionInheritance_instance MethodAbstract_staticMethod);
11288 });
11289 _ut.test('test_duplicateDefinitionInheritance_instanceMethod_staticMethod' , () {
11290 final __test = new CompileTimeErrorCodeTest();
11291 runJUnitTest(__test, __test.test_duplicateDefinitionInheritance_instance Method_staticMethod);
11292 });
11293 _ut.test('test_duplicateDefinitionInheritance_instanceSetterAbstract_stati cSetter', () {
11294 final __test = new CompileTimeErrorCodeTest();
11295 runJUnitTest(__test, __test.test_duplicateDefinitionInheritance_instance SetterAbstract_staticSetter);
11296 });
11297 _ut.test('test_duplicateDefinitionInheritance_instanceSetter_staticSetter' , () {
11298 final __test = new CompileTimeErrorCodeTest();
11299 runJUnitTest(__test, __test.test_duplicateDefinitionInheritance_instance Setter_staticSetter);
11300 });
11301 _ut.test('test_duplicateDefinition_acrossLibraries', () {
11302 final __test = new CompileTimeErrorCodeTest();
11303 runJUnitTest(__test, __test.test_duplicateDefinition_acrossLibraries);
11304 });
11305 _ut.test('test_duplicateDefinition_classMembers_fields', () {
11306 final __test = new CompileTimeErrorCodeTest();
11307 runJUnitTest(__test, __test.test_duplicateDefinition_classMembers_fields );
11308 });
11309 _ut.test('test_duplicateDefinition_classMembers_fields_oneStatic', () {
11310 final __test = new CompileTimeErrorCodeTest();
11311 runJUnitTest(__test, __test.test_duplicateDefinition_classMembers_fields _oneStatic);
11312 });
11313 _ut.test('test_duplicateDefinition_classMembers_methods', () {
11314 final __test = new CompileTimeErrorCodeTest();
11315 runJUnitTest(__test, __test.test_duplicateDefinition_classMembers_method s);
11316 });
11317 _ut.test('test_duplicateDefinition_localFields', () {
11318 final __test = new CompileTimeErrorCodeTest();
11319 runJUnitTest(__test, __test.test_duplicateDefinition_localFields);
11320 });
11321 _ut.test('test_duplicateDefinition_parameterWithFunctionName_local', () {
11322 final __test = new CompileTimeErrorCodeTest();
11323 runJUnitTest(__test, __test.test_duplicateDefinition_parameterWithFuncti onName_local);
11324 });
11325 _ut.test('test_duplicateDefinition_parameterWithFunctionName_topLevel', () {
11326 final __test = new CompileTimeErrorCodeTest();
11327 runJUnitTest(__test, __test.test_duplicateDefinition_parameterWithFuncti onName_topLevel);
11328 });
11329 _ut.test('test_duplicateNamedArgument', () {
11330 final __test = new CompileTimeErrorCodeTest();
11331 runJUnitTest(__test, __test.test_duplicateNamedArgument);
11332 });
11333 _ut.test('test_exportInternalLibrary', () {
11334 final __test = new CompileTimeErrorCodeTest();
11335 runJUnitTest(__test, __test.test_exportInternalLibrary);
11336 });
11337 _ut.test('test_exportOfNonLibrary', () {
11338 final __test = new CompileTimeErrorCodeTest();
11339 runJUnitTest(__test, __test.test_exportOfNonLibrary);
11340 });
11341 _ut.test('test_extendsDisallowedClass_Null', () {
11342 final __test = new CompileTimeErrorCodeTest();
11343 runJUnitTest(__test, __test.test_extendsDisallowedClass_Null);
11344 });
11345 _ut.test('test_extendsDisallowedClass_String', () {
11346 final __test = new CompileTimeErrorCodeTest();
11347 runJUnitTest(__test, __test.test_extendsDisallowedClass_String);
11348 });
11349 _ut.test('test_extendsDisallowedClass_bool', () {
11350 final __test = new CompileTimeErrorCodeTest();
11351 runJUnitTest(__test, __test.test_extendsDisallowedClass_bool);
11352 });
11353 _ut.test('test_extendsDisallowedClass_double', () {
11354 final __test = new CompileTimeErrorCodeTest();
11355 runJUnitTest(__test, __test.test_extendsDisallowedClass_double);
11356 });
11357 _ut.test('test_extendsDisallowedClass_int', () {
11358 final __test = new CompileTimeErrorCodeTest();
11359 runJUnitTest(__test, __test.test_extendsDisallowedClass_int);
11360 });
11361 _ut.test('test_extendsDisallowedClass_num', () {
11362 final __test = new CompileTimeErrorCodeTest();
11363 runJUnitTest(__test, __test.test_extendsDisallowedClass_num);
11364 });
11365 _ut.test('test_extendsNonClass_class', () {
11366 final __test = new CompileTimeErrorCodeTest();
11367 runJUnitTest(__test, __test.test_extendsNonClass_class);
11368 });
11369 _ut.test('test_extendsNonClass_dynamic', () {
11370 final __test = new CompileTimeErrorCodeTest();
11371 runJUnitTest(__test, __test.test_extendsNonClass_dynamic);
11372 });
11373 _ut.test('test_extraPositionalArguments_const', () {
11374 final __test = new CompileTimeErrorCodeTest();
11375 runJUnitTest(__test, __test.test_extraPositionalArguments_const);
11376 });
11377 _ut.test('test_extraPositionalArguments_const_super', () {
11378 final __test = new CompileTimeErrorCodeTest();
11379 runJUnitTest(__test, __test.test_extraPositionalArguments_const_super);
11380 });
11381 _ut.test('test_fieldInitializedByMultipleInitializers', () {
11382 final __test = new CompileTimeErrorCodeTest();
11383 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers) ;
11384 });
11385 _ut.test('test_fieldInitializedByMultipleInitializers_multipleInits', () {
11386 final __test = new CompileTimeErrorCodeTest();
11387 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers_ multipleInits);
11388 });
11389 _ut.test('test_fieldInitializedByMultipleInitializers_multipleNames', () {
11390 final __test = new CompileTimeErrorCodeTest();
11391 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers_ multipleNames);
11392 });
11393 _ut.test('test_fieldInitializedInParameterAndInitializer', () {
11394 final __test = new CompileTimeErrorCodeTest();
11395 runJUnitTest(__test, __test.test_fieldInitializedInParameterAndInitializ er);
11396 });
11397 _ut.test('test_fieldInitializerFactoryConstructor', () {
11398 final __test = new CompileTimeErrorCodeTest();
11399 runJUnitTest(__test, __test.test_fieldInitializerFactoryConstructor);
11400 });
11401 _ut.test('test_fieldInitializerNotAssignable', () {
11402 final __test = new CompileTimeErrorCodeTest();
11403 runJUnitTest(__test, __test.test_fieldInitializerNotAssignable);
11404 });
11405 _ut.test('test_fieldInitializerOutsideConstructor', () {
11406 final __test = new CompileTimeErrorCodeTest();
11407 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor);
11408 });
11409 _ut.test('test_fieldInitializerOutsideConstructor_defaultParameter', () {
11410 final __test = new CompileTimeErrorCodeTest();
11411 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor_defa ultParameter);
11412 });
11413 _ut.test('test_fieldInitializerRedirectingConstructor_afterRedirection', ( ) {
11414 final __test = new CompileTimeErrorCodeTest();
11415 runJUnitTest(__test, __test.test_fieldInitializerRedirectingConstructor_ afterRedirection);
11416 });
11417 _ut.test('test_fieldInitializerRedirectingConstructor_beforeRedirection', () {
11418 final __test = new CompileTimeErrorCodeTest();
11419 runJUnitTest(__test, __test.test_fieldInitializerRedirectingConstructor_ beforeRedirection);
11420 });
11421 _ut.test('test_fieldInitializingFormalRedirectingConstructor', () {
11422 final __test = new CompileTimeErrorCodeTest();
11423 runJUnitTest(__test, __test.test_fieldInitializingFormalRedirectingConst ructor);
11424 });
11425 _ut.test('test_finalInitializedMultipleTimes_initializers', () {
11426 final __test = new CompileTimeErrorCodeTest();
11427 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ ers);
11428 });
11429 _ut.test('test_finalInitializedMultipleTimes_initializingFormal_initialize r', () {
11430 final __test = new CompileTimeErrorCodeTest();
11431 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ ingFormal_initializer);
11432 });
11433 _ut.test('test_finalInitializedMultipleTimes_initializingFormals', () {
11434 final __test = new CompileTimeErrorCodeTest();
11435 runJUnitTest(__test, __test.test_finalInitializedMultipleTimes_initializ ingFormals);
11436 });
11437 _ut.test('test_finalNotInitialized_instanceField_const_static', () {
11438 final __test = new CompileTimeErrorCodeTest();
11439 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_const _static);
11440 });
11441 _ut.test('test_finalNotInitialized_library_const', () {
11442 final __test = new CompileTimeErrorCodeTest();
11443 runJUnitTest(__test, __test.test_finalNotInitialized_library_const);
11444 });
11445 _ut.test('test_finalNotInitialized_local_const', () {
11446 final __test = new CompileTimeErrorCodeTest();
11447 runJUnitTest(__test, __test.test_finalNotInitialized_local_const);
11448 });
11449 _ut.test('test_getterAndMethodWithSameName', () {
11450 final __test = new CompileTimeErrorCodeTest();
11451 runJUnitTest(__test, __test.test_getterAndMethodWithSameName);
11452 });
11453 _ut.test('test_implementsDisallowedClass_Null', () {
11454 final __test = new CompileTimeErrorCodeTest();
11455 runJUnitTest(__test, __test.test_implementsDisallowedClass_Null);
11456 });
11457 _ut.test('test_implementsDisallowedClass_String', () {
11458 final __test = new CompileTimeErrorCodeTest();
11459 runJUnitTest(__test, __test.test_implementsDisallowedClass_String);
11460 });
11461 _ut.test('test_implementsDisallowedClass_bool', () {
11462 final __test = new CompileTimeErrorCodeTest();
11463 runJUnitTest(__test, __test.test_implementsDisallowedClass_bool);
11464 });
11465 _ut.test('test_implementsDisallowedClass_double', () {
11466 final __test = new CompileTimeErrorCodeTest();
11467 runJUnitTest(__test, __test.test_implementsDisallowedClass_double);
11468 });
11469 _ut.test('test_implementsDisallowedClass_int', () {
11470 final __test = new CompileTimeErrorCodeTest();
11471 runJUnitTest(__test, __test.test_implementsDisallowedClass_int);
11472 });
11473 _ut.test('test_implementsDisallowedClass_num', () {
11474 final __test = new CompileTimeErrorCodeTest();
11475 runJUnitTest(__test, __test.test_implementsDisallowedClass_num);
11476 });
11477 _ut.test('test_implementsDynamic', () {
11478 final __test = new CompileTimeErrorCodeTest();
11479 runJUnitTest(__test, __test.test_implementsDynamic);
11480 });
11481 _ut.test('test_implementsNonClass_class', () {
11482 final __test = new CompileTimeErrorCodeTest();
11483 runJUnitTest(__test, __test.test_implementsNonClass_class);
11484 });
11485 _ut.test('test_implementsNonClass_typeAlias', () {
11486 final __test = new CompileTimeErrorCodeTest();
11487 runJUnitTest(__test, __test.test_implementsNonClass_typeAlias);
11488 });
11489 _ut.test('test_implementsRepeated', () {
11490 final __test = new CompileTimeErrorCodeTest();
11491 runJUnitTest(__test, __test.test_implementsRepeated);
11492 });
11493 _ut.test('test_implementsRepeated_3times', () {
11494 final __test = new CompileTimeErrorCodeTest();
11495 runJUnitTest(__test, __test.test_implementsRepeated_3times);
11496 });
11497 _ut.test('test_implementsSuperClass', () {
11498 final __test = new CompileTimeErrorCodeTest();
11499 runJUnitTest(__test, __test.test_implementsSuperClass);
11500 });
11501 _ut.test('test_implementsSuperClass_Object', () {
11502 final __test = new CompileTimeErrorCodeTest();
11503 runJUnitTest(__test, __test.test_implementsSuperClass_Object);
11504 });
11505 _ut.test('test_implicitThisReferenceInInitializer_field', () {
11506 final __test = new CompileTimeErrorCodeTest();
11507 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_fiel d);
11508 });
11509 _ut.test('test_implicitThisReferenceInInitializer_field2', () {
11510 final __test = new CompileTimeErrorCodeTest();
11511 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_fiel d2);
11512 });
11513 _ut.test('test_implicitThisReferenceInInitializer_invocation', () {
11514 final __test = new CompileTimeErrorCodeTest();
11515 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_invo cation);
11516 });
11517 _ut.test('test_implicitThisReferenceInInitializer_invocationInStatic', () {
11518 final __test = new CompileTimeErrorCodeTest();
11519 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_invo cationInStatic);
11520 });
11521 _ut.test('test_implicitThisReferenceInInitializer_redirectingConstructorIn vocation', () {
11522 final __test = new CompileTimeErrorCodeTest();
11523 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_redi rectingConstructorInvocation);
11524 });
11525 _ut.test('test_implicitThisReferenceInInitializer_superConstructorInvocati on', () {
11526 final __test = new CompileTimeErrorCodeTest();
11527 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_supe rConstructorInvocation);
11528 });
11529 _ut.test('test_importInternalLibrary', () {
11530 final __test = new CompileTimeErrorCodeTest();
11531 runJUnitTest(__test, __test.test_importInternalLibrary);
11532 });
11533 _ut.test('test_importInternalLibrary_collection', () {
11534 final __test = new CompileTimeErrorCodeTest();
11535 runJUnitTest(__test, __test.test_importInternalLibrary_collection);
11536 });
11537 _ut.test('test_importOfNonLibrary', () {
11538 final __test = new CompileTimeErrorCodeTest();
11539 runJUnitTest(__test, __test.test_importOfNonLibrary);
11540 });
11541 _ut.test('test_inconsistentCaseExpressionTypes', () {
11542 final __test = new CompileTimeErrorCodeTest();
11543 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes);
11544 });
11545 _ut.test('test_inconsistentCaseExpressionTypes_repeated', () {
11546 final __test = new CompileTimeErrorCodeTest();
11547 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes_repeate d);
11548 });
11549 _ut.test('test_initializerForNonExistant_initializer', () {
11550 final __test = new CompileTimeErrorCodeTest();
11551 runJUnitTest(__test, __test.test_initializerForNonExistant_initializer);
11552 });
11553 _ut.test('test_initializerForStaticField', () {
11554 final __test = new CompileTimeErrorCodeTest();
11555 runJUnitTest(__test, __test.test_initializerForStaticField);
11556 });
11557 _ut.test('test_initializingFormalForNonExistantField', () {
11558 final __test = new CompileTimeErrorCodeTest();
11559 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField);
11560 });
11561 _ut.test('test_initializingFormalForNonExistantField_notInEnclosingClass', () {
11562 final __test = new CompileTimeErrorCodeTest();
11563 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass);
11564 });
11565 _ut.test('test_initializingFormalForNonExistantField_optional', () {
11566 final __test = new CompileTimeErrorCodeTest();
11567 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_o ptional);
11568 });
11569 _ut.test('test_initializingFormalForNonExistantField_synthetic', () {
11570 final __test = new CompileTimeErrorCodeTest();
11571 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_s ynthetic);
11572 });
11573 _ut.test('test_initializingFormalForStaticField', () {
11574 final __test = new CompileTimeErrorCodeTest();
11575 runJUnitTest(__test, __test.test_initializingFormalForStaticField);
11576 });
11577 _ut.test('test_instanceMemberAccessFromStatic_field', () {
11578 final __test = new CompileTimeErrorCodeTest();
11579 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_field);
11580 });
11581 _ut.test('test_instanceMemberAccessFromStatic_getter', () {
11582 final __test = new CompileTimeErrorCodeTest();
11583 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_getter);
11584 });
11585 _ut.test('test_instanceMemberAccessFromStatic_method', () {
11586 final __test = new CompileTimeErrorCodeTest();
11587 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_method);
11588 });
11589 _ut.test('test_invalidAnnotation_getter', () {
11590 final __test = new CompileTimeErrorCodeTest();
11591 runJUnitTest(__test, __test.test_invalidAnnotation_getter);
11592 });
11593 _ut.test('test_invalidAnnotation_importWithPrefix_getter', () {
11594 final __test = new CompileTimeErrorCodeTest();
11595 runJUnitTest(__test, __test.test_invalidAnnotation_importWithPrefix_gett er);
11596 });
11597 _ut.test('test_invalidAnnotation_importWithPrefix_notConstantVariable', () {
11598 final __test = new CompileTimeErrorCodeTest();
11599 runJUnitTest(__test, __test.test_invalidAnnotation_importWithPrefix_notC onstantVariable);
11600 });
11601 _ut.test('test_invalidAnnotation_importWithPrefix_notVariableOrConstructor Invocation', () {
11602 final __test = new CompileTimeErrorCodeTest();
11603 runJUnitTest(__test, __test.test_invalidAnnotation_importWithPrefix_notV ariableOrConstructorInvocation);
11604 });
11605 _ut.test('test_invalidAnnotation_notConstantVariable', () {
11606 final __test = new CompileTimeErrorCodeTest();
11607 runJUnitTest(__test, __test.test_invalidAnnotation_notConstantVariable);
11608 });
11609 _ut.test('test_invalidAnnotation_notVariableOrConstructorInvocation', () {
11610 final __test = new CompileTimeErrorCodeTest();
11611 runJUnitTest(__test, __test.test_invalidAnnotation_notVariableOrConstruc torInvocation);
11612 });
11613 _ut.test('test_invalidAnnotation_staticMethodReference', () {
11614 final __test = new CompileTimeErrorCodeTest();
11615 runJUnitTest(__test, __test.test_invalidAnnotation_staticMethodReference );
11616 });
11617 _ut.test('test_invalidConstructorName_notEnclosingClassName_defined', () {
11618 final __test = new CompileTimeErrorCodeTest();
11619 runJUnitTest(__test, __test.test_invalidConstructorName_notEnclosingClas sName_defined);
11620 });
11621 _ut.test('test_invalidConstructorName_notEnclosingClassName_undefined', () {
11622 final __test = new CompileTimeErrorCodeTest();
11623 runJUnitTest(__test, __test.test_invalidConstructorName_notEnclosingClas sName_undefined);
11624 });
11625 _ut.test('test_invalidFactoryNameNotAClass_notClassName', () {
11626 final __test = new CompileTimeErrorCodeTest();
11627 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass_notClassNam e);
11628 });
11629 _ut.test('test_invalidFactoryNameNotAClass_notEnclosingClassName', () {
11630 final __test = new CompileTimeErrorCodeTest();
11631 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass_notEnclosin gClassName);
11632 });
11633 _ut.test('test_invalidReferenceToThis_factoryConstructor', () {
11634 final __test = new CompileTimeErrorCodeTest();
11635 runJUnitTest(__test, __test.test_invalidReferenceToThis_factoryConstruct or);
11636 });
11637 _ut.test('test_invalidReferenceToThis_instanceVariableInitializer_inConstr uctor', () {
11638 final __test = new CompileTimeErrorCodeTest();
11639 runJUnitTest(__test, __test.test_invalidReferenceToThis_instanceVariable Initializer_inConstructor);
11640 });
11641 _ut.test('test_invalidReferenceToThis_instanceVariableInitializer_inDeclar ation', () {
11642 final __test = new CompileTimeErrorCodeTest();
11643 runJUnitTest(__test, __test.test_invalidReferenceToThis_instanceVariable Initializer_inDeclaration);
11644 });
11645 _ut.test('test_invalidReferenceToThis_staticMethod', () {
11646 final __test = new CompileTimeErrorCodeTest();
11647 runJUnitTest(__test, __test.test_invalidReferenceToThis_staticMethod);
11648 });
11649 _ut.test('test_invalidReferenceToThis_staticVariableInitializer', () {
11650 final __test = new CompileTimeErrorCodeTest();
11651 runJUnitTest(__test, __test.test_invalidReferenceToThis_staticVariableIn itializer);
11652 });
11653 _ut.test('test_invalidReferenceToThis_superInitializer', () {
11654 final __test = new CompileTimeErrorCodeTest();
11655 runJUnitTest(__test, __test.test_invalidReferenceToThis_superInitializer );
11656 });
11657 _ut.test('test_invalidReferenceToThis_topLevelFunction', () {
11658 final __test = new CompileTimeErrorCodeTest();
11659 runJUnitTest(__test, __test.test_invalidReferenceToThis_topLevelFunction );
11660 });
11661 _ut.test('test_invalidReferenceToThis_variableInitializer', () {
11662 final __test = new CompileTimeErrorCodeTest();
11663 runJUnitTest(__test, __test.test_invalidReferenceToThis_variableInitiali zer);
11664 });
11665 _ut.test('test_invalidTypeArgumentInConstList', () {
11666 final __test = new CompileTimeErrorCodeTest();
11667 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList);
11668 });
11669 _ut.test('test_invalidTypeArgumentInConstMap', () {
11670 final __test = new CompileTimeErrorCodeTest();
11671 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstMap);
11672 });
11673 _ut.test('test_invalidUri_export', () {
11674 final __test = new CompileTimeErrorCodeTest();
11675 runJUnitTest(__test, __test.test_invalidUri_export);
11676 });
11677 _ut.test('test_invalidUri_import', () {
11678 final __test = new CompileTimeErrorCodeTest();
11679 runJUnitTest(__test, __test.test_invalidUri_import);
11680 });
11681 _ut.test('test_invalidUri_part', () {
11682 final __test = new CompileTimeErrorCodeTest();
11683 runJUnitTest(__test, __test.test_invalidUri_part);
11684 });
11685 _ut.test('test_labelInOuterScope', () {
11686 final __test = new CompileTimeErrorCodeTest();
11687 runJUnitTest(__test, __test.test_labelInOuterScope);
11688 });
11689 _ut.test('test_labelUndefined_break', () {
11690 final __test = new CompileTimeErrorCodeTest();
11691 runJUnitTest(__test, __test.test_labelUndefined_break);
11692 });
11693 _ut.test('test_labelUndefined_continue', () {
11694 final __test = new CompileTimeErrorCodeTest();
11695 runJUnitTest(__test, __test.test_labelUndefined_continue);
11696 });
11697 _ut.test('test_listElementTypeNotAssignable', () {
11698 final __test = new CompileTimeErrorCodeTest();
11699 runJUnitTest(__test, __test.test_listElementTypeNotAssignable);
11700 });
11701 _ut.test('test_mapKeyTypeNotAssignable', () {
11702 final __test = new CompileTimeErrorCodeTest();
11703 runJUnitTest(__test, __test.test_mapKeyTypeNotAssignable);
11704 });
11705 _ut.test('test_mapValueTypeNotAssignable', () {
11706 final __test = new CompileTimeErrorCodeTest();
11707 runJUnitTest(__test, __test.test_mapValueTypeNotAssignable);
11708 });
11709 _ut.test('test_memberWithClassName_field', () {
11710 final __test = new CompileTimeErrorCodeTest();
11711 runJUnitTest(__test, __test.test_memberWithClassName_field);
11712 });
11713 _ut.test('test_memberWithClassName_field2', () {
11714 final __test = new CompileTimeErrorCodeTest();
11715 runJUnitTest(__test, __test.test_memberWithClassName_field2);
11716 });
11717 _ut.test('test_memberWithClassName_getter', () {
11718 final __test = new CompileTimeErrorCodeTest();
11719 runJUnitTest(__test, __test.test_memberWithClassName_getter);
11720 });
11721 _ut.test('test_memberWithClassName_method', () {
11722 final __test = new CompileTimeErrorCodeTest();
11723 runJUnitTest(__test, __test.test_memberWithClassName_method);
11724 });
11725 _ut.test('test_methodAndGetterWithSameName', () {
11726 final __test = new CompileTimeErrorCodeTest();
11727 runJUnitTest(__test, __test.test_methodAndGetterWithSameName);
11728 });
11729 _ut.test('test_mixinDeclaresConstructor_classDeclaration', () {
11730 final __test = new CompileTimeErrorCodeTest();
11731 runJUnitTest(__test, __test.test_mixinDeclaresConstructor_classDeclarati on);
11732 });
11733 _ut.test('test_mixinDeclaresConstructor_typeAlias', () {
11734 final __test = new CompileTimeErrorCodeTest();
11735 runJUnitTest(__test, __test.test_mixinDeclaresConstructor_typeAlias);
11736 });
11737 _ut.test('test_mixinInheritsFromNotObject_classDeclaration_extends', () {
11738 final __test = new CompileTimeErrorCodeTest();
11739 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_classDeclara tion_extends);
11740 });
11741 _ut.test('test_mixinInheritsFromNotObject_classDeclaration_with', () {
11742 final __test = new CompileTimeErrorCodeTest();
11743 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_classDeclara tion_with);
11744 });
11745 _ut.test('test_mixinInheritsFromNotObject_typeAlias_extends', () {
11746 final __test = new CompileTimeErrorCodeTest();
11747 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_typeAlias_ex tends);
11748 });
11749 _ut.test('test_mixinInheritsFromNotObject_typeAlias_with', () {
11750 final __test = new CompileTimeErrorCodeTest();
11751 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_typeAlias_wi th);
11752 });
11753 _ut.test('test_mixinOfDisallowedClass_Null', () {
11754 final __test = new CompileTimeErrorCodeTest();
11755 runJUnitTest(__test, __test.test_mixinOfDisallowedClass_Null);
11756 });
11757 _ut.test('test_mixinOfDisallowedClass_String', () {
11758 final __test = new CompileTimeErrorCodeTest();
11759 runJUnitTest(__test, __test.test_mixinOfDisallowedClass_String);
11760 });
11761 _ut.test('test_mixinOfDisallowedClass_bool', () {
11762 final __test = new CompileTimeErrorCodeTest();
11763 runJUnitTest(__test, __test.test_mixinOfDisallowedClass_bool);
11764 });
11765 _ut.test('test_mixinOfDisallowedClass_double', () {
11766 final __test = new CompileTimeErrorCodeTest();
11767 runJUnitTest(__test, __test.test_mixinOfDisallowedClass_double);
11768 });
11769 _ut.test('test_mixinOfDisallowedClass_int', () {
11770 final __test = new CompileTimeErrorCodeTest();
11771 runJUnitTest(__test, __test.test_mixinOfDisallowedClass_int);
11772 });
11773 _ut.test('test_mixinOfDisallowedClass_num', () {
11774 final __test = new CompileTimeErrorCodeTest();
11775 runJUnitTest(__test, __test.test_mixinOfDisallowedClass_num);
11776 });
11777 _ut.test('test_mixinOfNonClass_class', () {
11778 final __test = new CompileTimeErrorCodeTest();
11779 runJUnitTest(__test, __test.test_mixinOfNonClass_class);
11780 });
11781 _ut.test('test_mixinOfNonClass_typeAlias', () {
11782 final __test = new CompileTimeErrorCodeTest();
11783 runJUnitTest(__test, __test.test_mixinOfNonClass_typeAlias);
11784 });
11785 _ut.test('test_mixinReferencesSuper', () {
11786 final __test = new CompileTimeErrorCodeTest();
11787 runJUnitTest(__test, __test.test_mixinReferencesSuper);
11788 });
11789 _ut.test('test_mixinWithNonClassSuperclass_class', () {
11790 final __test = new CompileTimeErrorCodeTest();
11791 runJUnitTest(__test, __test.test_mixinWithNonClassSuperclass_class);
11792 });
11793 _ut.test('test_mixinWithNonClassSuperclass_typeAlias', () {
11794 final __test = new CompileTimeErrorCodeTest();
11795 runJUnitTest(__test, __test.test_mixinWithNonClassSuperclass_typeAlias);
11796 });
11797 _ut.test('test_multipleRedirectingConstructorInvocations', () {
11798 final __test = new CompileTimeErrorCodeTest();
11799 runJUnitTest(__test, __test.test_multipleRedirectingConstructorInvocatio ns);
11800 });
11801 _ut.test('test_multipleSuperInitializers', () {
11802 final __test = new CompileTimeErrorCodeTest();
11803 runJUnitTest(__test, __test.test_multipleSuperInitializers);
11804 });
11805 _ut.test('test_nativeClauseInNonSDKCode', () {
11806 final __test = new CompileTimeErrorCodeTest();
11807 runJUnitTest(__test, __test.test_nativeClauseInNonSDKCode);
11808 });
11809 _ut.test('test_nativeFunctionBodyInNonSDKCode_function', () {
11810 final __test = new CompileTimeErrorCodeTest();
11811 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_function );
11812 });
11813 _ut.test('test_nativeFunctionBodyInNonSDKCode_method', () {
11814 final __test = new CompileTimeErrorCodeTest();
11815 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_method);
11816 });
11817 _ut.test('test_noAnnotationConstructorArguments', () {
11818 final __test = new CompileTimeErrorCodeTest();
11819 runJUnitTest(__test, __test.test_noAnnotationConstructorArguments);
11820 });
11821 _ut.test('test_noDefaultSuperConstructorExplicit', () {
11822 final __test = new CompileTimeErrorCodeTest();
11823 runJUnitTest(__test, __test.test_noDefaultSuperConstructorExplicit);
11824 });
11825 _ut.test('test_noDefaultSuperConstructorImplicit_superHasParameters', () {
11826 final __test = new CompileTimeErrorCodeTest();
11827 runJUnitTest(__test, __test.test_noDefaultSuperConstructorImplicit_super HasParameters);
11828 });
11829 _ut.test('test_noDefaultSuperConstructorImplicit_superOnlyNamed', () {
11830 final __test = new CompileTimeErrorCodeTest();
11831 runJUnitTest(__test, __test.test_noDefaultSuperConstructorImplicit_super OnlyNamed);
11832 });
11833 _ut.test('test_nonConstCaseExpression', () {
11834 final __test = new CompileTimeErrorCodeTest();
11835 runJUnitTest(__test, __test.test_nonConstCaseExpression);
11836 });
11837 _ut.test('test_nonConstListElement', () {
11838 final __test = new CompileTimeErrorCodeTest();
11839 runJUnitTest(__test, __test.test_nonConstListElement);
11840 });
11841 _ut.test('test_nonConstMapAsExpressionStatement_begin', () {
11842 final __test = new CompileTimeErrorCodeTest();
11843 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_begin) ;
11844 });
11845 _ut.test('test_nonConstMapAsExpressionStatement_only', () {
11846 final __test = new CompileTimeErrorCodeTest();
11847 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_only);
11848 });
11849 _ut.test('test_nonConstMapKey', () {
11850 final __test = new CompileTimeErrorCodeTest();
11851 runJUnitTest(__test, __test.test_nonConstMapKey);
11852 });
11853 _ut.test('test_nonConstMapValue', () {
11854 final __test = new CompileTimeErrorCodeTest();
11855 runJUnitTest(__test, __test.test_nonConstMapValue);
11856 });
11857 _ut.test('test_nonConstValueInInitializer_binary_notBool_left', () {
11858 final __test = new CompileTimeErrorCodeTest();
11859 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_notBo ol_left);
11860 });
11861 _ut.test('test_nonConstValueInInitializer_binary_notBool_right', () {
11862 final __test = new CompileTimeErrorCodeTest();
11863 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_notBo ol_right);
11864 });
11865 _ut.test('test_nonConstValueInInitializer_binary_notInt', () {
11866 final __test = new CompileTimeErrorCodeTest();
11867 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_notIn t);
11868 });
11869 _ut.test('test_nonConstValueInInitializer_binary_notNum', () {
11870 final __test = new CompileTimeErrorCodeTest();
11871 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_notNu m);
11872 });
11873 _ut.test('test_nonConstValueInInitializer_field', () {
11874 final __test = new CompileTimeErrorCodeTest();
11875 runJUnitTest(__test, __test.test_nonConstValueInInitializer_field);
11876 });
11877 _ut.test('test_nonConstValueInInitializer_redirecting', () {
11878 final __test = new CompileTimeErrorCodeTest();
11879 runJUnitTest(__test, __test.test_nonConstValueInInitializer_redirecting) ;
11880 });
11881 _ut.test('test_nonConstValueInInitializer_super', () {
11882 final __test = new CompileTimeErrorCodeTest();
11883 runJUnitTest(__test, __test.test_nonConstValueInInitializer_super);
11884 });
11885 _ut.test('test_nonConstantAnnotationConstructor_named', () {
11886 final __test = new CompileTimeErrorCodeTest();
11887 runJUnitTest(__test, __test.test_nonConstantAnnotationConstructor_named) ;
11888 });
11889 _ut.test('test_nonConstantAnnotationConstructor_unnamed', () {
11890 final __test = new CompileTimeErrorCodeTest();
11891 runJUnitTest(__test, __test.test_nonConstantAnnotationConstructor_unname d);
11892 });
11893 _ut.test('test_nonConstantDefaultValue_function_named', () {
11894 final __test = new CompileTimeErrorCodeTest();
11895 runJUnitTest(__test, __test.test_nonConstantDefaultValue_function_named) ;
11896 });
11897 _ut.test('test_nonConstantDefaultValue_function_positional', () {
11898 final __test = new CompileTimeErrorCodeTest();
11899 runJUnitTest(__test, __test.test_nonConstantDefaultValue_function_positi onal);
11900 });
11901 _ut.test('test_nonConstantDefaultValue_inConstructor_named', () {
11902 final __test = new CompileTimeErrorCodeTest();
11903 runJUnitTest(__test, __test.test_nonConstantDefaultValue_inConstructor_n amed);
11904 });
11905 _ut.test('test_nonConstantDefaultValue_inConstructor_positional', () {
11906 final __test = new CompileTimeErrorCodeTest();
11907 runJUnitTest(__test, __test.test_nonConstantDefaultValue_inConstructor_p ositional);
11908 });
11909 _ut.test('test_nonConstantDefaultValue_method_named', () {
11910 final __test = new CompileTimeErrorCodeTest();
11911 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_named);
11912 });
11913 _ut.test('test_nonConstantDefaultValue_method_positional', () {
11914 final __test = new CompileTimeErrorCodeTest();
11915 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_position al);
11916 });
11917 _ut.test('test_nonGenerativeConstructor_explicit', () {
11918 final __test = new CompileTimeErrorCodeTest();
11919 runJUnitTest(__test, __test.test_nonGenerativeConstructor_explicit);
11920 });
11921 _ut.test('test_nonGenerativeConstructor_implicit', () {
11922 final __test = new CompileTimeErrorCodeTest();
11923 runJUnitTest(__test, __test.test_nonGenerativeConstructor_implicit);
11924 });
11925 _ut.test('test_nonGenerativeConstructor_implicit2', () {
11926 final __test = new CompileTimeErrorCodeTest();
11927 runJUnitTest(__test, __test.test_nonGenerativeConstructor_implicit2);
11928 });
11929 _ut.test('test_notEnoughRequiredArguments_const', () {
11930 final __test = new CompileTimeErrorCodeTest();
11931 runJUnitTest(__test, __test.test_notEnoughRequiredArguments_const);
11932 });
11933 _ut.test('test_notEnoughRequiredArguments_const_super', () {
11934 final __test = new CompileTimeErrorCodeTest();
11935 runJUnitTest(__test, __test.test_notEnoughRequiredArguments_const_super) ;
11936 });
11937 _ut.test('test_optionalParameterInOperator_named', () {
11938 final __test = new CompileTimeErrorCodeTest();
11939 runJUnitTest(__test, __test.test_optionalParameterInOperator_named);
11940 });
11941 _ut.test('test_optionalParameterInOperator_positional', () {
11942 final __test = new CompileTimeErrorCodeTest();
11943 runJUnitTest(__test, __test.test_optionalParameterInOperator_positional) ;
11944 });
11945 _ut.test('test_partOfNonPart', () {
11946 final __test = new CompileTimeErrorCodeTest();
11947 runJUnitTest(__test, __test.test_partOfNonPart);
11948 });
11949 _ut.test('test_prefixCollidesWithTopLevelMembers_functionTypeAlias', () {
11950 final __test = new CompileTimeErrorCodeTest();
11951 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers_funct ionTypeAlias);
11952 });
11953 _ut.test('test_prefixCollidesWithTopLevelMembers_topLevelFunction', () {
11954 final __test = new CompileTimeErrorCodeTest();
11955 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers_topLe velFunction);
11956 });
11957 _ut.test('test_prefixCollidesWithTopLevelMembers_topLevelVariable', () {
11958 final __test = new CompileTimeErrorCodeTest();
11959 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers_topLe velVariable);
11960 });
11961 _ut.test('test_prefixCollidesWithTopLevelMembers_type', () {
11962 final __test = new CompileTimeErrorCodeTest();
11963 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers_type) ;
11964 });
11965 _ut.test('test_privateOptionalParameter', () {
11966 final __test = new CompileTimeErrorCodeTest();
11967 runJUnitTest(__test, __test.test_privateOptionalParameter);
11968 });
11969 _ut.test('test_privateOptionalParameter_fieldFormal', () {
11970 final __test = new CompileTimeErrorCodeTest();
11971 runJUnitTest(__test, __test.test_privateOptionalParameter_fieldFormal);
11972 });
11973 _ut.test('test_privateOptionalParameter_withDefaultValue', () {
11974 final __test = new CompileTimeErrorCodeTest();
11975 runJUnitTest(__test, __test.test_privateOptionalParameter_withDefaultVal ue);
11976 });
11977 _ut.test('test_recursiveConstructorRedirect', () {
11978 final __test = new CompileTimeErrorCodeTest();
11979 runJUnitTest(__test, __test.test_recursiveConstructorRedirect);
11980 });
11981 _ut.test('test_recursiveConstructorRedirect_directSelfReference', () {
11982 final __test = new CompileTimeErrorCodeTest();
11983 runJUnitTest(__test, __test.test_recursiveConstructorRedirect_directSelf Reference);
11984 });
11985 _ut.test('test_recursiveFactoryRedirect', () {
11986 final __test = new CompileTimeErrorCodeTest();
11987 runJUnitTest(__test, __test.test_recursiveFactoryRedirect);
11988 });
11989 _ut.test('test_recursiveFactoryRedirect_directSelfReference', () {
11990 final __test = new CompileTimeErrorCodeTest();
11991 runJUnitTest(__test, __test.test_recursiveFactoryRedirect_directSelfRefe rence);
11992 });
11993 _ut.test('test_recursiveFactoryRedirect_generic', () {
11994 final __test = new CompileTimeErrorCodeTest();
11995 runJUnitTest(__test, __test.test_recursiveFactoryRedirect_generic);
11996 });
11997 _ut.test('test_recursiveFactoryRedirect_named', () {
11998 final __test = new CompileTimeErrorCodeTest();
11999 runJUnitTest(__test, __test.test_recursiveFactoryRedirect_named);
12000 });
12001 _ut.test('test_recursiveFactoryRedirect_outsideCycle', () {
12002 final __test = new CompileTimeErrorCodeTest();
12003 runJUnitTest(__test, __test.test_recursiveFactoryRedirect_outsideCycle);
12004 });
12005 _ut.test('test_recursiveInterfaceInheritanceBaseCaseExtends', () {
12006 final __test = new CompileTimeErrorCodeTest();
12007 runJUnitTest(__test, __test.test_recursiveInterfaceInheritanceBaseCaseEx tends);
12008 });
12009 _ut.test('test_recursiveInterfaceInheritanceBaseCaseImplements', () {
12010 final __test = new CompileTimeErrorCodeTest();
12011 runJUnitTest(__test, __test.test_recursiveInterfaceInheritanceBaseCaseIm plements);
12012 });
12013 _ut.test('test_recursiveInterfaceInheritanceBaseCaseImplements_typeAlias', () {
12014 final __test = new CompileTimeErrorCodeTest();
12015 runJUnitTest(__test, __test.test_recursiveInterfaceInheritanceBaseCaseIm plements_typeAlias);
12016 });
12017 _ut.test('test_recursiveInterfaceInheritance_extends', () {
12018 final __test = new CompileTimeErrorCodeTest();
12019 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_extends);
12020 });
12021 _ut.test('test_recursiveInterfaceInheritance_extends_implements', () {
12022 final __test = new CompileTimeErrorCodeTest();
12023 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_extends_i mplements);
12024 });
12025 _ut.test('test_recursiveInterfaceInheritance_implements', () {
12026 final __test = new CompileTimeErrorCodeTest();
12027 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_implement s);
12028 });
12029 _ut.test('test_recursiveInterfaceInheritance_tail', () {
12030 final __test = new CompileTimeErrorCodeTest();
12031 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_tail);
12032 });
12033 _ut.test('test_recursiveInterfaceInheritance_tail2', () {
12034 final __test = new CompileTimeErrorCodeTest();
12035 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_tail2);
12036 });
12037 _ut.test('test_recursiveInterfaceInheritance_tail3', () {
12038 final __test = new CompileTimeErrorCodeTest();
12039 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_tail3);
12040 });
12041 _ut.test('test_redirectToNonConstConstructor', () {
12042 final __test = new CompileTimeErrorCodeTest();
12043 runJUnitTest(__test, __test.test_redirectToNonConstConstructor);
12044 });
12045 _ut.test('test_referenceToDeclaredVariableInInitializer_closure', () {
12046 final __test = new CompileTimeErrorCodeTest();
12047 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_closure);
12048 });
12049 _ut.test('test_referenceToDeclaredVariableInInitializer_getter', () {
12050 final __test = new CompileTimeErrorCodeTest();
12051 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_getter);
12052 });
12053 _ut.test('test_referenceToDeclaredVariableInInitializer_setter', () {
12054 final __test = new CompileTimeErrorCodeTest();
12055 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_setter);
12056 });
12057 _ut.test('test_referenceToDeclaredVariableInInitializer_unqualifiedInvocat ion', () {
12058 final __test = new CompileTimeErrorCodeTest();
12059 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_unqualifiedInvocation);
12060 });
12061 _ut.test('test_referencedBeforeDeclaration_hideInBlock_function', () {
12062 final __test = new CompileTimeErrorCodeTest();
12063 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock _function);
12064 });
12065 _ut.test('test_referencedBeforeDeclaration_hideInBlock_local', () {
12066 final __test = new CompileTimeErrorCodeTest();
12067 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock _local);
12068 });
12069 _ut.test('test_referencedBeforeDeclaration_hideInBlock_subBlock', () {
12070 final __test = new CompileTimeErrorCodeTest();
12071 runJUnitTest(__test, __test.test_referencedBeforeDeclaration_hideInBlock _subBlock);
12072 });
12073 _ut.test('test_rethrowOutsideCatch', () {
12074 final __test = new CompileTimeErrorCodeTest();
12075 runJUnitTest(__test, __test.test_rethrowOutsideCatch);
12076 });
12077 _ut.test('test_returnInGenerativeConstructor', () {
12078 final __test = new CompileTimeErrorCodeTest();
12079 runJUnitTest(__test, __test.test_returnInGenerativeConstructor);
12080 });
12081 _ut.test('test_returnInGenerativeConstructor_expressionFunctionBody', () {
12082 final __test = new CompileTimeErrorCodeTest();
12083 runJUnitTest(__test, __test.test_returnInGenerativeConstructor_expressio nFunctionBody);
12084 });
12085 _ut.test('test_superInInvalidContext_binaryExpression', () {
12086 final __test = new CompileTimeErrorCodeTest();
12087 runJUnitTest(__test, __test.test_superInInvalidContext_binaryExpression) ;
12088 });
12089 _ut.test('test_superInInvalidContext_constructorFieldInitializer', () {
12090 final __test = new CompileTimeErrorCodeTest();
12091 runJUnitTest(__test, __test.test_superInInvalidContext_constructorFieldI nitializer);
12092 });
12093 _ut.test('test_superInInvalidContext_factoryConstructor', () {
12094 final __test = new CompileTimeErrorCodeTest();
12095 runJUnitTest(__test, __test.test_superInInvalidContext_factoryConstructo r);
12096 });
12097 _ut.test('test_superInInvalidContext_instanceVariableInitializer', () {
12098 final __test = new CompileTimeErrorCodeTest();
12099 runJUnitTest(__test, __test.test_superInInvalidContext_instanceVariableI nitializer);
12100 });
12101 _ut.test('test_superInInvalidContext_staticMethod', () {
12102 final __test = new CompileTimeErrorCodeTest();
12103 runJUnitTest(__test, __test.test_superInInvalidContext_staticMethod);
12104 });
12105 _ut.test('test_superInInvalidContext_staticVariableInitializer', () {
12106 final __test = new CompileTimeErrorCodeTest();
12107 runJUnitTest(__test, __test.test_superInInvalidContext_staticVariableIni tializer);
12108 });
12109 _ut.test('test_superInInvalidContext_topLevelFunction', () {
12110 final __test = new CompileTimeErrorCodeTest();
12111 runJUnitTest(__test, __test.test_superInInvalidContext_topLevelFunction) ;
12112 });
12113 _ut.test('test_superInInvalidContext_topLevelVariableInitializer', () {
12114 final __test = new CompileTimeErrorCodeTest();
12115 runJUnitTest(__test, __test.test_superInInvalidContext_topLevelVariableI nitializer);
12116 });
12117 _ut.test('test_superInRedirectingConstructor_redirectionSuper', () {
12118 final __test = new CompileTimeErrorCodeTest();
12119 runJUnitTest(__test, __test.test_superInRedirectingConstructor_redirecti onSuper);
12120 });
12121 _ut.test('test_superInRedirectingConstructor_superRedirection', () {
12122 final __test = new CompileTimeErrorCodeTest();
12123 runJUnitTest(__test, __test.test_superInRedirectingConstructor_superRedi rection);
12124 });
12125 _ut.test('test_typeAliasCannotReferenceItself_parameterType_named', () {
12126 final __test = new CompileTimeErrorCodeTest();
12127 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_paramete rType_named);
12128 });
12129 _ut.test('test_typeAliasCannotReferenceItself_parameterType_positional', ( ) {
12130 final __test = new CompileTimeErrorCodeTest();
12131 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_paramete rType_positional);
12132 });
12133 _ut.test('test_typeAliasCannotReferenceItself_parameterType_required', () {
12134 final __test = new CompileTimeErrorCodeTest();
12135 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_paramete rType_required);
12136 });
12137 _ut.test('test_typeAliasCannotReferenceItself_parameterType_typeArgument', () {
12138 final __test = new CompileTimeErrorCodeTest();
12139 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_paramete rType_typeArgument);
12140 });
12141 _ut.test('test_typeAliasCannotReferenceItself_returnClass_withTypeAlias', () {
12142 final __test = new CompileTimeErrorCodeTest();
12143 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_returnCl ass_withTypeAlias);
12144 });
12145 _ut.test('test_typeAliasCannotReferenceItself_returnType', () {
12146 final __test = new CompileTimeErrorCodeTest();
12147 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_returnTy pe);
12148 });
12149 _ut.test('test_typeAliasCannotReferenceItself_returnType_indirect', () {
12150 final __test = new CompileTimeErrorCodeTest();
12151 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_returnTy pe_indirect);
12152 });
12153 _ut.test('test_typeAliasCannotReferenceItself_typeVariableBounds', () {
12154 final __test = new CompileTimeErrorCodeTest();
12155 runJUnitTest(__test, __test.test_typeAliasCannotReferenceItself_typeVari ableBounds);
12156 });
12157 _ut.test('test_typeAliasCannotRereferenceItself_mixin_direct', () {
12158 final __test = new CompileTimeErrorCodeTest();
12159 runJUnitTest(__test, __test.test_typeAliasCannotRereferenceItself_mixin_ direct);
12160 });
12161 _ut.test('test_typeAliasCannotRereferenceItself_mixin_indirect', () {
12162 final __test = new CompileTimeErrorCodeTest();
12163 runJUnitTest(__test, __test.test_typeAliasCannotRereferenceItself_mixin_ indirect);
12164 });
12165 _ut.test('test_typeArgumentNotMatchingBounds_const', () {
12166 final __test = new CompileTimeErrorCodeTest();
12167 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
12168 });
12169 _ut.test('test_undefinedClass_const', () {
12170 final __test = new CompileTimeErrorCodeTest();
12171 runJUnitTest(__test, __test.test_undefinedClass_const);
12172 });
12173 _ut.test('test_undefinedConstructorInInitializer_explicit_named', () {
12174 final __test = new CompileTimeErrorCodeTest();
12175 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_named);
12176 });
12177 _ut.test('test_undefinedConstructorInInitializer_explicit_unnamed', () {
12178 final __test = new CompileTimeErrorCodeTest();
12179 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_unnamed);
12180 });
12181 _ut.test('test_undefinedConstructorInInitializer_implicit', () {
12182 final __test = new CompileTimeErrorCodeTest();
12183 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit);
12184 });
12185 _ut.test('test_undefinedFunction', () {
12186 final __test = new CompileTimeErrorCodeTest();
12187 runJUnitTest(__test, __test.test_undefinedFunction);
12188 });
12189 _ut.test('test_undefinedFunction_hasImportPrefix', () {
12190 final __test = new CompileTimeErrorCodeTest();
12191 runJUnitTest(__test, __test.test_undefinedFunction_hasImportPrefix);
12192 });
12193 _ut.test('test_undefinedFunction_inCatch', () {
12194 final __test = new CompileTimeErrorCodeTest();
12195 runJUnitTest(__test, __test.test_undefinedFunction_inCatch);
12196 });
12197 _ut.test('test_undefinedNamedParameter', () {
12198 final __test = new CompileTimeErrorCodeTest();
12199 runJUnitTest(__test, __test.test_undefinedNamedParameter);
12200 });
12201 _ut.test('test_uriDoesNotExist_export', () {
12202 final __test = new CompileTimeErrorCodeTest();
12203 runJUnitTest(__test, __test.test_uriDoesNotExist_export);
12204 });
12205 _ut.test('test_uriDoesNotExist_import', () {
12206 final __test = new CompileTimeErrorCodeTest();
12207 runJUnitTest(__test, __test.test_uriDoesNotExist_import);
12208 });
12209 _ut.test('test_uriDoesNotExist_part', () {
12210 final __test = new CompileTimeErrorCodeTest();
12211 runJUnitTest(__test, __test.test_uriDoesNotExist_part);
12212 });
12213 _ut.test('test_uriWithInterpolation_constant', () {
12214 final __test = new CompileTimeErrorCodeTest();
12215 runJUnitTest(__test, __test.test_uriWithInterpolation_constant);
12216 });
12217 _ut.test('test_uriWithInterpolation_nonConstant', () {
12218 final __test = new CompileTimeErrorCodeTest();
12219 runJUnitTest(__test, __test.test_uriWithInterpolation_nonConstant);
12220 });
12221 _ut.test('test_wrongNumberOfParametersForOperator1', () {
12222 final __test = new CompileTimeErrorCodeTest();
12223 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator1);
12224 });
12225 _ut.test('test_wrongNumberOfParametersForOperator_minus', () {
12226 final __test = new CompileTimeErrorCodeTest();
12227 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_minu s);
12228 });
12229 _ut.test('test_wrongNumberOfParametersForOperator_tilde', () {
12230 final __test = new CompileTimeErrorCodeTest();
12231 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_tild e);
12232 });
12233 _ut.test('test_wrongNumberOfParametersForSetter_function_named', () {
12234 final __test = new CompileTimeErrorCodeTest();
12235 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_named);
12236 });
12237 _ut.test('test_wrongNumberOfParametersForSetter_function_optional', () {
12238 final __test = new CompileTimeErrorCodeTest();
12239 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_optional);
12240 });
12241 _ut.test('test_wrongNumberOfParametersForSetter_function_tooFew', () {
12242 final __test = new CompileTimeErrorCodeTest();
12243 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_tooFew);
12244 });
12245 _ut.test('test_wrongNumberOfParametersForSetter_function_tooMany', () {
12246 final __test = new CompileTimeErrorCodeTest();
12247 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_tooMany);
12248 });
12249 _ut.test('test_wrongNumberOfParametersForSetter_method_named', () {
12250 final __test = new CompileTimeErrorCodeTest();
12251 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _named);
12252 });
12253 _ut.test('test_wrongNumberOfParametersForSetter_method_optional', () {
12254 final __test = new CompileTimeErrorCodeTest();
12255 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _optional);
12256 });
12257 _ut.test('test_wrongNumberOfParametersForSetter_method_tooFew', () {
12258 final __test = new CompileTimeErrorCodeTest();
12259 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooFew);
12260 });
12261 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () {
12262 final __test = new CompileTimeErrorCodeTest();
12263 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooMany);
12264 });
12265 });
12266 }
12267 }
12268 /**
12269 * Instances of the class `StaticTypeVerifier` verify that all of the nodes in a n AST
12270 * structure that should have a static type associated with them do have a stati c type.
12271 */
12272 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> {
12273
12274 /**
12275 * A list containing all of the AST Expression nodes that were not resolved.
12276 */
12277 List<Expression> _unresolvedExpressions = new List<Expression>();
12278
12279 /**
12280 * A list containing all of the AST Expression nodes for which a propagated ty pe was computed but
12281 * where that type was not more specific than the static type.
12282 */
12283 List<Expression> _invalidlyPropagatedExpressions = new List<Expression>();
12284
12285 /**
12286 * A list containing all of the AST TypeName nodes that were not resolved.
12287 */
12288 List<TypeName> _unresolvedTypes = new List<TypeName>();
12289
12290 /**
12291 * Counter for the number of Expression nodes visited that are resolved.
12292 */
12293 int _resolvedExpressionCount = 0;
12294
12295 /**
12296 * Counter for the number of Expression nodes visited that have propagated typ e information.
12297 */
12298 int _propagatedExpressionCount = 0;
12299
12300 /**
12301 * Counter for the number of TypeName nodes visited that are resolved.
12302 */
12303 int _resolvedTypeCount = 0;
12304
12305 /**
12306 * Assert that all of the visited nodes have a static type associated with the m.
12307 */
12308 void assertResolved() {
12309 if (!_unresolvedExpressions.isEmpty || !_unresolvedTypes.isEmpty) {
12310 PrintStringWriter writer = new PrintStringWriter();
12311 int unresolvedTypeCount = _unresolvedTypes.length;
12312 if (unresolvedTypeCount > 0) {
12313 writer.print("Failed to resolve ");
12314 writer.print(unresolvedTypeCount);
12315 writer.print(" of ");
12316 writer.print(_resolvedTypeCount + unresolvedTypeCount);
12317 writer.println(" type names:");
12318 for (TypeName identifier in _unresolvedTypes) {
12319 writer.print(" ");
12320 writer.print(identifier.toString());
12321 writer.print(" (");
12322 writer.print(getFileName(identifier));
12323 writer.print(" : ");
12324 writer.print(identifier.offset);
12325 writer.println(")");
12326 }
12327 }
12328 int unresolvedExpressionCount = _unresolvedExpressions.length;
12329 if (unresolvedExpressionCount > 0) {
12330 writer.println("Failed to resolve ");
12331 writer.print(unresolvedExpressionCount);
12332 writer.print(" of ");
12333 writer.print(_resolvedExpressionCount + unresolvedExpressionCount);
12334 writer.println(" expressions:");
12335 for (Expression expression in _unresolvedExpressions) {
12336 writer.print(" ");
12337 writer.print(expression.toString());
12338 writer.print(" (");
12339 writer.print(getFileName(expression));
12340 writer.print(" : ");
12341 writer.print(expression.offset);
12342 writer.println(")");
12343 }
12344 }
12345 int invalidlyPropagatedExpressionCount = _invalidlyPropagatedExpressions.l ength;
12346 if (invalidlyPropagatedExpressionCount > 0) {
12347 writer.println("Incorrectly propagated ");
12348 writer.print(invalidlyPropagatedExpressionCount);
12349 writer.print(" of ");
12350 writer.print(_propagatedExpressionCount);
12351 writer.println(" expressions:");
12352 for (Expression expression in _invalidlyPropagatedExpressions) {
12353 writer.print(" ");
12354 writer.print(expression.toString());
12355 writer.print(" [");
12356 writer.print(expression.staticType.displayName);
12357 writer.print(", ");
12358 writer.print(expression.propagatedType.displayName);
12359 writer.println("]");
12360 writer.print(" ");
12361 writer.print(getFileName(expression));
12362 writer.print(" : ");
12363 writer.print(expression.offset);
12364 writer.println(")");
12365 }
12366 }
12367 JUnitTestCase.fail(writer.toString());
12368 }
12369 }
12370 Object visitBreakStatement(BreakStatement node) => null;
12371 Object visitCommentReference(CommentReference node) => null;
12372 Object visitContinueStatement(ContinueStatement node) => null;
12373 Object visitExportDirective(ExportDirective node) => null;
12374 Object visitExpression(Expression node) {
12375 node.visitChildren(this);
12376 Type2 staticType = node.staticType;
12377 if (staticType == null) {
12378 _unresolvedExpressions.add(node);
12379 } else {
12380 _resolvedExpressionCount++;
12381 Type2 propagatedType = node.propagatedType;
12382 if (propagatedType != null) {
12383 _propagatedExpressionCount++;
12384 if (!propagatedType.isMoreSpecificThan(staticType)) {
12385 _invalidlyPropagatedExpressions.add(node);
12386 }
12387 }
12388 }
12389 return null;
12390 }
12391 Object visitImportDirective(ImportDirective node) => null;
12392 Object visitLabel(Label node) => null;
12393 Object visitLibraryIdentifier(LibraryIdentifier node) => null;
12394 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
12395 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) {
12396 return null;
12397 }
12398 return super.visitPrefixedIdentifier(node);
12399 }
12400 Object visitSimpleIdentifier(SimpleIdentifier node) {
12401 ASTNode parent = node.parent;
12402 if (parent is MethodInvocation && identical(node, ((parent as MethodInvocati on)).methodName)) {
12403 return null;
12404 } else if (parent is RedirectingConstructorInvocation && identical(node, ((p arent as RedirectingConstructorInvocation)).constructorName)) {
12405 return null;
12406 } else if (parent is SuperConstructorInvocation && identical(node, ((parent as SuperConstructorInvocation)).constructorName)) {
12407 return null;
12408 } else if (parent is ConstructorName && identical(node, ((parent as Construc torName)).name)) {
12409 return null;
12410 } else if (parent is ConstructorFieldInitializer && identical(node, ((parent as ConstructorFieldInitializer)).fieldName)) {
12411 return null;
12412 } else if (node.staticElement is PrefixElement) {
12413 return null;
12414 }
12415 return super.visitSimpleIdentifier(node);
12416 }
12417 Object visitTypeName(TypeName node) {
12418 if (node.type == null) {
12419 _unresolvedTypes.add(node);
12420 } else {
12421 _resolvedTypeCount++;
12422 }
12423 return null;
12424 }
12425 String getFileName(ASTNode node) {
12426 if (node != null) {
12427 ASTNode root = node.root;
12428 if (root is CompilationUnit) {
12429 CompilationUnit rootCU = root as CompilationUnit;
12430 if (rootCU.element != null) {
12431 return rootCU.element.source.fullName;
12432 } else {
12433 return "<unknown file- CompilationUnit.getElement() returned null>";
12434 }
12435 } else {
12436 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
12437 }
12438 }
12439 return "<unknown file- ASTNode is null>";
12440 }
12441 }
12442 /**
12443 * The class `StrictModeTest` contains tests to ensure that the correct errors a nd warnings
12444 * are reported when the analysis engine is run in strict mode.
12445 */
12446 class StrictModeTest extends ResolverTestCase {
12447 void fail_for() {
12448 Source source = addSource(EngineTestCase.createSource([
12449 "int f(List<int> list) {",
12450 " num sum = 0;",
12451 " for (num i = 0; i < list.length; i++) {",
12452 " sum += list[i];",
12453 " }",
12454 "}"]));
12455 resolve(source);
12456 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12457 }
12458 void setUp() {
12459 super.setUp();
12460 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
12461 options.strictMode = true;
12462 options.hint = false;
12463 analysisContext.analysisOptions = options;
12464 }
12465 void test_assert_is() {
12466 Source source = addSource(EngineTestCase.createSource([
12467 "int f(num n) {",
12468 " assert (n is int);",
12469 " return n & 0x0F;",
12470 "}"]));
12471 resolve(source);
12472 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12473 }
12474 void test_conditional_and_is() {
12475 Source source = addSource(EngineTestCase.createSource([
12476 "int f(num n) {",
12477 " return (n is int && n > 0) ? n & 0x0F : 0;",
12478 "}"]));
12479 resolve(source);
12480 assertNoErrors(source);
12481 }
12482 void test_conditional_is() {
12483 Source source = addSource(EngineTestCase.createSource([
12484 "int f(num n) {",
12485 " return (n is int) ? n & 0x0F : 0;",
12486 "}"]));
12487 resolve(source);
12488 assertNoErrors(source);
12489 }
12490 void test_conditional_isNot() {
12491 Source source = addSource(EngineTestCase.createSource([
12492 "int f(num n) {",
12493 " return (n is! int) ? 0 : n & 0x0F;",
12494 "}"]));
12495 resolve(source);
12496 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12497 }
12498 void test_conditional_or_is() {
12499 Source source = addSource(EngineTestCase.createSource([
12500 "int f(num n) {",
12501 " return (n is! int || n < 0) ? 0 : n & 0x0F;",
12502 "}"]));
12503 resolve(source);
12504 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12505 }
12506 void test_forEach() {
12507 Source source = addSource(EngineTestCase.createSource([
12508 "int f(List<int> list) {",
12509 " num sum = 0;",
12510 " for (num n in list) {",
12511 " sum += n & 0x0F;",
12512 " }",
12513 "}"]));
12514 resolve(source);
12515 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12516 }
12517 void test_if_and_is() {
12518 Source source = addSource(EngineTestCase.createSource([
12519 "int f(num n) {",
12520 " if (n is int && n > 0) {",
12521 " return n & 0x0F;",
12522 " }",
12523 " return 0;",
12524 "}"]));
12525 resolve(source);
12526 assertNoErrors(source);
12527 }
12528 void test_if_is() {
12529 Source source = addSource(EngineTestCase.createSource([
12530 "int f(num n) {",
12531 " if (n is int) {",
12532 " return n & 0x0F;",
12533 " }",
12534 " return 0;",
12535 "}"]));
12536 resolve(source);
12537 assertNoErrors(source);
12538 }
12539 void test_if_isNot() {
12540 Source source = addSource(EngineTestCase.createSource([
12541 "int f(num n) {",
12542 " if (n is! int) {",
12543 " return 0;",
12544 " } else {",
12545 " return n & 0x0F;",
12546 " }",
12547 "}"]));
12548 resolve(source);
12549 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12550 }
12551 void test_if_isNot_abrupt() {
12552 Source source = addSource(EngineTestCase.createSource([
12553 "int f(num n) {",
12554 " if (n is! int) {",
12555 " return 0;",
12556 " }",
12557 " return n & 0x0F;",
12558 "}"]));
12559 resolve(source);
12560 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12561 }
12562 void test_if_or_is() {
12563 Source source = addSource(EngineTestCase.createSource([
12564 "int f(num n) {",
12565 " if (n is! int || n < 0) {",
12566 " return 0;",
12567 " } else {",
12568 " return n & 0x0F;",
12569 " }",
12570 "}"]));
12571 resolve(source);
12572 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12573 }
12574 void test_localVar() {
12575 Source source = addSource(EngineTestCase.createSource(["int f() {", " num n = 1234;", " return n & 0x0F;", "}"]));
12576 resolve(source);
12577 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
12578 }
12579 static dartSuite() {
12580 _ut.group('StrictModeTest', () {
12581 _ut.test('test_assert_is', () {
12582 final __test = new StrictModeTest();
12583 runJUnitTest(__test, __test.test_assert_is);
12584 });
12585 _ut.test('test_conditional_and_is', () {
12586 final __test = new StrictModeTest();
12587 runJUnitTest(__test, __test.test_conditional_and_is);
12588 });
12589 _ut.test('test_conditional_is', () {
12590 final __test = new StrictModeTest();
12591 runJUnitTest(__test, __test.test_conditional_is);
12592 });
12593 _ut.test('test_conditional_isNot', () {
12594 final __test = new StrictModeTest();
12595 runJUnitTest(__test, __test.test_conditional_isNot);
12596 });
12597 _ut.test('test_conditional_or_is', () {
12598 final __test = new StrictModeTest();
12599 runJUnitTest(__test, __test.test_conditional_or_is);
12600 });
12601 _ut.test('test_forEach', () {
12602 final __test = new StrictModeTest();
12603 runJUnitTest(__test, __test.test_forEach);
12604 });
12605 _ut.test('test_if_and_is', () {
12606 final __test = new StrictModeTest();
12607 runJUnitTest(__test, __test.test_if_and_is);
12608 });
12609 _ut.test('test_if_is', () {
12610 final __test = new StrictModeTest();
12611 runJUnitTest(__test, __test.test_if_is);
12612 });
12613 _ut.test('test_if_isNot', () {
12614 final __test = new StrictModeTest();
12615 runJUnitTest(__test, __test.test_if_isNot);
12616 });
12617 _ut.test('test_if_isNot_abrupt', () {
12618 final __test = new StrictModeTest();
12619 runJUnitTest(__test, __test.test_if_isNot_abrupt);
12620 });
12621 _ut.test('test_if_or_is', () {
12622 final __test = new StrictModeTest();
12623 runJUnitTest(__test, __test.test_if_or_is);
12624 });
12625 _ut.test('test_localVar', () {
12626 final __test = new StrictModeTest();
12627 runJUnitTest(__test, __test.test_localVar);
12628 });
12629 });
12630 }
12631 }
12632 class ElementResolverTest extends EngineTestCase {
12633
12634 /**
12635 * The error listener to which errors will be reported.
12636 */
12637 GatheringErrorListener _listener;
12638
12639 /**
12640 * The type provider used to access the types.
12641 */
12642 TestTypeProvider _typeProvider;
12643
12644 /**
12645 * The library containing the code being resolved.
12646 */
12647 LibraryElementImpl _definingLibrary;
12648
12649 /**
12650 * The resolver visitor that maintains the state for the resolver.
12651 */
12652 ResolverVisitor _visitor;
12653
12654 /**
12655 * The resolver being used to resolve the test cases.
12656 */
12657 ElementResolver _resolver;
12658 void fail_visitExportDirective_combinators() {
12659 JUnitTestCase.fail("Not yet tested");
12660 ExportDirective directive = ASTFactory.exportDirective2(null, [ASTFactory.hi deCombinator2(["A"])]);
12661 resolveNode(directive, []);
12662 _listener.assertNoErrors();
12663 }
12664 void fail_visitFunctionExpressionInvocation() {
12665 JUnitTestCase.fail("Not yet tested");
12666 _listener.assertNoErrors();
12667 }
12668 void fail_visitImportDirective_combinators_noPrefix() {
12669 JUnitTestCase.fail("Not yet tested");
12670 ImportDirective directive = ASTFactory.importDirective2(null, null, [ASTFact ory.showCombinator2(["A"])]);
12671 resolveNode(directive, []);
12672 _listener.assertNoErrors();
12673 }
12674 void fail_visitImportDirective_combinators_prefix() {
12675 JUnitTestCase.fail("Not yet tested");
12676 String prefixName = "p";
12677 _definingLibrary.imports = <ImportElement> [ElementFactory.importFor(null, E lementFactory.prefix(prefixName), [])];
12678 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, [
12679 ASTFactory.showCombinator2(["A"]),
12680 ASTFactory.hideCombinator2(["B"])]);
12681 resolveNode(directive, []);
12682 _listener.assertNoErrors();
12683 }
12684 void fail_visitRedirectingConstructorInvocation() {
12685 JUnitTestCase.fail("Not yet tested");
12686 _listener.assertNoErrors();
12687 }
12688 void setUp() {
12689 _listener = new GatheringErrorListener();
12690 _typeProvider = new TestTypeProvider();
12691 _resolver = createResolver();
12692 }
12693 void test_lookUpMethodInInterfaces() {
12694 InterfaceType intType = _typeProvider.intType;
12695 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12696 MethodElement operator = ElementFactory.methodElement("[]", intType, [intTyp e]);
12697 classA.methods = <MethodElement> [operator];
12698 ClassElementImpl classB = ElementFactory.classElement2("B", []);
12699 classB.interfaces = <InterfaceType> [classA.type];
12700 ClassElementImpl classC = ElementFactory.classElement2("C", []);
12701 classC.mixins = <InterfaceType> [classB.type];
12702 ClassElementImpl classD = ElementFactory.classElement("D", classC.type, []);
12703 SimpleIdentifier array = ASTFactory.identifier3("a");
12704 array.staticType = classD.type;
12705 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i"));
12706 JUnitTestCase.assertSame(operator, resolve5(expression, []));
12707 _listener.assertNoErrors();
12708 }
12709 void test_visitAssignmentExpression_compound() {
12710 InterfaceType intType = _typeProvider.intType;
12711 SimpleIdentifier leftHandSide = ASTFactory.identifier3("a");
12712 leftHandSide.staticType = intType;
12713 AssignmentExpression assignment = ASTFactory.assignmentExpression(leftHandSi de, TokenType.PLUS_EQ, ASTFactory.integer(1));
12714 resolveNode(assignment, []);
12715 JUnitTestCase.assertSame(getMethod(_typeProvider.numType, "+"), assignment.s taticElement);
12716 _listener.assertNoErrors();
12717 }
12718 void test_visitAssignmentExpression_simple() {
12719 AssignmentExpression expression = ASTFactory.assignmentExpression(ASTFactory .identifier3("x"), TokenType.EQ, ASTFactory.integer(0));
12720 resolveNode(expression, []);
12721 JUnitTestCase.assertNull(expression.staticElement);
12722 _listener.assertNoErrors();
12723 }
12724 void test_visitBinaryExpression() {
12725 InterfaceType numType = _typeProvider.numType;
12726 SimpleIdentifier left = ASTFactory.identifier3("i");
12727 left.staticType = numType;
12728 BinaryExpression expression = ASTFactory.binaryExpression(left, TokenType.PL US, ASTFactory.identifier3("j"));
12729 resolveNode(expression, []);
12730 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement );
12731 _listener.assertNoErrors();
12732 }
12733 void test_visitBreakStatement_withLabel() {
12734 String label = "loop";
12735 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3( label), false, false);
12736 BreakStatement statement = ASTFactory.breakStatement2(label);
12737 JUnitTestCase.assertSame(labelElement, resolve(statement, labelElement));
12738 _listener.assertNoErrors();
12739 }
12740 void test_visitBreakStatement_withoutLabel() {
12741 BreakStatement statement = ASTFactory.breakStatement();
12742 resolveStatement(statement, null);
12743 _listener.assertNoErrors();
12744 }
12745 void test_visitConstructorName_named() {
12746 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12747 String constructorName = "a";
12748 ConstructorElement constructor = ElementFactory.constructorElement(classA, c onstructorName);
12749 classA.constructors = <ConstructorElement> [constructor];
12750 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
12751 resolveNode(name, []);
12752 JUnitTestCase.assertSame(constructor, name.staticElement);
12753 _listener.assertNoErrors();
12754 }
12755 void test_visitConstructorName_unnamed() {
12756 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12757 String constructorName = null;
12758 ConstructorElement constructor = ElementFactory.constructorElement(classA, c onstructorName);
12759 classA.constructors = <ConstructorElement> [constructor];
12760 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
12761 resolveNode(name, []);
12762 JUnitTestCase.assertSame(constructor, name.staticElement);
12763 _listener.assertNoErrors();
12764 }
12765 void test_visitContinueStatement_withLabel() {
12766 String label = "loop";
12767 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3( label), false, false);
12768 ContinueStatement statement = ASTFactory.continueStatement2(label);
12769 JUnitTestCase.assertSame(labelElement, resolve3(statement, labelElement));
12770 _listener.assertNoErrors();
12771 }
12772 void test_visitContinueStatement_withoutLabel() {
12773 ContinueStatement statement = ASTFactory.continueStatement();
12774 resolveStatement(statement, null);
12775 _listener.assertNoErrors();
12776 }
12777 void test_visitExportDirective_noCombinators() {
12778 ExportDirective directive = ASTFactory.exportDirective2(null, []);
12779 directive.element = ElementFactory.exportFor(ElementFactory.library(_definin gLibrary.context, "lib"), []);
12780 resolveNode(directive, []);
12781 _listener.assertNoErrors();
12782 }
12783 void test_visitFieldFormalParameter() {
12784 InterfaceType intType = _typeProvider.intType;
12785 String fieldName = "f";
12786 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12787 classA.fields = <FieldElement> [ElementFactory.fieldElement(fieldName, false , false, false, intType)];
12788 FieldFormalParameter parameter = ASTFactory.fieldFormalParameter3(fieldName) ;
12789 parameter.identifier.staticElement = ElementFactory.fieldFormalParameter(par ameter.identifier);
12790 resolveInClass(parameter, classA);
12791 JUnitTestCase.assertSame(intType, parameter.element.type);
12792 }
12793 void test_visitImportDirective_noCombinators_noPrefix() {
12794 ImportDirective directive = ASTFactory.importDirective2(null, null, []);
12795 directive.element = ElementFactory.importFor(ElementFactory.library(_definin gLibrary.context, "lib"), null, []);
12796 resolveNode(directive, []);
12797 _listener.assertNoErrors();
12798 }
12799 void test_visitImportDirective_noCombinators_prefix() {
12800 String prefixName = "p";
12801 ImportElement importElement = ElementFactory.importFor(ElementFactory.librar y(_definingLibrary.context, "lib"), ElementFactory.prefix(prefixName), []);
12802 _definingLibrary.imports = <ImportElement> [importElement];
12803 ImportDirective directive = ASTFactory.importDirective2(null, prefixName, [] );
12804 directive.element = importElement;
12805 resolveNode(directive, []);
12806 _listener.assertNoErrors();
12807 }
12808 void test_visitIndexExpression_get() {
12809 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12810 InterfaceType intType = _typeProvider.intType;
12811 MethodElement getter = ElementFactory.methodElement("[]", intType, [intType] );
12812 classA.methods = <MethodElement> [getter];
12813 SimpleIdentifier array = ASTFactory.identifier3("a");
12814 array.staticType = classA.type;
12815 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i"));
12816 JUnitTestCase.assertSame(getter, resolve5(expression, []));
12817 _listener.assertNoErrors();
12818 }
12819 void test_visitIndexExpression_set() {
12820 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12821 InterfaceType intType = _typeProvider.intType;
12822 MethodElement setter = ElementFactory.methodElement("[]=", intType, [intType ]);
12823 classA.methods = <MethodElement> [setter];
12824 SimpleIdentifier array = ASTFactory.identifier3("a");
12825 array.staticType = classA.type;
12826 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i"));
12827 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer (0));
12828 JUnitTestCase.assertSame(setter, resolve5(expression, []));
12829 _listener.assertNoErrors();
12830 }
12831 void test_visitInstanceCreationExpression_named() {
12832 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12833 String constructorName = "a";
12834 ConstructorElement constructor = ElementFactory.constructorElement(classA, c onstructorName);
12835 classA.constructors = <ConstructorElement> [constructor];
12836 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
12837 name.staticElement = constructor;
12838 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, []);
12839 resolveNode(creation, []);
12840 JUnitTestCase.assertSame(constructor, creation.staticElement);
12841 _listener.assertNoErrors();
12842 }
12843 void test_visitInstanceCreationExpression_unnamed() {
12844 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12845 String constructorName = null;
12846 ConstructorElement constructor = ElementFactory.constructorElement(classA, c onstructorName);
12847 classA.constructors = <ConstructorElement> [constructor];
12848 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
12849 name.staticElement = constructor;
12850 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, []);
12851 resolveNode(creation, []);
12852 JUnitTestCase.assertSame(constructor, creation.staticElement);
12853 _listener.assertNoErrors();
12854 }
12855 void test_visitInstanceCreationExpression_unnamed_namedParameter() {
12856 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12857 String constructorName = null;
12858 ConstructorElementImpl constructor = ElementFactory.constructorElement(class A, constructorName);
12859 String parameterName = "a";
12860 ParameterElement parameter = ElementFactory.namedParameter(parameterName);
12861 constructor.parameters = <ParameterElement> [parameter];
12862 classA.constructors = <ConstructorElement> [constructor];
12863 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
12864 name.staticElement = constructor;
12865 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege r(0))]);
12866 resolveNode(creation, []);
12867 JUnitTestCase.assertSame(constructor, creation.staticElement);
12868 JUnitTestCase.assertSame(parameter, ((creation.argumentList.arguments[0] as NamedExpression)).name.label.staticElement);
12869 _listener.assertNoErrors();
12870 }
12871 void test_visitMethodInvocation() {
12872 InterfaceType numType = _typeProvider.numType;
12873 SimpleIdentifier left = ASTFactory.identifier3("i");
12874 left.staticType = numType;
12875 String methodName = "abs";
12876 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName, []);
12877 resolveNode(invocation, []);
12878 JUnitTestCase.assertSame(getMethod(numType, methodName), invocation.methodNa me.staticElement);
12879 _listener.assertNoErrors();
12880 }
12881 void test_visitMethodInvocation_namedParameter() {
12882 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12883 String methodName = "m";
12884 String parameterName = "p";
12885 MethodElementImpl method = ElementFactory.methodElement(methodName, null, [] );
12886 ParameterElement parameter = ElementFactory.namedParameter(parameterName);
12887 method.parameters = <ParameterElement> [parameter];
12888 classA.methods = <MethodElement> [method];
12889 SimpleIdentifier left = ASTFactory.identifier3("i");
12890 left.staticType = classA.type;
12891 MethodInvocation invocation = ASTFactory.methodInvocation(left, methodName, [ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]);
12892 resolveNode(invocation, []);
12893 JUnitTestCase.assertSame(method, invocation.methodName.staticElement);
12894 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a s NamedExpression)).name.label.staticElement);
12895 _listener.assertNoErrors();
12896 }
12897 void test_visitPostfixExpression() {
12898 InterfaceType numType = _typeProvider.numType;
12899 SimpleIdentifier operand = ASTFactory.identifier3("i");
12900 operand.staticType = numType;
12901 PostfixExpression expression = ASTFactory.postfixExpression(operand, TokenTy pe.PLUS_PLUS);
12902 resolveNode(expression, []);
12903 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement );
12904 _listener.assertNoErrors();
12905 }
12906 void test_visitPrefixedIdentifier_dynamic() {
12907 Type2 dynamicType = _typeProvider.dynamicType;
12908 SimpleIdentifier target = ASTFactory.identifier3("a");
12909 VariableElementImpl variable = ElementFactory.localVariableElement(target);
12910 variable.type = dynamicType;
12911 target.staticElement = variable;
12912 target.staticType = dynamicType;
12913 PrefixedIdentifier identifier = ASTFactory.identifier(target, ASTFactory.ide ntifier3("b"));
12914 resolveNode(identifier, []);
12915 JUnitTestCase.assertNull(identifier.staticElement);
12916 JUnitTestCase.assertNull(identifier.identifier.staticElement);
12917 _listener.assertNoErrors();
12918 }
12919 void test_visitPrefixedIdentifier_nonDynamic() {
12920 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12921 String getterName = "b";
12922 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType);
12923 classA.accessors = <PropertyAccessorElement> [getter];
12924 SimpleIdentifier target = ASTFactory.identifier3("a");
12925 VariableElementImpl variable = ElementFactory.localVariableElement(target);
12926 variable.type = classA.type;
12927 target.staticElement = variable;
12928 target.staticType = classA.type;
12929 PrefixedIdentifier identifier = ASTFactory.identifier(target, ASTFactory.ide ntifier3(getterName));
12930 resolveNode(identifier, []);
12931 JUnitTestCase.assertSame(getter, identifier.staticElement);
12932 JUnitTestCase.assertSame(getter, identifier.identifier.staticElement);
12933 _listener.assertNoErrors();
12934 }
12935 void test_visitPrefixExpression() {
12936 InterfaceType numType = _typeProvider.numType;
12937 SimpleIdentifier operand = ASTFactory.identifier3("i");
12938 operand.staticType = numType;
12939 PrefixExpression expression = ASTFactory.prefixExpression(TokenType.PLUS_PLU S, operand);
12940 resolveNode(expression, []);
12941 JUnitTestCase.assertEquals(getMethod(numType, "+"), expression.staticElement );
12942 _listener.assertNoErrors();
12943 }
12944 void test_visitPropertyAccess_getter_identifier() {
12945 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12946 String getterName = "b";
12947 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType);
12948 classA.accessors = <PropertyAccessorElement> [getter];
12949 SimpleIdentifier target = ASTFactory.identifier3("a");
12950 target.staticType = classA.type;
12951 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName);
12952 resolveNode(access, []);
12953 JUnitTestCase.assertSame(getter, access.propertyName.staticElement);
12954 _listener.assertNoErrors();
12955 }
12956 void test_visitPropertyAccess_getter_super() {
12957 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12958 String getterName = "b";
12959 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType);
12960 classA.accessors = <PropertyAccessorElement> [getter];
12961 SuperExpression target = ASTFactory.superExpression();
12962 target.staticType = ElementFactory.classElement("B", classA.type, []).type;
12963 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName);
12964 ASTFactory.methodDeclaration2(null, null, null, null, ASTFactory.identifier3 ("m"), ASTFactory.formalParameterList([]), ASTFactory.expressionFunctionBody(acc ess));
12965 resolveNode(access, []);
12966 JUnitTestCase.assertSame(getter, access.propertyName.staticElement);
12967 _listener.assertNoErrors();
12968 }
12969 void test_visitPropertyAccess_setter_this() {
12970 ClassElementImpl classA = ElementFactory.classElement2("A", []);
12971 String setterName = "b";
12972 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, _typeProvider.intType);
12973 classA.accessors = <PropertyAccessorElement> [setter];
12974 ThisExpression target = ASTFactory.thisExpression();
12975 target.staticType = classA.type;
12976 PropertyAccess access = ASTFactory.propertyAccess2(target, setterName);
12977 ASTFactory.assignmentExpression(access, TokenType.EQ, ASTFactory.integer(0)) ;
12978 resolveNode(access, []);
12979 JUnitTestCase.assertSame(setter, access.propertyName.staticElement);
12980 _listener.assertNoErrors();
12981 }
12982 void test_visitSimpleIdentifier_classScope() {
12983 InterfaceType doubleType = _typeProvider.doubleType;
12984 String fieldName = "NAN";
12985 SimpleIdentifier node = ASTFactory.identifier3(fieldName);
12986 resolveInClass(node, doubleType.element);
12987 JUnitTestCase.assertEquals(getGetter(doubleType, fieldName), node.staticElem ent);
12988 _listener.assertNoErrors();
12989 }
12990 void test_visitSimpleIdentifier_dynamic() {
12991 SimpleIdentifier node = ASTFactory.identifier3("dynamic");
12992 resolve4(node, []);
12993 JUnitTestCase.assertSame(_typeProvider.dynamicType.element, node.staticEleme nt);
12994 JUnitTestCase.assertSame(_typeProvider.typeType, node.staticType);
12995 _listener.assertNoErrors();
12996 }
12997 void test_visitSimpleIdentifier_lexicalScope() {
12998 SimpleIdentifier node = ASTFactory.identifier3("i");
12999 VariableElementImpl element = ElementFactory.localVariableElement(node);
13000 JUnitTestCase.assertSame(element, resolve4(node, [element]));
13001 _listener.assertNoErrors();
13002 }
13003 void test_visitSimpleIdentifier_lexicalScope_field_setter() {
13004 InterfaceType intType = _typeProvider.intType;
13005 ClassElementImpl classA = ElementFactory.classElement2("A", []);
13006 String fieldName = "a";
13007 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa lse, intType);
13008 classA.fields = <FieldElement> [field];
13009 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter];
13010 SimpleIdentifier node = ASTFactory.identifier3(fieldName);
13011 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0));
13012 resolveInClass(node, classA);
13013 Element element = node.staticElement;
13014 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element);
13015 JUnitTestCase.assertTrue(((element as PropertyAccessorElement)).isSetter);
13016 _listener.assertNoErrors();
13017 }
13018 void test_visitSuperConstructorInvocation() {
13019 ClassElementImpl superclass = ElementFactory.classElement2("A", []);
13020 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( superclass, null);
13021 superclass.constructors = <ConstructorElement> [superConstructor];
13022 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []);
13023 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su bclass, null);
13024 subclass.constructors = <ConstructorElement> [subConstructor];
13025 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([]);
13026 resolveInClass(invocation, subclass);
13027 JUnitTestCase.assertEquals(superConstructor, invocation.staticElement);
13028 _listener.assertNoErrors();
13029 }
13030 void test_visitSuperConstructorInvocation_namedParameter() {
13031 ClassElementImpl superclass = ElementFactory.classElement2("A", []);
13032 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( superclass, null);
13033 String parameterName = "p";
13034 ParameterElement parameter = ElementFactory.namedParameter(parameterName);
13035 superConstructor.parameters = <ParameterElement> [parameter];
13036 superclass.constructors = <ConstructorElement> [superConstructor];
13037 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []);
13038 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su bclass, null);
13039 subclass.constructors = <ConstructorElement> [subConstructor];
13040 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]);
13041 resolveInClass(invocation, subclass);
13042 JUnitTestCase.assertEquals(superConstructor, invocation.staticElement);
13043 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a s NamedExpression)).name.label.staticElement);
13044 _listener.assertNoErrors();
13045 }
13046
13047 /**
13048 * Create the resolver used by the tests.
13049 *
13050 * @return the resolver that was created
13051 */
13052 ElementResolver createResolver() {
13053 AnalysisContextImpl context = new AnalysisContextImpl();
13054 ContentCache contentCache = new ContentCache();
13055 SourceFactory sourceFactory = new SourceFactory.con1(contentCache, [new Dart UriResolver(DirectoryBasedDartSdk.defaultSdk)]);
13056 context.sourceFactory = sourceFactory;
13057 FileBasedSource source = new FileBasedSource.con1(contentCache, FileUtilitie s2.createFile("/test.dart"));
13058 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart");
13059 definingCompilationUnit.source = source;
13060 _definingLibrary = ElementFactory.library(context, "test");
13061 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
13062 Library library = new Library(context, _listener, source);
13063 library.libraryElement = _definingLibrary;
13064 _visitor = new ResolverVisitor.con1(library, source, _typeProvider);
13065 try {
13066 return _visitor.elementResolver_J2DAccessor as ElementResolver;
13067 } on JavaException catch (exception) {
13068 throw new IllegalArgumentException("Could not create resolver", exception) ;
13069 }
13070 }
13071
13072 /**
13073 * Return the element associated with the label of the given statement after t he resolver has
13074 * resolved the statement.
13075 *
13076 * @param statement the statement to be resolved
13077 * @param labelElement the label element to be defined in the statement's labe l scope
13078 * @return the element to which the statement's label was resolved
13079 */
13080 Element resolve(BreakStatement statement, LabelElementImpl labelElement) {
13081 resolveStatement(statement, labelElement);
13082 return statement.label.staticElement;
13083 }
13084
13085 /**
13086 * Return the element associated with the label of the given statement after t he resolver has
13087 * resolved the statement.
13088 *
13089 * @param statement the statement to be resolved
13090 * @param labelElement the label element to be defined in the statement's labe l scope
13091 * @return the element to which the statement's label was resolved
13092 */
13093 Element resolve3(ContinueStatement statement, LabelElementImpl labelElement) {
13094 resolveStatement(statement, labelElement);
13095 return statement.label.staticElement;
13096 }
13097
13098 /**
13099 * Return the element associated with the given identifier after the resolver has resolved the
13100 * identifier.
13101 *
13102 * @param node the expression to be resolved
13103 * @param definedElements the elements that are to be defined in the scope in which the element is
13104 * being resolved
13105 * @return the element to which the expression was resolved
13106 */
13107 Element resolve4(Identifier node, List<Element> definedElements) {
13108 resolveNode(node, definedElements);
13109 return node.staticElement;
13110 }
13111
13112 /**
13113 * Return the element associated with the given expression after the resolver has resolved the
13114 * expression.
13115 *
13116 * @param node the expression to be resolved
13117 * @param definedElements the elements that are to be defined in the scope in which the element is
13118 * being resolved
13119 * @return the element to which the expression was resolved
13120 */
13121 Element resolve5(IndexExpression node, List<Element> definedElements) {
13122 resolveNode(node, definedElements);
13123 return node.staticElement;
13124 }
13125
13126 /**
13127 * Return the element associated with the given identifier after the resolver has resolved the
13128 * identifier.
13129 *
13130 * @param node the expression to be resolved
13131 * @param enclosingClass the element representing the class enclosing the iden tifier
13132 * @return the element to which the expression was resolved
13133 */
13134 void resolveInClass(ASTNode node, ClassElement enclosingClass) {
13135 try {
13136 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
13137 try {
13138 _visitor.enclosingClass_J2DAccessor = enclosingClass;
13139 EnclosedScope innerScope = new ClassScope(outerScope, enclosingClass);
13140 _visitor.nameScope_J2DAccessor = innerScope;
13141 node.accept(_resolver);
13142 } finally {
13143 _visitor.enclosingClass_J2DAccessor = null;
13144 _visitor.nameScope_J2DAccessor = outerScope;
13145 }
13146 } on JavaException catch (exception) {
13147 throw new IllegalArgumentException("Could not resolve node", exception);
13148 }
13149 }
13150
13151 /**
13152 * Return the element associated with the given identifier after the resolver has resolved the
13153 * identifier.
13154 *
13155 * @param node the expression to be resolved
13156 * @param definedElements the elements that are to be defined in the scope in which the element is
13157 * being resolved
13158 * @return the element to which the expression was resolved
13159 */
13160 void resolveNode(ASTNode node, List<Element> definedElements) {
13161 try {
13162 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
13163 try {
13164 EnclosedScope innerScope = new EnclosedScope(outerScope);
13165 for (Element element in definedElements) {
13166 innerScope.define(element);
13167 }
13168 _visitor.nameScope_J2DAccessor = innerScope;
13169 node.accept(_resolver);
13170 } finally {
13171 _visitor.nameScope_J2DAccessor = outerScope;
13172 }
13173 } on JavaException catch (exception) {
13174 throw new IllegalArgumentException("Could not resolve node", exception);
13175 }
13176 }
13177
13178 /**
13179 * Return the element associated with the label of the given statement after t he resolver has
13180 * resolved the statement.
13181 *
13182 * @param statement the statement to be resolved
13183 * @param labelElement the label element to be defined in the statement's labe l scope
13184 * @return the element to which the statement's label was resolved
13185 */
13186 void resolveStatement(Statement statement, LabelElementImpl labelElement) {
13187 try {
13188 LabelScope outerScope = _visitor.labelScope_J2DAccessor as LabelScope;
13189 try {
13190 LabelScope innerScope;
13191 if (labelElement == null) {
13192 innerScope = new LabelScope.con1(outerScope, false, false);
13193 } else {
13194 innerScope = new LabelScope.con2(outerScope, labelElement.name, labelE lement);
13195 }
13196 _visitor.labelScope_J2DAccessor = innerScope;
13197 statement.accept(_resolver);
13198 } finally {
13199 _visitor.labelScope_J2DAccessor = outerScope;
13200 }
13201 } on JavaException catch (exception) {
13202 throw new IllegalArgumentException("Could not resolve node", exception);
13203 }
13204 }
13205 static dartSuite() {
13206 _ut.group('ElementResolverTest', () {
13207 _ut.test('test_lookUpMethodInInterfaces', () {
13208 final __test = new ElementResolverTest();
13209 runJUnitTest(__test, __test.test_lookUpMethodInInterfaces);
13210 });
13211 _ut.test('test_visitAssignmentExpression_compound', () {
13212 final __test = new ElementResolverTest();
13213 runJUnitTest(__test, __test.test_visitAssignmentExpression_compound);
13214 });
13215 _ut.test('test_visitAssignmentExpression_simple', () {
13216 final __test = new ElementResolverTest();
13217 runJUnitTest(__test, __test.test_visitAssignmentExpression_simple);
13218 });
13219 _ut.test('test_visitBinaryExpression', () {
13220 final __test = new ElementResolverTest();
13221 runJUnitTest(__test, __test.test_visitBinaryExpression);
13222 });
13223 _ut.test('test_visitBreakStatement_withLabel', () {
13224 final __test = new ElementResolverTest();
13225 runJUnitTest(__test, __test.test_visitBreakStatement_withLabel);
13226 });
13227 _ut.test('test_visitBreakStatement_withoutLabel', () {
13228 final __test = new ElementResolverTest();
13229 runJUnitTest(__test, __test.test_visitBreakStatement_withoutLabel);
13230 });
13231 _ut.test('test_visitConstructorName_named', () {
13232 final __test = new ElementResolverTest();
13233 runJUnitTest(__test, __test.test_visitConstructorName_named);
13234 });
13235 _ut.test('test_visitConstructorName_unnamed', () {
13236 final __test = new ElementResolverTest();
13237 runJUnitTest(__test, __test.test_visitConstructorName_unnamed);
13238 });
13239 _ut.test('test_visitContinueStatement_withLabel', () {
13240 final __test = new ElementResolverTest();
13241 runJUnitTest(__test, __test.test_visitContinueStatement_withLabel);
13242 });
13243 _ut.test('test_visitContinueStatement_withoutLabel', () {
13244 final __test = new ElementResolverTest();
13245 runJUnitTest(__test, __test.test_visitContinueStatement_withoutLabel);
13246 });
13247 _ut.test('test_visitExportDirective_noCombinators', () {
13248 final __test = new ElementResolverTest();
13249 runJUnitTest(__test, __test.test_visitExportDirective_noCombinators);
13250 });
13251 _ut.test('test_visitFieldFormalParameter', () {
13252 final __test = new ElementResolverTest();
13253 runJUnitTest(__test, __test.test_visitFieldFormalParameter);
13254 });
13255 _ut.test('test_visitImportDirective_noCombinators_noPrefix', () {
13256 final __test = new ElementResolverTest();
13257 runJUnitTest(__test, __test.test_visitImportDirective_noCombinators_noPr efix);
13258 });
13259 _ut.test('test_visitImportDirective_noCombinators_prefix', () {
13260 final __test = new ElementResolverTest();
13261 runJUnitTest(__test, __test.test_visitImportDirective_noCombinators_pref ix);
13262 });
13263 _ut.test('test_visitIndexExpression_get', () {
13264 final __test = new ElementResolverTest();
13265 runJUnitTest(__test, __test.test_visitIndexExpression_get);
13266 });
13267 _ut.test('test_visitIndexExpression_set', () {
13268 final __test = new ElementResolverTest();
13269 runJUnitTest(__test, __test.test_visitIndexExpression_set);
13270 });
13271 _ut.test('test_visitInstanceCreationExpression_named', () {
13272 final __test = new ElementResolverTest();
13273 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_named);
13274 });
13275 _ut.test('test_visitInstanceCreationExpression_unnamed', () {
13276 final __test = new ElementResolverTest();
13277 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_unnamed );
13278 });
13279 _ut.test('test_visitInstanceCreationExpression_unnamed_namedParameter', () {
13280 final __test = new ElementResolverTest();
13281 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_unnamed _namedParameter);
13282 });
13283 _ut.test('test_visitMethodInvocation', () {
13284 final __test = new ElementResolverTest();
13285 runJUnitTest(__test, __test.test_visitMethodInvocation);
13286 });
13287 _ut.test('test_visitMethodInvocation_namedParameter', () {
13288 final __test = new ElementResolverTest();
13289 runJUnitTest(__test, __test.test_visitMethodInvocation_namedParameter);
13290 });
13291 _ut.test('test_visitPostfixExpression', () {
13292 final __test = new ElementResolverTest();
13293 runJUnitTest(__test, __test.test_visitPostfixExpression);
13294 });
13295 _ut.test('test_visitPrefixExpression', () {
13296 final __test = new ElementResolverTest();
13297 runJUnitTest(__test, __test.test_visitPrefixExpression);
13298 });
13299 _ut.test('test_visitPrefixedIdentifier_dynamic', () {
13300 final __test = new ElementResolverTest();
13301 runJUnitTest(__test, __test.test_visitPrefixedIdentifier_dynamic);
13302 });
13303 _ut.test('test_visitPrefixedIdentifier_nonDynamic', () {
13304 final __test = new ElementResolverTest();
13305 runJUnitTest(__test, __test.test_visitPrefixedIdentifier_nonDynamic);
13306 });
13307 _ut.test('test_visitPropertyAccess_getter_identifier', () {
13308 final __test = new ElementResolverTest();
13309 runJUnitTest(__test, __test.test_visitPropertyAccess_getter_identifier);
13310 });
13311 _ut.test('test_visitPropertyAccess_getter_super', () {
13312 final __test = new ElementResolverTest();
13313 runJUnitTest(__test, __test.test_visitPropertyAccess_getter_super);
13314 });
13315 _ut.test('test_visitPropertyAccess_setter_this', () {
13316 final __test = new ElementResolverTest();
13317 runJUnitTest(__test, __test.test_visitPropertyAccess_setter_this);
13318 });
13319 _ut.test('test_visitSimpleIdentifier_classScope', () {
13320 final __test = new ElementResolverTest();
13321 runJUnitTest(__test, __test.test_visitSimpleIdentifier_classScope);
13322 });
13323 _ut.test('test_visitSimpleIdentifier_dynamic', () {
13324 final __test = new ElementResolverTest();
13325 runJUnitTest(__test, __test.test_visitSimpleIdentifier_dynamic);
13326 });
13327 _ut.test('test_visitSimpleIdentifier_lexicalScope', () {
13328 final __test = new ElementResolverTest();
13329 runJUnitTest(__test, __test.test_visitSimpleIdentifier_lexicalScope);
13330 });
13331 _ut.test('test_visitSimpleIdentifier_lexicalScope_field_setter', () {
13332 final __test = new ElementResolverTest();
13333 runJUnitTest(__test, __test.test_visitSimpleIdentifier_lexicalScope_fiel d_setter);
13334 });
13335 _ut.test('test_visitSuperConstructorInvocation', () {
13336 final __test = new ElementResolverTest();
13337 runJUnitTest(__test, __test.test_visitSuperConstructorInvocation);
13338 });
13339 _ut.test('test_visitSuperConstructorInvocation_namedParameter', () {
13340 final __test = new ElementResolverTest();
13341 runJUnitTest(__test, __test.test_visitSuperConstructorInvocation_namedPa rameter);
13342 });
13343 });
13344 }
13345 }
13346 class TypeOverrideManagerTest extends EngineTestCase {
13347 void test_exitScope_noScopes() {
13348 TypeOverrideManager manager = new TypeOverrideManager();
13349 try {
13350 manager.exitScope();
13351 JUnitTestCase.fail("Expected IllegalStateException");
13352 } on IllegalStateException catch (exception) {
13353 }
13354 }
13355 void test_exitScope_oneScope() {
13356 TypeOverrideManager manager = new TypeOverrideManager();
13357 manager.enterScope();
13358 manager.exitScope();
13359 try {
13360 manager.exitScope();
13361 JUnitTestCase.fail("Expected IllegalStateException");
13362 } on IllegalStateException catch (exception) {
13363 }
13364 }
13365 void test_exitScope_twoScopes() {
13366 TypeOverrideManager manager = new TypeOverrideManager();
13367 manager.enterScope();
13368 manager.exitScope();
13369 manager.enterScope();
13370 manager.exitScope();
13371 try {
13372 manager.exitScope();
13373 JUnitTestCase.fail("Expected IllegalStateException");
13374 } on IllegalStateException catch (exception) {
13375 }
13376 }
13377 void test_getType_enclosedOverride() {
13378 TypeOverrideManager manager = new TypeOverrideManager();
13379 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v") ;
13380 InterfaceType type = ElementFactory.classElement2("C", []).type;
13381 manager.enterScope();
13382 manager.setType(element, type);
13383 manager.enterScope();
13384 JUnitTestCase.assertSame(type, manager.getType(element));
13385 }
13386 void test_getType_immediateOverride() {
13387 TypeOverrideManager manager = new TypeOverrideManager();
13388 LocalVariableElementImpl element = ElementFactory.localVariableElement2("v") ;
13389 InterfaceType type = ElementFactory.classElement2("C", []).type;
13390 manager.enterScope();
13391 manager.setType(element, type);
13392 JUnitTestCase.assertSame(type, manager.getType(element));
13393 }
13394 void test_getType_noOverride() {
13395 TypeOverrideManager manager = new TypeOverrideManager();
13396 manager.enterScope();
13397 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement 2("v")));
13398 }
13399 void test_getType_noScope() {
13400 TypeOverrideManager manager = new TypeOverrideManager();
13401 JUnitTestCase.assertNull(manager.getType(ElementFactory.localVariableElement 2("v")));
13402 }
13403 static dartSuite() {
13404 _ut.group('TypeOverrideManagerTest', () {
13405 _ut.test('test_exitScope_noScopes', () {
13406 final __test = new TypeOverrideManagerTest();
13407 runJUnitTest(__test, __test.test_exitScope_noScopes);
13408 });
13409 _ut.test('test_exitScope_oneScope', () {
13410 final __test = new TypeOverrideManagerTest();
13411 runJUnitTest(__test, __test.test_exitScope_oneScope);
13412 });
13413 _ut.test('test_exitScope_twoScopes', () {
13414 final __test = new TypeOverrideManagerTest();
13415 runJUnitTest(__test, __test.test_exitScope_twoScopes);
13416 });
13417 _ut.test('test_getType_enclosedOverride', () {
13418 final __test = new TypeOverrideManagerTest();
13419 runJUnitTest(__test, __test.test_getType_enclosedOverride);
13420 });
13421 _ut.test('test_getType_immediateOverride', () {
13422 final __test = new TypeOverrideManagerTest();
13423 runJUnitTest(__test, __test.test_getType_immediateOverride);
13424 });
13425 _ut.test('test_getType_noOverride', () {
13426 final __test = new TypeOverrideManagerTest();
13427 runJUnitTest(__test, __test.test_getType_noOverride);
13428 });
13429 _ut.test('test_getType_noScope', () {
13430 final __test = new TypeOverrideManagerTest();
13431 runJUnitTest(__test, __test.test_getType_noScope);
13432 });
13433 });
13434 }
13435 }
13436 class PubSuggestionCodeTest extends ResolverTestCase {
13437 void test_import_package() {
13438 Source source = addSource(EngineTestCase.createSource(["import 'package:some package/other.dart';"]));
13439 resolve(source);
13440 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
13441 }
13442 void test_import_packageWithDotDot() {
13443 Source source = addSource(EngineTestCase.createSource(["import 'package:some package/../other.dart';"]));
13444 resolve(source);
13445 assertErrors(source, [
13446 CompileTimeErrorCode.URI_DOES_NOT_EXIST,
13447 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]);
13448 }
13449 void test_import_packageWithLeadingDotDot() {
13450 Source source = addSource(EngineTestCase.createSource(["import 'package:../o ther.dart';"]));
13451 resolve(source);
13452 assertErrors(source, [
13453 CompileTimeErrorCode.URI_DOES_NOT_EXIST,
13454 PubSuggestionCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT]);
13455 }
13456 void test_import_referenceIntoLibDirectory() {
13457 cacheSource("/myproj/pubspec.yaml", "");
13458 cacheSource("/myproj/lib/other.dart", "");
13459 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou rce(["import '../lib/other.dart';"]));
13460 resolve(source);
13461 assertErrors(source, [PubSuggestionCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_F ILE_INSIDE]);
13462 }
13463 void test_import_referenceIntoLibDirectory_no_pubspec() {
13464 cacheSource("/myproj/lib/other.dart", "");
13465 Source source = addSource2("/myproj/web/test.dart", EngineTestCase.createSou rce(["import '../lib/other.dart';"]));
13466 resolve(source);
13467 assertNoErrors(source);
13468 }
13469 void test_import_referenceOutOfLibDirectory() {
13470 cacheSource("/myproj/pubspec.yaml", "");
13471 cacheSource("/myproj/web/other.dart", "");
13472 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou rce(["import '../web/other.dart';"]));
13473 resolve(source);
13474 assertErrors(source, [PubSuggestionCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FI LE_OUTSIDE]);
13475 }
13476 void test_import_referenceOutOfLibDirectory_no_pubspec() {
13477 cacheSource("/myproj/web/other.dart", "");
13478 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou rce(["import '../web/other.dart';"]));
13479 resolve(source);
13480 assertNoErrors(source);
13481 }
13482 void test_import_valid_inside_lib1() {
13483 cacheSource("/myproj/pubspec.yaml", "");
13484 cacheSource("/myproj/lib/other.dart", "");
13485 Source source = addSource2("/myproj/lib/test.dart", EngineTestCase.createSou rce(["import 'other.dart';"]));
13486 resolve(source);
13487 assertNoErrors(source);
13488 }
13489 void test_import_valid_inside_lib2() {
13490 cacheSource("/myproj/pubspec.yaml", "");
13491 cacheSource("/myproj/lib/bar/other.dart", "");
13492 Source source = addSource2("/myproj/lib/foo/test.dart", EngineTestCase.creat eSource(["import '../bar/other.dart';"]));
13493 resolve(source);
13494 assertNoErrors(source);
13495 }
13496 void test_import_valid_outside_lib() {
13497 cacheSource("/myproj/pubspec.yaml", "");
13498 cacheSource("/myproj/web/other.dart", "");
13499 Source source = addSource2("/myproj/lib2/test.dart", EngineTestCase.createSo urce(["import '../web/other.dart';"]));
13500 resolve(source);
13501 assertNoErrors(source);
13502 }
13503 static dartSuite() {
13504 _ut.group('PubSuggestionCodeTest', () {
13505 _ut.test('test_import_package', () {
13506 final __test = new PubSuggestionCodeTest();
13507 runJUnitTest(__test, __test.test_import_package);
13508 });
13509 _ut.test('test_import_packageWithDotDot', () {
13510 final __test = new PubSuggestionCodeTest();
13511 runJUnitTest(__test, __test.test_import_packageWithDotDot);
13512 });
13513 _ut.test('test_import_packageWithLeadingDotDot', () {
13514 final __test = new PubSuggestionCodeTest();
13515 runJUnitTest(__test, __test.test_import_packageWithLeadingDotDot);
13516 });
13517 _ut.test('test_import_referenceIntoLibDirectory', () {
13518 final __test = new PubSuggestionCodeTest();
13519 runJUnitTest(__test, __test.test_import_referenceIntoLibDirectory);
13520 });
13521 _ut.test('test_import_referenceIntoLibDirectory_no_pubspec', () {
13522 final __test = new PubSuggestionCodeTest();
13523 runJUnitTest(__test, __test.test_import_referenceIntoLibDirectory_no_pub spec);
13524 });
13525 _ut.test('test_import_referenceOutOfLibDirectory', () {
13526 final __test = new PubSuggestionCodeTest();
13527 runJUnitTest(__test, __test.test_import_referenceOutOfLibDirectory);
13528 });
13529 _ut.test('test_import_referenceOutOfLibDirectory_no_pubspec', () {
13530 final __test = new PubSuggestionCodeTest();
13531 runJUnitTest(__test, __test.test_import_referenceOutOfLibDirectory_no_pu bspec);
13532 });
13533 _ut.test('test_import_valid_inside_lib1', () {
13534 final __test = new PubSuggestionCodeTest();
13535 runJUnitTest(__test, __test.test_import_valid_inside_lib1);
13536 });
13537 _ut.test('test_import_valid_inside_lib2', () {
13538 final __test = new PubSuggestionCodeTest();
13539 runJUnitTest(__test, __test.test_import_valid_inside_lib2);
13540 });
13541 _ut.test('test_import_valid_outside_lib', () {
13542 final __test = new PubSuggestionCodeTest();
13543 runJUnitTest(__test, __test.test_import_valid_outside_lib);
13544 });
13545 });
13546 }
13547 }
13548 class StaticWarningCodeTest extends ResolverTestCase {
13549 void fail_undefinedGetter() {
13550 Source source = addSource(EngineTestCase.createSource([]));
13551 resolve(source);
13552 assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]);
13553 verify([source]);
13554 }
13555 void fail_undefinedIdentifier_commentReference() {
13556 Source source = addSource(EngineTestCase.createSource(["/** [m] xxx [new B.c ] */", "class A {", "}"]));
13557 resolve(source);
13558 assertErrors(source, [
13559 StaticWarningCode.UNDEFINED_IDENTIFIER,
13560 StaticWarningCode.UNDEFINED_IDENTIFIER]);
13561 }
13562 void fail_undefinedSetter() {
13563 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " C.m = 0;", "}"]));
13564 resolve(source);
13565 assertErrors(source, [StaticWarningCode.UNDEFINED_SETTER]);
13566 verify([source]);
13567 }
13568 void fail_undefinedStaticMethodOrGetter_getter() {
13569 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m);", "}"]));
13570 resolve(source);
13571 assertErrors(source, [StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]);
13572 verify([source]);
13573 }
13574 void fail_undefinedStaticMethodOrGetter_method() {
13575 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m());", "}"]));
13576 resolve(source);
13577 assertErrors(source, [StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]);
13578 verify([source]);
13579 }
13580 void test_ambiguousImport_as() {
13581 Source source = addSource(EngineTestCase.createSource([
13582 "import 'lib1.dart';",
13583 "import 'lib2.dart';",
13584 "f(p) {p as N;}"]));
13585 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13586 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13587 resolve(source);
13588 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
13589 }
13590 void test_ambiguousImport_extends() {
13591 Source source = addSource(EngineTestCase.createSource([
13592 "import 'lib1.dart';",
13593 "import 'lib2.dart';",
13594 "class A extends N {}"]));
13595 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13596 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13597 resolve(source);
13598 assertErrors(source, [
13599 StaticWarningCode.AMBIGUOUS_IMPORT,
13600 CompileTimeErrorCode.EXTENDS_NON_CLASS]);
13601 }
13602 void test_ambiguousImport_implements() {
13603 Source source = addSource(EngineTestCase.createSource([
13604 "import 'lib1.dart';",
13605 "import 'lib2.dart';",
13606 "class A implements N {}"]));
13607 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13608 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13609 resolve(source);
13610 assertErrors(source, [
13611 StaticWarningCode.AMBIGUOUS_IMPORT,
13612 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
13613 }
13614 void test_ambiguousImport_inPart() {
13615 Source source = addSource(EngineTestCase.createSource([
13616 "library lib;",
13617 "import 'lib1.dart';",
13618 "import 'lib2.dart';",
13619 "part 'part.dart';"]));
13620 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13621 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13622 Source partSource = addSource2("/part.dart", EngineTestCase.createSource(["p art of lib;", "class A extends N {}"]));
13623 resolve(source);
13624 assertErrors(partSource, [
13625 StaticWarningCode.AMBIGUOUS_IMPORT,
13626 CompileTimeErrorCode.EXTENDS_NON_CLASS]);
13627 }
13628 void test_ambiguousImport_instanceCreation() {
13629 Source source = addSource(EngineTestCase.createSource([
13630 "library L;",
13631 "import 'lib1.dart';",
13632 "import 'lib2.dart';",
13633 "f() {new N();}"]));
13634 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13635 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13636 resolve(source);
13637 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
13638 }
13639 void test_ambiguousImport_is() {
13640 Source source = addSource(EngineTestCase.createSource([
13641 "import 'lib1.dart';",
13642 "import 'lib2.dart';",
13643 "f(p) {p is N;}"]));
13644 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13645 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13646 resolve(source);
13647 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
13648 }
13649 void test_ambiguousImport_qualifier() {
13650 Source source = addSource(EngineTestCase.createSource([
13651 "import 'lib1.dart';",
13652 "import 'lib2.dart';",
13653 "g() { N.FOO; }"]));
13654 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13655 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13656 resolve(source);
13657 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
13658 }
13659 void test_ambiguousImport_typeAnnotation() {
13660 Source source = addSource(EngineTestCase.createSource([
13661 "import 'lib1.dart';",
13662 "import 'lib2.dart';",
13663 "typedef N FT(N p);",
13664 "N f(N p) {",
13665 " N v;",
13666 "}",
13667 "class A {",
13668 " N m() {}",
13669 "}",
13670 "class B<T extends N> {}"]));
13671 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13672 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13673 resolve(source);
13674 assertErrors(source, [
13675 StaticWarningCode.AMBIGUOUS_IMPORT,
13676 StaticWarningCode.AMBIGUOUS_IMPORT,
13677 StaticWarningCode.AMBIGUOUS_IMPORT,
13678 StaticWarningCode.AMBIGUOUS_IMPORT,
13679 StaticWarningCode.AMBIGUOUS_IMPORT,
13680 StaticWarningCode.AMBIGUOUS_IMPORT,
13681 StaticWarningCode.AMBIGUOUS_IMPORT]);
13682 }
13683 void test_ambiguousImport_typeArgument_annotation() {
13684 Source source = addSource(EngineTestCase.createSource([
13685 "import 'lib1.dart';",
13686 "import 'lib2.dart';",
13687 "class A<T> {}",
13688 "A<N> f() {}"]));
13689 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13690 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13691 resolve(source);
13692 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
13693 }
13694 void test_ambiguousImport_typeArgument_instanceCreation() {
13695 Source source = addSource(EngineTestCase.createSource([
13696 "import 'lib1.dart';",
13697 "import 'lib2.dart';",
13698 "class A<T> {}",
13699 "f() {new A<N>();}"]));
13700 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
13701 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
13702 resolve(source);
13703 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
13704 }
13705 void test_ambiguousImport_varRead() {
13706 Source source = addSource(EngineTestCase.createSource([
13707 "import 'lib1.dart';",
13708 "import 'lib2.dart';",
13709 "f() { g(v); }",
13710 "g(p) {}"]));
13711 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var v;"]));
13712 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var v;"]));
13713 resolve(source);
13714 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
13715 }
13716 void test_ambiguousImport_varWrite() {
13717 Source source = addSource(EngineTestCase.createSource([
13718 "import 'lib1.dart';",
13719 "import 'lib2.dart';",
13720 "f() { v = 0; }"]));
13721 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var v;"]));
13722 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var v;"]));
13723 resolve(source);
13724 assertErrors(source, [StaticWarningCode.AMBIGUOUS_IMPORT]);
13725 }
13726 void test_argumentTypeNotAssignable_annotation_namedConstructor() {
13727 Source source = addSource(EngineTestCase.createSource([
13728 "class A {",
13729 " const A.fromInt(int p);",
13730 "}",
13731 "@A.fromInt('0')",
13732 "main() {",
13733 "}"]));
13734 resolve(source);
13735 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13736 verify([source]);
13737 }
13738 void test_argumentTypeNotAssignable_annotation_unnamedConstructor() {
13739 Source source = addSource(EngineTestCase.createSource([
13740 "class A {",
13741 " const A(int p);",
13742 "}",
13743 "@A('0')",
13744 "main() {",
13745 "}"]));
13746 resolve(source);
13747 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13748 verify([source]);
13749 }
13750 void test_argumentTypeNotAssignable_binary() {
13751 Source source = addSource(EngineTestCase.createSource([
13752 "class A {",
13753 " operator +(int p) {}",
13754 "}",
13755 "f(A a) {",
13756 " a + '0';",
13757 "}"]));
13758 resolve(source);
13759 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13760 verify([source]);
13761 }
13762 void test_argumentTypeNotAssignable_const() {
13763 Source source = addSource(EngineTestCase.createSource([
13764 "class A {",
13765 " const A(String p);",
13766 "}",
13767 "main() {",
13768 " const A(42);",
13769 "}"]));
13770 resolve(source);
13771 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13772 verify([source]);
13773 }
13774 void test_argumentTypeNotAssignable_const_super() {
13775 Source source = addSource(EngineTestCase.createSource([
13776 "class A {",
13777 " const A(String p);",
13778 "}",
13779 "class B extends A {",
13780 " const B() : super(42);",
13781 "}"]));
13782 resolve(source);
13783 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13784 verify([source]);
13785 }
13786 void test_argumentTypeNotAssignable_index() {
13787 Source source = addSource(EngineTestCase.createSource([
13788 "class A {",
13789 " operator [](int index) {}",
13790 "}",
13791 "f(A a) {",
13792 " a['0'];",
13793 "}"]));
13794 resolve(source);
13795 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13796 verify([source]);
13797 }
13798 void test_argumentTypeNotAssignable_invocation_callParameter() {
13799 Source source = addSource(EngineTestCase.createSource([
13800 "class A {",
13801 " call(int p) {}",
13802 "}",
13803 "f(A a) {",
13804 " a('0');",
13805 "}"]));
13806 resolve(source);
13807 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13808 verify([source]);
13809 }
13810 void test_argumentTypeNotAssignable_invocation_callVariable() {
13811 Source source = addSource(EngineTestCase.createSource([
13812 "class A {",
13813 " call(int p) {}",
13814 "}",
13815 "main() {",
13816 " A a = new A();",
13817 " a('0');",
13818 "}"]));
13819 resolve(source);
13820 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13821 verify([source]);
13822 }
13823 void test_argumentTypeNotAssignable_invocation_functionParameter() {
13824 Source source = addSource(EngineTestCase.createSource(["a(b(int p)) {", " b ('0');", "}"]));
13825 resolve(source);
13826 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13827 verify([source]);
13828 }
13829 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() {
13830 Source source = addSource(EngineTestCase.createSource([
13831 "class A<K, V> {",
13832 " m(f(K k), V v) {",
13833 " f(v);",
13834 " }",
13835 "}"]));
13836 resolve(source);
13837 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13838 verify([source]);
13839 }
13840 void test_argumentTypeNotAssignable_invocation_functionTypes_optional() {
13841 Source source = addSource(EngineTestCase.createSource([
13842 "void acceptFunNumOptBool(void funNumOptBool([bool b])) {}",
13843 "void funNumBool(bool b) {}",
13844 "main() {",
13845 " acceptFunNumOptBool(funNumBool);",
13846 "}"]));
13847 resolve(source);
13848 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13849 verify([source]);
13850 }
13851 void test_argumentTypeNotAssignable_invocation_generic() {
13852 Source source = addSource(EngineTestCase.createSource([
13853 "class A<T> {",
13854 " m(T t) {}",
13855 "}",
13856 "f(A<String> a) {",
13857 " a.m(1);",
13858 "}"]));
13859 resolve(source);
13860 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13861 verify([source]);
13862 }
13863 void test_argumentTypeNotAssignable_invocation_named() {
13864 Source source = addSource(EngineTestCase.createSource(["f({String p}) {}", " main() {", " f(p: 42);", "}"]));
13865 resolve(source);
13866 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13867 verify([source]);
13868 }
13869 void test_argumentTypeNotAssignable_invocation_optional() {
13870 Source source = addSource(EngineTestCase.createSource(["f([String p]) {}", " main() {", " f(42);", "}"]));
13871 resolve(source);
13872 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13873 verify([source]);
13874 }
13875 void test_argumentTypeNotAssignable_invocation_required() {
13876 Source source = addSource(EngineTestCase.createSource(["f(String p) {}", "ma in() {", " f(42);", "}"]));
13877 resolve(source);
13878 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13879 verify([source]);
13880 }
13881 void test_argumentTypeNotAssignable_invocation_typedef_generic() {
13882 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);", "f(A<int> a) {", " a('1');", "}"]));
13883 resolve(source);
13884 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13885 verify([source]);
13886 }
13887 void test_argumentTypeNotAssignable_invocation_typedef_local() {
13888 Source source = addSource(EngineTestCase.createSource([
13889 "typedef A(int p);",
13890 "A getA() => null;",
13891 "main() {",
13892 " A a = getA();",
13893 " a('1');",
13894 "}"]));
13895 resolve(source);
13896 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13897 verify([source]);
13898 }
13899 void test_argumentTypeNotAssignable_invocation_typedef_parameter() {
13900 Source source = addSource(EngineTestCase.createSource(["typedef A(int p);", "f(A a) {", " a('1');", "}"]));
13901 resolve(source);
13902 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13903 verify([source]);
13904 }
13905 void test_argumentTypeNotAssignable_new_generic() {
13906 Source source = addSource(EngineTestCase.createSource([
13907 "class A<T> {",
13908 " A(T p) {}",
13909 "}",
13910 "main() {",
13911 " new A<String>(42);",
13912 "}"]));
13913 resolve(source);
13914 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13915 verify([source]);
13916 }
13917 void test_argumentTypeNotAssignable_new_optional() {
13918 Source source = addSource(EngineTestCase.createSource([
13919 "class A {",
13920 " A([String p]) {}",
13921 "}",
13922 "main() {",
13923 " new A(42);",
13924 "}"]));
13925 resolve(source);
13926 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13927 verify([source]);
13928 }
13929 void test_argumentTypeNotAssignable_new_required() {
13930 Source source = addSource(EngineTestCase.createSource([
13931 "class A {",
13932 " A(String p) {}",
13933 "}",
13934 "main() {",
13935 " new A(42);",
13936 "}"]));
13937 resolve(source);
13938 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
13939 verify([source]);
13940 }
13941 void test_assignmentToConst_instanceVariable() {
13942 Source source = addSource(EngineTestCase.createSource([
13943 "class A {",
13944 " static const v = 0;",
13945 "}",
13946 "f() {",
13947 " A.v = 1;",
13948 "}"]));
13949 resolve(source);
13950 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
13951 verify([source]);
13952 }
13953 void test_assignmentToConst_localVariable() {
13954 Source source = addSource(EngineTestCase.createSource(["f() {", " const x = 0;", " x = 1;", "}"]));
13955 resolve(source);
13956 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_CONST]);
13957 verify([source]);
13958 }
13959 void test_assignmentToFinal_instanceVariable() {
13960 Source source = addSource(EngineTestCase.createSource([
13961 "class A {",
13962 " final v = 0;",
13963 "}",
13964 "f() {",
13965 " A a = new A();",
13966 " a.v = 1;",
13967 "}"]));
13968 resolve(source);
13969 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
13970 verify([source]);
13971 }
13972 void test_assignmentToFinal_localVariable() {
13973 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " x = 1;", "}"]));
13974 resolve(source);
13975 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
13976 verify([source]);
13977 }
13978 void test_assignmentToFinal_prefixMinusMinus() {
13979 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " --x;", "}"]));
13980 resolve(source);
13981 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
13982 verify([source]);
13983 }
13984 void test_assignmentToFinal_prefixPlusPlus() {
13985 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " ++x;", "}"]));
13986 resolve(source);
13987 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
13988 verify([source]);
13989 }
13990 void test_assignmentToFinal_propertyAccess() {
13991 Source source = addSource(EngineTestCase.createSource([
13992 "class A {",
13993 " int get x => 0;",
13994 "}",
13995 "class B {",
13996 " static A a;",
13997 "}",
13998 "main() {",
13999 " B.a.x = 0;",
14000 "}"]));
14001 resolve(source);
14002 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
14003 verify([source]);
14004 }
14005 void test_assignmentToFinal_suffixMinusMinus() {
14006 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " x--;", "}"]));
14007 resolve(source);
14008 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
14009 verify([source]);
14010 }
14011 void test_assignmentToFinal_suffixPlusPlus() {
14012 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " x++;", "}"]));
14013 resolve(source);
14014 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
14015 verify([source]);
14016 }
14017 void test_assignmentToFinal_topLevelVariable() {
14018 Source source = addSource(EngineTestCase.createSource(["final x = 0;", "f() { x = 1; }"]));
14019 resolve(source);
14020 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_FINAL]);
14021 verify([source]);
14022 }
14023 void test_assignmentToMethod() {
14024 Source source = addSource(EngineTestCase.createSource([
14025 "class A {",
14026 " m() {}",
14027 "}",
14028 "f(A a) {",
14029 " a.m = () {};",
14030 "}"]));
14031 resolve(source);
14032 assertErrors(source, [StaticWarningCode.ASSIGNMENT_TO_METHOD]);
14033 verify([source]);
14034 }
14035 void test_caseBlockNotTerminated() {
14036 Source source = addSource(EngineTestCase.createSource([
14037 "f(int p) {",
14038 " switch (p) {",
14039 " case 0:",
14040 " f(p);",
14041 " case 1:",
14042 " break;",
14043 " }",
14044 "}"]));
14045 resolve(source);
14046 assertErrors(source, [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
14047 verify([source]);
14048 }
14049 void test_castToNonType() {
14050 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri ng s) { var x = s as A; }"]));
14051 resolve(source);
14052 assertErrors(source, [StaticWarningCode.CAST_TO_NON_TYPE]);
14053 verify([source]);
14054 }
14055 void test_concreteClassWithAbstractMember() {
14056 Source source = addSource(EngineTestCase.createSource(["class A {", " m();" , "}"]));
14057 resolve(source);
14058 assertErrors(source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER] );
14059 verify([source]);
14060 }
14061 void test_conflictingDartImport() {
14062 Source source = addSource(EngineTestCase.createSource([
14063 "import 'lib.dart';",
14064 "import 'dart:async';",
14065 "Future f = null;",
14066 "Stream s;"]));
14067 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class Future {}"]));
14068 resolve(source);
14069 assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]);
14070 }
14071 void test_conflictingInstanceGetterAndSuperclassMember_direct_field() {
14072 Source source = addSource(EngineTestCase.createSource([
14073 "class A {",
14074 " static int v;",
14075 "}",
14076 "class B extends A {",
14077 " get v => 0;",
14078 "}"]));
14079 resolve(source);
14080 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE RCLASS_MEMBER]);
14081 verify([source]);
14082 }
14083 void test_conflictingInstanceGetterAndSuperclassMember_direct_getter() {
14084 Source source = addSource(EngineTestCase.createSource([
14085 "class A {",
14086 " static get v => 0;",
14087 "}",
14088 "class B extends A {",
14089 " get v => 0;",
14090 "}"]));
14091 resolve(source);
14092 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE RCLASS_MEMBER]);
14093 verify([source]);
14094 }
14095 void test_conflictingInstanceGetterAndSuperclassMember_direct_method() {
14096 Source source = addSource(EngineTestCase.createSource([
14097 "class A {",
14098 " static v() {}",
14099 "}",
14100 "class B extends A {",
14101 " get v => 0;",
14102 "}"]));
14103 resolve(source);
14104 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE RCLASS_MEMBER]);
14105 verify([source]);
14106 }
14107 void test_conflictingInstanceGetterAndSuperclassMember_direct_setter() {
14108 Source source = addSource(EngineTestCase.createSource([
14109 "class A {",
14110 " static set v(x) {}",
14111 "}",
14112 "class B extends A {",
14113 " get v => 0;",
14114 "}"]));
14115 resolve(source);
14116 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE RCLASS_MEMBER]);
14117 verify([source]);
14118 }
14119 void test_conflictingInstanceGetterAndSuperclassMember_indirect() {
14120 Source source = addSource(EngineTestCase.createSource([
14121 "class A {",
14122 " static int v;",
14123 "}",
14124 "class B extends A {}",
14125 "class C extends B {",
14126 " get v => 0;",
14127 "}"]));
14128 resolve(source);
14129 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE RCLASS_MEMBER]);
14130 verify([source]);
14131 }
14132 void test_conflictingInstanceGetterAndSuperclassMember_mixin() {
14133 Source source = addSource(EngineTestCase.createSource([
14134 "class M {",
14135 " static int v;",
14136 "}",
14137 "class B extends Object with M {",
14138 " get v => 0;",
14139 "}"]));
14140 resolve(source);
14141 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPE RCLASS_MEMBER]);
14142 verify([source]);
14143 }
14144 void test_conflictingInstanceSetterAndSuperclassMember() {
14145 Source source = addSource(EngineTestCase.createSource([
14146 "class A {",
14147 " static int v;",
14148 "}",
14149 "class B extends A {",
14150 " set v(x) {}",
14151 "}"]));
14152 resolve(source);
14153 assertErrors(source, [StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPE RCLASS_MEMBER]);
14154 verify([source]);
14155 }
14156 void test_conflictingStaticGetterAndInstanceSetter_mixin() {
14157 Source source = addSource(EngineTestCase.createSource([
14158 "class A {",
14159 " set x(int p) {}",
14160 "}",
14161 "class B extends Object with A {",
14162 " static get x => 0;",
14163 "}"]));
14164 resolve(source);
14165 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN CE_SETTER]);
14166 verify([source]);
14167 }
14168 void test_conflictingStaticGetterAndInstanceSetter_superClass() {
14169 Source source = addSource(EngineTestCase.createSource([
14170 "class A {",
14171 " set x(int p) {}",
14172 "}",
14173 "class B extends A {",
14174 " static get x => 0;",
14175 "}"]));
14176 resolve(source);
14177 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN CE_SETTER]);
14178 verify([source]);
14179 }
14180 void test_conflictingStaticGetterAndInstanceSetter_thisClass() {
14181 Source source = addSource(EngineTestCase.createSource([
14182 "class A {",
14183 " static get x => 0;",
14184 " set x(int p) {}",
14185 "}"]));
14186 resolve(source);
14187 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTAN CE_SETTER]);
14188 verify([source]);
14189 }
14190 void test_conflictingStaticSetterAndInstanceMember_thisClass_getter() {
14191 Source source = addSource(EngineTestCase.createSource([
14192 "class A {",
14193 " get x => 0;",
14194 " static set x(int p) {}",
14195 "}"]));
14196 resolve(source);
14197 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTAN CE_MEMBER]);
14198 verify([source]);
14199 }
14200 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() {
14201 Source source = addSource(EngineTestCase.createSource(["class A {", " x() { }", " static set x(int p) {}", "}"]));
14202 resolve(source);
14203 assertErrors(source, [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTAN CE_MEMBER]);
14204 verify([source]);
14205 }
14206 void test_constWithAbstractClass() {
14207 Source source = addSource(EngineTestCase.createSource([
14208 "abstract class A {",
14209 " const A();",
14210 "}",
14211 "void f() {",
14212 " A a = const A();",
14213 "}"]));
14214 resolve(source);
14215 assertErrors(source, [StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]);
14216 verify([source]);
14217 }
14218 void test_equalKeysInMap() {
14219 Source source = addSource(EngineTestCase.createSource(["var m = {'a' : 0, 'b ' : 1, 'a' : 2};"]));
14220 resolve(source);
14221 assertErrors(source, [StaticWarningCode.EQUAL_KEYS_IN_MAP]);
14222 verify([source]);
14223 }
14224 void test_exportDuplicatedLibraryName() {
14225 Source source = addSource(EngineTestCase.createSource([
14226 "library test;",
14227 "export 'lib1.dart';",
14228 "export 'lib2.dart';"]));
14229 addSource2("/lib1.dart", "library lib;");
14230 addSource2("/lib2.dart", "library lib;");
14231 resolve(source);
14232 assertErrors(source, [StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAME]);
14233 verify([source]);
14234 }
14235 void test_extraPositionalArguments() {
14236 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {", " f(0, 1, '2');", "}"]));
14237 resolve(source);
14238 assertErrors(source, [StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]);
14239 verify([source]);
14240 }
14241 void test_fieldInitializedInInitializerAndDeclaration_final() {
14242 Source source = addSource(EngineTestCase.createSource([
14243 "class A {",
14244 " final int x = 0;",
14245 " A() : x = 1 {}",
14246 "}"]));
14247 resolve(source);
14248 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND _DECLARATION]);
14249 verify([source]);
14250 }
14251 void test_fieldInitializerNotAssignable() {
14252 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A() : x = '';", "}"]));
14253 resolve(source);
14254 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]);
14255 verify([source]);
14256 }
14257 void test_fieldInitializingFormalNotAssignable() {
14258 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(String this.x) {}", "}"]));
14259 resolve(source);
14260 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGN ABLE]);
14261 verify([source]);
14262 }
14263
14264 /**
14265 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR code, but tests the
14266 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid ed here to show
14267 * coverage over all of the permutations of initializers in constructor declar ations.
14268 *
14269 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of
14270 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w e use it instead of
14271 * the broader code
14272 */
14273 void test_finalInitializedInDeclarationAndConstructor_initializers() {
14274 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A() : x = 0 {}", "}"]));
14275 resolve(source);
14276 assertErrors(source, [StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND _DECLARATION]);
14277 verify([source]);
14278 }
14279 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
14280 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"]));
14281 resolve(source);
14282 assertErrors(source, [StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND _CONSTRUCTOR]);
14283 verify([source]);
14284 }
14285 void test_finalNotInitialized_inConstructor() {
14286 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() {}", "}"]));
14287 resolve(source);
14288 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
14289 verify([source]);
14290 }
14291 void test_finalNotInitialized_instanceField_final() {
14292 Source source = addSource(EngineTestCase.createSource(["class A {", " final F;", "}"]));
14293 resolve(source);
14294 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
14295 verify([source]);
14296 }
14297 void test_finalNotInitialized_instanceField_final_static() {
14298 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c final F;", "}"]));
14299 resolve(source);
14300 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
14301 verify([source]);
14302 }
14303 void test_finalNotInitialized_library_final() {
14304 Source source = addSource(EngineTestCase.createSource(["final F;"]));
14305 resolve(source);
14306 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
14307 verify([source]);
14308 }
14309 void test_finalNotInitialized_local_final() {
14310 Source source = addSource(EngineTestCase.createSource(["f() {", " final int x;", "}"]));
14311 resolve(source);
14312 assertErrors(source, [StaticWarningCode.FINAL_NOT_INITIALIZED]);
14313 verify([source]);
14314 }
14315 void test_functionWithoutCall_direct() {
14316 Source source = addSource(EngineTestCase.createSource(["class A implements F unction {", "}"]));
14317 resolve(source);
14318 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
14319 verify([source]);
14320 }
14321 void test_functionWithoutCall_indirect_extends() {
14322 Source source = addSource(EngineTestCase.createSource([
14323 "abstract class A implements Function {",
14324 "}",
14325 "class B extends A {",
14326 "}"]));
14327 resolve(source);
14328 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
14329 verify([source]);
14330 }
14331 void test_functionWithoutCall_indirect_implements() {
14332 Source source = addSource(EngineTestCase.createSource([
14333 "abstract class A implements Function {",
14334 "}",
14335 "class B implements A {",
14336 "}"]));
14337 resolve(source);
14338 assertErrors(source, [StaticWarningCode.FUNCTION_WITHOUT_CALL]);
14339 verify([source]);
14340 }
14341 void test_importDuplicatedLibraryName() {
14342 Source source = addSource(EngineTestCase.createSource([
14343 "library test;",
14344 "import 'lib1.dart';",
14345 "import 'lib2.dart';"]));
14346 addSource2("/lib1.dart", "library lib;");
14347 addSource2("/lib2.dart", "library lib;");
14348 resolve(source);
14349 assertErrors(source, [
14350 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAME,
14351 HintCode.UNUSED_IMPORT,
14352 HintCode.UNUSED_IMPORT]);
14353 verify([source]);
14354 }
14355 void test_inconsistentMethodInheritanceGetterAndMethod() {
14356 Source source = addSource(EngineTestCase.createSource([
14357 "abstract class A {",
14358 " int x();",
14359 "}",
14360 "abstract class B {",
14361 " int get x;",
14362 "}",
14363 "class C implements A, B {",
14364 "}"]));
14365 resolve(source);
14366 assertErrors(source, [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETT ER_AND_METHOD]);
14367 verify([source]);
14368 }
14369 void test_instanceMethodNameCollidesWithSuperclassStatic_field() {
14370 Source source = addSource(EngineTestCase.createSource([
14371 "class A {",
14372 " static var n;",
14373 "}",
14374 "class B extends A {",
14375 " void n() {}",
14376 "}"]));
14377 resolve(source);
14378 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S UPERCLASS_STATIC]);
14379 verify([source]);
14380 }
14381 void test_instanceMethodNameCollidesWithSuperclassStatic_field2() {
14382 Source source = addSource(EngineTestCase.createSource([
14383 "class A {",
14384 " static var n;",
14385 "}",
14386 "class B extends A {",
14387 "}",
14388 "class C extends B {",
14389 " void n() {}",
14390 "}"]));
14391 resolve(source);
14392 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S UPERCLASS_STATIC]);
14393 verify([source]);
14394 }
14395 void test_instanceMethodNameCollidesWithSuperclassStatic_getter() {
14396 Source source = addSource(EngineTestCase.createSource([
14397 "class A {",
14398 " static get n {return 0;}",
14399 "}",
14400 "class B extends A {",
14401 " void n() {}",
14402 "}"]));
14403 resolve(source);
14404 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S UPERCLASS_STATIC]);
14405 verify([source]);
14406 }
14407 void test_instanceMethodNameCollidesWithSuperclassStatic_getter2() {
14408 Source source = addSource(EngineTestCase.createSource([
14409 "class A {",
14410 " static get n {return 0;}",
14411 "}",
14412 "class B extends A {",
14413 "}",
14414 "class C extends B {",
14415 " void n() {}",
14416 "}"]));
14417 resolve(source);
14418 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S UPERCLASS_STATIC]);
14419 verify([source]);
14420 }
14421 void test_instanceMethodNameCollidesWithSuperclassStatic_method() {
14422 Source source = addSource(EngineTestCase.createSource([
14423 "class A {",
14424 " static n () {}",
14425 "}",
14426 "class B extends A {",
14427 " void n() {}",
14428 "}"]));
14429 resolve(source);
14430 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S UPERCLASS_STATIC]);
14431 verify([source]);
14432 }
14433 void test_instanceMethodNameCollidesWithSuperclassStatic_method2() {
14434 Source source = addSource(EngineTestCase.createSource([
14435 "class A {",
14436 " static n () {}",
14437 "}",
14438 "class B extends A {",
14439 "}",
14440 "class C extends B {",
14441 " void n() {}",
14442 "}"]));
14443 resolve(source);
14444 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S UPERCLASS_STATIC]);
14445 verify([source]);
14446 }
14447 void test_instanceMethodNameCollidesWithSuperclassStatic_setter() {
14448 Source source = addSource(EngineTestCase.createSource([
14449 "class A {",
14450 " static set n(int x) {}",
14451 "}",
14452 "class B extends A {",
14453 " void n() {}",
14454 "}"]));
14455 resolve(source);
14456 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S UPERCLASS_STATIC]);
14457 verify([source]);
14458 }
14459 void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() {
14460 Source source = addSource(EngineTestCase.createSource([
14461 "class A {",
14462 " static set n(int x) {}",
14463 "}",
14464 "class B extends A {",
14465 "}",
14466 "class C extends B {",
14467 " void n() {}",
14468 "}"]));
14469 resolve(source);
14470 assertErrors(source, [StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_S UPERCLASS_STATIC]);
14471 verify([source]);
14472 }
14473 void test_invalidGetterOverrideReturnType() {
14474 Source source = addSource(EngineTestCase.createSource([
14475 "class A {",
14476 " int get g { return 0; }",
14477 "}",
14478 "class B extends A {",
14479 " String get g { return 'a'; }",
14480 "}"]));
14481 resolve(source);
14482 assertErrors(source, [StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE] );
14483 verify([source]);
14484 }
14485 void test_invalidGetterOverrideReturnType_implicit() {
14486 Source source = addSource(EngineTestCase.createSource([
14487 "class A {",
14488 " String f;",
14489 "}",
14490 "class B extends A {",
14491 " int f;",
14492 "}"]));
14493 resolve(source);
14494 assertErrors(source, [
14495 StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE,
14496 StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
14497 verify([source]);
14498 }
14499 void test_invalidMethodOverrideNamedParamType() {
14500 Source source = addSource(EngineTestCase.createSource([
14501 "class A {",
14502 " m({int a}) {}",
14503 "}",
14504 "class B implements A {",
14505 " m({String a}) {}",
14506 "}"]));
14507 resolve(source);
14508 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_ TYPE]);
14509 verify([source]);
14510 }
14511 void test_invalidMethodOverrideNormalParamType() {
14512 Source source = addSource(EngineTestCase.createSource([
14513 "class A {",
14514 " m(int a) {}",
14515 "}",
14516 "class B implements A {",
14517 " m(String a) {}",
14518 "}"]));
14519 resolve(source);
14520 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM _TYPE]);
14521 verify([source]);
14522 }
14523 void test_invalidMethodOverrideOptionalParamType() {
14524 Source source = addSource(EngineTestCase.createSource([
14525 "class A {",
14526 " m([int a]) {}",
14527 "}",
14528 "class B implements A {",
14529 " m([String a]) {}",
14530 "}"]));
14531 resolve(source);
14532 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PAR AM_TYPE]);
14533 verify([source]);
14534 }
14535 void test_invalidMethodOverrideReturnType_interface() {
14536 Source source = addSource(EngineTestCase.createSource([
14537 "class A {",
14538 " int m() { return 0; }",
14539 "}",
14540 "class B implements A {",
14541 " String m() { return 'a'; }",
14542 "}"]));
14543 resolve(source);
14544 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE] );
14545 verify([source]);
14546 }
14547 void test_invalidMethodOverrideReturnType_interface2() {
14548 Source source = addSource(EngineTestCase.createSource([
14549 "abstract class A {",
14550 " int m();",
14551 "}",
14552 "abstract class B implements A {",
14553 "}",
14554 "class C implements B {",
14555 " String m() { return 'a'; }",
14556 "}"]));
14557 resolve(source);
14558 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE] );
14559 verify([source]);
14560 }
14561 void test_invalidMethodOverrideReturnType_mixin() {
14562 Source source = addSource(EngineTestCase.createSource([
14563 "class A {",
14564 " int m() { return 0; }",
14565 "}",
14566 "class B extends Object with A {",
14567 " String m() { return 'a'; }",
14568 "}"]));
14569 resolve(source);
14570 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE] );
14571 verify([source]);
14572 }
14573 void test_invalidMethodOverrideReturnType_superclass() {
14574 Source source = addSource(EngineTestCase.createSource([
14575 "class A {",
14576 " int m() { return 0; }",
14577 "}",
14578 "class B extends A {",
14579 " String m() { return 'a'; }",
14580 "}"]));
14581 resolve(source);
14582 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE] );
14583 verify([source]);
14584 }
14585 void test_invalidMethodOverrideReturnType_superclass2() {
14586 Source source = addSource(EngineTestCase.createSource([
14587 "class A {",
14588 " int m() { return 0; }",
14589 "}",
14590 "class B extends A {",
14591 "}",
14592 "class C extends B {",
14593 " String m() { return 'a'; }",
14594 "}"]));
14595 resolve(source);
14596 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE] );
14597 verify([source]);
14598 }
14599 void test_invalidMethodOverrideReturnType_void() {
14600 Source source = addSource(EngineTestCase.createSource([
14601 "class A {",
14602 " int m() {}",
14603 "}",
14604 "class B extends A {",
14605 " void m() {}",
14606 "}"]));
14607 resolve(source);
14608 assertErrors(source, [StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE] );
14609 verify([source]);
14610 }
14611 void test_invalidOverrideDifferentDefaultValues_named() {
14612 Source source = addSource(EngineTestCase.createSource([
14613 "class A {",
14614 " m({int p : 0}) {}",
14615 "}",
14616 "class B extends A {",
14617 " m({int p : 1}) {}",
14618 "}"]));
14619 resolve(source);
14620 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_V ALUES_NAMED]);
14621 verify([source]);
14622 }
14623 void test_invalidOverrideDifferentDefaultValues_positional() {
14624 Source source = addSource(EngineTestCase.createSource([
14625 "class A {",
14626 " m([int p = 0]) {}",
14627 "}",
14628 "class B extends A {",
14629 " m([int p = 1]) {}",
14630 "}"]));
14631 resolve(source);
14632 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_V ALUES_POSITIONAL]);
14633 verify([source]);
14634 }
14635 void test_invalidOverrideNamed_fewerNamedParameters() {
14636 Source source = addSource(EngineTestCase.createSource([
14637 "class A {",
14638 " m({a, b}) {}",
14639 "}",
14640 "class B extends A {",
14641 " m({a}) {}",
14642 "}"]));
14643 resolve(source);
14644 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]);
14645 verify([source]);
14646 }
14647 void test_invalidOverrideNamed_missingNamedParameter() {
14648 Source source = addSource(EngineTestCase.createSource([
14649 "class A {",
14650 " m({a, b}) {}",
14651 "}",
14652 "class B extends A {",
14653 " m({a, c}) {}",
14654 "}"]));
14655 resolve(source);
14656 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_NAMED]);
14657 verify([source]);
14658 }
14659 void test_invalidOverridePositional_optional() {
14660 Source source = addSource(EngineTestCase.createSource([
14661 "class A {",
14662 " m([a, b]) {}",
14663 "}",
14664 "class B extends A {",
14665 " m([a]) {}",
14666 "}"]));
14667 resolve(source);
14668 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
14669 verify([source]);
14670 }
14671 void test_invalidOverridePositional_optionalAndRequired() {
14672 Source source = addSource(EngineTestCase.createSource([
14673 "class A {",
14674 " m(a, b, [c, d]) {}",
14675 "}",
14676 "class B extends A {",
14677 " m(a, b, [c]) {}",
14678 "}"]));
14679 resolve(source);
14680 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
14681 verify([source]);
14682 }
14683 void test_invalidOverridePositional_optionalAndRequired2() {
14684 Source source = addSource(EngineTestCase.createSource([
14685 "class A {",
14686 " m(a, b, [c, d]) {}",
14687 "}",
14688 "class B extends A {",
14689 " m(a, [c, d]) {}",
14690 "}"]));
14691 resolve(source);
14692 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_POSITIONAL]);
14693 verify([source]);
14694 }
14695 void test_invalidOverrideRequired() {
14696 Source source = addSource(EngineTestCase.createSource([
14697 "class A {",
14698 " m(a) {}",
14699 "}",
14700 "class B extends A {",
14701 " m(a, b) {}",
14702 "}"]));
14703 resolve(source);
14704 assertErrors(source, [StaticWarningCode.INVALID_OVERRIDE_REQUIRED]);
14705 verify([source]);
14706 }
14707 void test_invalidSetterOverrideNormalParamType() {
14708 Source source = addSource(EngineTestCase.createSource([
14709 "class A {",
14710 " void set s(int v) {}",
14711 "}",
14712 "class B extends A {",
14713 " void set s(String v) {}",
14714 "}"]));
14715 resolve(source);
14716 assertErrors(source, [StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM _TYPE]);
14717 verify([source]);
14718 }
14719 void test_listElementTypeNotAssignable() {
14720 Source source = addSource(EngineTestCase.createSource(["var v = <String> [42 ];"]));
14721 resolve(source);
14722 assertErrors(source, [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE]);
14723 verify([source]);
14724 }
14725 void test_mapKeyTypeNotAssignable() {
14726 Source source = addSource(EngineTestCase.createSource(["var v = <String, int > {1 : 2};"]));
14727 resolve(source);
14728 assertErrors(source, [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE]);
14729 verify([source]);
14730 }
14731 void test_mapValueTypeNotAssignable() {
14732 Source source = addSource(EngineTestCase.createSource(["var v = <String, Str ing> {'a' : 2};"]));
14733 resolve(source);
14734 assertErrors(source, [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE]);
14735 verify([source]);
14736 }
14737 void test_mismatchedAccessorTypes_class() {
14738 Source source = addSource(EngineTestCase.createSource([
14739 "class A {",
14740 " int get g { return 0; }",
14741 " set g(String v) {}",
14742 "}"]));
14743 resolve(source);
14744 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]) ;
14745 verify([source]);
14746 }
14747 void test_mismatchedAccessorTypes_getterAndSuperSetter() {
14748 Source source = addSource(EngineTestCase.createSource([
14749 "class A {",
14750 " int get g { return 0; }",
14751 "}",
14752 "class B extends A {",
14753 " set g(String v) {}",
14754 "}"]));
14755 resolve(source);
14756 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_F ROM_SUPERTYPE]);
14757 verify([source]);
14758 }
14759 void test_mismatchedAccessorTypes_setterAndSuperGetter() {
14760 Source source = addSource(EngineTestCase.createSource([
14761 "class A {",
14762 " set g(int v) {}",
14763 "}",
14764 "class B extends A {",
14765 " String get g { return ''; }",
14766 "}"]));
14767 resolve(source);
14768 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_F ROM_SUPERTYPE]);
14769 verify([source]);
14770 }
14771 void test_mismatchedAccessorTypes_topLevel() {
14772 Source source = addSource(EngineTestCase.createSource(["int get g { return 0 ; }", "set g(String v) {}"]));
14773 resolve(source);
14774 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]) ;
14775 verify([source]);
14776 }
14777 void test_mixedReturnTypes_localFunction() {
14778 Source source = addSource(EngineTestCase.createSource([
14779 "class C {",
14780 " m(int x) {",
14781 " return (int y) {",
14782 " if (y < 0) {",
14783 " return;",
14784 " }",
14785 " return 0;",
14786 " };",
14787 " }",
14788 "}"]));
14789 resolve(source);
14790 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]);
14791 verify([source]);
14792 }
14793 void test_mixedReturnTypes_method() {
14794 Source source = addSource(EngineTestCase.createSource([
14795 "class C {",
14796 " m(int x) {",
14797 " if (x < 0) {",
14798 " return;",
14799 " }",
14800 " return 0;",
14801 " }",
14802 "}"]));
14803 resolve(source);
14804 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]);
14805 verify([source]);
14806 }
14807 void test_mixedReturnTypes_topLevelFunction() {
14808 Source source = addSource(EngineTestCase.createSource([
14809 "f(int x) {",
14810 " if (x < 0) {",
14811 " return;",
14812 " }",
14813 " return 0;",
14814 "}"]));
14815 resolve(source);
14816 assertErrors(source, [StaticWarningCode.MIXED_RETURN_TYPES]);
14817 verify([source]);
14818 }
14819 void test_newWithAbstractClass() {
14820 Source source = addSource(EngineTestCase.createSource([
14821 "abstract class A {}",
14822 "void f() {",
14823 " A a = new A();",
14824 "}"]));
14825 resolve(source);
14826 assertErrors(source, [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]);
14827 verify([source]);
14828 }
14829 void test_newWithInvalidTypeParameters() {
14830 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"]));
14831 resolve(source);
14832 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
14833 verify([source]);
14834 }
14835 void test_newWithInvalidTypeParameters_tooFew() {
14836 Source source = addSource(EngineTestCase.createSource([
14837 "class A {}",
14838 "class C<K, V> {}",
14839 "f(p) {",
14840 " return new C<A>();",
14841 "}"]));
14842 resolve(source);
14843 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
14844 verify([source]);
14845 }
14846 void test_newWithInvalidTypeParameters_tooMany() {
14847 Source source = addSource(EngineTestCase.createSource([
14848 "class A {}",
14849 "class C<E> {}",
14850 "f(p) {",
14851 " return new C<A, A>();",
14852 "}"]));
14853 resolve(source);
14854 assertErrors(source, [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
14855 verify([source]);
14856 }
14857 void test_newWithNonType() {
14858 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f () {", " var a = new A();", "}"]));
14859 resolve(source);
14860 assertErrors(source, [StaticWarningCode.NEW_WITH_NON_TYPE]);
14861 verify([source]);
14862 }
14863 void test_newWithNonType_fromLibrary() {
14864 Source source1 = addSource2("lib.dart", "class B {}");
14865 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([
14866 "import 'lib.dart' as lib;",
14867 "void f() {",
14868 " var a = new lib.A();",
14869 "}",
14870 "lib.B b;"]));
14871 resolve(source1);
14872 resolve(source2);
14873 assertErrors(source2, [StaticWarningCode.NEW_WITH_NON_TYPE]);
14874 verify([source1]);
14875 }
14876 void test_newWithUndefinedConstructor() {
14877 Source source = addSource(EngineTestCase.createSource([
14878 "class A {",
14879 " A() {}",
14880 "}",
14881 "f() {",
14882 " new A.name();",
14883 "}"]));
14884 resolve(source);
14885 assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]);
14886 }
14887 void test_newWithUndefinedConstructorDefault() {
14888 Source source = addSource(EngineTestCase.createSource([
14889 "class A {",
14890 " A.name() {}",
14891 "}",
14892 "f() {",
14893 " new A();",
14894 "}"]));
14895 resolve(source);
14896 assertErrors(source, [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAU LT]);
14897 verify([source]);
14898 }
14899 void test_nonAbstractClassInheritsAbstractMemberFivePlus() {
14900 Source source = addSource(EngineTestCase.createSource([
14901 "abstract class A {",
14902 " m();",
14903 " n();",
14904 " o();",
14905 " p();",
14906 " q();",
14907 "}",
14908 "class C extends A {",
14909 "}"]));
14910 resolve(source);
14911 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_FIVE_PLUS]);
14912 verify([source]);
14913 }
14914 void test_nonAbstractClassInheritsAbstractMemberFour() {
14915 Source source = addSource(EngineTestCase.createSource([
14916 "abstract class A {",
14917 " m();",
14918 " n();",
14919 " o();",
14920 " p();",
14921 "}",
14922 "class C extends A {",
14923 "}"]));
14924 resolve(source);
14925 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_FOUR]);
14926 verify([source]);
14927 }
14928 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() {
14929 Source source = addSource(EngineTestCase.createSource([
14930 "class I {",
14931 " int get g {return 1;}",
14932 "}",
14933 "class C implements I {",
14934 "}"]));
14935 resolve(source);
14936 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_ONE]);
14937 verify([source]);
14938 }
14939 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() {
14940 Source source = addSource(EngineTestCase.createSource([
14941 "abstract class A {",
14942 " int get g;",
14943 "}",
14944 "class C extends A {",
14945 "}"]));
14946 resolve(source);
14947 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_ONE]);
14948 verify([source]);
14949 }
14950 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() {
14951 Source source = addSource(EngineTestCase.createSource([
14952 "class I {",
14953 " m(p) {}",
14954 "}",
14955 "class C implements I {",
14956 "}"]));
14957 resolve(source);
14958 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_ONE]);
14959 verify([source]);
14960 }
14961 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() {
14962 Source source = addSource(EngineTestCase.createSource([
14963 "abstract class A {",
14964 " m(p);",
14965 "}",
14966 "class C extends A {",
14967 "}"]));
14968 resolve(source);
14969 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_ONE]);
14970 verify([source]);
14971 }
14972 void test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount( ) {
14973 Source source = addSource(EngineTestCase.createSource([
14974 "abstract class A {",
14975 " int x(int a);",
14976 "}",
14977 "abstract class B {",
14978 " int x(int a, [int b]);",
14979 "}",
14980 "class C implements A, B {",
14981 "}"]));
14982 resolve(source);
14983 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_ONE]);
14984 verify([source]);
14985 }
14986 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() {
14987 Source source = addSource(EngineTestCase.createSource([
14988 "class I {",
14989 " set s(int i) {}",
14990 "}",
14991 "class C implements I {",
14992 "}"]));
14993 resolve(source);
14994 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_ONE]);
14995 verify([source]);
14996 }
14997 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() {
14998 Source source = addSource(EngineTestCase.createSource([
14999 "abstract class A {",
15000 " set s(int i);",
15001 "}",
15002 "class C extends A {",
15003 "}"]));
15004 resolve(source);
15005 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_ONE]);
15006 verify([source]);
15007 }
15008 void test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() {
15009 Source source = addSource(EngineTestCase.createSource([
15010 "class A {",
15011 " get a => 'a';",
15012 "}",
15013 "abstract class B implements A {",
15014 " get b => 'b';",
15015 "}",
15016 "class C extends B {",
15017 "}"]));
15018 resolve(source);
15019 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_ONE]);
15020 verify([source]);
15021 }
15022 void test_nonAbstractClassInheritsAbstractMemberThree() {
15023 Source source = addSource(EngineTestCase.createSource([
15024 "abstract class A {",
15025 " m();",
15026 " n();",
15027 " o();",
15028 "}",
15029 "class C extends A {",
15030 "}"]));
15031 resolve(source);
15032 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_THREE]);
15033 verify([source]);
15034 }
15035 void test_nonAbstractClassInheritsAbstractMemberTwo() {
15036 Source source = addSource(EngineTestCase.createSource([
15037 "abstract class A {",
15038 " m();",
15039 " n();",
15040 "}",
15041 "class C extends A {",
15042 "}"]));
15043 resolve(source);
15044 assertErrors(source, [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT _MEMBER_TWO]);
15045 verify([source]);
15046 }
15047 void test_nonTypeInCatchClause_noElement() {
15048 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", " } on T catch (e) {", " }", "}"]));
15049 resolve(source);
15050 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
15051 verify([source]);
15052 }
15053 void test_nonTypeInCatchClause_notType() {
15054 Source source = addSource(EngineTestCase.createSource([
15055 "var T = 0;",
15056 "f() {",
15057 " try {",
15058 " } on T catch (e) {",
15059 " }",
15060 "}"]));
15061 resolve(source);
15062 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
15063 verify([source]);
15064 }
15065 void test_nonVoidReturnForOperator() {
15066 Source source = addSource(EngineTestCase.createSource(["class A {", " int o perator []=(a, b) {}", "}"]));
15067 resolve(source);
15068 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]);
15069 verify([source]);
15070 }
15071 void test_nonVoidReturnForSetter_function() {
15072 Source source = addSource(EngineTestCase.createSource(["int set x(int v) {", " return 42;", "}"]));
15073 resolve(source);
15074 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
15075 verify([source]);
15076 }
15077 void test_nonVoidReturnForSetter_method() {
15078 Source source = addSource(EngineTestCase.createSource([
15079 "class A {",
15080 " int set x(int v) {",
15081 " return 42;",
15082 " }",
15083 "}"]));
15084 resolve(source);
15085 assertErrors(source, [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
15086 verify([source]);
15087 }
15088 void test_notAType() {
15089 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {", " f v = null;", "}"]));
15090 resolve(source);
15091 assertErrors(source, [StaticWarningCode.NOT_A_TYPE]);
15092 verify([source]);
15093 }
15094 void test_notEnoughRequiredArguments() {
15095 Source source = addSource(EngineTestCase.createSource(["f(int a, String b) { }", "main() {", " f();", "}"]));
15096 resolve(source);
15097 assertErrors(source, [StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
15098 verify([source]);
15099 }
15100 void test_partOfDifferentLibrary() {
15101 Source source = addSource(EngineTestCase.createSource(["library lib;", "part 'part.dart';"]));
15102 addSource2("/part.dart", EngineTestCase.createSource(["part of lub;"]));
15103 resolve(source);
15104 assertErrors(source, [StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]);
15105 verify([source]);
15106 }
15107 void test_redirectToInvalidFunctionType() {
15108 Source source = addSource(EngineTestCase.createSource([
15109 "class A implements B {",
15110 " A(int p) {}",
15111 "}",
15112 "class B {",
15113 " factory B() = A;",
15114 "}"]));
15115 resolve(source);
15116 assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]);
15117 verify([source]);
15118 }
15119 void test_redirectToInvalidReturnType() {
15120 Source source = addSource(EngineTestCase.createSource([
15121 "class A {",
15122 " A() {}",
15123 "}",
15124 "class B {",
15125 " factory B() = A;",
15126 "}"]));
15127 resolve(source);
15128 assertErrors(source, [StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]);
15129 verify([source]);
15130 }
15131 void test_redirectToMissingConstructor_named() {
15132 Source source = addSource(EngineTestCase.createSource([
15133 "class A implements B{",
15134 " A() {}",
15135 "}",
15136 "class B {",
15137 " factory B() = A.name;",
15138 "}"]));
15139 resolve(source);
15140 assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
15141 }
15142 void test_redirectToMissingConstructor_unnamed() {
15143 Source source = addSource(EngineTestCase.createSource([
15144 "class A implements B{",
15145 " A.name() {}",
15146 "}",
15147 "class B {",
15148 " factory B() = A;",
15149 "}"]));
15150 resolve(source);
15151 assertErrors(source, [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
15152 }
15153 void test_redirectToNonClass_notAType() {
15154 Source source = addSource(EngineTestCase.createSource(["class B {", " int A ;", " factory B() = A;", "}"]));
15155 resolve(source);
15156 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]);
15157 verify([source]);
15158 }
15159 void test_redirectToNonClass_undefinedIdentifier() {
15160 Source source = addSource(EngineTestCase.createSource(["class B {", " facto ry B() = A;", "}"]));
15161 resolve(source);
15162 assertErrors(source, [StaticWarningCode.REDIRECT_TO_NON_CLASS]);
15163 verify([source]);
15164 }
15165 void test_returnWithoutValue() {
15166 Source source = addSource(EngineTestCase.createSource(["int f() { return; }" ]));
15167 resolve(source);
15168 assertErrors(source, [StaticWarningCode.RETURN_WITHOUT_VALUE]);
15169 verify([source]);
15170 }
15171 void test_staticAccessToInstanceMember_method_invocation() {
15172 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "main() {", " A.m();", "}"]));
15173 resolve(source);
15174 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
15175 verify([source]);
15176 }
15177 void test_staticAccessToInstanceMember_method_reference() {
15178 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "main() {", " A.m;", "}"]));
15179 resolve(source);
15180 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
15181 verify([source]);
15182 }
15183 void test_staticAccessToInstanceMember_propertyAccess_field() {
15184 Source source = addSource(EngineTestCase.createSource(["class A {", " var f ;", "}", "main() {", " A.f;", "}"]));
15185 resolve(source);
15186 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
15187 verify([source]);
15188 }
15189 void test_staticAccessToInstanceMember_propertyAccess_getter() {
15190 Source source = addSource(EngineTestCase.createSource([
15191 "class A {",
15192 " get f => 42;",
15193 "}",
15194 "main() {",
15195 " A.f;",
15196 "}"]));
15197 resolve(source);
15198 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
15199 verify([source]);
15200 }
15201 void test_staticAccessToInstanceMember_propertyAccess_setter() {
15202 Source source = addSource(EngineTestCase.createSource([
15203 "class A {",
15204 " set f(x) {}",
15205 "}",
15206 "main() {",
15207 " A.f = 42;",
15208 "}"]));
15209 resolve(source);
15210 assertErrors(source, [StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
15211 verify([source]);
15212 }
15213 void test_switchExpressionNotAssignable() {
15214 Source source = addSource(EngineTestCase.createSource([
15215 "f(int p) {",
15216 " switch (p) {",
15217 " case 'a': break;",
15218 " }",
15219 "}"]));
15220 resolve(source);
15221 assertErrors(source, [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]);
15222 verify([source]);
15223 }
15224 void test_typeParameterReferencedByStatic_field() {
15225 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st atic K k;", "}"]));
15226 resolve(source);
15227 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC] );
15228 verify([source]);
15229 }
15230 void test_typeParameterReferencedByStatic_getter() {
15231 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st atic K get k => 0;", "}"]));
15232 resolve(source);
15233 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC] );
15234 verify([source]);
15235 }
15236 void test_typeParameterReferencedByStatic_methodBodyReference() {
15237 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st atic m() {", " K k;", " }", "}"]));
15238 resolve(source);
15239 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC] );
15240 verify([source]);
15241 }
15242 void test_typeParameterReferencedByStatic_methodParameter() {
15243 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st atic m(K k) {}", "}"]));
15244 resolve(source);
15245 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC] );
15246 verify([source]);
15247 }
15248 void test_typeParameterReferencedByStatic_methodReturn() {
15249 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st atic K m() {}", "}"]));
15250 resolve(source);
15251 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC] );
15252 verify([source]);
15253 }
15254 void test_typeParameterReferencedByStatic_setter() {
15255 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " st atic set s(K k) {}", "}"]));
15256 resolve(source);
15257 assertErrors(source, [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC] );
15258 verify([source]);
15259 }
15260 void test_typePromotion_functionType_arg_InterToDyn() {
15261 Source source = addSource(EngineTestCase.createSource([
15262 "typedef FuncDyn(x);",
15263 "typedef FuncA(A a);",
15264 "class A {}",
15265 "class B {}",
15266 "main(FuncA f) {",
15267 " if (f is FuncDyn) {",
15268 " f(new B());",
15269 " }",
15270 "}"]));
15271 resolve(source);
15272 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
15273 }
15274 void test_typeTestNonType() {
15275 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(var p) {", " if (p is A) {", " }", "}"]));
15276 resolve(source);
15277 assertErrors(source, [StaticWarningCode.TYPE_TEST_NON_TYPE]);
15278 verify([source]);
15279 }
15280 void test_undefinedClass_instanceCreation() {
15281 Source source = addSource(EngineTestCase.createSource(["f() { new C(); }"])) ;
15282 resolve(source);
15283 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
15284 }
15285 void test_undefinedClass_variableDeclaration() {
15286 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"]));
15287 resolve(source);
15288 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS]);
15289 }
15290 void test_undefinedClassBoolean_variableDeclaration() {
15291 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"] ));
15292 resolve(source);
15293 assertErrors(source, [StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]);
15294 }
15295 void test_undefinedGetter_fromLibrary() {
15296 Source source1 = addSource2("lib.dart", "");
15297 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([
15298 "import 'lib.dart' as lib;",
15299 "void f() {",
15300 " var g = lib.gg;",
15301 "}"]));
15302 resolve(source1);
15303 resolve(source2);
15304 assertErrors(source2, [StaticWarningCode.UNDEFINED_GETTER]);
15305 verify([source1]);
15306 }
15307 void test_undefinedIdentifier_for() {
15308 Source source = addSource(EngineTestCase.createSource(["f(var l) {", " for (e in l) {", " }", "}"]));
15309 resolve(source);
15310 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15311 }
15312 void test_undefinedIdentifier_function() {
15313 Source source = addSource(EngineTestCase.createSource(["int a() => b;"]));
15314 resolve(source);
15315 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15316 }
15317 void test_undefinedIdentifier_function_prefix() {
15318 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class C {}"]));
15319 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as b;", "", "int a() => b;", "b.C c;"]));
15320 resolve(source);
15321 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15322 verify([source]);
15323 }
15324 void test_undefinedIdentifier_initializer() {
15325 Source source = addSource(EngineTestCase.createSource(["var a = b;"]));
15326 resolve(source);
15327 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15328 }
15329 void test_undefinedIdentifier_initializer_prefix() {
15330 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class C {}"]));
15331 Source source = addSource(EngineTestCase.createSource(["import 'lib.dart' as b;", "", "var a = b;", "b.C c;"]));
15332 resolve(source);
15333 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15334 }
15335 void test_undefinedIdentifier_metadata() {
15336 Source source = addSource(EngineTestCase.createSource(["@undefined class A { }"]));
15337 resolve(source);
15338 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15339 }
15340 void test_undefinedIdentifier_methodInvocation() {
15341 Source source = addSource(EngineTestCase.createSource(["f() { C.m(); }"]));
15342 resolve(source);
15343 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15344 }
15345 void test_undefinedIdentifier_private_getter() {
15346 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class A {", " var _foo;", "}"]));
15347 Source source = addSource(EngineTestCase.createSource([
15348 "import 'lib.dart';",
15349 "class B extends A {",
15350 " test() {",
15351 " var v = _foo;",
15352 " }",
15353 "}"]));
15354 resolve(source);
15355 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15356 }
15357 void test_undefinedIdentifier_private_setter() {
15358 addSource2("/lib.dart", EngineTestCase.createSource(["library lib;", "class A {", " var _foo;", "}"]));
15359 Source source = addSource(EngineTestCase.createSource([
15360 "import 'lib.dart';",
15361 "class B extends A {",
15362 " test() {",
15363 " _foo = 42;",
15364 " }",
15365 "}"]));
15366 resolve(source);
15367 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
15368 }
15369 void test_undefinedNamedParameter() {
15370 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main () {", " f(c: 1);", "}"]));
15371 resolve(source);
15372 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]);
15373 }
15374 void test_undefinedSetter() {
15375 Source source1 = addSource2("lib.dart", "");
15376 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource([
15377 "import 'lib.dart' as lib;",
15378 "void f() {",
15379 " lib.gg = null;",
15380 "}"]));
15381 resolve(source1);
15382 resolve(source2);
15383 assertErrors(source2, [StaticWarningCode.UNDEFINED_SETTER]);
15384 }
15385 static dartSuite() {
15386 _ut.group('StaticWarningCodeTest', () {
15387 _ut.test('test_ambiguousImport_as', () {
15388 final __test = new StaticWarningCodeTest();
15389 runJUnitTest(__test, __test.test_ambiguousImport_as);
15390 });
15391 _ut.test('test_ambiguousImport_extends', () {
15392 final __test = new StaticWarningCodeTest();
15393 runJUnitTest(__test, __test.test_ambiguousImport_extends);
15394 });
15395 _ut.test('test_ambiguousImport_implements', () {
15396 final __test = new StaticWarningCodeTest();
15397 runJUnitTest(__test, __test.test_ambiguousImport_implements);
15398 });
15399 _ut.test('test_ambiguousImport_inPart', () {
15400 final __test = new StaticWarningCodeTest();
15401 runJUnitTest(__test, __test.test_ambiguousImport_inPart);
15402 });
15403 _ut.test('test_ambiguousImport_instanceCreation', () {
15404 final __test = new StaticWarningCodeTest();
15405 runJUnitTest(__test, __test.test_ambiguousImport_instanceCreation);
15406 });
15407 _ut.test('test_ambiguousImport_is', () {
15408 final __test = new StaticWarningCodeTest();
15409 runJUnitTest(__test, __test.test_ambiguousImport_is);
15410 });
15411 _ut.test('test_ambiguousImport_qualifier', () {
15412 final __test = new StaticWarningCodeTest();
15413 runJUnitTest(__test, __test.test_ambiguousImport_qualifier);
15414 });
15415 _ut.test('test_ambiguousImport_typeAnnotation', () {
15416 final __test = new StaticWarningCodeTest();
15417 runJUnitTest(__test, __test.test_ambiguousImport_typeAnnotation);
15418 });
15419 _ut.test('test_ambiguousImport_typeArgument_annotation', () {
15420 final __test = new StaticWarningCodeTest();
15421 runJUnitTest(__test, __test.test_ambiguousImport_typeArgument_annotation );
15422 });
15423 _ut.test('test_ambiguousImport_typeArgument_instanceCreation', () {
15424 final __test = new StaticWarningCodeTest();
15425 runJUnitTest(__test, __test.test_ambiguousImport_typeArgument_instanceCr eation);
15426 });
15427 _ut.test('test_ambiguousImport_varRead', () {
15428 final __test = new StaticWarningCodeTest();
15429 runJUnitTest(__test, __test.test_ambiguousImport_varRead);
15430 });
15431 _ut.test('test_ambiguousImport_varWrite', () {
15432 final __test = new StaticWarningCodeTest();
15433 runJUnitTest(__test, __test.test_ambiguousImport_varWrite);
15434 });
15435 _ut.test('test_argumentTypeNotAssignable_annotation_namedConstructor', () {
15436 final __test = new StaticWarningCodeTest();
15437 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_annotation_na medConstructor);
15438 });
15439 _ut.test('test_argumentTypeNotAssignable_annotation_unnamedConstructor', ( ) {
15440 final __test = new StaticWarningCodeTest();
15441 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_annotation_un namedConstructor);
15442 });
15443 _ut.test('test_argumentTypeNotAssignable_binary', () {
15444 final __test = new StaticWarningCodeTest();
15445 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_binary);
15446 });
15447 _ut.test('test_argumentTypeNotAssignable_const', () {
15448 final __test = new StaticWarningCodeTest();
15449 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_const);
15450 });
15451 _ut.test('test_argumentTypeNotAssignable_const_super', () {
15452 final __test = new StaticWarningCodeTest();
15453 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_const_super);
15454 });
15455 _ut.test('test_argumentTypeNotAssignable_index', () {
15456 final __test = new StaticWarningCodeTest();
15457 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_index);
15458 });
15459 _ut.test('test_argumentTypeNotAssignable_invocation_callParameter', () {
15460 final __test = new StaticWarningCodeTest();
15461 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ca llParameter);
15462 });
15463 _ut.test('test_argumentTypeNotAssignable_invocation_callVariable', () {
15464 final __test = new StaticWarningCodeTest();
15465 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ca llVariable);
15466 });
15467 _ut.test('test_argumentTypeNotAssignable_invocation_functionParameter', () {
15468 final __test = new StaticWarningCodeTest();
15469 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_fu nctionParameter);
15470 });
15471 _ut.test('test_argumentTypeNotAssignable_invocation_functionParameter_gene ric', () {
15472 final __test = new StaticWarningCodeTest();
15473 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_fu nctionParameter_generic);
15474 });
15475 _ut.test('test_argumentTypeNotAssignable_invocation_functionTypes_optional ', () {
15476 final __test = new StaticWarningCodeTest();
15477 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_fu nctionTypes_optional);
15478 });
15479 _ut.test('test_argumentTypeNotAssignable_invocation_generic', () {
15480 final __test = new StaticWarningCodeTest();
15481 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ge neric);
15482 });
15483 _ut.test('test_argumentTypeNotAssignable_invocation_named', () {
15484 final __test = new StaticWarningCodeTest();
15485 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_na med);
15486 });
15487 _ut.test('test_argumentTypeNotAssignable_invocation_optional', () {
15488 final __test = new StaticWarningCodeTest();
15489 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_op tional);
15490 });
15491 _ut.test('test_argumentTypeNotAssignable_invocation_required', () {
15492 final __test = new StaticWarningCodeTest();
15493 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_re quired);
15494 });
15495 _ut.test('test_argumentTypeNotAssignable_invocation_typedef_generic', () {
15496 final __test = new StaticWarningCodeTest();
15497 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ty pedef_generic);
15498 });
15499 _ut.test('test_argumentTypeNotAssignable_invocation_typedef_local', () {
15500 final __test = new StaticWarningCodeTest();
15501 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ty pedef_local);
15502 });
15503 _ut.test('test_argumentTypeNotAssignable_invocation_typedef_parameter', () {
15504 final __test = new StaticWarningCodeTest();
15505 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ty pedef_parameter);
15506 });
15507 _ut.test('test_argumentTypeNotAssignable_new_generic', () {
15508 final __test = new StaticWarningCodeTest();
15509 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_new_generic);
15510 });
15511 _ut.test('test_argumentTypeNotAssignable_new_optional', () {
15512 final __test = new StaticWarningCodeTest();
15513 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_new_optional) ;
15514 });
15515 _ut.test('test_argumentTypeNotAssignable_new_required', () {
15516 final __test = new StaticWarningCodeTest();
15517 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_new_required) ;
15518 });
15519 _ut.test('test_assignmentToConst_instanceVariable', () {
15520 final __test = new StaticWarningCodeTest();
15521 runJUnitTest(__test, __test.test_assignmentToConst_instanceVariable);
15522 });
15523 _ut.test('test_assignmentToConst_localVariable', () {
15524 final __test = new StaticWarningCodeTest();
15525 runJUnitTest(__test, __test.test_assignmentToConst_localVariable);
15526 });
15527 _ut.test('test_assignmentToFinal_instanceVariable', () {
15528 final __test = new StaticWarningCodeTest();
15529 runJUnitTest(__test, __test.test_assignmentToFinal_instanceVariable);
15530 });
15531 _ut.test('test_assignmentToFinal_localVariable', () {
15532 final __test = new StaticWarningCodeTest();
15533 runJUnitTest(__test, __test.test_assignmentToFinal_localVariable);
15534 });
15535 _ut.test('test_assignmentToFinal_prefixMinusMinus', () {
15536 final __test = new StaticWarningCodeTest();
15537 runJUnitTest(__test, __test.test_assignmentToFinal_prefixMinusMinus);
15538 });
15539 _ut.test('test_assignmentToFinal_prefixPlusPlus', () {
15540 final __test = new StaticWarningCodeTest();
15541 runJUnitTest(__test, __test.test_assignmentToFinal_prefixPlusPlus);
15542 });
15543 _ut.test('test_assignmentToFinal_propertyAccess', () {
15544 final __test = new StaticWarningCodeTest();
15545 runJUnitTest(__test, __test.test_assignmentToFinal_propertyAccess);
15546 });
15547 _ut.test('test_assignmentToFinal_suffixMinusMinus', () {
15548 final __test = new StaticWarningCodeTest();
15549 runJUnitTest(__test, __test.test_assignmentToFinal_suffixMinusMinus);
15550 });
15551 _ut.test('test_assignmentToFinal_suffixPlusPlus', () {
15552 final __test = new StaticWarningCodeTest();
15553 runJUnitTest(__test, __test.test_assignmentToFinal_suffixPlusPlus);
15554 });
15555 _ut.test('test_assignmentToFinal_topLevelVariable', () {
15556 final __test = new StaticWarningCodeTest();
15557 runJUnitTest(__test, __test.test_assignmentToFinal_topLevelVariable);
15558 });
15559 _ut.test('test_assignmentToMethod', () {
15560 final __test = new StaticWarningCodeTest();
15561 runJUnitTest(__test, __test.test_assignmentToMethod);
15562 });
15563 _ut.test('test_caseBlockNotTerminated', () {
15564 final __test = new StaticWarningCodeTest();
15565 runJUnitTest(__test, __test.test_caseBlockNotTerminated);
15566 });
15567 _ut.test('test_castToNonType', () {
15568 final __test = new StaticWarningCodeTest();
15569 runJUnitTest(__test, __test.test_castToNonType);
15570 });
15571 _ut.test('test_concreteClassWithAbstractMember', () {
15572 final __test = new StaticWarningCodeTest();
15573 runJUnitTest(__test, __test.test_concreteClassWithAbstractMember);
15574 });
15575 _ut.test('test_conflictingDartImport', () {
15576 final __test = new StaticWarningCodeTest();
15577 runJUnitTest(__test, __test.test_conflictingDartImport);
15578 });
15579 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_field', () {
15580 final __test = new StaticWarningCodeTest();
15581 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_direct_field);
15582 });
15583 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_getter' , () {
15584 final __test = new StaticWarningCodeTest();
15585 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_direct_getter);
15586 });
15587 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_method' , () {
15588 final __test = new StaticWarningCodeTest();
15589 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_direct_method);
15590 });
15591 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_setter' , () {
15592 final __test = new StaticWarningCodeTest();
15593 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_direct_setter);
15594 });
15595 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_indirect', () {
15596 final __test = new StaticWarningCodeTest();
15597 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_indirect);
15598 });
15599 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_mixin', () {
15600 final __test = new StaticWarningCodeTest();
15601 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_mixin);
15602 });
15603 _ut.test('test_conflictingInstanceSetterAndSuperclassMember', () {
15604 final __test = new StaticWarningCodeTest();
15605 runJUnitTest(__test, __test.test_conflictingInstanceSetterAndSuperclassM ember);
15606 });
15607 _ut.test('test_conflictingStaticGetterAndInstanceSetter_mixin', () {
15608 final __test = new StaticWarningCodeTest();
15609 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette r_mixin);
15610 });
15611 _ut.test('test_conflictingStaticGetterAndInstanceSetter_superClass', () {
15612 final __test = new StaticWarningCodeTest();
15613 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette r_superClass);
15614 });
15615 _ut.test('test_conflictingStaticGetterAndInstanceSetter_thisClass', () {
15616 final __test = new StaticWarningCodeTest();
15617 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette r_thisClass);
15618 });
15619 _ut.test('test_conflictingStaticSetterAndInstanceMember_thisClass_getter', () {
15620 final __test = new StaticWarningCodeTest();
15621 runJUnitTest(__test, __test.test_conflictingStaticSetterAndInstanceMembe r_thisClass_getter);
15622 });
15623 _ut.test('test_conflictingStaticSetterAndInstanceMember_thisClass_method', () {
15624 final __test = new StaticWarningCodeTest();
15625 runJUnitTest(__test, __test.test_conflictingStaticSetterAndInstanceMembe r_thisClass_method);
15626 });
15627 _ut.test('test_constWithAbstractClass', () {
15628 final __test = new StaticWarningCodeTest();
15629 runJUnitTest(__test, __test.test_constWithAbstractClass);
15630 });
15631 _ut.test('test_equalKeysInMap', () {
15632 final __test = new StaticWarningCodeTest();
15633 runJUnitTest(__test, __test.test_equalKeysInMap);
15634 });
15635 _ut.test('test_exportDuplicatedLibraryName', () {
15636 final __test = new StaticWarningCodeTest();
15637 runJUnitTest(__test, __test.test_exportDuplicatedLibraryName);
15638 });
15639 _ut.test('test_extraPositionalArguments', () {
15640 final __test = new StaticWarningCodeTest();
15641 runJUnitTest(__test, __test.test_extraPositionalArguments);
15642 });
15643 _ut.test('test_fieldInitializedInInitializerAndDeclaration_final', () {
15644 final __test = new StaticWarningCodeTest();
15645 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_final);
15646 });
15647 _ut.test('test_fieldInitializerNotAssignable', () {
15648 final __test = new StaticWarningCodeTest();
15649 runJUnitTest(__test, __test.test_fieldInitializerNotAssignable);
15650 });
15651 _ut.test('test_fieldInitializingFormalNotAssignable', () {
15652 final __test = new StaticWarningCodeTest();
15653 runJUnitTest(__test, __test.test_fieldInitializingFormalNotAssignable);
15654 });
15655 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializers', () {
15656 final __test = new StaticWarningCodeTest();
15657 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializers);
15658 });
15659 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializingFor mal', () {
15660 final __test = new StaticWarningCodeTest();
15661 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializingFormal);
15662 });
15663 _ut.test('test_finalNotInitialized_inConstructor', () {
15664 final __test = new StaticWarningCodeTest();
15665 runJUnitTest(__test, __test.test_finalNotInitialized_inConstructor);
15666 });
15667 _ut.test('test_finalNotInitialized_instanceField_final', () {
15668 final __test = new StaticWarningCodeTest();
15669 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_final );
15670 });
15671 _ut.test('test_finalNotInitialized_instanceField_final_static', () {
15672 final __test = new StaticWarningCodeTest();
15673 runJUnitTest(__test, __test.test_finalNotInitialized_instanceField_final _static);
15674 });
15675 _ut.test('test_finalNotInitialized_library_final', () {
15676 final __test = new StaticWarningCodeTest();
15677 runJUnitTest(__test, __test.test_finalNotInitialized_library_final);
15678 });
15679 _ut.test('test_finalNotInitialized_local_final', () {
15680 final __test = new StaticWarningCodeTest();
15681 runJUnitTest(__test, __test.test_finalNotInitialized_local_final);
15682 });
15683 _ut.test('test_functionWithoutCall_direct', () {
15684 final __test = new StaticWarningCodeTest();
15685 runJUnitTest(__test, __test.test_functionWithoutCall_direct);
15686 });
15687 _ut.test('test_functionWithoutCall_indirect_extends', () {
15688 final __test = new StaticWarningCodeTest();
15689 runJUnitTest(__test, __test.test_functionWithoutCall_indirect_extends);
15690 });
15691 _ut.test('test_functionWithoutCall_indirect_implements', () {
15692 final __test = new StaticWarningCodeTest();
15693 runJUnitTest(__test, __test.test_functionWithoutCall_indirect_implements );
15694 });
15695 _ut.test('test_importDuplicatedLibraryName', () {
15696 final __test = new StaticWarningCodeTest();
15697 runJUnitTest(__test, __test.test_importDuplicatedLibraryName);
15698 });
15699 _ut.test('test_inconsistentMethodInheritanceGetterAndMethod', () {
15700 final __test = new StaticWarningCodeTest();
15701 runJUnitTest(__test, __test.test_inconsistentMethodInheritanceGetterAndM ethod);
15702 });
15703 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_field', () {
15704 final __test = new StaticWarningCodeTest();
15705 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_field);
15706 });
15707 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_field2', () {
15708 final __test = new StaticWarningCodeTest();
15709 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_field2);
15710 });
15711 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_getter', () {
15712 final __test = new StaticWarningCodeTest();
15713 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_getter);
15714 });
15715 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_getter2', () {
15716 final __test = new StaticWarningCodeTest();
15717 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_getter2);
15718 });
15719 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_method', () {
15720 final __test = new StaticWarningCodeTest();
15721 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_method);
15722 });
15723 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_method2', () {
15724 final __test = new StaticWarningCodeTest();
15725 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_method2);
15726 });
15727 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_setter', () {
15728 final __test = new StaticWarningCodeTest();
15729 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_setter);
15730 });
15731 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_setter2', () {
15732 final __test = new StaticWarningCodeTest();
15733 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_setter2);
15734 });
15735 _ut.test('test_invalidGetterOverrideReturnType', () {
15736 final __test = new StaticWarningCodeTest();
15737 runJUnitTest(__test, __test.test_invalidGetterOverrideReturnType);
15738 });
15739 _ut.test('test_invalidGetterOverrideReturnType_implicit', () {
15740 final __test = new StaticWarningCodeTest();
15741 runJUnitTest(__test, __test.test_invalidGetterOverrideReturnType_implici t);
15742 });
15743 _ut.test('test_invalidMethodOverrideNamedParamType', () {
15744 final __test = new StaticWarningCodeTest();
15745 runJUnitTest(__test, __test.test_invalidMethodOverrideNamedParamType);
15746 });
15747 _ut.test('test_invalidMethodOverrideNormalParamType', () {
15748 final __test = new StaticWarningCodeTest();
15749 runJUnitTest(__test, __test.test_invalidMethodOverrideNormalParamType);
15750 });
15751 _ut.test('test_invalidMethodOverrideOptionalParamType', () {
15752 final __test = new StaticWarningCodeTest();
15753 runJUnitTest(__test, __test.test_invalidMethodOverrideOptionalParamType) ;
15754 });
15755 _ut.test('test_invalidMethodOverrideReturnType_interface', () {
15756 final __test = new StaticWarningCodeTest();
15757 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_interfa ce);
15758 });
15759 _ut.test('test_invalidMethodOverrideReturnType_interface2', () {
15760 final __test = new StaticWarningCodeTest();
15761 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_interfa ce2);
15762 });
15763 _ut.test('test_invalidMethodOverrideReturnType_mixin', () {
15764 final __test = new StaticWarningCodeTest();
15765 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_mixin);
15766 });
15767 _ut.test('test_invalidMethodOverrideReturnType_superclass', () {
15768 final __test = new StaticWarningCodeTest();
15769 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_supercl ass);
15770 });
15771 _ut.test('test_invalidMethodOverrideReturnType_superclass2', () {
15772 final __test = new StaticWarningCodeTest();
15773 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_supercl ass2);
15774 });
15775 _ut.test('test_invalidMethodOverrideReturnType_void', () {
15776 final __test = new StaticWarningCodeTest();
15777 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_void);
15778 });
15779 _ut.test('test_invalidOverrideDifferentDefaultValues_named', () {
15780 final __test = new StaticWarningCodeTest();
15781 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_n amed);
15782 });
15783 _ut.test('test_invalidOverrideDifferentDefaultValues_positional', () {
15784 final __test = new StaticWarningCodeTest();
15785 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p ositional);
15786 });
15787 _ut.test('test_invalidOverrideNamed_fewerNamedParameters', () {
15788 final __test = new StaticWarningCodeTest();
15789 runJUnitTest(__test, __test.test_invalidOverrideNamed_fewerNamedParamete rs);
15790 });
15791 _ut.test('test_invalidOverrideNamed_missingNamedParameter', () {
15792 final __test = new StaticWarningCodeTest();
15793 runJUnitTest(__test, __test.test_invalidOverrideNamed_missingNamedParame ter);
15794 });
15795 _ut.test('test_invalidOverridePositional_optional', () {
15796 final __test = new StaticWarningCodeTest();
15797 runJUnitTest(__test, __test.test_invalidOverridePositional_optional);
15798 });
15799 _ut.test('test_invalidOverridePositional_optionalAndRequired', () {
15800 final __test = new StaticWarningCodeTest();
15801 runJUnitTest(__test, __test.test_invalidOverridePositional_optionalAndRe quired);
15802 });
15803 _ut.test('test_invalidOverridePositional_optionalAndRequired2', () {
15804 final __test = new StaticWarningCodeTest();
15805 runJUnitTest(__test, __test.test_invalidOverridePositional_optionalAndRe quired2);
15806 });
15807 _ut.test('test_invalidOverrideRequired', () {
15808 final __test = new StaticWarningCodeTest();
15809 runJUnitTest(__test, __test.test_invalidOverrideRequired);
15810 });
15811 _ut.test('test_invalidSetterOverrideNormalParamType', () {
15812 final __test = new StaticWarningCodeTest();
15813 runJUnitTest(__test, __test.test_invalidSetterOverrideNormalParamType);
15814 });
15815 _ut.test('test_listElementTypeNotAssignable', () {
15816 final __test = new StaticWarningCodeTest();
15817 runJUnitTest(__test, __test.test_listElementTypeNotAssignable);
15818 });
15819 _ut.test('test_mapKeyTypeNotAssignable', () {
15820 final __test = new StaticWarningCodeTest();
15821 runJUnitTest(__test, __test.test_mapKeyTypeNotAssignable);
15822 });
15823 _ut.test('test_mapValueTypeNotAssignable', () {
15824 final __test = new StaticWarningCodeTest();
15825 runJUnitTest(__test, __test.test_mapValueTypeNotAssignable);
15826 });
15827 _ut.test('test_mismatchedAccessorTypes_class', () {
15828 final __test = new StaticWarningCodeTest();
15829 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_class);
15830 });
15831 _ut.test('test_mismatchedAccessorTypes_getterAndSuperSetter', () {
15832 final __test = new StaticWarningCodeTest();
15833 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_getterAndSuperS etter);
15834 });
15835 _ut.test('test_mismatchedAccessorTypes_setterAndSuperGetter', () {
15836 final __test = new StaticWarningCodeTest();
15837 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_setterAndSuperG etter);
15838 });
15839 _ut.test('test_mismatchedAccessorTypes_topLevel', () {
15840 final __test = new StaticWarningCodeTest();
15841 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_topLevel);
15842 });
15843 _ut.test('test_mixedReturnTypes_localFunction', () {
15844 final __test = new StaticWarningCodeTest();
15845 runJUnitTest(__test, __test.test_mixedReturnTypes_localFunction);
15846 });
15847 _ut.test('test_mixedReturnTypes_method', () {
15848 final __test = new StaticWarningCodeTest();
15849 runJUnitTest(__test, __test.test_mixedReturnTypes_method);
15850 });
15851 _ut.test('test_mixedReturnTypes_topLevelFunction', () {
15852 final __test = new StaticWarningCodeTest();
15853 runJUnitTest(__test, __test.test_mixedReturnTypes_topLevelFunction);
15854 });
15855 _ut.test('test_newWithAbstractClass', () {
15856 final __test = new StaticWarningCodeTest();
15857 runJUnitTest(__test, __test.test_newWithAbstractClass);
15858 });
15859 _ut.test('test_newWithInvalidTypeParameters', () {
15860 final __test = new StaticWarningCodeTest();
15861 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters);
15862 });
15863 _ut.test('test_newWithInvalidTypeParameters_tooFew', () {
15864 final __test = new StaticWarningCodeTest();
15865 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters_tooFew);
15866 });
15867 _ut.test('test_newWithInvalidTypeParameters_tooMany', () {
15868 final __test = new StaticWarningCodeTest();
15869 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters_tooMany);
15870 });
15871 _ut.test('test_newWithNonType', () {
15872 final __test = new StaticWarningCodeTest();
15873 runJUnitTest(__test, __test.test_newWithNonType);
15874 });
15875 _ut.test('test_newWithNonType_fromLibrary', () {
15876 final __test = new StaticWarningCodeTest();
15877 runJUnitTest(__test, __test.test_newWithNonType_fromLibrary);
15878 });
15879 _ut.test('test_newWithUndefinedConstructor', () {
15880 final __test = new StaticWarningCodeTest();
15881 runJUnitTest(__test, __test.test_newWithUndefinedConstructor);
15882 });
15883 _ut.test('test_newWithUndefinedConstructorDefault', () {
15884 final __test = new StaticWarningCodeTest();
15885 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault);
15886 });
15887 _ut.test('test_nonAbstractClassInheritsAbstractMemberFivePlus', () {
15888 final __test = new StaticWarningCodeTest();
15889 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF ivePlus);
15890 });
15891 _ut.test('test_nonAbstractClassInheritsAbstractMemberFour', () {
15892 final __test = new StaticWarningCodeTest();
15893 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF our);
15894 });
15895 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterf ace', () {
15896 final __test = new StaticWarningCodeTest();
15897 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_getter_fromInterface);
15898 });
15899 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperc lass', () {
15900 final __test = new StaticWarningCodeTest();
15901 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_getter_fromSuperclass);
15902 });
15903 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterf ace', () {
15904 final __test = new StaticWarningCodeTest();
15905 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_method_fromInterface);
15906 });
15907 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperc lass', () {
15908 final __test = new StaticWarningCodeTest();
15909 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_method_fromSuperclass);
15910 });
15911 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_method_optionalPa ramCount', () {
15912 final __test = new StaticWarningCodeTest();
15913 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_method_optionalParamCount);
15914 });
15915 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterf ace', () {
15916 final __test = new StaticWarningCodeTest();
15917 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_setter_fromInterface);
15918 });
15919 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperc lass', () {
15920 final __test = new StaticWarningCodeTest();
15921 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_setter_fromSuperclass);
15922 });
15923 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_superclasses_inte rface', () {
15924 final __test = new StaticWarningCodeTest();
15925 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_superclasses_interface);
15926 });
15927 _ut.test('test_nonAbstractClassInheritsAbstractMemberThree', () {
15928 final __test = new StaticWarningCodeTest();
15929 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberT hree);
15930 });
15931 _ut.test('test_nonAbstractClassInheritsAbstractMemberTwo', () {
15932 final __test = new StaticWarningCodeTest();
15933 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberT wo);
15934 });
15935 _ut.test('test_nonTypeInCatchClause_noElement', () {
15936 final __test = new StaticWarningCodeTest();
15937 runJUnitTest(__test, __test.test_nonTypeInCatchClause_noElement);
15938 });
15939 _ut.test('test_nonTypeInCatchClause_notType', () {
15940 final __test = new StaticWarningCodeTest();
15941 runJUnitTest(__test, __test.test_nonTypeInCatchClause_notType);
15942 });
15943 _ut.test('test_nonVoidReturnForOperator', () {
15944 final __test = new StaticWarningCodeTest();
15945 runJUnitTest(__test, __test.test_nonVoidReturnForOperator);
15946 });
15947 _ut.test('test_nonVoidReturnForSetter_function', () {
15948 final __test = new StaticWarningCodeTest();
15949 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_function);
15950 });
15951 _ut.test('test_nonVoidReturnForSetter_method', () {
15952 final __test = new StaticWarningCodeTest();
15953 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_method);
15954 });
15955 _ut.test('test_notAType', () {
15956 final __test = new StaticWarningCodeTest();
15957 runJUnitTest(__test, __test.test_notAType);
15958 });
15959 _ut.test('test_notEnoughRequiredArguments', () {
15960 final __test = new StaticWarningCodeTest();
15961 runJUnitTest(__test, __test.test_notEnoughRequiredArguments);
15962 });
15963 _ut.test('test_partOfDifferentLibrary', () {
15964 final __test = new StaticWarningCodeTest();
15965 runJUnitTest(__test, __test.test_partOfDifferentLibrary);
15966 });
15967 _ut.test('test_redirectToInvalidFunctionType', () {
15968 final __test = new StaticWarningCodeTest();
15969 runJUnitTest(__test, __test.test_redirectToInvalidFunctionType);
15970 });
15971 _ut.test('test_redirectToInvalidReturnType', () {
15972 final __test = new StaticWarningCodeTest();
15973 runJUnitTest(__test, __test.test_redirectToInvalidReturnType);
15974 });
15975 _ut.test('test_redirectToMissingConstructor_named', () {
15976 final __test = new StaticWarningCodeTest();
15977 runJUnitTest(__test, __test.test_redirectToMissingConstructor_named);
15978 });
15979 _ut.test('test_redirectToMissingConstructor_unnamed', () {
15980 final __test = new StaticWarningCodeTest();
15981 runJUnitTest(__test, __test.test_redirectToMissingConstructor_unnamed);
15982 });
15983 _ut.test('test_redirectToNonClass_notAType', () {
15984 final __test = new StaticWarningCodeTest();
15985 runJUnitTest(__test, __test.test_redirectToNonClass_notAType);
15986 });
15987 _ut.test('test_redirectToNonClass_undefinedIdentifier', () {
15988 final __test = new StaticWarningCodeTest();
15989 runJUnitTest(__test, __test.test_redirectToNonClass_undefinedIdentifier) ;
15990 });
15991 _ut.test('test_returnWithoutValue', () {
15992 final __test = new StaticWarningCodeTest();
15993 runJUnitTest(__test, __test.test_returnWithoutValue);
15994 });
15995 _ut.test('test_staticAccessToInstanceMember_method_invocation', () {
15996 final __test = new StaticWarningCodeTest();
15997 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method_inv ocation);
15998 });
15999 _ut.test('test_staticAccessToInstanceMember_method_reference', () {
16000 final __test = new StaticWarningCodeTest();
16001 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method_ref erence);
16002 });
16003 _ut.test('test_staticAccessToInstanceMember_propertyAccess_field', () {
16004 final __test = new StaticWarningCodeTest();
16005 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_field);
16006 });
16007 _ut.test('test_staticAccessToInstanceMember_propertyAccess_getter', () {
16008 final __test = new StaticWarningCodeTest();
16009 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_getter);
16010 });
16011 _ut.test('test_staticAccessToInstanceMember_propertyAccess_setter', () {
16012 final __test = new StaticWarningCodeTest();
16013 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_setter);
16014 });
16015 _ut.test('test_switchExpressionNotAssignable', () {
16016 final __test = new StaticWarningCodeTest();
16017 runJUnitTest(__test, __test.test_switchExpressionNotAssignable);
16018 });
16019 _ut.test('test_typeParameterReferencedByStatic_field', () {
16020 final __test = new StaticWarningCodeTest();
16021 runJUnitTest(__test, __test.test_typeParameterReferencedByStatic_field);
16022 });
16023 _ut.test('test_typeParameterReferencedByStatic_getter', () {
16024 final __test = new StaticWarningCodeTest();
16025 runJUnitTest(__test, __test.test_typeParameterReferencedByStatic_getter) ;
16026 });
16027 _ut.test('test_typeParameterReferencedByStatic_methodBodyReference', () {
16028 final __test = new StaticWarningCodeTest();
16029 runJUnitTest(__test, __test.test_typeParameterReferencedByStatic_methodB odyReference);
16030 });
16031 _ut.test('test_typeParameterReferencedByStatic_methodParameter', () {
16032 final __test = new StaticWarningCodeTest();
16033 runJUnitTest(__test, __test.test_typeParameterReferencedByStatic_methodP arameter);
16034 });
16035 _ut.test('test_typeParameterReferencedByStatic_methodReturn', () {
16036 final __test = new StaticWarningCodeTest();
16037 runJUnitTest(__test, __test.test_typeParameterReferencedByStatic_methodR eturn);
16038 });
16039 _ut.test('test_typeParameterReferencedByStatic_setter', () {
16040 final __test = new StaticWarningCodeTest();
16041 runJUnitTest(__test, __test.test_typeParameterReferencedByStatic_setter) ;
16042 });
16043 _ut.test('test_typePromotion_functionType_arg_InterToDyn', () {
16044 final __test = new StaticWarningCodeTest();
16045 runJUnitTest(__test, __test.test_typePromotion_functionType_arg_InterToD yn);
16046 });
16047 _ut.test('test_typeTestNonType', () {
16048 final __test = new StaticWarningCodeTest();
16049 runJUnitTest(__test, __test.test_typeTestNonType);
16050 });
16051 _ut.test('test_undefinedClassBoolean_variableDeclaration', () {
16052 final __test = new StaticWarningCodeTest();
16053 runJUnitTest(__test, __test.test_undefinedClassBoolean_variableDeclarati on);
16054 });
16055 _ut.test('test_undefinedClass_instanceCreation', () {
16056 final __test = new StaticWarningCodeTest();
16057 runJUnitTest(__test, __test.test_undefinedClass_instanceCreation);
16058 });
16059 _ut.test('test_undefinedClass_variableDeclaration', () {
16060 final __test = new StaticWarningCodeTest();
16061 runJUnitTest(__test, __test.test_undefinedClass_variableDeclaration);
16062 });
16063 _ut.test('test_undefinedGetter_fromLibrary', () {
16064 final __test = new StaticWarningCodeTest();
16065 runJUnitTest(__test, __test.test_undefinedGetter_fromLibrary);
16066 });
16067 _ut.test('test_undefinedIdentifier_for', () {
16068 final __test = new StaticWarningCodeTest();
16069 runJUnitTest(__test, __test.test_undefinedIdentifier_for);
16070 });
16071 _ut.test('test_undefinedIdentifier_function', () {
16072 final __test = new StaticWarningCodeTest();
16073 runJUnitTest(__test, __test.test_undefinedIdentifier_function);
16074 });
16075 _ut.test('test_undefinedIdentifier_function_prefix', () {
16076 final __test = new StaticWarningCodeTest();
16077 runJUnitTest(__test, __test.test_undefinedIdentifier_function_prefix);
16078 });
16079 _ut.test('test_undefinedIdentifier_initializer', () {
16080 final __test = new StaticWarningCodeTest();
16081 runJUnitTest(__test, __test.test_undefinedIdentifier_initializer);
16082 });
16083 _ut.test('test_undefinedIdentifier_initializer_prefix', () {
16084 final __test = new StaticWarningCodeTest();
16085 runJUnitTest(__test, __test.test_undefinedIdentifier_initializer_prefix) ;
16086 });
16087 _ut.test('test_undefinedIdentifier_metadata', () {
16088 final __test = new StaticWarningCodeTest();
16089 runJUnitTest(__test, __test.test_undefinedIdentifier_metadata);
16090 });
16091 _ut.test('test_undefinedIdentifier_methodInvocation', () {
16092 final __test = new StaticWarningCodeTest();
16093 runJUnitTest(__test, __test.test_undefinedIdentifier_methodInvocation);
16094 });
16095 _ut.test('test_undefinedIdentifier_private_getter', () {
16096 final __test = new StaticWarningCodeTest();
16097 runJUnitTest(__test, __test.test_undefinedIdentifier_private_getter);
16098 });
16099 _ut.test('test_undefinedIdentifier_private_setter', () {
16100 final __test = new StaticWarningCodeTest();
16101 runJUnitTest(__test, __test.test_undefinedIdentifier_private_setter);
16102 });
16103 _ut.test('test_undefinedNamedParameter', () {
16104 final __test = new StaticWarningCodeTest();
16105 runJUnitTest(__test, __test.test_undefinedNamedParameter);
16106 });
16107 _ut.test('test_undefinedSetter', () {
16108 final __test = new StaticWarningCodeTest();
16109 runJUnitTest(__test, __test.test_undefinedSetter);
16110 });
16111 });
16112 }
16113 }
16114 class ErrorResolverTest extends ResolverTestCase {
16115 void test_breakLabelOnSwitchMember() {
16116 Source source = addSource(EngineTestCase.createSource([
16117 "class A {",
16118 " void m(int i) {",
16119 " switch (i) {",
16120 " l: case 0:",
16121 " break;",
16122 " case 1:",
16123 " break l;",
16124 " }",
16125 " }",
16126 "}"]));
16127 resolve(source);
16128 assertErrors(source, [ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]);
16129 verify([source]);
16130 }
16131 void test_continueLabelOnSwitch() {
16132 Source source = addSource(EngineTestCase.createSource([
16133 "class A {",
16134 " void m(int i) {",
16135 " l: switch (i) {",
16136 " case 0:",
16137 " continue l;",
16138 " }",
16139 " }",
16140 "}"]));
16141 resolve(source);
16142 assertErrors(source, [ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]);
16143 verify([source]);
16144 }
16145 static dartSuite() {
16146 _ut.group('ErrorResolverTest', () {
16147 _ut.test('test_breakLabelOnSwitchMember', () {
16148 final __test = new ErrorResolverTest();
16149 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember);
16150 });
16151 _ut.test('test_continueLabelOnSwitch', () {
16152 final __test = new ErrorResolverTest();
16153 runJUnitTest(__test, __test.test_continueLabelOnSwitch);
16154 });
16155 });
16156 }
16157 }
16158 /**
16159 * Instances of the class `TestTypeProvider` implement a type provider that can be used by
16160 * tests without creating the element model for the core library.
16161 */
16162 class TestTypeProvider implements TypeProvider {
16163
16164 /**
16165 * The type representing the built-in type 'bool'.
16166 */
16167 InterfaceType _boolType;
16168
16169 /**
16170 * The type representing the type 'bottom'.
16171 */
16172 Type2 _bottomType;
16173
16174 /**
16175 * The type representing the built-in type 'double'.
16176 */
16177 InterfaceType _doubleType;
16178
16179 /**
16180 * The type representing the built-in type 'dynamic'.
16181 */
16182 Type2 _dynamicType;
16183
16184 /**
16185 * The type representing the built-in type 'Function'.
16186 */
16187 InterfaceType _functionType;
16188
16189 /**
16190 * The type representing the built-in type 'int'.
16191 */
16192 InterfaceType _intType;
16193
16194 /**
16195 * The type representing the built-in type 'Iterable'.
16196 */
16197 InterfaceType _iterableType;
16198
16199 /**
16200 * The type representing the built-in type 'Iterator'.
16201 */
16202 InterfaceType _iteratorType;
16203
16204 /**
16205 * The type representing the built-in type 'List'.
16206 */
16207 InterfaceType _listType;
16208
16209 /**
16210 * The type representing the built-in type 'Map'.
16211 */
16212 InterfaceType _mapType;
16213
16214 /**
16215 * The type representing the built-in type 'Null'.
16216 */
16217 InterfaceType _nullType;
16218
16219 /**
16220 * The type representing the built-in type 'num'.
16221 */
16222 InterfaceType _numType;
16223
16224 /**
16225 * The type representing the built-in type 'Object'.
16226 */
16227 InterfaceType _objectType;
16228
16229 /**
16230 * The type representing the built-in type 'StackTrace'.
16231 */
16232 InterfaceType _stackTraceType;
16233
16234 /**
16235 * The type representing the built-in type 'String'.
16236 */
16237 InterfaceType _stringType;
16238
16239 /**
16240 * The type representing the built-in type 'Symbol'.
16241 */
16242 InterfaceType _symbolType;
16243
16244 /**
16245 * The type representing the built-in type 'Type'.
16246 */
16247 InterfaceType _typeType;
16248 InterfaceType get boolType {
16249 if (_boolType == null) {
16250 _boolType = ElementFactory.classElement2("bool", []).type;
16251 }
16252 return _boolType;
16253 }
16254 Type2 get bottomType {
16255 if (_bottomType == null) {
16256 _bottomType = BottomTypeImpl.instance;
16257 }
16258 return _bottomType;
16259 }
16260 InterfaceType get doubleType {
16261 if (_doubleType == null) {
16262 initializeNumericTypes();
16263 }
16264 return _doubleType;
16265 }
16266 Type2 get dynamicType {
16267 if (_dynamicType == null) {
16268 _dynamicType = DynamicTypeImpl.instance;
16269 }
16270 return _dynamicType;
16271 }
16272 InterfaceType get functionType {
16273 if (_functionType == null) {
16274 _functionType = ElementFactory.classElement2("Function", []).type;
16275 }
16276 return _functionType;
16277 }
16278 InterfaceType get intType {
16279 if (_intType == null) {
16280 initializeNumericTypes();
16281 }
16282 return _intType;
16283 }
16284 InterfaceType get iterableType {
16285 if (_iterableType == null) {
16286 ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable" , ["E"]);
16287 _iterableType = iterableElement.type;
16288 Type2 eType = iterableElement.typeParameters[0].type;
16289 iterableElement.accessors = <PropertyAccessorElement> [
16290 ElementFactory.getterElement("iterator", false, iteratorType.substitut e4(<Type2> [eType])),
16291 ElementFactory.getterElement("last", false, eType)];
16292 propagateTypeArguments(iterableElement);
16293 }
16294 return _iterableType;
16295 }
16296 InterfaceType get iteratorType {
16297 if (_iteratorType == null) {
16298 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator" , ["E"]);
16299 _iteratorType = iteratorElement.type;
16300 Type2 eType = iteratorElement.typeParameters[0].type;
16301 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("current", false, eType)];
16302 propagateTypeArguments(iteratorElement);
16303 }
16304 return _iteratorType;
16305 }
16306 InterfaceType get listType {
16307 if (_listType == null) {
16308 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]) ;
16309 listElement.constructors = <ConstructorElement> [ElementFactory.constructo rElement(listElement, null)];
16310 _listType = listElement.type;
16311 Type2 eType = listElement.typeParameters[0].type;
16312 InterfaceType iterableType = this.iterableType.substitute4(<Type2> [eType] );
16313 listElement.interfaces = <InterfaceType> [iterableType];
16314 listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEl ement("length", false, intType)];
16315 listElement.methods = <MethodElement> [
16316 ElementFactory.methodElement("[]", eType, [intType]),
16317 ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [intType, e Type]),
16318 ElementFactory.methodElement("add", VoidTypeImpl.instance, [eType])];
16319 propagateTypeArguments(listElement);
16320 }
16321 return _listType;
16322 }
16323 InterfaceType get mapType {
16324 if (_mapType == null) {
16325 ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V "]);
16326 _mapType = mapElement.type;
16327 mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEle ment("length", false, intType)];
16328 propagateTypeArguments(mapElement);
16329 }
16330 return _mapType;
16331 }
16332 InterfaceType get nullType {
16333 if (_nullType == null) {
16334 _nullType = ElementFactory.classElement2("Null", []).type;
16335 }
16336 return _nullType;
16337 }
16338 InterfaceType get numType {
16339 if (_numType == null) {
16340 initializeNumericTypes();
16341 }
16342 return _numType;
16343 }
16344 InterfaceType get objectType {
16345 if (_objectType == null) {
16346 ClassElementImpl objectElement = ElementFactory.object;
16347 _objectType = objectElement.type;
16348 objectElement.constructors = <ConstructorElement> [ElementFactory.construc torElement(objectElement, null)];
16349 objectElement.methods = <MethodElement> [
16350 ElementFactory.methodElement("toString", stringType, []),
16351 ElementFactory.methodElement("==", boolType, [_objectType]),
16352 ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType ])];
16353 objectElement.accessors = <PropertyAccessorElement> [
16354 ElementFactory.getterElement("hashCode", false, intType),
16355 ElementFactory.getterElement("runtimeType", false, typeType)];
16356 }
16357 return _objectType;
16358 }
16359 InterfaceType get stackTraceType {
16360 if (_stackTraceType == null) {
16361 _stackTraceType = ElementFactory.classElement2("StackTrace", []).type;
16362 }
16363 return _stackTraceType;
16364 }
16365 InterfaceType get stringType {
16366 if (_stringType == null) {
16367 _stringType = ElementFactory.classElement2("String", []).type;
16368 ClassElementImpl stringElement = _stringType.element as ClassElementImpl;
16369 stringElement.accessors = <PropertyAccessorElement> [
16370 ElementFactory.getterElement("isEmpty", false, boolType),
16371 ElementFactory.getterElement("length", false, intType),
16372 ElementFactory.getterElement("codeUnits", false, listType.substitute4( <Type2> [intType]))];
16373 stringElement.methods = <MethodElement> [
16374 ElementFactory.methodElement("+", _stringType, [_stringType]),
16375 ElementFactory.methodElement("toLowerCase", _stringType, []),
16376 ElementFactory.methodElement("toUpperCase", _stringType, [])];
16377 }
16378 return _stringType;
16379 }
16380 InterfaceType get symbolType {
16381 if (_symbolType == null) {
16382 _symbolType = ElementFactory.classElement2("Symbol", []).type;
16383 }
16384 return _symbolType;
16385 }
16386 InterfaceType get typeType {
16387 if (_typeType == null) {
16388 _typeType = ElementFactory.classElement2("Type", []).type;
16389 }
16390 return _typeType;
16391 }
16392
16393 /**
16394 * Initialize the numeric types. They are created as a group so that we can (a ) create the right
16395 * hierarchy and (b) add members to them.
16396 */
16397 void initializeNumericTypes() {
16398 ClassElementImpl numElement = ElementFactory.classElement2("num", []);
16399 _numType = numElement.type;
16400 ClassElementImpl intElement = ElementFactory.classElement("int", _numType, [ ]);
16401 _intType = intElement.type;
16402 ClassElementImpl doubleElement = ElementFactory.classElement("double", _numT ype, []);
16403 _doubleType = doubleElement.type;
16404 boolType;
16405 stringType;
16406 numElement.methods = <MethodElement> [
16407 ElementFactory.methodElement("+", _numType, [_numType]),
16408 ElementFactory.methodElement("-", _numType, [_numType]),
16409 ElementFactory.methodElement("*", _numType, [_numType]),
16410 ElementFactory.methodElement("%", _numType, [_numType]),
16411 ElementFactory.methodElement("/", _doubleType, [_numType]),
16412 ElementFactory.methodElement("~/", _numType, [_numType]),
16413 ElementFactory.methodElement("-", _numType, []),
16414 ElementFactory.methodElement("remainder", _numType, [_numType]),
16415 ElementFactory.methodElement("<", _boolType, [_numType]),
16416 ElementFactory.methodElement("<=", _boolType, [_numType]),
16417 ElementFactory.methodElement(">", _boolType, [_numType]),
16418 ElementFactory.methodElement(">=", _boolType, [_numType]),
16419 ElementFactory.methodElement("isNaN", _boolType, []),
16420 ElementFactory.methodElement("isNegative", _boolType, []),
16421 ElementFactory.methodElement("isInfinite", _boolType, []),
16422 ElementFactory.methodElement("abs", _numType, []),
16423 ElementFactory.methodElement("floor", _numType, []),
16424 ElementFactory.methodElement("ceil", _numType, []),
16425 ElementFactory.methodElement("round", _numType, []),
16426 ElementFactory.methodElement("truncate", _numType, []),
16427 ElementFactory.methodElement("toInt", _intType, []),
16428 ElementFactory.methodElement("toDouble", _doubleType, []),
16429 ElementFactory.methodElement("toStringAsFixed", _stringType, [_intType]) ,
16430 ElementFactory.methodElement("toStringAsExponential", _stringType, [_int Type]),
16431 ElementFactory.methodElement("toStringAsPrecision", _stringType, [_intTy pe]),
16432 ElementFactory.methodElement("toRadixString", _stringType, [_intType])];
16433 intElement.methods = <MethodElement> [
16434 ElementFactory.methodElement("&", _intType, [_intType]),
16435 ElementFactory.methodElement("|", _intType, [_intType]),
16436 ElementFactory.methodElement("^", _intType, [_intType]),
16437 ElementFactory.methodElement("~", _intType, []),
16438 ElementFactory.methodElement("<<", _intType, [_intType]),
16439 ElementFactory.methodElement(">>", _intType, [_intType]),
16440 ElementFactory.methodElement("-", _intType, []),
16441 ElementFactory.methodElement("abs", _intType, []),
16442 ElementFactory.methodElement("round", _intType, []),
16443 ElementFactory.methodElement("floor", _intType, []),
16444 ElementFactory.methodElement("ceil", _intType, []),
16445 ElementFactory.methodElement("truncate", _intType, []),
16446 ElementFactory.methodElement("toString", _stringType, [])];
16447 List<FieldElement> fields = <FieldElement> [
16448 ElementFactory.fieldElement("NAN", true, false, true, _doubleType),
16449 ElementFactory.fieldElement("INFINITY", true, false, true, _doubleType),
16450 ElementFactory.fieldElement("NEGATIVE_INFINITY", true, false, true, _dou bleType),
16451 ElementFactory.fieldElement("MIN_POSITIVE", true, false, true, _doubleTy pe),
16452 ElementFactory.fieldElement("MAX_FINITE", true, false, true, _doubleType )];
16453 doubleElement.fields = fields;
16454 int fieldCount = fields.length;
16455 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount);
16456 for (int i = 0; i < fieldCount; i++) {
16457 accessors[i] = fields[i].getter;
16458 }
16459 doubleElement.accessors = accessors;
16460 doubleElement.methods = <MethodElement> [
16461 ElementFactory.methodElement("remainder", _doubleType, [_numType]),
16462 ElementFactory.methodElement("+", _doubleType, [_numType]),
16463 ElementFactory.methodElement("-", _doubleType, [_numType]),
16464 ElementFactory.methodElement("*", _doubleType, [_numType]),
16465 ElementFactory.methodElement("%", _doubleType, [_numType]),
16466 ElementFactory.methodElement("/", _doubleType, [_numType]),
16467 ElementFactory.methodElement("~/", _doubleType, [_numType]),
16468 ElementFactory.methodElement("-", _doubleType, []),
16469 ElementFactory.methodElement("abs", _doubleType, []),
16470 ElementFactory.methodElement("round", _doubleType, []),
16471 ElementFactory.methodElement("floor", _doubleType, []),
16472 ElementFactory.methodElement("ceil", _doubleType, []),
16473 ElementFactory.methodElement("truncate", _doubleType, []),
16474 ElementFactory.methodElement("toString", _stringType, [])];
16475 }
16476
16477 /**
16478 * Given a class element representing a class with type parameters, propagate those type
16479 * parameters to all of the accessors, methods and constructors defined for th e class.
16480 *
16481 * @param classElement the element representing the class with type parameters
16482 */
16483 void propagateTypeArguments(ClassElementImpl classElement) {
16484 List<Type2> typeArguments = TypeParameterTypeImpl.getTypes(classElement.type Parameters);
16485 for (PropertyAccessorElement accessor in classElement.accessors) {
16486 FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl;
16487 functionType.typeArguments = typeArguments;
16488 }
16489 for (MethodElement method in classElement.methods) {
16490 FunctionTypeImpl functionType = method.type as FunctionTypeImpl;
16491 functionType.typeArguments = typeArguments;
16492 }
16493 for (ConstructorElement constructor in classElement.constructors) {
16494 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl;
16495 functionType.typeArguments = typeArguments;
16496 }
16497 }
16498 }
16499 /**
16500 * The class `AnalysisContextFactory` defines utility methods used to create ana lysis contexts
16501 * for testing purposes.
16502 */
16503 class AnalysisContextFactory {
16504
16505 /**
16506 * Create an analysis context that has a fake core library already resolved.
16507 *
16508 * @return the analysis context that was created
16509 */
16510 static AnalysisContextImpl contextWithCore() {
16511 AnalysisContext sdkContext = DirectoryBasedDartSdk.defaultSdk.context;
16512 SourceFactory sourceFactory = sdkContext.sourceFactory;
16513 TestTypeProvider provider = new TestTypeProvider();
16514 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art");
16515 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
16516 sdkContext.setContents(coreSource, "");
16517 coreUnit.source = coreSource;
16518 coreUnit.types = <ClassElement> [
16519 provider.boolType.element,
16520 provider.doubleType.element,
16521 provider.functionType.element,
16522 provider.intType.element,
16523 provider.listType.element,
16524 provider.mapType.element,
16525 provider.nullType.element,
16526 provider.numType.element,
16527 provider.objectType.element,
16528 provider.stackTraceType.element,
16529 provider.stringType.element,
16530 provider.symbolType.element,
16531 provider.typeType.element];
16532 coreUnit.functions = <FunctionElement> [ElementFactory.functionElement3("ide ntical", provider.boolType.element, <ClassElement> [provider.objectType.element, provider.objectType.element], null)];
16533 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "core"]));
16534 coreLibrary.definingCompilationUnit = coreUnit;
16535 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d artium.dart");
16536 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
16537 sdkContext.setContents(htmlSource, "");
16538 htmlUnit.source = htmlSource;
16539 ClassElementImpl elementElement = ElementFactory.classElement2("Element", [] );
16540 InterfaceType elementType = elementElement.type;
16541 ClassElementImpl documentElement = ElementFactory.classElement("Document", e lementType, []);
16542 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu ment", documentElement.type, []);
16543 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement( "query", elementType, <Type2> [provider.stringType])];
16544 htmlUnit.types = <ClassElement> [
16545 ElementFactory.classElement("AnchorElement", elementType, []),
16546 ElementFactory.classElement("BodyElement", elementType, []),
16547 ElementFactory.classElement("ButtonElement", elementType, []),
16548 ElementFactory.classElement("DivElement", elementType, []),
16549 documentElement,
16550 elementElement,
16551 htmlDocumentElement,
16552 ElementFactory.classElement("InputElement", elementType, []),
16553 ElementFactory.classElement("SelectElement", elementType, [])];
16554 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI mpl.EMPTY_ARRAY)];
16555 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen t3("document", true, htmlDocumentElement.type);
16556 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document];
16557 htmlUnit.accessors = <PropertyAccessorElement> [document.getter];
16558 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "dom", "html"]));
16559 htmlLibrary.definingCompilationUnit = htmlUnit;
16560 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
16561 elementMap[coreSource] = coreLibrary;
16562 elementMap[htmlSource] = htmlLibrary;
16563 ((sdkContext as AnalysisContextImpl)).recordLibraryElements(elementMap);
16564 AnalysisContextImpl context = new DelegatingAnalysisContextImpl();
16565 sourceFactory = new SourceFactory.con2([
16566 new DartUriResolver(sdkContext.sourceFactory.dartSdk),
16567 new FileUriResolver()]);
16568 context.sourceFactory = sourceFactory;
16569 return context;
16570 }
16571 }
16572 class LibraryImportScopeTest extends ResolverTestCase {
16573 void test_conflictingImports() {
16574 AnalysisContext context = new AnalysisContextImpl();
16575 String typeNameA = "A";
16576 String typeNameB = "B";
16577 String typeNameC = "C";
16578 ClassElement typeA = ElementFactory.classElement2(typeNameA, []);
16579 ClassElement typeB1 = ElementFactory.classElement2(typeNameB, []);
16580 ClassElement typeB2 = ElementFactory.classElement2(typeNameB, []);
16581 ClassElement typeC = ElementFactory.classElement2(typeNameC, []);
16582 LibraryElement importedLibrary1 = createTestLibrary2(context, "imported1", [ ]);
16583 ((importedLibrary1.definingCompilationUnit as CompilationUnitElementImpl)).t ypes = <ClassElement> [typeA, typeB1];
16584 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary1, null, []);
16585 LibraryElement importedLibrary2 = createTestLibrary2(context, "imported2", [ ]);
16586 ((importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl)).t ypes = <ClassElement> [typeB2, typeC];
16587 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary2, null, []);
16588 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing ", []);
16589 importingLibrary.imports = <ImportElement> [import1, import2];
16590 {
16591 GatheringErrorListener errorListener = new GatheringErrorListener();
16592 Scope scope = new LibraryImportScope(importingLibrary, errorListener);
16593 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(type NameA), importingLibrary));
16594 errorListener.assertNoErrors();
16595 JUnitTestCase.assertEquals(typeC, scope.lookup(ASTFactory.identifier3(type NameC), importingLibrary));
16596 errorListener.assertNoErrors();
16597 Element element = scope.lookup(ASTFactory.identifier3(typeNameB), importin gLibrary);
16598 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]);
16599 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element);
16600 List<Element> conflictingElements = ((element as MultiplyDefinedElement)). conflictingElements;
16601 EngineTestCase.assertLength(2, conflictingElements);
16602 if (identical(conflictingElements[0], typeB1)) {
16603 JUnitTestCase.assertSame(typeB2, conflictingElements[1]);
16604 } else if (identical(conflictingElements[0], typeB2)) {
16605 JUnitTestCase.assertSame(typeB1, conflictingElements[1]);
16606 } else {
16607 JUnitTestCase.assertSame(typeB1, conflictingElements[0]);
16608 }
16609 }
16610 {
16611 GatheringErrorListener errorListener = new GatheringErrorListener();
16612 Scope scope = new LibraryImportScope(importingLibrary, errorListener);
16613 Identifier identifier = ASTFactory.identifier3(typeNameB);
16614 ASTFactory.methodDeclaration(null, ASTFactory.typeName3(identifier, []), n ull, null, ASTFactory.identifier3("foo"), null);
16615 Element element = scope.lookup(identifier, importingLibrary);
16616 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]);
16617 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element);
16618 }
16619 }
16620 void test_creation_empty() {
16621 LibraryElement definingLibrary = createTestLibrary();
16622 GatheringErrorListener errorListener = new GatheringErrorListener();
16623 new LibraryImportScope(definingLibrary, errorListener);
16624 }
16625 void test_creation_nonEmpty() {
16626 AnalysisContext context = new AnalysisContextImpl();
16627 String importedTypeName = "A";
16628 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo rtedTypeName));
16629 LibraryElement importedLibrary = createTestLibrary2(context, "imported", []) ;
16630 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [importedType];
16631 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing" , []);
16632 ImportElementImpl importElement = new ImportElementImpl();
16633 importElement.importedLibrary = importedLibrary;
16634 definingLibrary.imports = <ImportElement> [importElement];
16635 GatheringErrorListener errorListener = new GatheringErrorListener();
16636 Scope scope = new LibraryImportScope(definingLibrary, errorListener);
16637 JUnitTestCase.assertEquals(importedType, scope.lookup(ASTFactory.identifier3 (importedTypeName), definingLibrary));
16638 }
16639 void test_getDefiningLibrary() {
16640 LibraryElement definingLibrary = createTestLibrary();
16641 GatheringErrorListener errorListener = new GatheringErrorListener();
16642 LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorList ener);
16643 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary);
16644 }
16645 void test_getErrorListener() {
16646 LibraryElement definingLibrary = createTestLibrary();
16647 GatheringErrorListener errorListener = new GatheringErrorListener();
16648 LibraryImportScope scope = new LibraryImportScope(definingLibrary, errorList ener);
16649 JUnitTestCase.assertEquals(errorListener, scope.errorListener);
16650 }
16651 void test_nonConflictingImports_fromSdk() {
16652 AnalysisContext context = AnalysisContextFactory.contextWithCore();
16653 String typeName = "List";
16654 ClassElement type = ElementFactory.classElement2(typeName, []);
16655 LibraryElement importedLibrary = createTestLibrary2(context, "lib", []);
16656 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [type];
16657 ImportElementImpl importCore = ElementFactory.importFor(context.getLibraryEl ement(context.sourceFactory.forUri("dart:core")), null, []);
16658 ImportElementImpl importLib = ElementFactory.importFor(importedLibrary, null , []);
16659 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing ", []);
16660 importingLibrary.imports = <ImportElement> [importCore, importLib];
16661 GatheringErrorListener errorListener = new GatheringErrorListener();
16662 Scope scope = new LibraryImportScope(importingLibrary, errorListener);
16663 JUnitTestCase.assertEquals(type, scope.lookup(ASTFactory.identifier3(typeNam e), importingLibrary));
16664 errorListener.assertErrors2([StaticWarningCode.CONFLICTING_DART_IMPORT]);
16665 }
16666 void test_nonConflictingImports_sameElement() {
16667 AnalysisContext context = new AnalysisContextImpl();
16668 String typeNameA = "A";
16669 String typeNameB = "B";
16670 ClassElement typeA = ElementFactory.classElement2(typeNameA, []);
16671 ClassElement typeB = ElementFactory.classElement2(typeNameB, []);
16672 LibraryElement importedLibrary = createTestLibrary2(context, "imported", []) ;
16673 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [typeA, typeB];
16674 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary, null, []);
16675 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary, null, []);
16676 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing ", []);
16677 importingLibrary.imports = <ImportElement> [import1, import2];
16678 GatheringErrorListener errorListener = new GatheringErrorListener();
16679 Scope scope = new LibraryImportScope(importingLibrary, errorListener);
16680 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(typeNa meA), importingLibrary));
16681 errorListener.assertNoErrors();
16682 JUnitTestCase.assertEquals(typeB, scope.lookup(ASTFactory.identifier3(typeNa meB), importingLibrary));
16683 errorListener.assertNoErrors();
16684 }
16685 void test_prefixedAndNonPrefixed() {
16686 AnalysisContext context = new AnalysisContextImpl();
16687 String typeName = "C";
16688 String prefixName = "p";
16689 ClassElement prefixedType = ElementFactory.classElement2(typeName, []);
16690 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName, []);
16691 LibraryElement prefixedLibrary = createTestLibrary2(context, "import.prefixe d", []);
16692 ((prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [prefixedType];
16693 ImportElementImpl prefixedImport = ElementFactory.importFor(prefixedLibrary, ElementFactory.prefix(prefixName), []);
16694 LibraryElement nonPrefixedLibrary = createTestLibrary2(context, "import.nonP refixed", []);
16695 ((nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)) .types = <ClassElement> [nonPrefixedType];
16696 ImportElementImpl nonPrefixedImport = ElementFactory.importFor(nonPrefixedLi brary, null, []);
16697 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing ", []);
16698 importingLibrary.imports = <ImportElement> [prefixedImport, nonPrefixedImpor t];
16699 GatheringErrorListener errorListener = new GatheringErrorListener();
16700 Scope scope = new LibraryImportScope(importingLibrary, errorListener);
16701 Element prefixedElement = scope.lookup(ASTFactory.identifier5(prefixName, ty peName), importingLibrary);
16702 errorListener.assertNoErrors();
16703 JUnitTestCase.assertSame(prefixedType, prefixedElement);
16704 Element nonPrefixedElement = scope.lookup(ASTFactory.identifier3(typeName), importingLibrary);
16705 errorListener.assertNoErrors();
16706 JUnitTestCase.assertSame(nonPrefixedType, nonPrefixedElement);
16707 }
16708 static dartSuite() {
16709 _ut.group('LibraryImportScopeTest', () {
16710 _ut.test('test_conflictingImports', () {
16711 final __test = new LibraryImportScopeTest();
16712 runJUnitTest(__test, __test.test_conflictingImports);
16713 });
16714 _ut.test('test_creation_empty', () {
16715 final __test = new LibraryImportScopeTest();
16716 runJUnitTest(__test, __test.test_creation_empty);
16717 });
16718 _ut.test('test_creation_nonEmpty', () {
16719 final __test = new LibraryImportScopeTest();
16720 runJUnitTest(__test, __test.test_creation_nonEmpty);
16721 });
16722 _ut.test('test_getDefiningLibrary', () {
16723 final __test = new LibraryImportScopeTest();
16724 runJUnitTest(__test, __test.test_getDefiningLibrary);
16725 });
16726 _ut.test('test_getErrorListener', () {
16727 final __test = new LibraryImportScopeTest();
16728 runJUnitTest(__test, __test.test_getErrorListener);
16729 });
16730 _ut.test('test_nonConflictingImports_fromSdk', () {
16731 final __test = new LibraryImportScopeTest();
16732 runJUnitTest(__test, __test.test_nonConflictingImports_fromSdk);
16733 });
16734 _ut.test('test_nonConflictingImports_sameElement', () {
16735 final __test = new LibraryImportScopeTest();
16736 runJUnitTest(__test, __test.test_nonConflictingImports_sameElement);
16737 });
16738 _ut.test('test_prefixedAndNonPrefixed', () {
16739 final __test = new LibraryImportScopeTest();
16740 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed);
16741 });
16742 });
16743 }
16744 }
16745 /**
16746 * Instances of the class `ResolutionVerifier` verify that all of the nodes in a n AST
16747 * structure that should have been resolved were resolved.
16748 */
16749 class ResolutionVerifier extends RecursiveASTVisitor<Object> {
16750
16751 /**
16752 * A set containing nodes that are known to not be resolvable and should there fore not cause the
16753 * test to fail.
16754 */
16755 Set<ASTNode> _knownExceptions;
16756
16757 /**
16758 * A list containing all of the AST nodes that were not resolved.
16759 */
16760 List<ASTNode> _unresolvedNodes = new List<ASTNode>();
16761
16762 /**
16763 * A list containing all of the AST nodes that were resolved to an element of the wrong type.
16764 */
16765 List<ASTNode> _wrongTypedNodes = new List<ASTNode>();
16766
16767 /**
16768 * Initialize a newly created verifier to verify that all of the nodes in the visited AST
16769 * structures that are expected to have been resolved have an element associat ed with them.
16770 */
16771 ResolutionVerifier() : this.con1(null);
16772
16773 /**
16774 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST
16775 * structures that are expected to have been resolved have an element associat ed with them. Nodes
16776 * in the set of known exceptions are not expected to have been resolved, even if they normally
16777 * would have been expected to have been resolved.
16778 *
16779 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should
16780 * therefore not cause the test to fail
16781 **/
16782 ResolutionVerifier.con1(Set<ASTNode> knownExceptions) {
16783 this._knownExceptions = knownExceptions;
16784 }
16785
16786 /**
16787 * Assert that all of the visited identifiers were resolved.
16788 */
16789 void assertResolved() {
16790 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) {
16791 PrintStringWriter writer = new PrintStringWriter();
16792 if (!_unresolvedNodes.isEmpty) {
16793 writer.print("Failed to resolve ");
16794 writer.print(_unresolvedNodes.length);
16795 writer.println(" nodes:");
16796 printNodes(writer, _unresolvedNodes);
16797 }
16798 if (!_wrongTypedNodes.isEmpty) {
16799 writer.print("Resolved ");
16800 writer.print(_wrongTypedNodes.length);
16801 writer.println(" to the wrong type of element:");
16802 printNodes(writer, _wrongTypedNodes);
16803 }
16804 JUnitTestCase.fail(writer.toString());
16805 }
16806 }
16807 Object visitBinaryExpression(BinaryExpression node) {
16808 node.visitChildren(this);
16809 if (!node.operator.isUserDefinableOperator) {
16810 return null;
16811 }
16812 Type2 operandType = node.leftOperand.staticType;
16813 if (operandType == null || operandType.isDynamic) {
16814 return null;
16815 }
16816 return checkResolved2(node, node.staticElement, MethodElement);
16817 }
16818 Object visitCommentReference(CommentReference node) => null;
16819 Object visitCompilationUnit(CompilationUnit node) {
16820 node.visitChildren(this);
16821 return checkResolved2(node, node.element, CompilationUnitElement);
16822 }
16823 Object visitExportDirective(ExportDirective node) => checkResolved2(node, node .element, ExportElement);
16824 Object visitFunctionDeclaration(FunctionDeclaration node) {
16825 node.visitChildren(this);
16826 if (node.element is LibraryElement) {
16827 _wrongTypedNodes.add(node);
16828 }
16829 return null;
16830 }
16831 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
16832 node.visitChildren(this);
16833 return null;
16834 }
16835 Object visitImportDirective(ImportDirective node) {
16836 checkResolved2(node, node.element, ImportElement);
16837 SimpleIdentifier prefix = node.prefix;
16838 if (prefix == null) {
16839 return null;
16840 }
16841 return checkResolved2(prefix, prefix.staticElement, PrefixElement);
16842 }
16843 Object visitIndexExpression(IndexExpression node) {
16844 node.visitChildren(this);
16845 Type2 targetType = node.realTarget.staticType;
16846 if (targetType == null || targetType.isDynamic) {
16847 return null;
16848 }
16849 return checkResolved2(node, node.staticElement, MethodElement);
16850 }
16851 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no de.element, LibraryElement);
16852 Object visitNamedExpression(NamedExpression node) => node.expression.accept(th is);
16853 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele ment, CompilationUnitElement);
16854 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node .element, LibraryElement);
16855 Object visitPostfixExpression(PostfixExpression node) {
16856 node.visitChildren(this);
16857 if (!node.operator.isUserDefinableOperator) {
16858 return null;
16859 }
16860 Type2 operandType = node.operand.staticType;
16861 if (operandType == null || operandType.isDynamic) {
16862 return null;
16863 }
16864 return checkResolved2(node, node.staticElement, MethodElement);
16865 }
16866 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
16867 SimpleIdentifier prefix = node.prefix;
16868 prefix.accept(this);
16869 Type2 prefixType = prefix.staticType;
16870 if (prefixType == null || prefixType.isDynamic) {
16871 return null;
16872 }
16873 return checkResolved(node, node.staticElement);
16874 }
16875 Object visitPrefixExpression(PrefixExpression node) {
16876 node.visitChildren(this);
16877 if (!node.operator.isUserDefinableOperator) {
16878 return null;
16879 }
16880 Type2 operandType = node.operand.staticType;
16881 if (operandType == null || operandType.isDynamic) {
16882 return null;
16883 }
16884 return checkResolved2(node, node.staticElement, MethodElement);
16885 }
16886 Object visitPropertyAccess(PropertyAccess node) {
16887 Expression target = node.realTarget;
16888 target.accept(this);
16889 Type2 targetType = target.staticType;
16890 if (targetType == null || targetType.isDynamic) {
16891 return null;
16892 }
16893 return node.propertyName.accept(this);
16894 }
16895 Object visitSimpleIdentifier(SimpleIdentifier node) {
16896 if (node.name == "void") {
16897 return null;
16898 }
16899 ASTNode parent = node.parent;
16900 if (parent is MethodInvocation) {
16901 MethodInvocation invocation = parent as MethodInvocation;
16902 if (identical(invocation.methodName, node)) {
16903 Expression target = invocation.realTarget;
16904 Type2 targetType = target == null ? null : target.staticType;
16905 if (targetType == null || targetType.isDynamic) {
16906 return null;
16907 }
16908 }
16909 }
16910 return checkResolved(node, node.staticElement);
16911 }
16912 Object checkResolved(ASTNode node, Element element) => checkResolved2(node, el ement, null);
16913 Object checkResolved2(ASTNode node, Element element, Type expectedClass) {
16914 if (element == null) {
16915 if (_knownExceptions == null || !_knownExceptions.contains(node)) {
16916 _unresolvedNodes.add(node);
16917 }
16918 } else if (expectedClass != null) {
16919 if (!isInstanceOf(element, expectedClass)) {
16920 _wrongTypedNodes.add(node);
16921 }
16922 }
16923 return null;
16924 }
16925 String getFileName(ASTNode node) {
16926 if (node != null) {
16927 ASTNode root = node.root;
16928 if (root is CompilationUnit) {
16929 CompilationUnit rootCU = root as CompilationUnit;
16930 if (rootCU.element != null) {
16931 return rootCU.element.source.fullName;
16932 } else {
16933 return "<unknown file- CompilationUnit.getElement() returned null>";
16934 }
16935 } else {
16936 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
16937 }
16938 }
16939 return "<unknown file- ASTNode is null>";
16940 }
16941 void printNodes(PrintStringWriter writer, List<ASTNode> nodes) {
16942 for (ASTNode identifier in nodes) {
16943 writer.print(" ");
16944 writer.print(identifier.toString());
16945 writer.print(" (");
16946 writer.print(getFileName(identifier));
16947 writer.print(" : ");
16948 writer.print(identifier.offset);
16949 writer.println(")");
16950 }
16951 }
16952 }
16953 class MemberMapTest extends JUnitTestCase {
16954
16955 /**
16956 * The null type.
16957 */
16958 InterfaceType _nullType;
16959 void setUp() {
16960 _nullType = new TestTypeProvider().nullType;
16961 }
16962 void test_MemberMap_copyConstructor() {
16963 MethodElement m1 = ElementFactory.methodElement("m1", _nullType, []);
16964 MethodElement m2 = ElementFactory.methodElement("m2", _nullType, []);
16965 MethodElement m3 = ElementFactory.methodElement("m3", _nullType, []);
16966 MemberMap map = new MemberMap();
16967 map.put(m1.name, m1);
16968 map.put(m2.name, m2);
16969 map.put(m3.name, m3);
16970 MemberMap copy = new MemberMap.con2(map);
16971 JUnitTestCase.assertEquals(map.size, copy.size);
16972 JUnitTestCase.assertEquals(m1, copy.get(m1.name));
16973 JUnitTestCase.assertEquals(m2, copy.get(m2.name));
16974 JUnitTestCase.assertEquals(m3, copy.get(m3.name));
16975 }
16976 void test_MemberMap_override() {
16977 MethodElement m1 = ElementFactory.methodElement("m", _nullType, []);
16978 MethodElement m2 = ElementFactory.methodElement("m", _nullType, []);
16979 MemberMap map = new MemberMap();
16980 map.put(m1.name, m1);
16981 map.put(m2.name, m2);
16982 JUnitTestCase.assertEquals(1, map.size);
16983 JUnitTestCase.assertEquals(m2, map.get("m"));
16984 }
16985 void test_MemberMap_put() {
16986 MethodElement m1 = ElementFactory.methodElement("m1", _nullType, []);
16987 MemberMap map = new MemberMap();
16988 JUnitTestCase.assertEquals(0, map.size);
16989 map.put(m1.name, m1);
16990 JUnitTestCase.assertEquals(1, map.size);
16991 JUnitTestCase.assertEquals(m1, map.get("m1"));
16992 }
16993 static dartSuite() {
16994 _ut.group('MemberMapTest', () {
16995 _ut.test('test_MemberMap_copyConstructor', () {
16996 final __test = new MemberMapTest();
16997 runJUnitTest(__test, __test.test_MemberMap_copyConstructor);
16998 });
16999 _ut.test('test_MemberMap_override', () {
17000 final __test = new MemberMapTest();
17001 runJUnitTest(__test, __test.test_MemberMap_override);
17002 });
17003 _ut.test('test_MemberMap_put', () {
17004 final __test = new MemberMapTest();
17005 runJUnitTest(__test, __test.test_MemberMap_put);
17006 });
17007 });
17008 }
17009 }
17010 class LibraryScopeTest extends ResolverTestCase {
17011 void test_creation_empty() {
17012 LibraryElement definingLibrary = createTestLibrary();
17013 GatheringErrorListener errorListener = new GatheringErrorListener();
17014 new LibraryScope(definingLibrary, errorListener);
17015 }
17016 void test_creation_nonEmpty() {
17017 AnalysisContext context = new AnalysisContextImpl();
17018 String importedTypeName = "A";
17019 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo rtedTypeName));
17020 LibraryElement importedLibrary = createTestLibrary2(context, "imported", []) ;
17021 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [importedType];
17022 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing" , []);
17023 ImportElementImpl importElement = new ImportElementImpl();
17024 importElement.importedLibrary = importedLibrary;
17025 definingLibrary.imports = <ImportElement> [importElement];
17026 GatheringErrorListener errorListener = new GatheringErrorListener();
17027 Scope scope = new LibraryScope(definingLibrary, errorListener);
17028 JUnitTestCase.assertEquals(importedType, scope.lookup(ASTFactory.identifier3 (importedTypeName), definingLibrary));
17029 }
17030 void test_getDefiningLibrary() {
17031 LibraryElement definingLibrary = createTestLibrary();
17032 GatheringErrorListener errorListener = new GatheringErrorListener();
17033 LibraryScope scope = new LibraryScope(definingLibrary, errorListener);
17034 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary);
17035 }
17036 void test_getErrorListener() {
17037 LibraryElement definingLibrary = createTestLibrary();
17038 GatheringErrorListener errorListener = new GatheringErrorListener();
17039 LibraryScope scope = new LibraryScope(definingLibrary, errorListener);
17040 JUnitTestCase.assertEquals(errorListener, scope.errorListener);
17041 }
17042 static dartSuite() {
17043 _ut.group('LibraryScopeTest', () {
17044 _ut.test('test_creation_empty', () {
17045 final __test = new LibraryScopeTest();
17046 runJUnitTest(__test, __test.test_creation_empty);
17047 });
17048 _ut.test('test_creation_nonEmpty', () {
17049 final __test = new LibraryScopeTest();
17050 runJUnitTest(__test, __test.test_creation_nonEmpty);
17051 });
17052 _ut.test('test_getDefiningLibrary', () {
17053 final __test = new LibraryScopeTest();
17054 runJUnitTest(__test, __test.test_getDefiningLibrary);
17055 });
17056 _ut.test('test_getErrorListener', () {
17057 final __test = new LibraryScopeTest();
17058 runJUnitTest(__test, __test.test_getErrorListener);
17059 });
17060 });
17061 }
17062 }
17063 class StaticTypeAnalyzerTest extends EngineTestCase {
17064
17065 /**
17066 * The error listener to which errors will be reported.
17067 */
17068 GatheringErrorListener _listener;
17069
17070 /**
17071 * The resolver visitor used to create the analyzer.
17072 */
17073 ResolverVisitor _visitor;
17074
17075 /**
17076 * The analyzer being used to analyze the test cases.
17077 */
17078 StaticTypeAnalyzer _analyzer;
17079
17080 /**
17081 * The type provider used to access the types.
17082 */
17083 TestTypeProvider _typeProvider;
17084 void fail_visitFunctionExpressionInvocation() {
17085 JUnitTestCase.fail("Not yet tested");
17086 _listener.assertNoErrors();
17087 }
17088 void fail_visitMethodInvocation() {
17089 JUnitTestCase.fail("Not yet tested");
17090 _listener.assertNoErrors();
17091 }
17092 void fail_visitSimpleIdentifier() {
17093 JUnitTestCase.fail("Not yet tested");
17094 _listener.assertNoErrors();
17095 }
17096 void setUp() {
17097 _listener = new GatheringErrorListener();
17098 _typeProvider = new TestTypeProvider();
17099 _analyzer = createAnalyzer();
17100 }
17101 void test_visitAdjacentStrings() {
17102 Expression node = ASTFactory.adjacentStrings([resolvedString("a"), resolvedS tring("b")]);
17103 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
17104 _listener.assertNoErrors();
17105 }
17106 void test_visitArgumentDefinitionTest() {
17107 Expression node = ASTFactory.argumentDefinitionTest("p");
17108 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17109 _listener.assertNoErrors();
17110 }
17111 void test_visitAsExpression() {
17112 ClassElement superclass = ElementFactory.classElement2("A", []);
17113 InterfaceType superclassType = superclass.type;
17114 ClassElement subclass = ElementFactory.classElement("B", superclassType, []) ;
17115 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa ctory.typeName(subclass, []));
17116 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType));
17117 _listener.assertNoErrors();
17118 }
17119 void test_visitAssignmentExpression_compound() {
17120 InterfaceType numType = _typeProvider.numType;
17121 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i");
17122 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke nType.PLUS_EQ, resolvedInteger(1));
17123 MethodElement plusMethod = getMethod(numType, "+");
17124 node.staticElement = plusMethod;
17125 JUnitTestCase.assertSame(numType, analyze(node));
17126 _listener.assertNoErrors();
17127 }
17128 void test_visitAssignmentExpression_simple() {
17129 InterfaceType intType = _typeProvider.intType;
17130 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType, "i"), TokenType.EQ, resolvedInteger(0));
17131 JUnitTestCase.assertSame(intType, analyze(node));
17132 _listener.assertNoErrors();
17133 }
17134 void test_visitBinaryExpression_equals() {
17135 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. EQ_EQ, resolvedInteger(3));
17136 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17137 _listener.assertNoErrors();
17138 }
17139 void test_visitBinaryExpression_logicalAnd() {
17140 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true));
17141 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17142 _listener.assertNoErrors();
17143 }
17144 void test_visitBinaryExpression_logicalOr() {
17145 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.BAR_BAR, ASTFactory.booleanLiteral(true));
17146 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17147 _listener.assertNoErrors();
17148 }
17149 void test_visitBinaryExpression_notEquals() {
17150 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. BANG_EQ, resolvedInteger(3));
17151 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17152 _listener.assertNoErrors();
17153 }
17154 void test_visitBinaryExpression_plusID() {
17155 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke nType.PLUS, resolvedDouble(2.0));
17156 node.staticElement = getMethod(_typeProvider.numType, "+");
17157 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node));
17158 _listener.assertNoErrors();
17159 }
17160 void test_visitBinaryExpression_plusII() {
17161 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke nType.PLUS, resolvedInteger(2));
17162 node.staticElement = getMethod(_typeProvider.numType, "+");
17163 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17164 _listener.assertNoErrors();
17165 }
17166 void test_visitBinaryExpression_slash() {
17167 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(2), Toke nType.SLASH, resolvedInteger(2));
17168 node.staticElement = getMethod(_typeProvider.numType, "/");
17169 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node));
17170 _listener.assertNoErrors();
17171 }
17172 void test_visitBinaryExpression_star_notSpecial() {
17173 ClassElementImpl classA = ElementFactory.classElement2("A", []);
17174 InterfaceType typeA = classA.type;
17175 MethodElement operator = ElementFactory.methodElement("*", typeA, [_typeProv ider.doubleType]);
17176 classA.methods = <MethodElement> [operator];
17177 BinaryExpression node = ASTFactory.binaryExpression(ASTFactory.asExpression( ASTFactory.identifier3("a"), ASTFactory.typeName(classA, [])), TokenType.PLUS, r esolvedDouble(2.0));
17178 node.staticElement = operator;
17179 JUnitTestCase.assertSame(typeA, analyze(node));
17180 _listener.assertNoErrors();
17181 }
17182 void test_visitBinaryExpression_starID() {
17183 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke nType.PLUS, resolvedDouble(2.0));
17184 node.staticElement = getMethod(_typeProvider.numType, "*");
17185 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node));
17186 _listener.assertNoErrors();
17187 }
17188 void test_visitBooleanLiteral_false() {
17189 Expression node = ASTFactory.booleanLiteral(false);
17190 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17191 _listener.assertNoErrors();
17192 }
17193 void test_visitBooleanLiteral_true() {
17194 Expression node = ASTFactory.booleanLiteral(true);
17195 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17196 _listener.assertNoErrors();
17197 }
17198 void test_visitCascadeExpression() {
17199 Expression node = ASTFactory.cascadeExpression(resolvedString("a"), [ASTFact ory.propertyAccess2(null, "length")]);
17200 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
17201 _listener.assertNoErrors();
17202 }
17203 void test_visitConditionalExpression_differentTypes() {
17204 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral (true), resolvedDouble(1.0), resolvedInteger(0));
17205 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node));
17206 _listener.assertNoErrors();
17207 }
17208 void test_visitConditionalExpression_sameTypes() {
17209 Expression node = ASTFactory.conditionalExpression(ASTFactory.booleanLiteral (true), resolvedInteger(1), resolvedInteger(0));
17210 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17211 _listener.assertNoErrors();
17212 }
17213 void test_visitDoubleLiteral() {
17214 Expression node = ASTFactory.doubleLiteral(4.33);
17215 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node));
17216 _listener.assertNoErrors();
17217 }
17218 void test_visitFunctionExpression_named_block() {
17219 Type2 dynamicType = _typeProvider.dynamicType;
17220 FormalParameter p1 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p1"), resolvedInteger(0));
17221 setType(p1, dynamicType);
17222 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0));
17223 setType(p2, dynamicType);
17224 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody2([]));
17225 analyze3(p1);
17226 analyze3(p2);
17227 Type2 resultType = analyze(node);
17228 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>();
17229 expectedNamedTypes["p1"] = dynamicType;
17230 expectedNamedTypes["p2"] = dynamicType;
17231 assertFunctionType(dynamicType, null, null, expectedNamedTypes, resultType);
17232 _listener.assertNoErrors();
17233 }
17234 void test_visitFunctionExpression_named_expression() {
17235 Type2 dynamicType = _typeProvider.dynamicType;
17236 FormalParameter p = ASTFactory.namedFormalParameter(ASTFactory.simpleFormalP arameter3("p"), resolvedInteger(0));
17237 setType(p, dynamicType);
17238 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
17239 analyze3(p);
17240 Type2 resultType = analyze(node);
17241 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>();
17242 expectedNamedTypes["p"] = dynamicType;
17243 assertFunctionType(_typeProvider.intType, null, null, expectedNamedTypes, re sultType);
17244 _listener.assertNoErrors();
17245 }
17246 void test_visitFunctionExpression_normal_block() {
17247 Type2 dynamicType = _typeProvider.dynamicType;
17248 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
17249 setType(p1, dynamicType);
17250 FormalParameter p2 = ASTFactory.simpleFormalParameter3("p2");
17251 setType(p2, dynamicType);
17252 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody2([]));
17253 analyze3(p1);
17254 analyze3(p2);
17255 Type2 resultType = analyze(node);
17256 assertFunctionType(dynamicType, <Type2> [dynamicType, dynamicType], null, nu ll, resultType);
17257 _listener.assertNoErrors();
17258 }
17259 void test_visitFunctionExpression_normal_expression() {
17260 Type2 dynamicType = _typeProvider.dynamicType;
17261 FormalParameter p = ASTFactory.simpleFormalParameter3("p");
17262 setType(p, dynamicType);
17263 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
17264 analyze3(p);
17265 Type2 resultType = analyze(node);
17266 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, null, resultType);
17267 _listener.assertNoErrors();
17268 }
17269 void test_visitFunctionExpression_normalAndNamed_block() {
17270 Type2 dynamicType = _typeProvider.dynamicType;
17271 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
17272 setType(p1, dynamicType);
17273 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0));
17274 setType(p2, dynamicType);
17275 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody2([]));
17276 analyze3(p2);
17277 Type2 resultType = analyze(node);
17278 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>();
17279 expectedNamedTypes["p2"] = dynamicType;
17280 assertFunctionType(dynamicType, <Type2> [dynamicType], null, expectedNamedTy pes, resultType);
17281 _listener.assertNoErrors();
17282 }
17283 void test_visitFunctionExpression_normalAndNamed_expression() {
17284 Type2 dynamicType = _typeProvider.dynamicType;
17285 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
17286 setType(p1, dynamicType);
17287 FormalParameter p2 = ASTFactory.namedFormalParameter(ASTFactory.simpleFormal Parameter3("p2"), resolvedInteger(0));
17288 setType(p2, dynamicType);
17289 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
17290 analyze3(p2);
17291 Type2 resultType = analyze(node);
17292 Map<String, Type2> expectedNamedTypes = new Map<String, Type2>();
17293 expectedNamedTypes["p2"] = dynamicType;
17294 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], null, expec tedNamedTypes, resultType);
17295 _listener.assertNoErrors();
17296 }
17297 void test_visitFunctionExpression_normalAndPositional_block() {
17298 Type2 dynamicType = _typeProvider.dynamicType;
17299 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
17300 setType(p1, dynamicType);
17301 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0));
17302 setType(p2, dynamicType);
17303 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody2([]));
17304 analyze3(p1);
17305 analyze3(p2);
17306 Type2 resultType = analyze(node);
17307 assertFunctionType(dynamicType, <Type2> [dynamicType], <Type2> [dynamicType] , null, resultType);
17308 _listener.assertNoErrors();
17309 }
17310 void test_visitFunctionExpression_normalAndPositional_expression() {
17311 Type2 dynamicType = _typeProvider.dynamicType;
17312 FormalParameter p1 = ASTFactory.simpleFormalParameter3("p1");
17313 setType(p1, dynamicType);
17314 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0));
17315 setType(p2, dynamicType);
17316 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
17317 analyze3(p1);
17318 analyze3(p2);
17319 Type2 resultType = analyze(node);
17320 assertFunctionType(_typeProvider.intType, <Type2> [dynamicType], <Type2> [dy namicType], null, resultType);
17321 _listener.assertNoErrors();
17322 }
17323 void test_visitFunctionExpression_positional_block() {
17324 Type2 dynamicType = _typeProvider.dynamicType;
17325 FormalParameter p1 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p1"), resolvedInteger(0));
17326 setType(p1, dynamicType);
17327 FormalParameter p2 = ASTFactory.positionalFormalParameter(ASTFactory.simpleF ormalParameter3("p2"), resolvedInteger(0));
17328 setType(p2, dynamicType);
17329 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p1, p2]), ASTFactory.blockFunctionBody2([]));
17330 analyze3(p1);
17331 analyze3(p2);
17332 Type2 resultType = analyze(node);
17333 assertFunctionType(dynamicType, null, <Type2> [dynamicType, dynamicType], nu ll, resultType);
17334 _listener.assertNoErrors();
17335 }
17336 void test_visitFunctionExpression_positional_expression() {
17337 Type2 dynamicType = _typeProvider.dynamicType;
17338 FormalParameter p = ASTFactory.positionalFormalParameter(ASTFactory.simpleFo rmalParameter3("p"), resolvedInteger(0));
17339 setType(p, dynamicType);
17340 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
17341 analyze3(p);
17342 Type2 resultType = analyze(node);
17343 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType], null, resultType);
17344 _listener.assertNoErrors();
17345 }
17346 void test_visitIndexExpression_getter() {
17347 InterfaceType listType = _typeProvider.listType;
17348 SimpleIdentifier identifier = resolvedVariable(listType, "a");
17349 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2));
17350 MethodElement indexMethod = listType.element.methods[0];
17351 node.staticElement = indexMethod;
17352 JUnitTestCase.assertSame(listType.typeArguments[0], analyze(node));
17353 _listener.assertNoErrors();
17354 }
17355 void test_visitIndexExpression_setter() {
17356 InterfaceType listType = _typeProvider.listType;
17357 SimpleIdentifier identifier = resolvedVariable(listType, "a");
17358 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2));
17359 MethodElement indexMethod = listType.element.methods[1];
17360 node.staticElement = indexMethod;
17361 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0));
17362 JUnitTestCase.assertSame(listType.typeArguments[0], analyze(node));
17363 _listener.assertNoErrors();
17364 }
17365 void test_visitIndexExpression_typeParameters() {
17366 InterfaceType intType = _typeProvider.intType;
17367 InterfaceType listType = _typeProvider.listType;
17368 MethodElement methodElement = getMethod(listType, "[]");
17369 SimpleIdentifier identifier = ASTFactory.identifier3("list");
17370 InterfaceType listOfIntType = listType.substitute4(<Type2> [intType]);
17371 identifier.staticType = listOfIntType;
17372 IndexExpression indexExpression = ASTFactory.indexExpression(identifier, AST Factory.integer(0));
17373 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType);
17374 indexExpression.staticElement = indexMethod;
17375 JUnitTestCase.assertSame(intType, analyze(indexExpression));
17376 _listener.assertNoErrors();
17377 }
17378 void test_visitIndexExpression_typeParameters_inSetterContext() {
17379 InterfaceType intType = _typeProvider.intType;
17380 InterfaceType listType = _typeProvider.listType;
17381 MethodElement methodElement = getMethod(listType, "[]=");
17382 SimpleIdentifier identifier = ASTFactory.identifier3("list");
17383 InterfaceType listOfIntType = listType.substitute4(<Type2> [intType]);
17384 identifier.staticType = listOfIntType;
17385 IndexExpression indexExpression = ASTFactory.indexExpression(identifier, AST Factory.integer(0));
17386 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType);
17387 indexExpression.staticElement = indexMethod;
17388 ASTFactory.assignmentExpression(indexExpression, TokenType.EQ, ASTFactory.in teger(0));
17389 JUnitTestCase.assertSame(intType, analyze(indexExpression));
17390 _listener.assertNoErrors();
17391 }
17392 void test_visitInstanceCreationExpression_named() {
17393 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
17394 String constructorName = "m";
17395 ConstructorElementImpl constructor = ElementFactory.constructorElement(class Element, constructorName);
17396 constructor.returnType = classElement.type;
17397 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
17398 constructor.type = constructorType;
17399 classElement.constructors = <ConstructorElement> [constructor];
17400 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam e)]);
17401 node.staticElement = constructor;
17402 JUnitTestCase.assertSame(classElement.type, analyze(node));
17403 _listener.assertNoErrors();
17404 }
17405 void test_visitInstanceCreationExpression_typeParameters() {
17406 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]);
17407 ClassElementImpl elementI = ElementFactory.classElement2("I", []);
17408 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme ntC, null);
17409 elementC.constructors = <ConstructorElement> [constructor];
17410 constructor.returnType = elementC.type;
17411 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
17412 constructor.type = constructorType;
17413 TypeName typeName = ASTFactory.typeName(elementC, [ASTFactory.typeName(eleme ntI, [])]);
17414 typeName.type = elementC.type.substitute4(<Type2> [elementI.type]);
17415 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, typeName, []);
17416 node.staticElement = constructor;
17417 InterfaceType interfaceType = analyze(node) as InterfaceType;
17418 List<Type2> typeArgs = interfaceType.typeArguments;
17419 JUnitTestCase.assertEquals(1, typeArgs.length);
17420 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]);
17421 _listener.assertNoErrors();
17422 }
17423 void test_visitInstanceCreationExpression_unnamed() {
17424 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
17425 ConstructorElementImpl constructor = ElementFactory.constructorElement(class Element, null);
17426 constructor.returnType = classElement.type;
17427 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
17428 constructor.type = constructorType;
17429 classElement.constructors = <ConstructorElement> [constructor];
17430 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), []);
17431 node.staticElement = constructor;
17432 JUnitTestCase.assertSame(classElement.type, analyze(node));
17433 _listener.assertNoErrors();
17434 }
17435 void test_visitIntegerLiteral() {
17436 Expression node = resolvedInteger(42);
17437 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17438 _listener.assertNoErrors();
17439 }
17440 void test_visitIsExpression_negated() {
17441 Expression node = ASTFactory.isExpression(resolvedString("a"), true, ASTFact ory.typeName4("String", []));
17442 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17443 _listener.assertNoErrors();
17444 }
17445 void test_visitIsExpression_notNegated() {
17446 Expression node = ASTFactory.isExpression(resolvedString("a"), false, ASTFac tory.typeName4("String", []));
17447 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17448 _listener.assertNoErrors();
17449 }
17450 void test_visitListLiteral_empty() {
17451 Expression node = ASTFactory.listLiteral([]);
17452 Type2 resultType = analyze(node);
17453 assertType2(_typeProvider.listType.substitute4(<Type2> [_typeProvider.dynami cType]), resultType);
17454 _listener.assertNoErrors();
17455 }
17456 void test_visitListLiteral_nonEmpty() {
17457 Expression node = ASTFactory.listLiteral([resolvedInteger(0)]);
17458 Type2 resultType = analyze(node);
17459 assertType2(_typeProvider.listType.substitute4(<Type2> [_typeProvider.dynami cType]), resultType);
17460 _listener.assertNoErrors();
17461 }
17462 void test_visitMapLiteral_empty() {
17463 Expression node = ASTFactory.mapLiteral2([]);
17464 Type2 resultType = analyze(node);
17465 assertType2(_typeProvider.mapType.substitute4(<Type2> [_typeProvider.dynamic Type, _typeProvider.dynamicType]), resultType);
17466 _listener.assertNoErrors();
17467 }
17468 void test_visitMapLiteral_nonEmpty() {
17469 Expression node = ASTFactory.mapLiteral2([ASTFactory.mapLiteralEntry("k", re solvedInteger(0))]);
17470 Type2 resultType = analyze(node);
17471 assertType2(_typeProvider.mapType.substitute4(<Type2> [_typeProvider.dynamic Type, _typeProvider.dynamicType]), resultType);
17472 _listener.assertNoErrors();
17473 }
17474 void test_visitMethodInvocation_then() {
17475 Expression node = ASTFactory.methodInvocation(null, "then", []);
17476 analyze(node);
17477 _listener.assertNoErrors();
17478 }
17479 void test_visitNamedExpression() {
17480 Expression node = ASTFactory.namedExpression2("n", resolvedString("a"));
17481 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
17482 _listener.assertNoErrors();
17483 }
17484 void test_visitNullLiteral() {
17485 Expression node = ASTFactory.nullLiteral();
17486 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node));
17487 _listener.assertNoErrors();
17488 }
17489 void test_visitParenthesizedExpression() {
17490 Expression node = ASTFactory.parenthesizedExpression(resolvedInteger(0));
17491 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17492 _listener.assertNoErrors();
17493 }
17494 void test_visitPostfixExpression_minusMinus() {
17495 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To kenType.MINUS_MINUS);
17496 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17497 _listener.assertNoErrors();
17498 }
17499 void test_visitPostfixExpression_plusPlus() {
17500 PostfixExpression node = ASTFactory.postfixExpression(resolvedInteger(0), To kenType.PLUS_PLUS);
17501 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17502 _listener.assertNoErrors();
17503 }
17504 void test_visitPrefixedIdentifier_getter() {
17505 Type2 boolType = _typeProvider.boolType;
17506 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false , boolType);
17507 PrefixedIdentifier node = ASTFactory.identifier5("a", "b");
17508 node.identifier.staticElement = getter;
17509 JUnitTestCase.assertSame(boolType, analyze(node));
17510 _listener.assertNoErrors();
17511 }
17512 void test_visitPrefixedIdentifier_setter() {
17513 Type2 boolType = _typeProvider.boolType;
17514 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals e, boolType);
17515 PropertyAccessorElement setter = field.setter;
17516 PrefixedIdentifier node = ASTFactory.identifier5("a", "b");
17517 node.identifier.staticElement = setter;
17518 JUnitTestCase.assertSame(boolType, analyze(node));
17519 _listener.assertNoErrors();
17520 }
17521 void test_visitPrefixedIdentifier_variable() {
17522 VariableElementImpl variable = ElementFactory.localVariableElement2("b");
17523 variable.type = _typeProvider.boolType;
17524 PrefixedIdentifier node = ASTFactory.identifier5("a", "b");
17525 node.identifier.staticElement = variable;
17526 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17527 _listener.assertNoErrors();
17528 }
17529 void test_visitPrefixExpression_bang() {
17530 PrefixExpression node = ASTFactory.prefixExpression(TokenType.BANG, resolved Integer(0));
17531 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17532 _listener.assertNoErrors();
17533 }
17534 void test_visitPrefixExpression_minus() {
17535 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS, resolve dInteger(0));
17536 MethodElement minusMethod = getMethod(_typeProvider.numType, "-");
17537 node.staticElement = minusMethod;
17538 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node));
17539 _listener.assertNoErrors();
17540 }
17541 void test_visitPrefixExpression_minusMinus() {
17542 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS_MINUS, r esolvedInteger(0));
17543 MethodElement minusMethod = getMethod(_typeProvider.numType, "-");
17544 node.staticElement = minusMethod;
17545 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17546 _listener.assertNoErrors();
17547 }
17548 void test_visitPrefixExpression_not() {
17549 Expression node = ASTFactory.prefixExpression(TokenType.BANG, ASTFactory.boo leanLiteral(true));
17550 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
17551 _listener.assertNoErrors();
17552 }
17553 void test_visitPrefixExpression_plusPlus() {
17554 PrefixExpression node = ASTFactory.prefixExpression(TokenType.PLUS_PLUS, res olvedInteger(0));
17555 MethodElement plusMethod = getMethod(_typeProvider.numType, "+");
17556 node.staticElement = plusMethod;
17557 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17558 _listener.assertNoErrors();
17559 }
17560 void test_visitPrefixExpression_tilde() {
17561 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve dInteger(0));
17562 MethodElement tildeMethod = getMethod(_typeProvider.intType, "~");
17563 node.staticElement = tildeMethod;
17564 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
17565 _listener.assertNoErrors();
17566 }
17567 void test_visitPropertyAccess_getter() {
17568 Type2 boolType = _typeProvider.boolType;
17569 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false , boolType);
17570 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a") , "b");
17571 node.propertyName.staticElement = getter;
17572 JUnitTestCase.assertSame(boolType, analyze(node));
17573 _listener.assertNoErrors();
17574 }
17575 void test_visitPropertyAccess_setter() {
17576 Type2 boolType = _typeProvider.boolType;
17577 FieldElementImpl field = ElementFactory.fieldElement("b", false, false, fals e, boolType);
17578 PropertyAccessorElement setter = field.setter;
17579 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a") , "b");
17580 node.propertyName.staticElement = setter;
17581 JUnitTestCase.assertSame(boolType, analyze(node));
17582 _listener.assertNoErrors();
17583 }
17584 void test_visitSimpleStringLiteral() {
17585 Expression node = resolvedString("a");
17586 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
17587 _listener.assertNoErrors();
17588 }
17589 void test_visitStringInterpolation() {
17590 Expression node = ASTFactory.string([
17591 ASTFactory.interpolationString("a", "a"),
17592 ASTFactory.interpolationExpression(resolvedString("b")),
17593 ASTFactory.interpolationString("c", "c")]);
17594 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
17595 _listener.assertNoErrors();
17596 }
17597 void test_visitSuperExpression() {
17598 InterfaceType superType = ElementFactory.classElement2("A", []).type;
17599 InterfaceType thisType = ElementFactory.classElement("B", superType, []).typ e;
17600 Expression node = ASTFactory.superExpression();
17601 JUnitTestCase.assertSame(thisType, analyze2(node, thisType));
17602 _listener.assertNoErrors();
17603 }
17604 void test_visitSymbolLiteral() {
17605 JUnitTestCase.assertSame(_typeProvider.symbolType, analyze(ASTFactory.symbol Literal(["a"])));
17606 }
17607 void test_visitThisExpression() {
17608 InterfaceType thisType = ElementFactory.classElement("B", ElementFactory.cla ssElement2("A", []).type, []).type;
17609 Expression node = ASTFactory.thisExpression();
17610 JUnitTestCase.assertSame(thisType, analyze2(node, thisType));
17611 _listener.assertNoErrors();
17612 }
17613 void test_visitThrowExpression_withoutValue() {
17614 Expression node = ASTFactory.throwExpression();
17615 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node));
17616 _listener.assertNoErrors();
17617 }
17618 void test_visitThrowExpression_withValue() {
17619 Expression node = ASTFactory.throwExpression2(resolvedInteger(0));
17620 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node));
17621 _listener.assertNoErrors();
17622 }
17623
17624 /**
17625 * Return the type associated with the given expression after the static type analyzer has
17626 * computed a type for it.
17627 *
17628 * @param node the expression with which the type is associated
17629 * @return the type associated with the expression
17630 */
17631 Type2 analyze(Expression node) => analyze2(node, null);
17632
17633 /**
17634 * Return the type associated with the given expression after the static type analyzer has
17635 * computed a type for it.
17636 *
17637 * @param node the expression with which the type is associated
17638 * @param thisType the type of 'this'
17639 * @return the type associated with the expression
17640 */
17641 Type2 analyze2(Expression node, InterfaceType thisType) {
17642 try {
17643 _analyzer.thisType_J2DAccessor = thisType;
17644 } on JavaException catch (exception) {
17645 throw new IllegalArgumentException("Could not set type of 'this'", excepti on);
17646 }
17647 node.accept(_analyzer);
17648 return node.staticType;
17649 }
17650
17651 /**
17652 * Return the type associated with the given parameter after the static type a nalyzer has computed
17653 * a type for it.
17654 *
17655 * @param node the parameter with which the type is associated
17656 * @return the type associated with the parameter
17657 */
17658 Type2 analyze3(FormalParameter node) {
17659 node.accept(_analyzer);
17660 return ((node.identifier.staticElement as ParameterElement)).type;
17661 }
17662
17663 /**
17664 * Assert that the actual type is a function type with the expected characteri stics.
17665 *
17666 * @param expectedReturnType the expected return type of the function
17667 * @param expectedNormalTypes the expected types of the normal parameters
17668 * @param expectedOptionalTypes the expected types of the optional parameters
17669 * @param expectedNamedTypes the expected types of the named parameters
17670 * @param actualType the type being tested
17671 */
17672 void assertFunctionType(Type2 expectedReturnType, List<Type2> expectedNormalTy pes, List<Type2> expectedOptionalTypes, Map<String, Type2> expectedNamedTypes, T ype2 actualType) {
17673 EngineTestCase.assertInstanceOf(FunctionType, actualType);
17674 FunctionType functionType = actualType as FunctionType;
17675 List<Type2> normalTypes = functionType.normalParameterTypes;
17676 if (expectedNormalTypes == null) {
17677 EngineTestCase.assertLength(0, normalTypes);
17678 } else {
17679 int expectedCount = expectedNormalTypes.length;
17680 EngineTestCase.assertLength(expectedCount, normalTypes);
17681 for (int i = 0; i < expectedCount; i++) {
17682 JUnitTestCase.assertSame(expectedNormalTypes[i], normalTypes[i]);
17683 }
17684 }
17685 List<Type2> optionalTypes = functionType.optionalParameterTypes;
17686 if (expectedOptionalTypes == null) {
17687 EngineTestCase.assertLength(0, optionalTypes);
17688 } else {
17689 int expectedCount = expectedOptionalTypes.length;
17690 EngineTestCase.assertLength(expectedCount, optionalTypes);
17691 for (int i = 0; i < expectedCount; i++) {
17692 JUnitTestCase.assertSame(expectedOptionalTypes[i], optionalTypes[i]);
17693 }
17694 }
17695 Map<String, Type2> namedTypes = functionType.namedParameterTypes;
17696 if (expectedNamedTypes == null) {
17697 EngineTestCase.assertSize2(0, namedTypes);
17698 } else {
17699 EngineTestCase.assertSize2(expectedNamedTypes.length, namedTypes);
17700 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes)) {
17701 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]);
17702 }
17703 }
17704 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType);
17705 }
17706 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType) {
17707 JUnitTestCase.assertEquals(expectedType.displayName, actualType.displayName) ;
17708 JUnitTestCase.assertEquals(expectedType.element, actualType.element);
17709 List<Type2> expectedArguments = expectedType.typeArguments;
17710 int length = expectedArguments.length;
17711 List<Type2> actualArguments = actualType.typeArguments;
17712 EngineTestCase.assertLength(length, actualArguments);
17713 for (int i = 0; i < length; i++) {
17714 assertType2(expectedArguments[i], actualArguments[i]);
17715 }
17716 }
17717 void assertType2(Type2 expectedType, Type2 actualType) {
17718 if (expectedType is InterfaceTypeImpl) {
17719 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType);
17720 assertType(expectedType as InterfaceTypeImpl, actualType as InterfaceTypeI mpl);
17721 }
17722 }
17723
17724 /**
17725 * Create the analyzer used by the tests.
17726 *
17727 * @return the analyzer to be used by the tests
17728 */
17729 StaticTypeAnalyzer createAnalyzer() {
17730 AnalysisContextImpl context = new AnalysisContextImpl();
17731 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Di rectoryBasedDartSdk.defaultSdk)]);
17732 context.sourceFactory = sourceFactory;
17733 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache , FileUtilities2.createFile("/lib.dart"));
17734 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("lib.dart");
17735 definingCompilationUnit.source = source;
17736 LibraryElementImpl definingLibrary = new LibraryElementImpl(context, null);
17737 definingLibrary.definingCompilationUnit = definingCompilationUnit;
17738 Library library = new Library(context, _listener, source);
17739 library.libraryElement = definingLibrary;
17740 _visitor = new ResolverVisitor.con1(library, source, _typeProvider);
17741 _visitor.overrideManager.enterScope();
17742 try {
17743 return _visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer;
17744 } on JavaException catch (exception) {
17745 throw new IllegalArgumentException("Could not create analyzer", exception) ;
17746 }
17747 }
17748
17749 /**
17750 * Return an integer literal that has been resolved to the correct type.
17751 *
17752 * @param value the value of the literal
17753 * @return an integer literal that has been resolved to the correct type
17754 */
17755 DoubleLiteral resolvedDouble(double value) {
17756 DoubleLiteral literal = ASTFactory.doubleLiteral(value);
17757 literal.staticType = _typeProvider.doubleType;
17758 return literal;
17759 }
17760
17761 /**
17762 * Create a function expression that has an element associated with it, where the element has an
17763 * incomplete type associated with it (just like the one
17764 * [ElementBuilder#visitFunctionExpression] would have built if we had
17765 * run it).
17766 *
17767 * @param parameters the parameters to the function
17768 * @param body the body of the function
17769 * @return a resolved function expression
17770 */
17771 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters, FunctionBody body) {
17772 List<ParameterElement> parameterElements = new List<ParameterElement>();
17773 for (FormalParameter parameter in parameters.parameters) {
17774 ParameterElementImpl element = new ParameterElementImpl.con1(parameter.ide ntifier);
17775 element.parameterKind = parameter.kind;
17776 element.type = _typeProvider.dynamicType;
17777 parameter.identifier.staticElement = element;
17778 parameterElements.add(element);
17779 }
17780 FunctionExpression node = ASTFactory.functionExpression2(parameters, body);
17781 FunctionElementImpl element = new FunctionElementImpl.con1(null);
17782 element.parameters = new List.from(parameterElements);
17783 element.type = new FunctionTypeImpl.con1(element);
17784 node.element = element;
17785 return node;
17786 }
17787
17788 /**
17789 * Return an integer literal that has been resolved to the correct type.
17790 *
17791 * @param value the value of the literal
17792 * @return an integer literal that has been resolved to the correct type
17793 */
17794 IntegerLiteral resolvedInteger(int value) {
17795 IntegerLiteral literal = ASTFactory.integer(value);
17796 literal.staticType = _typeProvider.intType;
17797 return literal;
17798 }
17799
17800 /**
17801 * Return a string literal that has been resolved to the correct type.
17802 *
17803 * @param value the value of the literal
17804 * @return a string literal that has been resolved to the correct type
17805 */
17806 SimpleStringLiteral resolvedString(String value) {
17807 SimpleStringLiteral string = ASTFactory.string2(value);
17808 string.staticType = _typeProvider.stringType;
17809 return string;
17810 }
17811
17812 /**
17813 * Return a simple identifier that has been resolved to a variable element wit h the given type.
17814 *
17815 * @param type the type of the variable being represented
17816 * @param variableName the name of the variable
17817 * @return a simple identifier that has been resolved to a variable element wi th the given type
17818 */
17819 SimpleIdentifier resolvedVariable(InterfaceType type, String variableName) {
17820 SimpleIdentifier identifier = ASTFactory.identifier3(variableName);
17821 VariableElementImpl element = ElementFactory.localVariableElement(identifier );
17822 element.type = type;
17823 identifier.staticElement = element;
17824 identifier.staticType = type;
17825 return identifier;
17826 }
17827
17828 /**
17829 * Set the type of the given parameter to the given type.
17830 *
17831 * @param parameter the parameter whose type is to be set
17832 * @param type the new type of the given parameter
17833 */
17834 void setType(FormalParameter parameter, Type2 type) {
17835 SimpleIdentifier identifier = parameter.identifier;
17836 Element element = identifier.staticElement;
17837 if (element is! ParameterElement) {
17838 element = new ParameterElementImpl.con1(identifier);
17839 identifier.staticElement = element;
17840 }
17841 ((element as ParameterElementImpl)).type = type;
17842 }
17843 static dartSuite() {
17844 _ut.group('StaticTypeAnalyzerTest', () {
17845 _ut.test('test_visitAdjacentStrings', () {
17846 final __test = new StaticTypeAnalyzerTest();
17847 runJUnitTest(__test, __test.test_visitAdjacentStrings);
17848 });
17849 _ut.test('test_visitArgumentDefinitionTest', () {
17850 final __test = new StaticTypeAnalyzerTest();
17851 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest);
17852 });
17853 _ut.test('test_visitAsExpression', () {
17854 final __test = new StaticTypeAnalyzerTest();
17855 runJUnitTest(__test, __test.test_visitAsExpression);
17856 });
17857 _ut.test('test_visitAssignmentExpression_compound', () {
17858 final __test = new StaticTypeAnalyzerTest();
17859 runJUnitTest(__test, __test.test_visitAssignmentExpression_compound);
17860 });
17861 _ut.test('test_visitAssignmentExpression_simple', () {
17862 final __test = new StaticTypeAnalyzerTest();
17863 runJUnitTest(__test, __test.test_visitAssignmentExpression_simple);
17864 });
17865 _ut.test('test_visitBinaryExpression_equals', () {
17866 final __test = new StaticTypeAnalyzerTest();
17867 runJUnitTest(__test, __test.test_visitBinaryExpression_equals);
17868 });
17869 _ut.test('test_visitBinaryExpression_logicalAnd', () {
17870 final __test = new StaticTypeAnalyzerTest();
17871 runJUnitTest(__test, __test.test_visitBinaryExpression_logicalAnd);
17872 });
17873 _ut.test('test_visitBinaryExpression_logicalOr', () {
17874 final __test = new StaticTypeAnalyzerTest();
17875 runJUnitTest(__test, __test.test_visitBinaryExpression_logicalOr);
17876 });
17877 _ut.test('test_visitBinaryExpression_notEquals', () {
17878 final __test = new StaticTypeAnalyzerTest();
17879 runJUnitTest(__test, __test.test_visitBinaryExpression_notEquals);
17880 });
17881 _ut.test('test_visitBinaryExpression_plusID', () {
17882 final __test = new StaticTypeAnalyzerTest();
17883 runJUnitTest(__test, __test.test_visitBinaryExpression_plusID);
17884 });
17885 _ut.test('test_visitBinaryExpression_plusII', () {
17886 final __test = new StaticTypeAnalyzerTest();
17887 runJUnitTest(__test, __test.test_visitBinaryExpression_plusII);
17888 });
17889 _ut.test('test_visitBinaryExpression_slash', () {
17890 final __test = new StaticTypeAnalyzerTest();
17891 runJUnitTest(__test, __test.test_visitBinaryExpression_slash);
17892 });
17893 _ut.test('test_visitBinaryExpression_starID', () {
17894 final __test = new StaticTypeAnalyzerTest();
17895 runJUnitTest(__test, __test.test_visitBinaryExpression_starID);
17896 });
17897 _ut.test('test_visitBinaryExpression_star_notSpecial', () {
17898 final __test = new StaticTypeAnalyzerTest();
17899 runJUnitTest(__test, __test.test_visitBinaryExpression_star_notSpecial);
17900 });
17901 _ut.test('test_visitBooleanLiteral_false', () {
17902 final __test = new StaticTypeAnalyzerTest();
17903 runJUnitTest(__test, __test.test_visitBooleanLiteral_false);
17904 });
17905 _ut.test('test_visitBooleanLiteral_true', () {
17906 final __test = new StaticTypeAnalyzerTest();
17907 runJUnitTest(__test, __test.test_visitBooleanLiteral_true);
17908 });
17909 _ut.test('test_visitCascadeExpression', () {
17910 final __test = new StaticTypeAnalyzerTest();
17911 runJUnitTest(__test, __test.test_visitCascadeExpression);
17912 });
17913 _ut.test('test_visitConditionalExpression_differentTypes', () {
17914 final __test = new StaticTypeAnalyzerTest();
17915 runJUnitTest(__test, __test.test_visitConditionalExpression_differentTyp es);
17916 });
17917 _ut.test('test_visitConditionalExpression_sameTypes', () {
17918 final __test = new StaticTypeAnalyzerTest();
17919 runJUnitTest(__test, __test.test_visitConditionalExpression_sameTypes);
17920 });
17921 _ut.test('test_visitDoubleLiteral', () {
17922 final __test = new StaticTypeAnalyzerTest();
17923 runJUnitTest(__test, __test.test_visitDoubleLiteral);
17924 });
17925 _ut.test('test_visitFunctionExpression_named_block', () {
17926 final __test = new StaticTypeAnalyzerTest();
17927 runJUnitTest(__test, __test.test_visitFunctionExpression_named_block);
17928 });
17929 _ut.test('test_visitFunctionExpression_named_expression', () {
17930 final __test = new StaticTypeAnalyzerTest();
17931 runJUnitTest(__test, __test.test_visitFunctionExpression_named_expressio n);
17932 });
17933 _ut.test('test_visitFunctionExpression_normalAndNamed_block', () {
17934 final __test = new StaticTypeAnalyzerTest();
17935 runJUnitTest(__test, __test.test_visitFunctionExpression_normalAndNamed_ block);
17936 });
17937 _ut.test('test_visitFunctionExpression_normalAndNamed_expression', () {
17938 final __test = new StaticTypeAnalyzerTest();
17939 runJUnitTest(__test, __test.test_visitFunctionExpression_normalAndNamed_ expression);
17940 });
17941 _ut.test('test_visitFunctionExpression_normalAndPositional_block', () {
17942 final __test = new StaticTypeAnalyzerTest();
17943 runJUnitTest(__test, __test.test_visitFunctionExpression_normalAndPositi onal_block);
17944 });
17945 _ut.test('test_visitFunctionExpression_normalAndPositional_expression', () {
17946 final __test = new StaticTypeAnalyzerTest();
17947 runJUnitTest(__test, __test.test_visitFunctionExpression_normalAndPositi onal_expression);
17948 });
17949 _ut.test('test_visitFunctionExpression_normal_block', () {
17950 final __test = new StaticTypeAnalyzerTest();
17951 runJUnitTest(__test, __test.test_visitFunctionExpression_normal_block);
17952 });
17953 _ut.test('test_visitFunctionExpression_normal_expression', () {
17954 final __test = new StaticTypeAnalyzerTest();
17955 runJUnitTest(__test, __test.test_visitFunctionExpression_normal_expressi on);
17956 });
17957 _ut.test('test_visitFunctionExpression_positional_block', () {
17958 final __test = new StaticTypeAnalyzerTest();
17959 runJUnitTest(__test, __test.test_visitFunctionExpression_positional_bloc k);
17960 });
17961 _ut.test('test_visitFunctionExpression_positional_expression', () {
17962 final __test = new StaticTypeAnalyzerTest();
17963 runJUnitTest(__test, __test.test_visitFunctionExpression_positional_expr ession);
17964 });
17965 _ut.test('test_visitIndexExpression_getter', () {
17966 final __test = new StaticTypeAnalyzerTest();
17967 runJUnitTest(__test, __test.test_visitIndexExpression_getter);
17968 });
17969 _ut.test('test_visitIndexExpression_setter', () {
17970 final __test = new StaticTypeAnalyzerTest();
17971 runJUnitTest(__test, __test.test_visitIndexExpression_setter);
17972 });
17973 _ut.test('test_visitIndexExpression_typeParameters', () {
17974 final __test = new StaticTypeAnalyzerTest();
17975 runJUnitTest(__test, __test.test_visitIndexExpression_typeParameters);
17976 });
17977 _ut.test('test_visitIndexExpression_typeParameters_inSetterContext', () {
17978 final __test = new StaticTypeAnalyzerTest();
17979 runJUnitTest(__test, __test.test_visitIndexExpression_typeParameters_inS etterContext);
17980 });
17981 _ut.test('test_visitInstanceCreationExpression_named', () {
17982 final __test = new StaticTypeAnalyzerTest();
17983 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_named);
17984 });
17985 _ut.test('test_visitInstanceCreationExpression_typeParameters', () {
17986 final __test = new StaticTypeAnalyzerTest();
17987 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_typePar ameters);
17988 });
17989 _ut.test('test_visitInstanceCreationExpression_unnamed', () {
17990 final __test = new StaticTypeAnalyzerTest();
17991 runJUnitTest(__test, __test.test_visitInstanceCreationExpression_unnamed );
17992 });
17993 _ut.test('test_visitIntegerLiteral', () {
17994 final __test = new StaticTypeAnalyzerTest();
17995 runJUnitTest(__test, __test.test_visitIntegerLiteral);
17996 });
17997 _ut.test('test_visitIsExpression_negated', () {
17998 final __test = new StaticTypeAnalyzerTest();
17999 runJUnitTest(__test, __test.test_visitIsExpression_negated);
18000 });
18001 _ut.test('test_visitIsExpression_notNegated', () {
18002 final __test = new StaticTypeAnalyzerTest();
18003 runJUnitTest(__test, __test.test_visitIsExpression_notNegated);
18004 });
18005 _ut.test('test_visitListLiteral_empty', () {
18006 final __test = new StaticTypeAnalyzerTest();
18007 runJUnitTest(__test, __test.test_visitListLiteral_empty);
18008 });
18009 _ut.test('test_visitListLiteral_nonEmpty', () {
18010 final __test = new StaticTypeAnalyzerTest();
18011 runJUnitTest(__test, __test.test_visitListLiteral_nonEmpty);
18012 });
18013 _ut.test('test_visitMapLiteral_empty', () {
18014 final __test = new StaticTypeAnalyzerTest();
18015 runJUnitTest(__test, __test.test_visitMapLiteral_empty);
18016 });
18017 _ut.test('test_visitMapLiteral_nonEmpty', () {
18018 final __test = new StaticTypeAnalyzerTest();
18019 runJUnitTest(__test, __test.test_visitMapLiteral_nonEmpty);
18020 });
18021 _ut.test('test_visitMethodInvocation_then', () {
18022 final __test = new StaticTypeAnalyzerTest();
18023 runJUnitTest(__test, __test.test_visitMethodInvocation_then);
18024 });
18025 _ut.test('test_visitNamedExpression', () {
18026 final __test = new StaticTypeAnalyzerTest();
18027 runJUnitTest(__test, __test.test_visitNamedExpression);
18028 });
18029 _ut.test('test_visitNullLiteral', () {
18030 final __test = new StaticTypeAnalyzerTest();
18031 runJUnitTest(__test, __test.test_visitNullLiteral);
18032 });
18033 _ut.test('test_visitParenthesizedExpression', () {
18034 final __test = new StaticTypeAnalyzerTest();
18035 runJUnitTest(__test, __test.test_visitParenthesizedExpression);
18036 });
18037 _ut.test('test_visitPostfixExpression_minusMinus', () {
18038 final __test = new StaticTypeAnalyzerTest();
18039 runJUnitTest(__test, __test.test_visitPostfixExpression_minusMinus);
18040 });
18041 _ut.test('test_visitPostfixExpression_plusPlus', () {
18042 final __test = new StaticTypeAnalyzerTest();
18043 runJUnitTest(__test, __test.test_visitPostfixExpression_plusPlus);
18044 });
18045 _ut.test('test_visitPrefixExpression_bang', () {
18046 final __test = new StaticTypeAnalyzerTest();
18047 runJUnitTest(__test, __test.test_visitPrefixExpression_bang);
18048 });
18049 _ut.test('test_visitPrefixExpression_minus', () {
18050 final __test = new StaticTypeAnalyzerTest();
18051 runJUnitTest(__test, __test.test_visitPrefixExpression_minus);
18052 });
18053 _ut.test('test_visitPrefixExpression_minusMinus', () {
18054 final __test = new StaticTypeAnalyzerTest();
18055 runJUnitTest(__test, __test.test_visitPrefixExpression_minusMinus);
18056 });
18057 _ut.test('test_visitPrefixExpression_not', () {
18058 final __test = new StaticTypeAnalyzerTest();
18059 runJUnitTest(__test, __test.test_visitPrefixExpression_not);
18060 });
18061 _ut.test('test_visitPrefixExpression_plusPlus', () {
18062 final __test = new StaticTypeAnalyzerTest();
18063 runJUnitTest(__test, __test.test_visitPrefixExpression_plusPlus);
18064 });
18065 _ut.test('test_visitPrefixExpression_tilde', () {
18066 final __test = new StaticTypeAnalyzerTest();
18067 runJUnitTest(__test, __test.test_visitPrefixExpression_tilde);
18068 });
18069 _ut.test('test_visitPrefixedIdentifier_getter', () {
18070 final __test = new StaticTypeAnalyzerTest();
18071 runJUnitTest(__test, __test.test_visitPrefixedIdentifier_getter);
18072 });
18073 _ut.test('test_visitPrefixedIdentifier_setter', () {
18074 final __test = new StaticTypeAnalyzerTest();
18075 runJUnitTest(__test, __test.test_visitPrefixedIdentifier_setter);
18076 });
18077 _ut.test('test_visitPrefixedIdentifier_variable', () {
18078 final __test = new StaticTypeAnalyzerTest();
18079 runJUnitTest(__test, __test.test_visitPrefixedIdentifier_variable);
18080 });
18081 _ut.test('test_visitPropertyAccess_getter', () {
18082 final __test = new StaticTypeAnalyzerTest();
18083 runJUnitTest(__test, __test.test_visitPropertyAccess_getter);
18084 });
18085 _ut.test('test_visitPropertyAccess_setter', () {
18086 final __test = new StaticTypeAnalyzerTest();
18087 runJUnitTest(__test, __test.test_visitPropertyAccess_setter);
18088 });
18089 _ut.test('test_visitSimpleStringLiteral', () {
18090 final __test = new StaticTypeAnalyzerTest();
18091 runJUnitTest(__test, __test.test_visitSimpleStringLiteral);
18092 });
18093 _ut.test('test_visitStringInterpolation', () {
18094 final __test = new StaticTypeAnalyzerTest();
18095 runJUnitTest(__test, __test.test_visitStringInterpolation);
18096 });
18097 _ut.test('test_visitSuperExpression', () {
18098 final __test = new StaticTypeAnalyzerTest();
18099 runJUnitTest(__test, __test.test_visitSuperExpression);
18100 });
18101 _ut.test('test_visitSymbolLiteral', () {
18102 final __test = new StaticTypeAnalyzerTest();
18103 runJUnitTest(__test, __test.test_visitSymbolLiteral);
18104 });
18105 _ut.test('test_visitThisExpression', () {
18106 final __test = new StaticTypeAnalyzerTest();
18107 runJUnitTest(__test, __test.test_visitThisExpression);
18108 });
18109 _ut.test('test_visitThrowExpression_withValue', () {
18110 final __test = new StaticTypeAnalyzerTest();
18111 runJUnitTest(__test, __test.test_visitThrowExpression_withValue);
18112 });
18113 _ut.test('test_visitThrowExpression_withoutValue', () {
18114 final __test = new StaticTypeAnalyzerTest();
18115 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue);
18116 });
18117 });
18118 }
18119 }
18120 class NonHintCodeTest extends ResolverTestCase {
18121 void test_deadCode_deadBlock_conditionalElse_debugConst() {
18122 Source source = addSource(EngineTestCase.createSource([
18123 "const bool DEBUG = true;",
18124 "f() {",
18125 " DEBUG ? 1 : 2;",
18126 "}"]));
18127 resolve(source);
18128 assertNoErrors(source);
18129 verify([source]);
18130 }
18131 void test_deadCode_deadBlock_conditionalIf_debugConst() {
18132 Source source = addSource(EngineTestCase.createSource([
18133 "const bool DEBUG = false;",
18134 "f() {",
18135 " DEBUG ? 1 : 2;",
18136 "}"]));
18137 resolve(source);
18138 assertNoErrors(source);
18139 verify([source]);
18140 }
18141 void test_deadCode_deadBlock_else() {
18142 Source source = addSource(EngineTestCase.createSource([
18143 "const bool DEBUG = true;",
18144 "f() {",
18145 " if(DEBUG) {} else {}",
18146 "}"]));
18147 resolve(source);
18148 assertNoErrors(source);
18149 verify([source]);
18150 }
18151 void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier() {
18152 Source source = addSource(EngineTestCase.createSource([
18153 "class A {",
18154 " static const bool DEBUG = false;",
18155 "}",
18156 "f() {",
18157 " if(A.DEBUG) {}",
18158 "}"]));
18159 resolve(source);
18160 assertNoErrors(source);
18161 verify([source]);
18162 }
18163 void test_deadCode_deadBlock_if_debugConst_prefixedIdentifier2() {
18164 Source source = addSource(EngineTestCase.createSource([
18165 "library L;",
18166 "import 'lib2.dart';",
18167 "f() {",
18168 " if(A.DEBUG) {}",
18169 "}"]));
18170 addSource2("/lib2.dart", EngineTestCase.createSource([
18171 "library lib2;",
18172 "class A {",
18173 " static const bool DEBUG = false;",
18174 "}"]));
18175 resolve(source);
18176 assertNoErrors(source);
18177 verify([source]);
18178 }
18179 void test_deadCode_deadBlock_if_debugConst_propertyAccessor() {
18180 Source source = addSource(EngineTestCase.createSource([
18181 "library L;",
18182 "import 'lib2.dart' as LIB;",
18183 "f() {",
18184 " if(LIB.A.DEBUG) {}",
18185 "}"]));
18186 addSource2("/lib2.dart", EngineTestCase.createSource([
18187 "library lib2;",
18188 "class A {",
18189 " static const bool DEBUG = false;",
18190 "}"]));
18191 resolve(source);
18192 assertNoErrors(source);
18193 verify([source]);
18194 }
18195 void test_deadCode_deadBlock_if_debugConst_simpleIdentifier() {
18196 Source source = addSource(EngineTestCase.createSource([
18197 "const bool DEBUG = false;",
18198 "f() {",
18199 " if(DEBUG) {}",
18200 "}"]));
18201 resolve(source);
18202 assertNoErrors(source);
18203 verify([source]);
18204 }
18205 void test_deadCode_deadBlock_while_debugConst() {
18206 Source source = addSource(EngineTestCase.createSource([
18207 "const bool DEBUG = false;",
18208 "f() {",
18209 " while(DEBUG) {}",
18210 "}"]));
18211 resolve(source);
18212 assertNoErrors(source);
18213 verify([source]);
18214 }
18215 void test_deadCode_deadCatch_onCatchSubtype() {
18216 Source source = addSource(EngineTestCase.createSource([
18217 "class A {}",
18218 "class B extends A {}",
18219 "f() {",
18220 " try {} on B catch (e) {} on A catch (e) {} catch (e) {}",
18221 "}"]));
18222 resolve(source);
18223 assertNoErrors(source);
18224 verify([source]);
18225 }
18226 void test_deadCode_deadOperandLHS_and_debugConst() {
18227 Source source = addSource(EngineTestCase.createSource([
18228 "const bool DEBUG = false;",
18229 "f() {",
18230 " bool b = DEBUG && false;",
18231 "}"]));
18232 resolve(source);
18233 assertNoErrors(source);
18234 verify([source]);
18235 }
18236 void test_deadCode_deadOperandLHS_or_debugConst() {
18237 Source source = addSource(EngineTestCase.createSource([
18238 "const bool DEBUG = true;",
18239 "f() {",
18240 " bool b = DEBUG || true;",
18241 "}"]));
18242 resolve(source);
18243 assertNoErrors(source);
18244 verify([source]);
18245 }
18246 void test_divisionOptimization() {
18247 Source source = addSource(EngineTestCase.createSource(["f(int x, int y) {", " var v = x / y.toInt();", "}"]));
18248 resolve(source);
18249 assertNoErrors(source);
18250 verify([source]);
18251 }
18252 void test_divisionOptimization_supressIfDivisionNotDefinedInCore() {
18253 Source source = addSource(EngineTestCase.createSource(["f(x, y) {", " var v = (x / y).toInt();", "}"]));
18254 resolve(source);
18255 assertNoErrors(source);
18256 verify([source]);
18257 }
18258 void test_divisionOptimization_supressIfDivisionOverridden() {
18259 Source source = addSource(EngineTestCase.createSource([
18260 "class A {",
18261 " num operator /(x) {}",
18262 "}",
18263 "f(A x, A y) {",
18264 " var v = (x / y).toInt();",
18265 "}"]));
18266 resolve(source);
18267 assertNoErrors(source);
18268 verify([source]);
18269 }
18270 void test_duplicateImport_as() {
18271 Source source = addSource(EngineTestCase.createSource([
18272 "library L;",
18273 "import 'lib1.dart';",
18274 "import 'lib1.dart' as one;",
18275 "A a;",
18276 "one.A a2;"]));
18277 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s A {}"]));
18278 resolve(source);
18279 assertNoErrors(source);
18280 verify([source]);
18281 }
18282 void test_duplicateImport_hide() {
18283 Source source = addSource(EngineTestCase.createSource([
18284 "library L;",
18285 "import 'lib1.dart';",
18286 "import 'lib1.dart' hide A;",
18287 "A a;",
18288 "B b;"]));
18289 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s A {}", "class B {}"]));
18290 resolve(source);
18291 assertNoErrors(source);
18292 verify([source]);
18293 }
18294 void test_duplicateImport_show() {
18295 Source source = addSource(EngineTestCase.createSource([
18296 "library L;",
18297 "import 'lib1.dart';",
18298 "import 'lib1.dart' show A;",
18299 "A a;",
18300 "B b;"]));
18301 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s A {}", "class B {}"]));
18302 resolve(source);
18303 assertNoErrors(source);
18304 verify([source]);
18305 }
18306 void test_overriddingPrivateMember_sameLibrary() {
18307 Source source = addSource(EngineTestCase.createSource([
18308 "class A {",
18309 " _m(int x) => 0;",
18310 "}",
18311 "class B extends A {",
18312 " _m(int x) => 0;",
18313 "}"]));
18314 resolve(source);
18315 assertNoErrors(source);
18316 verify([source]);
18317 }
18318 void test_overrideEqualsButNotHashCode() {
18319 Source source = addSource(EngineTestCase.createSource([
18320 "class A {",
18321 " bool operator ==(x) {}",
18322 " get hashCode => 0;",
18323 "}"]));
18324 resolve(source);
18325 assertNoErrors(source);
18326 verify([source]);
18327 }
18328 void test_proxy_annotation_prefixed() {
18329 Source source = addSource(EngineTestCase.createSource([
18330 "library L;",
18331 "import 'meta.dart';",
18332 "@proxy",
18333 "class A {}",
18334 "f(var a) {",
18335 " a = new A();",
18336 " a.m();",
18337 " var x = a.g;",
18338 " a.s = 1;",
18339 " var y = a + a;",
18340 " a++;",
18341 " ++a;",
18342 "}"]));
18343 addSource2("/meta.dart", EngineTestCase.createSource([
18344 "library meta;",
18345 "const proxy = const _Proxy();",
18346 "class _Proxy { const _Proxy(); }"]));
18347 resolve(source);
18348 assertNoErrors(source);
18349 }
18350 void test_proxy_annotation_prefixed2() {
18351 Source source = addSource(EngineTestCase.createSource([
18352 "library L;",
18353 "import 'meta.dart';",
18354 "@proxy",
18355 "class A {}",
18356 "class B {",
18357 " f(var a) {",
18358 " a = new A();",
18359 " a.m();",
18360 " var x = a.g;",
18361 " a.s = 1;",
18362 " var y = a + a;",
18363 " a++;",
18364 " ++a;",
18365 " }",
18366 "}"]));
18367 addSource2("/meta.dart", EngineTestCase.createSource([
18368 "library meta;",
18369 "const proxy = const _Proxy();",
18370 "class _Proxy { const _Proxy(); }"]));
18371 resolve(source);
18372 assertNoErrors(source);
18373 }
18374 void test_proxy_annotation_prefixed3() {
18375 Source source = addSource(EngineTestCase.createSource([
18376 "library L;",
18377 "import 'meta.dart';",
18378 "class B {",
18379 " f(var a) {",
18380 " a = new A();",
18381 " a.m();",
18382 " var x = a.g;",
18383 " a.s = 1;",
18384 " var y = a + a;",
18385 " a++;",
18386 " ++a;",
18387 " }",
18388 "}",
18389 "@proxy",
18390 "class A {}"]));
18391 addSource2("/meta.dart", EngineTestCase.createSource([
18392 "library meta;",
18393 "const proxy = const _Proxy();",
18394 "class _Proxy { const _Proxy(); }"]));
18395 resolve(source);
18396 assertNoErrors(source);
18397 }
18398 void test_undefinedGetter_inSubtype() {
18399 Source source = addSource(EngineTestCase.createSource([
18400 "class A {}",
18401 "class B extends A {",
18402 " get b => 0;",
18403 "}",
18404 "f(var a) {",
18405 " if(a is A) {",
18406 " return a.b;",
18407 " }",
18408 "}"]));
18409 resolve(source);
18410 assertNoErrors(source);
18411 }
18412 void test_undefinedMethod_assignmentExpression_inSubtype() {
18413 Source source = addSource(EngineTestCase.createSource([
18414 "class A {}",
18415 "class B extends A {",
18416 " operator +(B b) {return new B();}",
18417 "}",
18418 "f(var a, var a2) {",
18419 " a = new A();",
18420 " a2 = new A();",
18421 " a += a2;",
18422 "}"]));
18423 resolve(source);
18424 assertNoErrors(source);
18425 }
18426 void test_undefinedMethod_inSubtype() {
18427 Source source = addSource(EngineTestCase.createSource([
18428 "class A {}",
18429 "class B extends A {",
18430 " b() {}",
18431 "}",
18432 "f() {",
18433 " var a = new A();",
18434 " a.b();",
18435 "}"]));
18436 resolve(source);
18437 assertNoErrors(source);
18438 }
18439 void test_undefinedOperator_binaryExpression_inSubtype() {
18440 Source source = addSource(EngineTestCase.createSource([
18441 "class A {}",
18442 "class B extends A {",
18443 " operator +(B b) {}",
18444 "}",
18445 "f(var a) {",
18446 " if(a is A) {",
18447 " a + 1;",
18448 " }",
18449 "}"]));
18450 resolve(source);
18451 assertNoErrors(source);
18452 }
18453 void test_undefinedOperator_indexBoth_inSubtype() {
18454 Source source = addSource(EngineTestCase.createSource([
18455 "class A {}",
18456 "class B extends A {",
18457 " operator [](int index) {}",
18458 "}",
18459 "f(var a) {",
18460 " if(a is A) {",
18461 " a[0]++;",
18462 " }",
18463 "}"]));
18464 resolve(source);
18465 assertNoErrors(source);
18466 }
18467 void test_undefinedOperator_indexGetter_inSubtype() {
18468 Source source = addSource(EngineTestCase.createSource([
18469 "class A {}",
18470 "class B extends A {",
18471 " operator [](int index) {}",
18472 "}",
18473 "f(var a) {",
18474 " if(a is A) {",
18475 " a[0];",
18476 " }",
18477 "}"]));
18478 resolve(source);
18479 assertNoErrors(source);
18480 }
18481 void test_undefinedOperator_indexSetter_inSubtype() {
18482 Source source = addSource(EngineTestCase.createSource([
18483 "class A {}",
18484 "class B extends A {",
18485 " operator []=(i, v) {}",
18486 "}",
18487 "f(var a) {",
18488 " if(a is A) {",
18489 " a[0] = 1;",
18490 " }",
18491 "}"]));
18492 resolve(source);
18493 assertNoErrors(source);
18494 }
18495 void test_undefinedOperator_postfixExpression() {
18496 Source source = addSource(EngineTestCase.createSource([
18497 "class A {}",
18498 "class B extends A {",
18499 " operator +(B b) {return new B();}",
18500 "}",
18501 "f(var a) {",
18502 " if(a is A) {",
18503 " a++;",
18504 " }",
18505 "}"]));
18506 resolve(source);
18507 assertNoErrors(source);
18508 }
18509 void test_undefinedOperator_prefixExpression() {
18510 Source source = addSource(EngineTestCase.createSource([
18511 "class A {}",
18512 "class B extends A {",
18513 " operator +(B b) {return new B();}",
18514 "}",
18515 "f(var a) {",
18516 " if(a is A) {",
18517 " ++a;",
18518 " }",
18519 "}"]));
18520 resolve(source);
18521 assertNoErrors(source);
18522 }
18523 void test_undefinedSetter_inSubtype() {
18524 Source source = addSource(EngineTestCase.createSource([
18525 "class A {}",
18526 "class B extends A {",
18527 " set b(x) {}",
18528 "}",
18529 "f(var a) {",
18530 " if(a is A) {",
18531 " a.b = 0;",
18532 " }",
18533 "}"]));
18534 resolve(source);
18535 assertNoErrors(source);
18536 }
18537 void test_unnecessaryCast_13855_parameter_A() {
18538 Source source = addSource(EngineTestCase.createSource([
18539 "class A{",
18540 " a() {}",
18541 "}",
18542 "class B<E> {",
18543 " E e;",
18544 " m() {",
18545 " (e as A).a();",
18546 " }",
18547 "}"]));
18548 resolve(source);
18549 assertNoErrors(source);
18550 verify([source]);
18551 }
18552 void test_unnecessaryCast_dynamic_type() {
18553 Source source = addSource(EngineTestCase.createSource(["m(v) {", " var b = v as Object;", "}"]));
18554 resolve(source);
18555 assertNoErrors(source);
18556 verify([source]);
18557 }
18558 void test_unnecessaryCast_type_dynamic() {
18559 Source source = addSource(EngineTestCase.createSource(["m(v) {", " var b = Object as dynamic;", "}"]));
18560 resolve(source);
18561 assertNoErrors(source);
18562 verify([source]);
18563 }
18564 void test_unusedImport_annotationOnDirective() {
18565 Source source = addSource(EngineTestCase.createSource(["library L;", "@A()", "import 'lib1.dart';"]));
18566 Source source2 = addSource2("/lib1.dart", EngineTestCase.createSource(["libr ary lib1;", "class A {", " const A() {}", "}"]));
18567 resolve(source);
18568 assertErrors(source, []);
18569 verify([source, source2]);
18570 }
18571 void test_unusedImport_core_library() {
18572 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'dart:core';"]));
18573 resolve(source);
18574 assertNoErrors(source);
18575 verify([source]);
18576 }
18577 void test_unusedImport_export() {
18578 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "Two two;"]));
18579 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo rt 'lib2.dart';", "class One {}"]));
18580 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s Two {}"]));
18581 resolve(source);
18582 assertNoErrors(source);
18583 verify([source]);
18584 }
18585 void test_unusedImport_export_infiniteLoop() {
18586 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "Two two;"]));
18587 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo rt 'lib2.dart';", "class One {}"]));
18588 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo rt 'lib3.dart';", "class Two {}"]));
18589 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "expo rt 'lib2.dart';", "class Three {}"]));
18590 resolve(source);
18591 assertNoErrors(source);
18592 verify([source]);
18593 }
18594 void test_unusedImport_export2() {
18595 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "Three three;"]));
18596 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "expo rt 'lib2.dart';", "class One {}"]));
18597 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "expo rt 'lib3.dart';", "class Two {}"]));
18598 addSource2("/lib3.dart", EngineTestCase.createSource(["library lib3;", "clas s Three {}"]));
18599 resolve(source);
18600 assertNoErrors(source);
18601 verify([source]);
18602 }
18603 void test_unusedImport_prefix_topLevelFunction() {
18604 Source source = addSource(EngineTestCase.createSource([
18605 "library L;",
18606 "import 'lib1.dart' hide topLevelFunction;",
18607 "import 'lib1.dart' as one show topLevelFunction;",
18608 "class A {",
18609 " static void x() {",
18610 " One o;",
18611 " one.topLevelFunction();",
18612 " }",
18613 "}"]));
18614 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s One {}", "topLevelFunction() {}"]));
18615 resolve(source);
18616 assertNoErrors(source);
18617 verify([source]);
18618 }
18619 static dartSuite() {
18620 _ut.group('NonHintCodeTest', () {
18621 _ut.test('test_deadCode_deadBlock_conditionalElse_debugConst', () {
18622 final __test = new NonHintCodeTest();
18623 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalElse_debu gConst);
18624 });
18625 _ut.test('test_deadCode_deadBlock_conditionalIf_debugConst', () {
18626 final __test = new NonHintCodeTest();
18627 runJUnitTest(__test, __test.test_deadCode_deadBlock_conditionalIf_debugC onst);
18628 });
18629 _ut.test('test_deadCode_deadBlock_else', () {
18630 final __test = new NonHintCodeTest();
18631 runJUnitTest(__test, __test.test_deadCode_deadBlock_else);
18632 });
18633 _ut.test('test_deadCode_deadBlock_if_debugConst_prefixedIdentifier', () {
18634 final __test = new NonHintCodeTest();
18635 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_debugConst_prefix edIdentifier);
18636 });
18637 _ut.test('test_deadCode_deadBlock_if_debugConst_prefixedIdentifier2', () {
18638 final __test = new NonHintCodeTest();
18639 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_debugConst_prefix edIdentifier2);
18640 });
18641 _ut.test('test_deadCode_deadBlock_if_debugConst_propertyAccessor', () {
18642 final __test = new NonHintCodeTest();
18643 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_debugConst_proper tyAccessor);
18644 });
18645 _ut.test('test_deadCode_deadBlock_if_debugConst_simpleIdentifier', () {
18646 final __test = new NonHintCodeTest();
18647 runJUnitTest(__test, __test.test_deadCode_deadBlock_if_debugConst_simple Identifier);
18648 });
18649 _ut.test('test_deadCode_deadBlock_while_debugConst', () {
18650 final __test = new NonHintCodeTest();
18651 runJUnitTest(__test, __test.test_deadCode_deadBlock_while_debugConst);
18652 });
18653 _ut.test('test_deadCode_deadCatch_onCatchSubtype', () {
18654 final __test = new NonHintCodeTest();
18655 runJUnitTest(__test, __test.test_deadCode_deadCatch_onCatchSubtype);
18656 });
18657 _ut.test('test_deadCode_deadOperandLHS_and_debugConst', () {
18658 final __test = new NonHintCodeTest();
18659 runJUnitTest(__test, __test.test_deadCode_deadOperandLHS_and_debugConst) ;
18660 });
18661 _ut.test('test_deadCode_deadOperandLHS_or_debugConst', () {
18662 final __test = new NonHintCodeTest();
18663 runJUnitTest(__test, __test.test_deadCode_deadOperandLHS_or_debugConst);
18664 });
18665 _ut.test('test_divisionOptimization', () {
18666 final __test = new NonHintCodeTest();
18667 runJUnitTest(__test, __test.test_divisionOptimization);
18668 });
18669 _ut.test('test_divisionOptimization_supressIfDivisionNotDefinedInCore', () {
18670 final __test = new NonHintCodeTest();
18671 runJUnitTest(__test, __test.test_divisionOptimization_supressIfDivisionN otDefinedInCore);
18672 });
18673 _ut.test('test_divisionOptimization_supressIfDivisionOverridden', () {
18674 final __test = new NonHintCodeTest();
18675 runJUnitTest(__test, __test.test_divisionOptimization_supressIfDivisionO verridden);
18676 });
18677 _ut.test('test_duplicateImport_as', () {
18678 final __test = new NonHintCodeTest();
18679 runJUnitTest(__test, __test.test_duplicateImport_as);
18680 });
18681 _ut.test('test_duplicateImport_hide', () {
18682 final __test = new NonHintCodeTest();
18683 runJUnitTest(__test, __test.test_duplicateImport_hide);
18684 });
18685 _ut.test('test_duplicateImport_show', () {
18686 final __test = new NonHintCodeTest();
18687 runJUnitTest(__test, __test.test_duplicateImport_show);
18688 });
18689 _ut.test('test_overriddingPrivateMember_sameLibrary', () {
18690 final __test = new NonHintCodeTest();
18691 runJUnitTest(__test, __test.test_overriddingPrivateMember_sameLibrary);
18692 });
18693 _ut.test('test_overrideEqualsButNotHashCode', () {
18694 final __test = new NonHintCodeTest();
18695 runJUnitTest(__test, __test.test_overrideEqualsButNotHashCode);
18696 });
18697 _ut.test('test_proxy_annotation_prefixed', () {
18698 final __test = new NonHintCodeTest();
18699 runJUnitTest(__test, __test.test_proxy_annotation_prefixed);
18700 });
18701 _ut.test('test_proxy_annotation_prefixed2', () {
18702 final __test = new NonHintCodeTest();
18703 runJUnitTest(__test, __test.test_proxy_annotation_prefixed2);
18704 });
18705 _ut.test('test_proxy_annotation_prefixed3', () {
18706 final __test = new NonHintCodeTest();
18707 runJUnitTest(__test, __test.test_proxy_annotation_prefixed3);
18708 });
18709 _ut.test('test_undefinedGetter_inSubtype', () {
18710 final __test = new NonHintCodeTest();
18711 runJUnitTest(__test, __test.test_undefinedGetter_inSubtype);
18712 });
18713 _ut.test('test_undefinedMethod_assignmentExpression_inSubtype', () {
18714 final __test = new NonHintCodeTest();
18715 runJUnitTest(__test, __test.test_undefinedMethod_assignmentExpression_in Subtype);
18716 });
18717 _ut.test('test_undefinedMethod_inSubtype', () {
18718 final __test = new NonHintCodeTest();
18719 runJUnitTest(__test, __test.test_undefinedMethod_inSubtype);
18720 });
18721 _ut.test('test_undefinedOperator_binaryExpression_inSubtype', () {
18722 final __test = new NonHintCodeTest();
18723 runJUnitTest(__test, __test.test_undefinedOperator_binaryExpression_inSu btype);
18724 });
18725 _ut.test('test_undefinedOperator_indexBoth_inSubtype', () {
18726 final __test = new NonHintCodeTest();
18727 runJUnitTest(__test, __test.test_undefinedOperator_indexBoth_inSubtype);
18728 });
18729 _ut.test('test_undefinedOperator_indexGetter_inSubtype', () {
18730 final __test = new NonHintCodeTest();
18731 runJUnitTest(__test, __test.test_undefinedOperator_indexGetter_inSubtype );
18732 });
18733 _ut.test('test_undefinedOperator_indexSetter_inSubtype', () {
18734 final __test = new NonHintCodeTest();
18735 runJUnitTest(__test, __test.test_undefinedOperator_indexSetter_inSubtype );
18736 });
18737 _ut.test('test_undefinedOperator_postfixExpression', () {
18738 final __test = new NonHintCodeTest();
18739 runJUnitTest(__test, __test.test_undefinedOperator_postfixExpression);
18740 });
18741 _ut.test('test_undefinedOperator_prefixExpression', () {
18742 final __test = new NonHintCodeTest();
18743 runJUnitTest(__test, __test.test_undefinedOperator_prefixExpression);
18744 });
18745 _ut.test('test_undefinedSetter_inSubtype', () {
18746 final __test = new NonHintCodeTest();
18747 runJUnitTest(__test, __test.test_undefinedSetter_inSubtype);
18748 });
18749 _ut.test('test_unnecessaryCast_13855_parameter_A', () {
18750 final __test = new NonHintCodeTest();
18751 runJUnitTest(__test, __test.test_unnecessaryCast_13855_parameter_A);
18752 });
18753 _ut.test('test_unnecessaryCast_dynamic_type', () {
18754 final __test = new NonHintCodeTest();
18755 runJUnitTest(__test, __test.test_unnecessaryCast_dynamic_type);
18756 });
18757 _ut.test('test_unnecessaryCast_type_dynamic', () {
18758 final __test = new NonHintCodeTest();
18759 runJUnitTest(__test, __test.test_unnecessaryCast_type_dynamic);
18760 });
18761 _ut.test('test_unusedImport_annotationOnDirective', () {
18762 final __test = new NonHintCodeTest();
18763 runJUnitTest(__test, __test.test_unusedImport_annotationOnDirective);
18764 });
18765 _ut.test('test_unusedImport_core_library', () {
18766 final __test = new NonHintCodeTest();
18767 runJUnitTest(__test, __test.test_unusedImport_core_library);
18768 });
18769 _ut.test('test_unusedImport_export', () {
18770 final __test = new NonHintCodeTest();
18771 runJUnitTest(__test, __test.test_unusedImport_export);
18772 });
18773 _ut.test('test_unusedImport_export2', () {
18774 final __test = new NonHintCodeTest();
18775 runJUnitTest(__test, __test.test_unusedImport_export2);
18776 });
18777 _ut.test('test_unusedImport_export_infiniteLoop', () {
18778 final __test = new NonHintCodeTest();
18779 runJUnitTest(__test, __test.test_unusedImport_export_infiniteLoop);
18780 });
18781 _ut.test('test_unusedImport_prefix_topLevelFunction', () {
18782 final __test = new NonHintCodeTest();
18783 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction);
18784 });
18785 });
18786 }
18787 }
18788 class EnclosedScopeTest extends ResolverTestCase {
18789 void test_define_duplicate() {
18790 LibraryElement definingLibrary2 = createTestLibrary();
18791 GatheringErrorListener errorListener2 = new GatheringErrorListener();
18792 Scope rootScope = new Scope_21(definingLibrary2, errorListener2);
18793 EnclosedScope scope = new EnclosedScope(rootScope);
18794 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
18795 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
18796 scope.define(element1);
18797 scope.define(element2);
18798 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
18799 }
18800 void test_define_normal() {
18801 LibraryElement definingLibrary3 = createTestLibrary();
18802 GatheringErrorListener errorListener3 = new GatheringErrorListener();
18803 Scope rootScope = new Scope_22(definingLibrary3, errorListener3);
18804 EnclosedScope outerScope = new EnclosedScope(rootScope);
18805 EnclosedScope innerScope = new EnclosedScope(outerScope);
18806 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
18807 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
18808 outerScope.define(element1);
18809 innerScope.define(element2);
18810 errorListener3.assertNoErrors();
18811 }
18812 static dartSuite() {
18813 _ut.group('EnclosedScopeTest', () {
18814 _ut.test('test_define_duplicate', () {
18815 final __test = new EnclosedScopeTest();
18816 runJUnitTest(__test, __test.test_define_duplicate);
18817 });
18818 _ut.test('test_define_normal', () {
18819 final __test = new EnclosedScopeTest();
18820 runJUnitTest(__test, __test.test_define_normal);
18821 });
18822 });
18823 }
18824 }
18825 class Scope_21 extends Scope {
18826 LibraryElement definingLibrary2;
18827 GatheringErrorListener errorListener2;
18828 Scope_21(this.definingLibrary2, this.errorListener2) : super();
18829 LibraryElement get definingLibrary => definingLibrary2;
18830 AnalysisErrorListener get errorListener => errorListener2;
18831 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
18832 }
18833 class Scope_22 extends Scope {
18834 LibraryElement definingLibrary3;
18835 GatheringErrorListener errorListener3;
18836 Scope_22(this.definingLibrary3, this.errorListener3) : super();
18837 LibraryElement get definingLibrary => definingLibrary3;
18838 AnalysisErrorListener get errorListener => errorListener3;
18839 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
18840 }
18841 class LibraryElementBuilderTest extends EngineTestCase {
18842
18843 /**
18844 * The source factory used to create [Source].
18845 */
18846 SourceFactory _sourceFactory;
18847 void setUp() {
18848 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
18849 }
18850 void test_accessorsAcrossFiles() {
18851 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([
18852 "library lib;",
18853 "part 'first.dart';",
18854 "part 'second.dart';"]));
18855 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "int g et V => 0;"]));
18856 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "void set V(int v) {}"]));
18857 LibraryElement element = buildLibrary(librarySource, []);
18858 JUnitTestCase.assertNotNull(element);
18859 List<CompilationUnitElement> sourcedUnits = element.parts;
18860 EngineTestCase.assertLength(2, sourcedUnits);
18861 List<PropertyAccessorElement> firstAccessors = sourcedUnits[0].accessors;
18862 EngineTestCase.assertLength(1, firstAccessors);
18863 List<PropertyAccessorElement> secondAccessors = sourcedUnits[1].accessors;
18864 EngineTestCase.assertLength(1, secondAccessors);
18865 JUnitTestCase.assertSame(firstAccessors[0].variable, secondAccessors[0].vari able);
18866 }
18867 void test_empty() {
18868 Source librarySource = addSource("/lib.dart", "library lib;");
18869 LibraryElement element = buildLibrary(librarySource, []);
18870 JUnitTestCase.assertNotNull(element);
18871 JUnitTestCase.assertEquals("lib", element.name);
18872 JUnitTestCase.assertNull(element.entryPoint);
18873 EngineTestCase.assertLength(0, element.importedLibraries);
18874 EngineTestCase.assertLength(0, element.imports);
18875 JUnitTestCase.assertSame(element, element.library);
18876 EngineTestCase.assertLength(0, element.prefixes);
18877 EngineTestCase.assertLength(0, element.parts);
18878 CompilationUnitElement unit = element.definingCompilationUnit;
18879 JUnitTestCase.assertNotNull(unit);
18880 JUnitTestCase.assertEquals("lib.dart", unit.name);
18881 JUnitTestCase.assertEquals(element, unit.library);
18882 EngineTestCase.assertLength(0, unit.accessors);
18883 EngineTestCase.assertLength(0, unit.functions);
18884 EngineTestCase.assertLength(0, unit.functionTypeAliases);
18885 EngineTestCase.assertLength(0, unit.types);
18886 EngineTestCase.assertLength(0, unit.topLevelVariables);
18887 }
18888 void test_invalidUri_part() {
18889 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "part '\${'a'}.dart';"]));
18890 LibraryElement element = buildLibrary(librarySource, [CompileTimeErrorCode.U RI_WITH_INTERPOLATION]);
18891 JUnitTestCase.assertNotNull(element);
18892 }
18893 void test_missingLibraryDirectiveWithPart() {
18894 addSource("/a.dart", EngineTestCase.createSource(["part of lib;"]));
18895 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" part 'a.dart';"]));
18896 LibraryElement element = buildLibrary(librarySource, [ResolverErrorCode.MISS ING_LIBRARY_DIRECTIVE_WITH_PART]);
18897 JUnitTestCase.assertNotNull(element);
18898 }
18899 void test_missingPartOfDirective() {
18900 addSource("/a.dart", "class A {}");
18901 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "part 'a.dart';"]));
18902 LibraryElement element = buildLibrary(librarySource, [CompileTimeErrorCode.P ART_OF_NON_PART]);
18903 JUnitTestCase.assertNotNull(element);
18904 }
18905 void test_multipleFiles() {
18906 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([
18907 "library lib;",
18908 "part 'first.dart';",
18909 "part 'second.dart';",
18910 "",
18911 "class A {}"]));
18912 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "class B {}"]));
18913 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "clas s C {}"]));
18914 LibraryElement element = buildLibrary(librarySource, []);
18915 JUnitTestCase.assertNotNull(element);
18916 List<CompilationUnitElement> sourcedUnits = element.parts;
18917 EngineTestCase.assertLength(2, sourcedUnits);
18918 assertTypes(element.definingCompilationUnit, ["A"]);
18919 if (sourcedUnits[0].name == "first.dart") {
18920 assertTypes(sourcedUnits[0], ["B"]);
18921 assertTypes(sourcedUnits[1], ["C"]);
18922 } else {
18923 assertTypes(sourcedUnits[0], ["C"]);
18924 assertTypes(sourcedUnits[1], ["B"]);
18925 }
18926 }
18927 void test_singleFile() {
18928 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "class A {}"]));
18929 LibraryElement element = buildLibrary(librarySource, []);
18930 JUnitTestCase.assertNotNull(element);
18931 assertTypes(element.definingCompilationUnit, ["A"]);
18932 }
18933
18934 /**
18935 * Add a source file to the content provider. The file path should be absolute .
18936 *
18937 * @param filePath the path of the file being added
18938 * @param contents the contents to be returned by the content provider for the specified file
18939 * @return the source object representing the added file
18940 */
18941 Source addSource(String filePath, String contents) {
18942 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath));
18943 _sourceFactory.setContents(source, contents);
18944 return source;
18945 }
18946
18947 /**
18948 * Ensure that there are elements representing all of the types in the given a rray of type names.
18949 *
18950 * @param unit the compilation unit containing the types
18951 * @param typeNames the names of the types that should be found
18952 */
18953 void assertTypes(CompilationUnitElement unit, List<String> typeNames) {
18954 JUnitTestCase.assertNotNull(unit);
18955 List<ClassElement> types = unit.types;
18956 EngineTestCase.assertLength(typeNames.length, types);
18957 for (ClassElement type in types) {
18958 JUnitTestCase.assertNotNull(type);
18959 String actualTypeName = type.displayName;
18960 bool wasExpected = false;
18961 for (String expectedTypeName in typeNames) {
18962 if (expectedTypeName == actualTypeName) {
18963 wasExpected = true;
18964 }
18965 }
18966 if (!wasExpected) {
18967 JUnitTestCase.fail("Found unexpected type ${actualTypeName}");
18968 }
18969 }
18970 }
18971
18972 /**
18973 * Build the element model for the library whose defining compilation unit has the given source.
18974 *
18975 * @param librarySource the source of the defining compilation unit for the li brary
18976 * @param expectedErrorCodes the errors that are expected to be found while bu ilding the element
18977 * model
18978 * @return the element model that was built for the library
18979 * @throws Exception if the element model could not be built
18980 */
18981 LibraryElement buildLibrary(Source librarySource, List<ErrorCode> expectedErro rCodes) {
18982 AnalysisContextImpl context = new AnalysisContextImpl();
18983 context.sourceFactory = new SourceFactory.con2([
18984 new DartUriResolver(DirectoryBasedDartSdk.defaultSdk),
18985 new FileUriResolver()]);
18986 LibraryResolver resolver = new LibraryResolver(context);
18987 LibraryElementBuilder builder = new LibraryElementBuilder(resolver);
18988 Library library = resolver.createLibrary(librarySource) as Library;
18989 LibraryElement element = builder.buildLibrary(library);
18990 GatheringErrorListener listener = new GatheringErrorListener();
18991 listener.addAll(resolver.errorListener);
18992 listener.assertErrors2(expectedErrorCodes);
18993 return element;
18994 }
18995 static dartSuite() {
18996 _ut.group('LibraryElementBuilderTest', () {
18997 _ut.test('test_accessorsAcrossFiles', () {
18998 final __test = new LibraryElementBuilderTest();
18999 runJUnitTest(__test, __test.test_accessorsAcrossFiles);
19000 });
19001 _ut.test('test_empty', () {
19002 final __test = new LibraryElementBuilderTest();
19003 runJUnitTest(__test, __test.test_empty);
19004 });
19005 _ut.test('test_invalidUri_part', () {
19006 final __test = new LibraryElementBuilderTest();
19007 runJUnitTest(__test, __test.test_invalidUri_part);
19008 });
19009 _ut.test('test_missingLibraryDirectiveWithPart', () {
19010 final __test = new LibraryElementBuilderTest();
19011 runJUnitTest(__test, __test.test_missingLibraryDirectiveWithPart);
19012 });
19013 _ut.test('test_missingPartOfDirective', () {
19014 final __test = new LibraryElementBuilderTest();
19015 runJUnitTest(__test, __test.test_missingPartOfDirective);
19016 });
19017 _ut.test('test_multipleFiles', () {
19018 final __test = new LibraryElementBuilderTest();
19019 runJUnitTest(__test, __test.test_multipleFiles);
19020 });
19021 _ut.test('test_singleFile', () {
19022 final __test = new LibraryElementBuilderTest();
19023 runJUnitTest(__test, __test.test_singleFile);
19024 });
19025 });
19026 }
19027 }
19028 class ScopeTest extends ResolverTestCase {
19029 void test_define_duplicate() {
19030 LibraryElement definingLibrary = createTestLibrary();
19031 GatheringErrorListener errorListener = new GatheringErrorListener();
19032 ScopeTest_TestScope scope = new ScopeTest_TestScope(definingLibrary, errorLi stener);
19033 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
19034 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
19035 scope.define(element1);
19036 scope.define(element2);
19037 errorListener.assertErrors3([ErrorSeverity.ERROR]);
19038 }
19039 void test_define_normal() {
19040 LibraryElement definingLibrary = createTestLibrary();
19041 GatheringErrorListener errorListener = new GatheringErrorListener();
19042 ScopeTest_TestScope scope = new ScopeTest_TestScope(definingLibrary, errorLi stener);
19043 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
19044 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
19045 scope.define(element1);
19046 scope.define(element2);
19047 errorListener.assertNoErrors();
19048 }
19049 void test_getDefiningLibrary() {
19050 LibraryElement definingLibrary = createTestLibrary();
19051 ScopeTest_TestScope scope = new ScopeTest_TestScope(definingLibrary, null);
19052 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary);
19053 }
19054 void test_getErrorListener() {
19055 LibraryElement definingLibrary = new LibraryElementImpl(new AnalysisContextI mpl(), ASTFactory.libraryIdentifier2(["test"]));
19056 GatheringErrorListener errorListener = new GatheringErrorListener();
19057 ScopeTest_TestScope scope = new ScopeTest_TestScope(definingLibrary, errorLi stener);
19058 JUnitTestCase.assertEquals(errorListener, scope.errorListener);
19059 }
19060 void test_isPrivateName_nonPrivate() {
19061 JUnitTestCase.assertFalse(Scope.isPrivateName("Public"));
19062 }
19063 void test_isPrivateName_private() {
19064 JUnitTestCase.assertTrue(Scope.isPrivateName("_Private"));
19065 }
19066 static dartSuite() {
19067 _ut.group('ScopeTest', () {
19068 _ut.test('test_define_duplicate', () {
19069 final __test = new ScopeTest();
19070 runJUnitTest(__test, __test.test_define_duplicate);
19071 });
19072 _ut.test('test_define_normal', () {
19073 final __test = new ScopeTest();
19074 runJUnitTest(__test, __test.test_define_normal);
19075 });
19076 _ut.test('test_getDefiningLibrary', () {
19077 final __test = new ScopeTest();
19078 runJUnitTest(__test, __test.test_getDefiningLibrary);
19079 });
19080 _ut.test('test_getErrorListener', () {
19081 final __test = new ScopeTest();
19082 runJUnitTest(__test, __test.test_getErrorListener);
19083 });
19084 _ut.test('test_isPrivateName_nonPrivate', () {
19085 final __test = new ScopeTest();
19086 runJUnitTest(__test, __test.test_isPrivateName_nonPrivate);
19087 });
19088 _ut.test('test_isPrivateName_private', () {
19089 final __test = new ScopeTest();
19090 runJUnitTest(__test, __test.test_isPrivateName_private);
19091 });
19092 });
19093 }
19094 }
19095 /**
19096 * A non-abstract subclass that can be used for testing purposes.
19097 */
19098 class ScopeTest_TestScope extends Scope {
19099
19100 /**
19101 * The element representing the library in which this scope is enclosed.
19102 */
19103 LibraryElement _definingLibrary;
19104
19105 /**
19106 * The listener that is to be informed when an error is encountered.
19107 */
19108 AnalysisErrorListener _errorListener;
19109 ScopeTest_TestScope(LibraryElement definingLibrary, AnalysisErrorListener erro rListener) {
19110 this._definingLibrary = definingLibrary;
19111 this._errorListener = errorListener;
19112 }
19113 LibraryElement get definingLibrary => _definingLibrary;
19114 AnalysisErrorListener get errorListener => _errorListener;
19115 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => localLookup(name, referencingLibrary);
19116 }
19117 class SimpleResolverTest extends ResolverTestCase {
19118 void fail_staticInvocation() {
19119 Source source = addSource(EngineTestCase.createSource([
19120 "class A {",
19121 " static int get g => (a,b) => 0;",
19122 "}",
19123 "class B {",
19124 " f() {",
19125 " A.g(1,0);",
19126 " }",
19127 "}"]));
19128 resolve(source);
19129 assertNoErrors(source);
19130 verify([source]);
19131 }
19132 void test_argumentResolution_required_matching() {
19133 Source source = addSource(EngineTestCase.createSource([
19134 "class A {",
19135 " void f() {",
19136 " g(1, 2, 3);",
19137 " }",
19138 " void g(a, b, c) {}",
19139 "}"]));
19140 validateArgumentResolution(source, [0, 1, 2]);
19141 }
19142 void test_argumentResolution_required_tooFew() {
19143 Source source = addSource(EngineTestCase.createSource([
19144 "class A {",
19145 " void f() {",
19146 " g(1, 2);",
19147 " }",
19148 " void g(a, b, c) {}",
19149 "}"]));
19150 validateArgumentResolution(source, [0, 1]);
19151 }
19152 void test_argumentResolution_required_tooMany() {
19153 Source source = addSource(EngineTestCase.createSource([
19154 "class A {",
19155 " void f() {",
19156 " g(1, 2, 3);",
19157 " }",
19158 " void g(a, b) {}",
19159 "}"]));
19160 validateArgumentResolution(source, [0, 1, -1]);
19161 }
19162 void test_argumentResolution_requiredAndNamed_extra() {
19163 Source source = addSource(EngineTestCase.createSource([
19164 "class A {",
19165 " void f() {",
19166 " g(1, 2, c: 3, d: 4);",
19167 " }",
19168 " void g(a, b, {c}) {}",
19169 "}"]));
19170 validateArgumentResolution(source, [0, 1, 2, -1]);
19171 }
19172 void test_argumentResolution_requiredAndNamed_matching() {
19173 Source source = addSource(EngineTestCase.createSource([
19174 "class A {",
19175 " void f() {",
19176 " g(1, 2, c: 3);",
19177 " }",
19178 " void g(a, b, {c}) {}",
19179 "}"]));
19180 validateArgumentResolution(source, [0, 1, 2]);
19181 }
19182 void test_argumentResolution_requiredAndNamed_missing() {
19183 Source source = addSource(EngineTestCase.createSource([
19184 "class A {",
19185 " void f() {",
19186 " g(1, 2, d: 3);",
19187 " }",
19188 " void g(a, b, {c, d}) {}",
19189 "}"]));
19190 validateArgumentResolution(source, [0, 1, 3]);
19191 }
19192 void test_argumentResolution_requiredAndPositional_fewer() {
19193 Source source = addSource(EngineTestCase.createSource([
19194 "class A {",
19195 " void f() {",
19196 " g(1, 2, 3);",
19197 " }",
19198 " void g(a, b, [c, d]) {}",
19199 "}"]));
19200 validateArgumentResolution(source, [0, 1, 2]);
19201 }
19202 void test_argumentResolution_requiredAndPositional_matching() {
19203 Source source = addSource(EngineTestCase.createSource([
19204 "class A {",
19205 " void f() {",
19206 " g(1, 2, 3, 4);",
19207 " }",
19208 " void g(a, b, [c, d]) {}",
19209 "}"]));
19210 validateArgumentResolution(source, [0, 1, 2, 3]);
19211 }
19212 void test_argumentResolution_requiredAndPositional_more() {
19213 Source source = addSource(EngineTestCase.createSource([
19214 "class A {",
19215 " void f() {",
19216 " g(1, 2, 3, 4);",
19217 " }",
19218 " void g(a, b, [c]) {}",
19219 "}"]));
19220 validateArgumentResolution(source, [0, 1, 2, -1]);
19221 }
19222 void test_class_definesCall() {
19223 Source source = addSource(EngineTestCase.createSource([
19224 "class A {",
19225 " int call(int x) { return x; }",
19226 "}",
19227 "int f(A a) {",
19228 " return a(0);",
19229 "}"]));
19230 resolve(source);
19231 assertNoErrors(source);
19232 verify([source]);
19233 }
19234 void test_class_extends_implements() {
19235 Source source = addSource(EngineTestCase.createSource([
19236 "class A extends B implements C {}",
19237 "class B {}",
19238 "class C {}"]));
19239 resolve(source);
19240 assertNoErrors(source);
19241 verify([source]);
19242 }
19243 void test_commentReference_class() {
19244 Source source = addSource(EngineTestCase.createSource([
19245 "f() {}",
19246 "/** [A] [new A] [A.n] [new A.n] [m] [f] */",
19247 "class A {",
19248 " A() {}",
19249 " A.n() {}",
19250 " m() {}",
19251 "}"]));
19252 resolve(source);
19253 assertNoErrors(source);
19254 verify([source]);
19255 }
19256 void test_commentReference_parameter() {
19257 Source source = addSource(EngineTestCase.createSource([
19258 "class A {",
19259 " A() {}",
19260 " A.n() {}",
19261 " /** [e] [f] */",
19262 " m(e, f()) {}",
19263 "}"]));
19264 resolve(source);
19265 assertNoErrors(source);
19266 verify([source]);
19267 }
19268 void test_commentReference_singleLine() {
19269 Source source = addSource(EngineTestCase.createSource(["/// [A]", "class A { }"]));
19270 resolve(source);
19271 assertNoErrors(source);
19272 verify([source]);
19273 }
19274 void test_empty() {
19275 Source source = addSource("");
19276 resolve(source);
19277 assertNoErrors(source);
19278 verify([source]);
19279 }
19280 void test_extractedMethodAsConstant() {
19281 Source source = addSource(EngineTestCase.createSource([
19282 "abstract class Comparable<T> {",
19283 " int compareTo(T other);",
19284 " static int compare(Comparable a, Comparable b) => a.compareTo(b);",
19285 "}",
19286 "class A {",
19287 " void sort([compare = Comparable.compare]) {}",
19288 "}"]));
19289 resolve(source);
19290 assertNoErrors(source);
19291 verify([source]);
19292 }
19293 void test_fieldFormalParameter() {
19294 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"]));
19295 resolve(source);
19296 assertNoErrors(source);
19297 verify([source]);
19298 }
19299 void test_forEachLoops_nonConflicting() {
19300 Source source = addSource(EngineTestCase.createSource([
19301 "f() {",
19302 " List list = [1,2,3];",
19303 " for (int x in list) {}",
19304 " for (int x in list) {}",
19305 "}"]));
19306 resolve(source);
19307 assertNoErrors(source);
19308 verify([source]);
19309 }
19310 void test_forLoops_nonConflicting() {
19311 Source source = addSource(EngineTestCase.createSource([
19312 "f() {",
19313 " for (int i = 0; i < 3; i++) {",
19314 " }",
19315 " for (int i = 0; i < 3; i++) {",
19316 " }",
19317 "}"]));
19318 resolve(source);
19319 assertNoErrors(source);
19320 verify([source]);
19321 }
19322 void test_functionTypeAlias() {
19323 Source source = addSource(EngineTestCase.createSource([
19324 "typedef bool P(e);",
19325 "class A {",
19326 " P p;",
19327 " m(e) {",
19328 " if (p(e)) {}",
19329 " }",
19330 "}"]));
19331 resolve(source);
19332 assertNoErrors(source);
19333 verify([source]);
19334 }
19335 void test_getterAndSetterWithDifferentTypes() {
19336 Source source = addSource(EngineTestCase.createSource([
19337 "class A {",
19338 " int get f => 0;",
19339 " void set f(String s) {}",
19340 "}",
19341 "g (A a) {",
19342 " a.f = a.f.toString();",
19343 "}"]));
19344 resolve(source);
19345 assertErrors(source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]) ;
19346 verify([source]);
19347 }
19348 void test_hasReferenceToSuper() {
19349 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {toString() => super.toString();}"]));
19350 LibraryElement library = resolve(source);
19351 JUnitTestCase.assertNotNull(library);
19352 CompilationUnitElement unit = library.definingCompilationUnit;
19353 JUnitTestCase.assertNotNull(unit);
19354 List<ClassElement> classes = unit.types;
19355 EngineTestCase.assertLength(2, classes);
19356 JUnitTestCase.assertFalse(classes[0].hasReferenceToSuper());
19357 JUnitTestCase.assertTrue(classes[1].hasReferenceToSuper());
19358 assertNoErrors(source);
19359 verify([source]);
19360 }
19361 void test_import_hide() {
19362 addSource2("lib1.dart", EngineTestCase.createSource(["library lib1;", "set f oo(value) {}", "class A {}"]));
19363 addSource2("lib2.dart", EngineTestCase.createSource(["library lib2;", "set f oo(value) {}"]));
19364 Source source = addSource2("lib3.dart", EngineTestCase.createSource([
19365 "import 'lib1.dart' hide foo;",
19366 "import 'lib2.dart';",
19367 "",
19368 "main() {",
19369 " foo = 0;",
19370 "}",
19371 "A a;"]));
19372 resolve(source);
19373 assertNoErrors(source);
19374 verify([source]);
19375 }
19376 void test_import_prefix() {
19377 addSource2("/two.dart", EngineTestCase.createSource(["library two;", "f(int x) {", " return x * x;", "}"]));
19378 Source source = addSource2("/one.dart", EngineTestCase.createSource([
19379 "library one;",
19380 "import 'two.dart' as _two;",
19381 "main() {",
19382 " _two.f(0);",
19383 "}"]));
19384 resolve(source);
19385 assertNoErrors(source);
19386 verify([source]);
19387 }
19388 void test_import_spaceInUri() {
19389 addSource2("sub folder/lib.dart", EngineTestCase.createSource(["library lib; ", "foo() {}"]));
19390 Source source = addSource2("app.dart", EngineTestCase.createSource([
19391 "import 'sub folder/lib.dart';",
19392 "",
19393 "main() {",
19394 " foo();",
19395 "}"]));
19396 resolve(source);
19397 assertNoErrors(source);
19398 verify([source]);
19399 }
19400 void test_indexExpression_typeParameters() {
19401 Source source = addSource(EngineTestCase.createSource([
19402 "f() {",
19403 " List<int> a;",
19404 " a[0];",
19405 " List<List<int>> b;",
19406 " b[0][0];",
19407 " List<List<List<int>>> c;",
19408 " c[0][0][0];",
19409 "}"]));
19410 resolve(source);
19411 assertNoErrors(source);
19412 verify([source]);
19413 }
19414 void test_indexExpression_typeParameters_invalidAssignmentWarning() {
19415 Source source = addSource(EngineTestCase.createSource(["f() {", " List<List <int>> b;", " b[0][0] = 'hi';", "}"]));
19416 resolve(source);
19417 assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
19418 verify([source]);
19419 }
19420 void test_indirectOperatorThroughCall() {
19421 Source source = addSource(EngineTestCase.createSource([
19422 "class A {",
19423 " B call() { return new B(); }",
19424 "}",
19425 "",
19426 "class B {",
19427 " int operator [](int i) { return i; }",
19428 "}",
19429 "",
19430 "A f = new A();",
19431 "",
19432 "g(int x) {}",
19433 "",
19434 "main() {",
19435 " g(f()[0]);",
19436 "}"]));
19437 resolve(source);
19438 assertNoErrors(source);
19439 verify([source]);
19440 }
19441 void test_invoke_dynamicThroughGetter() {
19442 Source source = addSource(EngineTestCase.createSource([
19443 "class A {",
19444 " List get X => [() => 0];",
19445 " m(A a) {",
19446 " X.last;",
19447 " }",
19448 "}"]));
19449 resolve(source);
19450 assertNoErrors(source);
19451 verify([source]);
19452 }
19453 void test_isValidMixin_badSuperclass() {
19454 Source source = addSource(EngineTestCase.createSource(["class A extends B {} ", "class B {}"]));
19455 LibraryElement library = resolve(source);
19456 JUnitTestCase.assertNotNull(library);
19457 CompilationUnitElement unit = library.definingCompilationUnit;
19458 JUnitTestCase.assertNotNull(unit);
19459 List<ClassElement> classes = unit.types;
19460 EngineTestCase.assertLength(2, classes);
19461 JUnitTestCase.assertFalse(classes[0].isValidMixin);
19462 assertNoErrors(source);
19463 verify([source]);
19464 }
19465 void test_isValidMixin_constructor() {
19466 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}"]));
19467 LibraryElement library = resolve(source);
19468 JUnitTestCase.assertNotNull(library);
19469 CompilationUnitElement unit = library.definingCompilationUnit;
19470 JUnitTestCase.assertNotNull(unit);
19471 List<ClassElement> classes = unit.types;
19472 EngineTestCase.assertLength(1, classes);
19473 JUnitTestCase.assertFalse(classes[0].isValidMixin);
19474 assertNoErrors(source);
19475 verify([source]);
19476 }
19477 void test_isValidMixin_super() {
19478 Source source = addSource(EngineTestCase.createSource([
19479 "class A {",
19480 " toString() {",
19481 " return super.toString();",
19482 " }",
19483 "}"]));
19484 LibraryElement library = resolve(source);
19485 JUnitTestCase.assertNotNull(library);
19486 CompilationUnitElement unit = library.definingCompilationUnit;
19487 JUnitTestCase.assertNotNull(unit);
19488 List<ClassElement> classes = unit.types;
19489 EngineTestCase.assertLength(1, classes);
19490 JUnitTestCase.assertFalse(classes[0].isValidMixin);
19491 assertNoErrors(source);
19492 verify([source]);
19493 }
19494 void test_isValidMixin_valid() {
19495 Source source = addSource(EngineTestCase.createSource(["class A {}"]));
19496 LibraryElement library = resolve(source);
19497 JUnitTestCase.assertNotNull(library);
19498 CompilationUnitElement unit = library.definingCompilationUnit;
19499 JUnitTestCase.assertNotNull(unit);
19500 List<ClassElement> classes = unit.types;
19501 EngineTestCase.assertLength(1, classes);
19502 JUnitTestCase.assertTrue(classes[0].isValidMixin);
19503 assertNoErrors(source);
19504 verify([source]);
19505 }
19506 void test_labels_switch() {
19507 Source source = addSource(EngineTestCase.createSource([
19508 "void doSwitch(int target) {",
19509 " switch (target) {",
19510 " l0: case 0:",
19511 " continue l1;",
19512 " l1: case 1:",
19513 " continue l0;",
19514 " default:",
19515 " continue l1;",
19516 " }",
19517 "}"]));
19518 LibraryElement library = resolve(source);
19519 JUnitTestCase.assertNotNull(library);
19520 assertNoErrors(source);
19521 verify([source]);
19522 }
19523 void test_metadata_class() {
19524 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@ A class C {}"]));
19525 LibraryElement library = resolve(source);
19526 JUnitTestCase.assertNotNull(library);
19527 CompilationUnitElement unit = library.definingCompilationUnit;
19528 JUnitTestCase.assertNotNull(unit);
19529 List<ClassElement> classes = unit.types;
19530 EngineTestCase.assertLength(1, classes);
19531 List<ElementAnnotation> annotations = classes[0].metadata;
19532 EngineTestCase.assertLength(1, annotations);
19533 assertNoErrors(source);
19534 verify([source]);
19535 }
19536 void test_metadata_field() {
19537 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c lass C {", " @A int f;", "}"]));
19538 LibraryElement library = resolve(source);
19539 JUnitTestCase.assertNotNull(library);
19540 CompilationUnitElement unit = library.definingCompilationUnit;
19541 JUnitTestCase.assertNotNull(unit);
19542 List<ClassElement> classes = unit.types;
19543 EngineTestCase.assertLength(1, classes);
19544 FieldElement field = classes[0].fields[0];
19545 List<ElementAnnotation> annotations = field.metadata;
19546 EngineTestCase.assertLength(1, annotations);
19547 assertNoErrors(source);
19548 verify([source]);
19549 }
19550 void test_metadata_libraryDirective() {
19551 Source source = addSource(EngineTestCase.createSource(["@A library lib;", "c onst A = null;"]));
19552 LibraryElement library = resolve(source);
19553 JUnitTestCase.assertNotNull(library);
19554 List<ElementAnnotation> annotations = library.metadata;
19555 EngineTestCase.assertLength(1, annotations);
19556 assertNoErrors(source);
19557 verify([source]);
19558 }
19559 void test_metadata_method() {
19560 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c lass C {", " @A void m() {}", "}"]));
19561 LibraryElement library = resolve(source);
19562 JUnitTestCase.assertNotNull(library);
19563 CompilationUnitElement unit = library.definingCompilationUnit;
19564 JUnitTestCase.assertNotNull(unit);
19565 List<ClassElement> classes = unit.types;
19566 EngineTestCase.assertLength(1, classes);
19567 MethodElement method = classes[0].methods[0];
19568 List<ElementAnnotation> annotations = method.metadata;
19569 EngineTestCase.assertLength(1, annotations);
19570 assertNoErrors(source);
19571 verify([source]);
19572 }
19573 void test_method_fromMixin() {
19574 Source source = addSource(EngineTestCase.createSource([
19575 "class B {",
19576 " bar() => 1;",
19577 "}",
19578 "class A {",
19579 " foo() => 2;",
19580 "}",
19581 "",
19582 "class C extends B with A {",
19583 " bar() => super.bar();",
19584 " foo() => super.foo();",
19585 "}"]));
19586 resolve(source);
19587 assertNoErrors(source);
19588 verify([source]);
19589 }
19590 void test_method_fromSuperclassMixin() {
19591 Source source = addSource(EngineTestCase.createSource([
19592 "class A {",
19593 " void m1() {}",
19594 "}",
19595 "class B extends Object with A {",
19596 "}",
19597 "class C extends B {",
19598 "}",
19599 "f(C c) {",
19600 " c.m1();",
19601 "}"]));
19602 resolve(source);
19603 assertNoErrors(source);
19604 verify([source]);
19605 }
19606 void test_methodCascades() {
19607 Source source = addSource(EngineTestCase.createSource([
19608 "class A {",
19609 " void m1() {}",
19610 " void m2() {}",
19611 " void m() {",
19612 " A a = new A();",
19613 " a..m1()",
19614 " ..m2();",
19615 " }",
19616 "}"]));
19617 resolve(source);
19618 assertNoErrors(source);
19619 verify([source]);
19620 }
19621 void test_methodCascades_withSetter() {
19622 Source source = addSource(EngineTestCase.createSource([
19623 "class A {",
19624 " String name;",
19625 " void m1() {}",
19626 " void m2() {}",
19627 " void m() {",
19628 " A a = new A();",
19629 " a..m1()",
19630 " ..name = 'name'",
19631 " ..m2();",
19632 " }",
19633 "}"]));
19634 resolve(source);
19635 assertNoErrors(source);
19636 verify([source]);
19637 }
19638 void test_resolveAgainstNull() {
19639 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu rn null == p;", "}"]));
19640 resolve(source);
19641 assertNoErrors(source);
19642 }
19643 void test_setter_inherited() {
19644 Source source = addSource(EngineTestCase.createSource([
19645 "class A {",
19646 " int get x => 0;",
19647 " set x(int p) {}",
19648 "}",
19649 "class B extends A {",
19650 " int get x => super.x == null ? 0 : super.x;",
19651 " int f() => x = 1;",
19652 "}"]));
19653 resolve(source);
19654 assertNoErrors(source);
19655 verify([source]);
19656 }
19657 void test_setter_static() {
19658 Source source = addSource(EngineTestCase.createSource(["set s(x) {", "}", "" , "main() {", " s = 123;", "}"]));
19659 resolve(source);
19660 assertNoErrors(source);
19661 verify([source]);
19662 }
19663
19664 /**
19665 * Resolve the given source and verify that the arguments in a specific method invocation were
19666 * correctly resolved.
19667 *
19668 * The source is expected to be source for a compilation unit, the first decla ration is expected
19669 * to be a class, the first member of which is expected to be a method with a block body, and the
19670 * first statement in the body is expected to be an expression statement whose expression is a
19671 * method invocation. It is the arguments to that method invocation that are t ested. The method
19672 * invocation can contain errors.
19673 *
19674 * The arguments were resolved correctly if the number of expressions in the l ist matches the
19675 * length of the array of indices and if, for each index in the array of indic es, the parameter to
19676 * which the argument expression was resolved is the parameter in the invoked method's list of
19677 * parameters at that index. Arguments that should not be resolved to a parame ter because of an
19678 * error can be denoted by including a negative index in the array of indices.
19679 *
19680 * @param source the source to be resolved
19681 * @param indices the array of indices used to associate arguments with parame ters
19682 * @throws Exception if the source could not be resolved or if the structure o f the source is not
19683 * valid
19684 */
19685 void validateArgumentResolution(Source source, List<int> indices) {
19686 LibraryElement library = resolve(source);
19687 JUnitTestCase.assertNotNull(library);
19688 ClassElement classElement = library.definingCompilationUnit.types[0];
19689 List<ParameterElement> parameters = classElement.methods[1].parameters;
19690 CompilationUnit unit = resolveCompilationUnit(source, library);
19691 JUnitTestCase.assertNotNull(unit);
19692 ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration ;
19693 MethodDeclaration methodDeclaration = classDeclaration.members[0] as MethodD eclaration;
19694 Block block = ((methodDeclaration.body as BlockFunctionBody)).block;
19695 ExpressionStatement statement = block.statements[0] as ExpressionStatement;
19696 MethodInvocation invocation = statement.expression as MethodInvocation;
19697 NodeList<Expression> arguments = invocation.argumentList.arguments;
19698 int argumentCount = arguments.length;
19699 JUnitTestCase.assertEquals(indices.length, argumentCount);
19700 for (int i = 0; i < argumentCount; i++) {
19701 Expression argument = arguments[i];
19702 ParameterElement element = argument.staticParameterElement;
19703 int index = indices[i];
19704 if (index < 0) {
19705 JUnitTestCase.assertNull(element);
19706 } else {
19707 JUnitTestCase.assertSame(parameters[index], element);
19708 }
19709 }
19710 }
19711 static dartSuite() {
19712 _ut.group('SimpleResolverTest', () {
19713 _ut.test('test_argumentResolution_requiredAndNamed_extra', () {
19714 final __test = new SimpleResolverTest();
19715 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_ext ra);
19716 });
19717 _ut.test('test_argumentResolution_requiredAndNamed_matching', () {
19718 final __test = new SimpleResolverTest();
19719 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_mat ching);
19720 });
19721 _ut.test('test_argumentResolution_requiredAndNamed_missing', () {
19722 final __test = new SimpleResolverTest();
19723 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_mis sing);
19724 });
19725 _ut.test('test_argumentResolution_requiredAndPositional_fewer', () {
19726 final __test = new SimpleResolverTest();
19727 runJUnitTest(__test, __test.test_argumentResolution_requiredAndPositiona l_fewer);
19728 });
19729 _ut.test('test_argumentResolution_requiredAndPositional_matching', () {
19730 final __test = new SimpleResolverTest();
19731 runJUnitTest(__test, __test.test_argumentResolution_requiredAndPositiona l_matching);
19732 });
19733 _ut.test('test_argumentResolution_requiredAndPositional_more', () {
19734 final __test = new SimpleResolverTest();
19735 runJUnitTest(__test, __test.test_argumentResolution_requiredAndPositiona l_more);
19736 });
19737 _ut.test('test_argumentResolution_required_matching', () {
19738 final __test = new SimpleResolverTest();
19739 runJUnitTest(__test, __test.test_argumentResolution_required_matching);
19740 });
19741 _ut.test('test_argumentResolution_required_tooFew', () {
19742 final __test = new SimpleResolverTest();
19743 runJUnitTest(__test, __test.test_argumentResolution_required_tooFew);
19744 });
19745 _ut.test('test_argumentResolution_required_tooMany', () {
19746 final __test = new SimpleResolverTest();
19747 runJUnitTest(__test, __test.test_argumentResolution_required_tooMany);
19748 });
19749 _ut.test('test_class_definesCall', () {
19750 final __test = new SimpleResolverTest();
19751 runJUnitTest(__test, __test.test_class_definesCall);
19752 });
19753 _ut.test('test_class_extends_implements', () {
19754 final __test = new SimpleResolverTest();
19755 runJUnitTest(__test, __test.test_class_extends_implements);
19756 });
19757 _ut.test('test_commentReference_class', () {
19758 final __test = new SimpleResolverTest();
19759 runJUnitTest(__test, __test.test_commentReference_class);
19760 });
19761 _ut.test('test_commentReference_parameter', () {
19762 final __test = new SimpleResolverTest();
19763 runJUnitTest(__test, __test.test_commentReference_parameter);
19764 });
19765 _ut.test('test_commentReference_singleLine', () {
19766 final __test = new SimpleResolverTest();
19767 runJUnitTest(__test, __test.test_commentReference_singleLine);
19768 });
19769 _ut.test('test_empty', () {
19770 final __test = new SimpleResolverTest();
19771 runJUnitTest(__test, __test.test_empty);
19772 });
19773 _ut.test('test_extractedMethodAsConstant', () {
19774 final __test = new SimpleResolverTest();
19775 runJUnitTest(__test, __test.test_extractedMethodAsConstant);
19776 });
19777 _ut.test('test_fieldFormalParameter', () {
19778 final __test = new SimpleResolverTest();
19779 runJUnitTest(__test, __test.test_fieldFormalParameter);
19780 });
19781 _ut.test('test_forEachLoops_nonConflicting', () {
19782 final __test = new SimpleResolverTest();
19783 runJUnitTest(__test, __test.test_forEachLoops_nonConflicting);
19784 });
19785 _ut.test('test_forLoops_nonConflicting', () {
19786 final __test = new SimpleResolverTest();
19787 runJUnitTest(__test, __test.test_forLoops_nonConflicting);
19788 });
19789 _ut.test('test_functionTypeAlias', () {
19790 final __test = new SimpleResolverTest();
19791 runJUnitTest(__test, __test.test_functionTypeAlias);
19792 });
19793 _ut.test('test_getterAndSetterWithDifferentTypes', () {
19794 final __test = new SimpleResolverTest();
19795 runJUnitTest(__test, __test.test_getterAndSetterWithDifferentTypes);
19796 });
19797 _ut.test('test_hasReferenceToSuper', () {
19798 final __test = new SimpleResolverTest();
19799 runJUnitTest(__test, __test.test_hasReferenceToSuper);
19800 });
19801 _ut.test('test_import_hide', () {
19802 final __test = new SimpleResolverTest();
19803 runJUnitTest(__test, __test.test_import_hide);
19804 });
19805 _ut.test('test_import_prefix', () {
19806 final __test = new SimpleResolverTest();
19807 runJUnitTest(__test, __test.test_import_prefix);
19808 });
19809 _ut.test('test_import_spaceInUri', () {
19810 final __test = new SimpleResolverTest();
19811 runJUnitTest(__test, __test.test_import_spaceInUri);
19812 });
19813 _ut.test('test_indexExpression_typeParameters', () {
19814 final __test = new SimpleResolverTest();
19815 runJUnitTest(__test, __test.test_indexExpression_typeParameters);
19816 });
19817 _ut.test('test_indexExpression_typeParameters_invalidAssignmentWarning', ( ) {
19818 final __test = new SimpleResolverTest();
19819 runJUnitTest(__test, __test.test_indexExpression_typeParameters_invalidA ssignmentWarning);
19820 });
19821 _ut.test('test_indirectOperatorThroughCall', () {
19822 final __test = new SimpleResolverTest();
19823 runJUnitTest(__test, __test.test_indirectOperatorThroughCall);
19824 });
19825 _ut.test('test_invoke_dynamicThroughGetter', () {
19826 final __test = new SimpleResolverTest();
19827 runJUnitTest(__test, __test.test_invoke_dynamicThroughGetter);
19828 });
19829 _ut.test('test_isValidMixin_badSuperclass', () {
19830 final __test = new SimpleResolverTest();
19831 runJUnitTest(__test, __test.test_isValidMixin_badSuperclass);
19832 });
19833 _ut.test('test_isValidMixin_constructor', () {
19834 final __test = new SimpleResolverTest();
19835 runJUnitTest(__test, __test.test_isValidMixin_constructor);
19836 });
19837 _ut.test('test_isValidMixin_super', () {
19838 final __test = new SimpleResolverTest();
19839 runJUnitTest(__test, __test.test_isValidMixin_super);
19840 });
19841 _ut.test('test_isValidMixin_valid', () {
19842 final __test = new SimpleResolverTest();
19843 runJUnitTest(__test, __test.test_isValidMixin_valid);
19844 });
19845 _ut.test('test_labels_switch', () {
19846 final __test = new SimpleResolverTest();
19847 runJUnitTest(__test, __test.test_labels_switch);
19848 });
19849 _ut.test('test_metadata_class', () {
19850 final __test = new SimpleResolverTest();
19851 runJUnitTest(__test, __test.test_metadata_class);
19852 });
19853 _ut.test('test_metadata_field', () {
19854 final __test = new SimpleResolverTest();
19855 runJUnitTest(__test, __test.test_metadata_field);
19856 });
19857 _ut.test('test_metadata_libraryDirective', () {
19858 final __test = new SimpleResolverTest();
19859 runJUnitTest(__test, __test.test_metadata_libraryDirective);
19860 });
19861 _ut.test('test_metadata_method', () {
19862 final __test = new SimpleResolverTest();
19863 runJUnitTest(__test, __test.test_metadata_method);
19864 });
19865 _ut.test('test_methodCascades', () {
19866 final __test = new SimpleResolverTest();
19867 runJUnitTest(__test, __test.test_methodCascades);
19868 });
19869 _ut.test('test_methodCascades_withSetter', () {
19870 final __test = new SimpleResolverTest();
19871 runJUnitTest(__test, __test.test_methodCascades_withSetter);
19872 });
19873 _ut.test('test_method_fromMixin', () {
19874 final __test = new SimpleResolverTest();
19875 runJUnitTest(__test, __test.test_method_fromMixin);
19876 });
19877 _ut.test('test_method_fromSuperclassMixin', () {
19878 final __test = new SimpleResolverTest();
19879 runJUnitTest(__test, __test.test_method_fromSuperclassMixin);
19880 });
19881 _ut.test('test_resolveAgainstNull', () {
19882 final __test = new SimpleResolverTest();
19883 runJUnitTest(__test, __test.test_resolveAgainstNull);
19884 });
19885 _ut.test('test_setter_inherited', () {
19886 final __test = new SimpleResolverTest();
19887 runJUnitTest(__test, __test.test_setter_inherited);
19888 });
19889 _ut.test('test_setter_static', () {
19890 final __test = new SimpleResolverTest();
19891 runJUnitTest(__test, __test.test_setter_static);
19892 });
19893 });
19894 }
19895 }
19896 class SubtypeManagerTest extends EngineTestCase {
19897
19898 /**
19899 * The inheritance manager being tested.
19900 */
19901 SubtypeManager _subtypeManager;
19902
19903 /**
19904 * The compilation unit element containing all of the types setup in each test .
19905 */
19906 CompilationUnitElementImpl _definingCompilationUnit;
19907 void test_computeAllSubtypes_infiniteLoop() {
19908 ClassElementImpl classA = ElementFactory.classElement2("A", []);
19909 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
19910 classA.supertype = classB.type;
19911 _definingCompilationUnit.types = <ClassElement> [classA, classB];
19912 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA);
19913 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA);
19914 EngineTestCase.assertSize3(2, subtypesOfA);
19915 EngineTestCase.assertContains(arraySubtypesOfA, [classA, classB]);
19916 }
19917 void test_computeAllSubtypes_manyRecursiveSubtypes() {
19918 ClassElementImpl classA = ElementFactory.classElement2("A", []);
19919 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
19920 ClassElementImpl classC = ElementFactory.classElement("C", classB.type, []);
19921 ClassElementImpl classD = ElementFactory.classElement("D", classB.type, []);
19922 ClassElementImpl classE = ElementFactory.classElement("E", classB.type, []);
19923 _definingCompilationUnit.types = <ClassElement> [classA, classB, classC, cla ssD, classE];
19924 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA);
19925 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA);
19926 Set<ClassElement> subtypesOfB = _subtypeManager.computeAllSubtypes(classB);
19927 List<ClassElement> arraySubtypesOfB = new List.from(subtypesOfB);
19928 EngineTestCase.assertSize3(4, subtypesOfA);
19929 EngineTestCase.assertContains(arraySubtypesOfA, [classB, classC, classD, cla ssE]);
19930 EngineTestCase.assertSize3(3, subtypesOfB);
19931 EngineTestCase.assertContains(arraySubtypesOfB, [classC, classD, classE]);
19932 }
19933 void test_computeAllSubtypes_noSubtypes() {
19934 ClassElementImpl classA = ElementFactory.classElement2("A", []);
19935 _definingCompilationUnit.types = <ClassElement> [classA];
19936 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA);
19937 EngineTestCase.assertSize3(0, subtypesOfA);
19938 }
19939 void test_computeAllSubtypes_oneSubtype() {
19940 ClassElementImpl classA = ElementFactory.classElement2("A", []);
19941 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
19942 _definingCompilationUnit.types = <ClassElement> [classA, classB];
19943 Set<ClassElement> subtypesOfA = _subtypeManager.computeAllSubtypes(classA);
19944 List<ClassElement> arraySubtypesOfA = new List.from(subtypesOfA);
19945 EngineTestCase.assertSize3(1, subtypesOfA);
19946 EngineTestCase.assertContains(arraySubtypesOfA, [classB]);
19947 }
19948 void setUp() {
19949 super.setUp();
19950 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
19951 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt ilities2.createFile("/test.dart"));
19952 _definingCompilationUnit = new CompilationUnitElementImpl("test.dart");
19953 _definingCompilationUnit.source = source;
19954 LibraryElementImpl definingLibrary = ElementFactory.library(context, "test") ;
19955 definingLibrary.definingCompilationUnit = _definingCompilationUnit;
19956 _subtypeManager = new SubtypeManager();
19957 }
19958 static dartSuite() {
19959 _ut.group('SubtypeManagerTest', () {
19960 _ut.test('test_computeAllSubtypes_infiniteLoop', () {
19961 final __test = new SubtypeManagerTest();
19962 runJUnitTest(__test, __test.test_computeAllSubtypes_infiniteLoop);
19963 });
19964 _ut.test('test_computeAllSubtypes_manyRecursiveSubtypes', () {
19965 final __test = new SubtypeManagerTest();
19966 runJUnitTest(__test, __test.test_computeAllSubtypes_manyRecursiveSubtype s);
19967 });
19968 _ut.test('test_computeAllSubtypes_noSubtypes', () {
19969 final __test = new SubtypeManagerTest();
19970 runJUnitTest(__test, __test.test_computeAllSubtypes_noSubtypes);
19971 });
19972 _ut.test('test_computeAllSubtypes_oneSubtype', () {
19973 final __test = new SubtypeManagerTest();
19974 runJUnitTest(__test, __test.test_computeAllSubtypes_oneSubtype);
19975 });
19976 });
19977 }
19978 }
19979 main() {
19980 // ElementResolverTest.dartSuite();
19981 // InheritanceManagerTest.dartSuite();
19982 // LibraryElementBuilderTest.dartSuite();
19983 // LibraryTest.dartSuite();
19984 // StaticTypeAnalyzerTest.dartSuite();
19985 // SubtypeManagerTest.dartSuite();
19986 // TypeOverrideManagerTest.dartSuite();
19987 // TypeProviderImplTest.dartSuite();
19988 // TypeResolverVisitorTest.dartSuite();
19989 // EnclosedScopeTest.dartSuite();
19990 // LibraryImportScopeTest.dartSuite();
19991 // LibraryScopeTest.dartSuite();
19992 // ScopeTest.dartSuite();
19993 // CompileTimeErrorCodeTest.dartSuite();
19994 // ErrorResolverTest.dartSuite();
19995 // HintCodeTest.dartSuite();
19996 // MemberMapTest.dartSuite();
19997 // NonHintCodeTest.dartSuite();
19998 // NonErrorResolverTest.dartSuite();
19999 // SimpleResolverTest.dartSuite();
20000 // StaticTypeWarningCodeTest.dartSuite();
20001 // StaticWarningCodeTest.dartSuite();
20002 // StrictModeTest.dartSuite();
20003 // TypePropagationTest.dartSuite();
20004 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/test/generated/parser_test.dart ('k') | pkg/analyzer_experimental/test/generated/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698