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

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

Issue 17932005: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Disable resolver tests Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine.resolver_test; 3 library engine.resolver_test;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'package:analyzer_experimental/src/generated/java_core.dart'; 5 import 'package:analyzer_experimental/src/generated/java_core.dart';
6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 6 import 'package:analyzer_experimental/src/generated/java_engine.dart';
7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 7 import 'package:analyzer_experimental/src/generated/java_junit.dart';
8 import 'package:analyzer_experimental/src/generated/source_io.dart'; 8 import 'package:analyzer_experimental/src/generated/source_io.dart';
9 import 'package:analyzer_experimental/src/generated/error.dart'; 9 import 'package:analyzer_experimental/src/generated/error.dart';
10 import 'package:analyzer_experimental/src/generated/scanner.dart'; 10 import 'package:analyzer_experimental/src/generated/scanner.dart';
11 import 'package:analyzer_experimental/src/generated/ast.dart'; 11 import 'package:analyzer_experimental/src/generated/ast.dart';
12 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode; 12 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode;
13 import 'package:analyzer_experimental/src/generated/element.dart'; 13 import 'package:analyzer_experimental/src/generated/element.dart';
14 import 'package:analyzer_experimental/src/generated/resolver.dart'; 14 import 'package:analyzer_experimental/src/generated/resolver.dart';
15 import 'package:analyzer_experimental/src/generated/engine.dart'; 15 import 'package:analyzer_experimental/src/generated/engine.dart';
16 import 'package:analyzer_experimental/src/generated/java_engine_io.dart'; 16 import 'package:analyzer_experimental/src/generated/java_engine_io.dart';
17 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk; 17 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk;
18 import 'package:analyzer_experimental/src/generated/sdk_io.dart' show DirectoryB asedDartSdk; 18 import 'package:analyzer_experimental/src/generated/sdk_io.dart' show DirectoryB asedDartSdk;
19 import 'package:unittest/unittest.dart' as _ut; 19 import 'package:unittest/unittest.dart' as _ut;
20 import 'test_support.dart'; 20 import 'test_support.dart';
21 import 'ast_test.dart' show ASTFactory; 21 import 'ast_test.dart' show ASTFactory;
22 import 'element_test.dart' show ElementFactory; 22 import 'element_test.dart' show ElementFactory;
23 class TypePropagationTest extends ResolverTestCase { 23 class TypePropagationTest extends ResolverTestCase {
24 void fail_functionExpression_asInvocationArgument_functionExpressionInvocation () {
25 String code = EngineTestCase.createSource(["main() {", " (f(String value)) {} ((v) {", " v;", " });", "}"]);
26 Source source = addSource(code);
27 LibraryElement library = resolve(source);
28 assertNoErrors();
29 verify([source]);
30 CompilationUnit unit = resolveCompilationUnit(source, library);
31 Type2 dynamicType = typeProvider.dynamicType;
32 Type2 stringType = typeProvider.stringType;
33 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Forma lParameter);
34 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType);
35 JUnitTestCase.assertSame(dynamicType, vParameter.identifier.staticType);
36 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim pleIdentifier);
37 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType);
38 JUnitTestCase.assertSame(dynamicType, vIdentifier.staticType);
39 }
40 void fail_propagatedReturnType_functionExpression() {
41 String code = EngineTestCase.createSource(["main() {", " var v = (() {retur n 42;})();", "}"]);
42 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
43 }
24 void test_as() { 44 void test_as() {
25 Source source = addSource(EngineTestCase.createSource(["class A {", " bool get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"])); 45 Source source = addSource(EngineTestCase.createSource(["class A {", " bool get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"]));
26 LibraryElement library = resolve(source); 46 LibraryElement library = resolve(source);
27 assertNoErrors(); 47 assertNoErrors();
28 verify([source]); 48 verify([source]);
29 CompilationUnit unit = resolveCompilationUnit(source, library); 49 CompilationUnit unit = resolveCompilationUnit(source, library);
30 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 50 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
31 InterfaceType typeA = classA.element.type; 51 InterfaceType typeA = classA.element.type;
32 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 52 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
33 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy; 53 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 CompilationUnit unit = resolveCompilationUnit(source, library); 102 CompilationUnit unit = resolveCompilationUnit(source, library);
83 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 103 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
84 InterfaceType typeA = classA.element.type; 104 InterfaceType typeA = classA.element.type;
85 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 105 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
86 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy; 106 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
87 ForEachStatement forStatement = body.block.statements[0] as ForEachStatement ; 107 ForEachStatement forStatement = body.block.statements[0] as ForEachStatement ;
88 ReturnStatement statement = ((forStatement.body as Block)).statements[0] as ReturnStatement; 108 ReturnStatement statement = ((forStatement.body as Block)).statements[0] as ReturnStatement;
89 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 109 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
90 JUnitTestCase.assertSame(typeA, variableName.propagatedType); 110 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
91 } 111 }
112 void test_functionExpression_asInvocationArgument() {
113 String code = EngineTestCase.createSource(["class MyMap<K, V> {", " forEach (f(K key, V value)) {}", "}", "f(MyMap<int, String> m) {", " m.forEach((k, v) { ", " k;", " v;", " });", "}"]);
114 Source source = addSource(code);
115 LibraryElement library = resolve(source);
116 assertNoErrors();
117 verify([source]);
118 CompilationUnit unit = resolveCompilationUnit(source, library);
119 Type2 intType = typeProvider.intType;
120 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp leFormalParameter);
121 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType);
122 SimpleIdentifier kIdentifier = EngineTestCase.findNode(unit, code, "k;", Sim pleIdentifier);
123 JUnitTestCase.assertSame(intType, kIdentifier.propagatedType);
124 JUnitTestCase.assertSame(typeProvider.dynamicType, kIdentifier.staticType);
125 Type2 stringType = typeProvider.stringType;
126 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl eFormalParameter);
127 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType);
128 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim pleIdentifier);
129 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType);
130 JUnitTestCase.assertSame(typeProvider.dynamicType, vIdentifier.staticType);
131 }
132 void test_functionExpression_asInvocationArgument_fromInferredInvocation() {
133 String code = EngineTestCase.createSource(["class MyMap<K, V> {", " forEach (f(K key, V value)) {}", "}", "f(MyMap<int, String> m) {", " var m2 = m;", " m 2.forEach((k, v) {});", "}"]);
134 Source source = addSource(code);
135 LibraryElement library = resolve(source);
136 assertNoErrors();
137 verify([source]);
138 CompilationUnit unit = resolveCompilationUnit(source, library);
139 Type2 intType = typeProvider.intType;
140 FormalParameter kParameter = EngineTestCase.findNode(unit, code, "k, ", Simp leFormalParameter);
141 JUnitTestCase.assertSame(intType, kParameter.identifier.propagatedType);
142 Type2 stringType = typeProvider.stringType;
143 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl eFormalParameter);
144 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType);
145 }
146 void test_functionExpression_asInvocationArgument_keepIfLessSpecific() {
147 String code = EngineTestCase.createSource(["class MyList {", " forEach(f(Ob ject value)) {}", "}", "f(MyList list) {", " list.forEach((int v) {", " v;", " });", "}"]);
148 Source source = addSource(code);
149 LibraryElement library = resolve(source);
150 assertNoErrors();
151 verify([source]);
152 CompilationUnit unit = resolveCompilationUnit(source, library);
153 Type2 intType = typeProvider.intType;
154 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl eFormalParameter);
155 JUnitTestCase.assertSame(null, vParameter.identifier.propagatedType);
156 JUnitTestCase.assertSame(intType, vParameter.identifier.staticType);
157 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim pleIdentifier);
158 JUnitTestCase.assertSame(intType, vIdentifier.staticType);
159 JUnitTestCase.assertSame(null, vIdentifier.propagatedType);
160 }
161 void test_functionExpression_asInvocationArgument_replaceIfMoreSpecific() {
162 String code = EngineTestCase.createSource(["class MyList<E> {", " forEach(f (E value)) {}", "}", "f(MyList<String> list) {", " list.forEach((Object v) {", " v;", " });", "}"]);
163 Source source = addSource(code);
164 LibraryElement library = resolve(source);
165 assertNoErrors();
166 verify([source]);
167 CompilationUnit unit = resolveCompilationUnit(source, library);
168 Type2 stringType = typeProvider.stringType;
169 FormalParameter vParameter = EngineTestCase.findNode(unit, code, "v)", Simpl eFormalParameter);
170 JUnitTestCase.assertSame(stringType, vParameter.identifier.propagatedType);
171 JUnitTestCase.assertSame(typeProvider.objectType, vParameter.identifier.stat icType);
172 SimpleIdentifier vIdentifier = EngineTestCase.findNode(unit, code, "v;", Sim pleIdentifier);
173 JUnitTestCase.assertSame(stringType, vIdentifier.propagatedType);
174 }
175 void test_Future_then() {
176 String code = EngineTestCase.createSource(["import 'dart:async';", "main(Fut ure<int> firstFuture) {", " firstFuture.then((p1) {", " return 1.0;", " }). then((p2) {", " return new Future<String>.value('str');", " }).then((p3) {", " });", "}"]);
177 Source source = addSource(code);
178 LibraryElement library = resolve(source);
179 assertNoErrors();
180 verify([source]);
181 CompilationUnit unit = resolveCompilationUnit(source, library);
182 FormalParameter p1 = EngineTestCase.findNode(unit, code, "p1) {", SimpleForm alParameter);
183 JUnitTestCase.assertSame(typeProvider.intType, p1.identifier.propagatedType) ;
184 FormalParameter p2 = EngineTestCase.findNode(unit, code, "p2) {", SimpleForm alParameter);
185 JUnitTestCase.assertSame(typeProvider.doubleType, p2.identifier.propagatedTy pe);
186 FormalParameter p3 = EngineTestCase.findNode(unit, code, "p3) {", SimpleForm alParameter);
187 JUnitTestCase.assertSame(typeProvider.stringType, p3.identifier.propagatedTy pe);
188 }
92 void test_initializer() { 189 void test_initializer() {
93 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0 ;", " return v;", "}"])); 190 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0 ;", " return v;", "}"]));
94 LibraryElement library = resolve(source); 191 LibraryElement library = resolve(source);
95 assertNoErrors(); 192 assertNoErrors();
96 verify([source]); 193 verify([source]);
97 CompilationUnit unit = resolveCompilationUnit(source, library); 194 CompilationUnit unit = resolveCompilationUnit(source, library);
98 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 195 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
99 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy; 196 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
100 ReturnStatement statement = body.block.statements[1] as ReturnStatement; 197 NodeList<Statement> statements = body.block.statements;
101 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 198 {
102 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType); 199 VariableDeclarationStatement statement = statements[0] as VariableDeclarat ionStatement;
200 SimpleIdentifier variableName = statement.variables.variables[0].name;
201 JUnitTestCase.assertSame(typeProvider.dynamicType, variableName.staticType );
202 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType );
203 }
204 {
205 ReturnStatement statement = statements[1] as ReturnStatement;
206 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
207 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType );
208 }
103 } 209 }
104 void test_initializer_dereference() { 210 void test_initializer_dereference() {
105 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = ' String';", " v.", "}"])); 211 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = ' String';", " v.", "}"]));
106 LibraryElement library = resolve(source); 212 LibraryElement library = resolve(source);
107 CompilationUnit unit = resolveCompilationUnit(source, library); 213 CompilationUnit unit = resolveCompilationUnit(source, library);
108 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 214 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
109 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy; 215 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
110 ExpressionStatement statement = body.block.statements[1] as ExpressionStatem ent; 216 ExpressionStatement statement = body.block.statements[1] as ExpressionStatem ent;
111 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier; 217 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier;
112 SimpleIdentifier variableName = invocation.prefix; 218 SimpleIdentifier variableName = invocation.prefix;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy; 456 BlockFunctionBody body = function.functionExpression.body as BlockFunctionBo dy;
351 ReturnStatement statement = body.block.statements[1] as ReturnStatement; 457 ReturnStatement statement = body.block.statements[1] as ReturnStatement;
352 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; 458 SimpleIdentifier identifier = statement.expression as SimpleIdentifier;
353 InterfaceType propagatedType = identifier.propagatedType as InterfaceType; 459 InterfaceType propagatedType = identifier.propagatedType as InterfaceType;
354 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen t); 460 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType.elemen t);
355 List<Type2> typeArguments = propagatedType.typeArguments; 461 List<Type2> typeArguments = propagatedType.typeArguments;
356 EngineTestCase.assertLength(2, typeArguments); 462 EngineTestCase.assertLength(2, typeArguments);
357 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments[0]); 463 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments[0]);
358 JUnitTestCase.assertSame(typeProvider.intType, typeArguments[1]); 464 JUnitTestCase.assertSame(typeProvider.intType, typeArguments[1]);
359 } 465 }
466 void test_propagatedReturnType_function_hasReturnType_returnsNull() {
467 String code = EngineTestCase.createSource(["String f() => null;", "main() {" , " var v = f();", "}"]);
468 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.stri ngType);
469 }
470 void test_propagatedReturnType_function_lessSpecificStaticReturnType() {
471 String code = EngineTestCase.createSource(["Object f() => 42;", "main() {", " var v = f();", "}"]);
472 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
473 }
474 void test_propagatedReturnType_function_moreSpecificStaticReturnType() {
475 String code = EngineTestCase.createSource(["int f() => (42 as Object);", "ma in() {", " var v = f();", "}"]);
476 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
477 }
478 void test_propagatedReturnType_function_noReturnTypeName_blockBody_multipleRet urns() {
479 String code = EngineTestCase.createSource(["f() {", " if (true) return 0;", " return 1.0;", "}", "main() {", " var v = f();", "}"]);
480 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.numT ype);
481 }
482 void test_propagatedReturnType_function_noReturnTypeName_blockBody_oneReturn() {
483 String code = EngineTestCase.createSource(["f() {", " var z = 42;", " retu rn z;", "}", "main() {", " var v = f();", "}"]);
484 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
485 }
486 void test_propagatedReturnType_function_noReturnTypeName_expressionBody() {
487 String code = EngineTestCase.createSource(["f() => 42;", "main() {", " var v = f();", "}"]);
488 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
489 }
490 void test_propagatedReturnType_localFunction() {
491 String code = EngineTestCase.createSource(["main() {", " f() => 42;", " va r v = f();", "}"]);
492 check_propagatedReturnType(code, typeProvider.dynamicType, typeProvider.intT ype);
493 }
360 void test_query() { 494 void test_query() {
361 Source source = addSource(EngineTestCase.createSource(["import 'dart:html';" , "", "main() {", " var v1 = query('a');", " var v2 = query('A');", " var v3 = query('body:active');", " var v4 = query('button[foo=\"bar\"]');", " var v5 = query('div.class');", " var v6 = query('input#id');", " var v7 = query('sele ct#id');", " // invocation of method", " var m1 = document.query('div');", " / / unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('D ART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"])); 495 Source source = addSource(EngineTestCase.createSource(["import 'dart:html';" , "", "main() {", " var v1 = query('a');", " var v2 = query('A');", " var v3 = query('body:active');", " var v4 = query('button[foo=\"bar\"]');", " var v5 = query('div.class');", " var v6 = query('input#id');", " var v7 = query('sele ct#id');", " // invocation of method", " var m1 = document.query('div');", " / / unsupported currently", " var b1 = query('noSuchTag');", " var b2 = query('D ART_EDITOR_NO_SUCH_TYPE');", " var b3 = query('body div');", " return [v1, v2, v3, v4, v5, v6, v7, m1, b1, b2, b3];", "}"]));
362 LibraryElement library = resolve(source); 496 LibraryElement library = resolve(source);
363 assertNoErrors(); 497 assertNoErrors();
364 verify([source]); 498 verify([source]);
365 CompilationUnit unit = resolveCompilationUnit(source, library); 499 CompilationUnit unit = resolveCompilationUnit(source, library);
366 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; 500 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration;
367 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody; 501 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody;
368 ReturnStatement statement = body.block.statements[11] as ReturnStatement; 502 ReturnStatement statement = body.block.statements[11] as ReturnStatement;
369 NodeList<Expression> elements = ((statement.expression as ListLiteral)).elem ents; 503 NodeList<Expression> elements = ((statement.expression as ListLiteral)).elem ents;
370 JUnitTestCase.assertEquals("AnchorElement", elements[0].propagatedType.name) ; 504 JUnitTestCase.assertEquals("AnchorElement", elements[0].propagatedType.name) ;
371 JUnitTestCase.assertEquals("AnchorElement", elements[1].propagatedType.name) ; 505 JUnitTestCase.assertEquals("AnchorElement", elements[1].propagatedType.name) ;
372 JUnitTestCase.assertEquals("BodyElement", elements[2].propagatedType.name); 506 JUnitTestCase.assertEquals("BodyElement", elements[2].propagatedType.name);
373 JUnitTestCase.assertEquals("ButtonElement", elements[3].propagatedType.name) ; 507 JUnitTestCase.assertEquals("ButtonElement", elements[3].propagatedType.name) ;
374 JUnitTestCase.assertEquals("DivElement", elements[4].propagatedType.name); 508 JUnitTestCase.assertEquals("DivElement", elements[4].propagatedType.name);
375 JUnitTestCase.assertEquals("InputElement", elements[5].propagatedType.name); 509 JUnitTestCase.assertEquals("InputElement", elements[5].propagatedType.name);
376 JUnitTestCase.assertEquals("SelectElement", elements[6].propagatedType.name) ; 510 JUnitTestCase.assertEquals("SelectElement", elements[6].propagatedType.name) ;
377 JUnitTestCase.assertEquals("DivElement", elements[7].propagatedType.name); 511 JUnitTestCase.assertEquals("DivElement", elements[7].propagatedType.name);
378 JUnitTestCase.assertEquals("Element", elements[8].propagatedType.name); 512 JUnitTestCase.assertEquals("Element", elements[8].propagatedType.name);
379 JUnitTestCase.assertEquals("Element", elements[9].propagatedType.name); 513 JUnitTestCase.assertEquals("Element", elements[9].propagatedType.name);
380 JUnitTestCase.assertEquals("Element", elements[10].propagatedType.name); 514 JUnitTestCase.assertEquals("Element", elements[10].propagatedType.name);
381 } 515 }
516
517 /**
518 * @param code the code that assigns the value to the variable "v", no matter how. We check that
519 * "v" has expected static and propagated type.
520 */
521 void check_propagatedReturnType(String code, Type2 expectedStaticType, Type2 e xpectedPropagatedType) {
522 Source source = addSource(code);
523 LibraryElement library = resolve(source);
524 assertNoErrors();
525 verify([source]);
526 CompilationUnit unit = resolveCompilationUnit(source, library);
527 SimpleIdentifier identifier = EngineTestCase.findNode(unit, code, "v = ", Si mpleIdentifier);
528 JUnitTestCase.assertSame(expectedStaticType, identifier.staticType);
529 JUnitTestCase.assertSame(expectedPropagatedType, identifier.propagatedType);
530 }
382 static dartSuite() { 531 static dartSuite() {
383 _ut.group('TypePropagationTest', () { 532 _ut.group('TypePropagationTest', () {
533 _ut.test('test_Future_then', () {
534 final __test = new TypePropagationTest();
535 runJUnitTest(__test, __test.test_Future_then);
536 });
384 _ut.test('test_as', () { 537 _ut.test('test_as', () {
385 final __test = new TypePropagationTest(); 538 final __test = new TypePropagationTest();
386 runJUnitTest(__test, __test.test_as); 539 runJUnitTest(__test, __test.test_as);
387 }); 540 });
388 _ut.test('test_assert', () { 541 _ut.test('test_assert', () {
389 final __test = new TypePropagationTest(); 542 final __test = new TypePropagationTest();
390 runJUnitTest(__test, __test.test_assert); 543 runJUnitTest(__test, __test.test_assert);
391 }); 544 });
392 _ut.test('test_assignment', () { 545 _ut.test('test_assignment', () {
393 final __test = new TypePropagationTest(); 546 final __test = new TypePropagationTest();
394 runJUnitTest(__test, __test.test_assignment); 547 runJUnitTest(__test, __test.test_assignment);
395 }); 548 });
396 _ut.test('test_assignment_afterInitializer', () { 549 _ut.test('test_assignment_afterInitializer', () {
397 final __test = new TypePropagationTest(); 550 final __test = new TypePropagationTest();
398 runJUnitTest(__test, __test.test_assignment_afterInitializer); 551 runJUnitTest(__test, __test.test_assignment_afterInitializer);
399 }); 552 });
400 _ut.test('test_forEach', () { 553 _ut.test('test_forEach', () {
401 final __test = new TypePropagationTest(); 554 final __test = new TypePropagationTest();
402 runJUnitTest(__test, __test.test_forEach); 555 runJUnitTest(__test, __test.test_forEach);
403 }); 556 });
557 _ut.test('test_functionExpression_asInvocationArgument', () {
558 final __test = new TypePropagationTest();
559 runJUnitTest(__test, __test.test_functionExpression_asInvocationArgument );
560 });
561 _ut.test('test_functionExpression_asInvocationArgument_fromInferredInvocat ion', () {
562 final __test = new TypePropagationTest();
563 runJUnitTest(__test, __test.test_functionExpression_asInvocationArgument _fromInferredInvocation);
564 });
565 _ut.test('test_functionExpression_asInvocationArgument_keepIfLessSpecific' , () {
566 final __test = new TypePropagationTest();
567 runJUnitTest(__test, __test.test_functionExpression_asInvocationArgument _keepIfLessSpecific);
568 });
569 _ut.test('test_functionExpression_asInvocationArgument_replaceIfMoreSpecif ic', () {
570 final __test = new TypePropagationTest();
571 runJUnitTest(__test, __test.test_functionExpression_asInvocationArgument _replaceIfMoreSpecific);
572 });
404 _ut.test('test_initializer', () { 573 _ut.test('test_initializer', () {
405 final __test = new TypePropagationTest(); 574 final __test = new TypePropagationTest();
406 runJUnitTest(__test, __test.test_initializer); 575 runJUnitTest(__test, __test.test_initializer);
407 }); 576 });
408 _ut.test('test_initializer_dereference', () { 577 _ut.test('test_initializer_dereference', () {
409 final __test = new TypePropagationTest(); 578 final __test = new TypePropagationTest();
410 runJUnitTest(__test, __test.test_initializer_dereference); 579 runJUnitTest(__test, __test.test_initializer_dereference);
411 }); 580 });
412 _ut.test('test_isNot_conditional', () { 581 _ut.test('test_isNot_conditional', () {
413 final __test = new TypePropagationTest(); 582 final __test = new TypePropagationTest();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 runJUnitTest(__test, __test.test_listLiteral_same); 639 runJUnitTest(__test, __test.test_listLiteral_same);
471 }); 640 });
472 _ut.test('test_mapLiteral_different', () { 641 _ut.test('test_mapLiteral_different', () {
473 final __test = new TypePropagationTest(); 642 final __test = new TypePropagationTest();
474 runJUnitTest(__test, __test.test_mapLiteral_different); 643 runJUnitTest(__test, __test.test_mapLiteral_different);
475 }); 644 });
476 _ut.test('test_mapLiteral_same', () { 645 _ut.test('test_mapLiteral_same', () {
477 final __test = new TypePropagationTest(); 646 final __test = new TypePropagationTest();
478 runJUnitTest(__test, __test.test_mapLiteral_same); 647 runJUnitTest(__test, __test.test_mapLiteral_same);
479 }); 648 });
649 _ut.test('test_propagatedReturnType_function_hasReturnType_returnsNull', ( ) {
650 final __test = new TypePropagationTest();
651 runJUnitTest(__test, __test.test_propagatedReturnType_function_hasReturn Type_returnsNull);
652 });
653 _ut.test('test_propagatedReturnType_function_lessSpecificStaticReturnType' , () {
654 final __test = new TypePropagationTest();
655 runJUnitTest(__test, __test.test_propagatedReturnType_function_lessSpeci ficStaticReturnType);
656 });
657 _ut.test('test_propagatedReturnType_function_moreSpecificStaticReturnType' , () {
658 final __test = new TypePropagationTest();
659 runJUnitTest(__test, __test.test_propagatedReturnType_function_moreSpeci ficStaticReturnType);
660 });
661 _ut.test('test_propagatedReturnType_function_noReturnTypeName_blockBody_mu ltipleReturns', () {
662 final __test = new TypePropagationTest();
663 runJUnitTest(__test, __test.test_propagatedReturnType_function_noReturnT ypeName_blockBody_multipleReturns);
664 });
665 _ut.test('test_propagatedReturnType_function_noReturnTypeName_blockBody_on eReturn', () {
666 final __test = new TypePropagationTest();
667 runJUnitTest(__test, __test.test_propagatedReturnType_function_noReturnT ypeName_blockBody_oneReturn);
668 });
669 _ut.test('test_propagatedReturnType_function_noReturnTypeName_expressionBo dy', () {
670 final __test = new TypePropagationTest();
671 runJUnitTest(__test, __test.test_propagatedReturnType_function_noReturnT ypeName_expressionBody);
672 });
673 _ut.test('test_propagatedReturnType_localFunction', () {
674 final __test = new TypePropagationTest();
675 runJUnitTest(__test, __test.test_propagatedReturnType_localFunction);
676 });
480 _ut.test('test_query', () { 677 _ut.test('test_query', () {
481 final __test = new TypePropagationTest(); 678 final __test = new TypePropagationTest();
482 runJUnitTest(__test, __test.test_query); 679 runJUnitTest(__test, __test.test_query);
483 }); 680 });
484 }); 681 });
485 } 682 }
486 } 683 }
487 class NonErrorResolverTest extends ResolverTestCase { 684 class NonErrorResolverTest extends ResolverTestCase {
488 void test_ambiguousExport() { 685 void test_ambiguousExport() {
489 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"])); 686 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"]));
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 resolve(source); 856 resolve(source);
660 assertNoErrors(); 857 assertNoErrors();
661 verify([source]); 858 verify([source]);
662 } 859 }
663 void test_constConstructorWithNonFinalField_syntheticField() { 860 void test_constConstructorWithNonFinalField_syntheticField() {
664 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"])); 861 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"]));
665 resolve(source); 862 resolve(source);
666 assertNoErrors(); 863 assertNoErrors();
667 verify([source]); 864 verify([source]);
668 } 865 }
866 void test_constEval_propertyExtraction_fieldStatic_targetType() {
867 addSource2("/math.dart", EngineTestCase.createSource(["library math;", "cons t PI = 3.14;"]));
868 Source source = addSource(EngineTestCase.createSource(["import 'math.dart' a s math;", "const C = math.PI;"]));
869 resolve(source);
870 assertNoErrors();
871 verify([source]);
872 }
873 void test_constEval_propertyExtraction_methodStatic_targetType() {
874 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", " static m() {}", "}", "const C = A.m;"]));
875 resolve(source);
876 assertNoErrors();
877 verify([source]);
878 }
669 void test_constEvalTypeBoolNumString_equal() { 879 void test_constEvalTypeBoolNumString_equal() {
670 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final v;", " const B.a1(bool p) : v = p == true;", " const B.a2(bool p) : v = p == false;", " const B.a3(bool p) : v = p == 0;", " const B.a4(bool p) : v = p == 0.0;", " const B.a5(bool p) : v = p == '';", " const B.b1(int p) : v = p == true;", " const B.b2(int p) : v = p == false;", " const B.b3(int p) : v = p == 0;", " const B.b4(int p) : v = p == 0.0;", " const B.b5(int p) : v = p == '';", " const B.c1(String p) : v = p == true;", " const B.c2(String p) : v = p == false;", " const B.c3(String p) : v = p == 0;" , " const B.c4(String p) : v = p == 0.0;", " const B.c5(String p) : v = p == ' ';", " const B.n1(num p) : v = p == null;", " const B.n2(num p) : v = null == p;", "}"])); 880 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final v;", " const B.a1(bool p) : v = p == true;", " const B.a2(bool p) : v = p == false;", " const B.a3(bool p) : v = p == 0;", " const B.a4(bool p) : v = p == 0.0;", " const B.a5(bool p) : v = p == '';", " const B.b1(int p) : v = p == true;", " const B.b2(int p) : v = p == false;", " const B.b3(int p) : v = p == 0;", " const B.b4(int p) : v = p == 0.0;", " const B.b5(int p) : v = p == '';", " const B.c1(String p) : v = p == true;", " const B.c2(String p) : v = p == false;", " const B.c3(String p) : v = p == 0;" , " const B.c4(String p) : v = p == 0.0;", " const B.c5(String p) : v = p == ' ';", " const B.n1(num p) : v = p == null;", " const B.n2(num p) : v = null == p;", "}"]));
671 resolve(source); 881 resolve(source);
672 assertNoErrors(); 882 assertNoErrors();
673 verify([source]); 883 verify([source]);
674 } 884 }
675 void test_constEvalTypeBoolNumString_notEqual() { 885 void test_constEvalTypeBoolNumString_notEqual() {
676 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final v;", " const B.a1(bool p) : v = p != true;", " const B.a2(bool p) : v = p != false;", " const B.a3(bool p) : v = p != 0;", " const B.a4(bool p) : v = p != 0.0;", " const B.a5(bool p) : v = p != '';", " const B.b1(int p) : v = p != true;", " const B.b2(int p) : v = p != false;", " const B.b3(int p) : v = p != 0;", " const B.b4(int p) : v = p != 0.0;", " const B.b5(int p) : v = p != '';", " const B.c1(String p) : v = p != true;", " const B.c2(String p) : v = p != false;", " const B.c3(String p) : v = p != 0;" , " const B.c4(String p) : v = p != 0.0;", " const B.c5(String p) : v = p != ' ';", " const B.n1(num p) : v = p != null;", " const B.n2(num p) : v = null != p;", "}"])); 886 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final v;", " const B.a1(bool p) : v = p != true;", " const B.a2(bool p) : v = p != false;", " const B.a3(bool p) : v = p != 0;", " const B.a4(bool p) : v = p != 0.0;", " const B.a5(bool p) : v = p != '';", " const B.b1(int p) : v = p != true;", " const B.b2(int p) : v = p != false;", " const B.b3(int p) : v = p != 0;", " const B.b4(int p) : v = p != 0.0;", " const B.b5(int p) : v = p != '';", " const B.c1(String p) : v = p != true;", " const B.c2(String p) : v = p != false;", " const B.c3(String p) : v = p != 0;" , " const B.c4(String p) : v = p != 0.0;", " const B.c5(String p) : v = p != ' ';", " const B.n1(num p) : v = p != null;", " const B.n2(num p) : v = null != p;", "}"]));
677 resolve(source); 887 resolve(source);
678 assertNoErrors(); 888 assertNoErrors();
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 resolve(source); 1132 resolve(source);
923 assertNoErrors(); 1133 assertNoErrors();
924 verify([source]); 1134 verify([source]);
925 } 1135 }
926 void test_initializingFormalForNonExistantField() { 1136 void test_initializingFormalForNonExistantField() {
927 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"])); 1137 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"]));
928 resolve(source); 1138 resolve(source);
929 assertNoErrors(); 1139 assertNoErrors();
930 verify([source]); 1140 verify([source]);
931 } 1141 }
1142 void test_instanceMemberAccessFromStatic_fromComment() {
1143 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", " /// [m]", " static foo() {", " }", "}"]));
1144 resolve(source);
1145 assertNoErrors();
1146 verify([source]);
1147 }
932 void test_invalidAssignment() { 1148 void test_invalidAssignment() {
933 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;", " var y;", " x = y;", "}"])); 1149 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;", " var y;", " x = y;", "}"]));
934 resolve(source); 1150 resolve(source);
935 assertNoErrors(); 1151 assertNoErrors();
936 verify([source]); 1152 verify([source]);
937 } 1153 }
938 void test_invalidAssignment_compoundAssignment() { 1154 void test_invalidAssignment_compoundAssignment() {
939 Source source = addSource(EngineTestCase.createSource(["class byte {", " in t _value;", " byte(this._value);", " byte operator +(int val) {}", "}", "", "v oid main() {", " byte b = new byte(52);", " b += 3;", "}"])); 1155 Source source = addSource(EngineTestCase.createSource(["class byte {", " in t _value;", " byte(this._value);", " byte operator +(int val) {}", "}", "", "v oid main() {", " byte b = new byte(52);", " b += 3;", "}"]));
940 resolve(source); 1156 resolve(source);
941 assertNoErrors(); 1157 assertNoErrors();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 resolve(source); 1282 resolve(source);
1067 assertNoErrors(); 1283 assertNoErrors();
1068 verify([source]); 1284 verify([source]);
1069 } 1285 }
1070 void test_invocationOfNonFunction_localVariable() { 1286 void test_invocationOfNonFunction_localVariable() {
1071 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g();", "}"])); 1287 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g();", "}"]));
1072 resolve(source); 1288 resolve(source);
1073 assertNoErrors(); 1289 assertNoErrors();
1074 verify([source]); 1290 verify([source]);
1075 } 1291 }
1292 void test_invocationOfNonFunction_localVariable_dynamic() {
1293 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {", " var v = f;", " v();", "}"]));
1294 resolve(source);
1295 assertNoErrors();
1296 verify([source]);
1297 }
1298 void test_invocationOfNonFunction_localVariable_dynamic2() {
1299 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {", " var v = f;", " v = 1;", " v();", "}"]));
1300 resolve(source);
1301 assertNoErrors();
1302 verify([source]);
1303 }
1304 void test_invocationOfNonFunction_Object() {
1305 Source source = addSource(EngineTestCase.createSource(["main() {", " Object v = null;", " v();", "}"]));
1306 resolve(source);
1307 assertNoErrors();
1308 verify([source]);
1309 }
1076 void test_memberWithClassName_setter() { 1310 void test_memberWithClassName_setter() {
1077 Source source = addSource(EngineTestCase.createSource(["class A {", " set A (v) {}", "}"])); 1311 Source source = addSource(EngineTestCase.createSource(["class A {", " set A (v) {}", "}"]));
1078 resolve(source); 1312 resolve(source);
1079 assertNoErrors(); 1313 assertNoErrors();
1080 verify([source]); 1314 verify([source]);
1081 } 1315 }
1082 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() { 1316 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() {
1083 Source source = addSource(EngineTestCase.createSource(["class C {", " int g et x => 0;", " set x(int v) {}", "}"])); 1317 Source source = addSource(EngineTestCase.createSource(["class C {", " int g et x => 0;", " set x(int v) {}", "}"]));
1084 resolve(source); 1318 resolve(source);
1085 assertNoErrors(); 1319 assertNoErrors();
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 resolve(source); 1684 resolve(source);
1451 assertNoErrors(); 1685 assertNoErrors();
1452 verify([source]); 1686 verify([source]);
1453 } 1687 }
1454 void test_returnWithoutValue_void() { 1688 void test_returnWithoutValue_void() {
1455 Source source = addSource(EngineTestCase.createSource(["void f() { return; } "])); 1689 Source source = addSource(EngineTestCase.createSource(["void f() { return; } "]));
1456 resolve(source); 1690 resolve(source);
1457 assertNoErrors(); 1691 assertNoErrors();
1458 verify([source]); 1692 verify([source]);
1459 } 1693 }
1694 void test_staticAccessToInstanceMember_annotation() {
1695 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam e() {}", "}", "@A.name()", "main() {", "}"]));
1696 resolve(source);
1697 assertNoErrors();
1698 verify([source]);
1699 }
1460 void test_staticAccessToInstanceMember_method() { 1700 void test_staticAccessToInstanceMember_method() {
1461 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c m() {}", "}", "main() {", " A.m;", " A.m();", "}"])); 1701 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c m() {}", "}", "main() {", " A.m;", " A.m();", "}"]));
1462 resolve(source); 1702 resolve(source);
1463 assertNoErrors(); 1703 assertNoErrors();
1464 verify([source]); 1704 verify([source]);
1465 } 1705 }
1466 void test_staticAccessToInstanceMember_propertyAccess_field() { 1706 void test_staticAccessToInstanceMember_propertyAccess_field() {
1467 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c var f;", "}", "main() {", " A.f;", " A.f = 1;", "}"])); 1707 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c var f;", "}", "main() {", " A.f;", " A.f = 1;", "}"]));
1468 resolve(source); 1708 resolve(source);
1469 assertNoErrors(); 1709 assertNoErrors();
(...skipping 16 matching lines...) Expand all
1486 resolve(source); 1726 resolve(source);
1487 assertNoErrors(); 1727 assertNoErrors();
1488 verify([source]); 1728 verify([source]);
1489 } 1729 }
1490 void test_typeArgumentNotMatchingBounds_new() { 1730 void test_typeArgumentNotMatchingBounds_new() {
1491 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {}", "f() { return new G<B>(); }"])); 1731 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {}", "f() { return new G<B>(); }"]));
1492 resolve(source); 1732 resolve(source);
1493 assertNoErrors(); 1733 assertNoErrors();
1494 verify([source]); 1734 verify([source]);
1495 } 1735 }
1736 void test_typeArgumentNotMatchingBounds_typeArgumentList_0() {
1737 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e xtends A>{}"]));
1738 resolve(source);
1739 assertNoErrors();
1740 verify([source]);
1741 }
1742 void test_typeArgumentNotMatchingBounds_typeArgumentList_1() {
1743 Source source = addSource(EngineTestCase.createSource(["abstract class A<T e xtends A<A>>{}"]));
1744 resolve(source);
1745 assertNoErrors();
1746 verify([source]);
1747 }
1748 void test_typeArgumentNotMatchingBounds_typeArgumentList_20() {
1749 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>>>>>>>>>>>>>>>>>>>>>{}"]));
1750 resolve(source);
1751 assertNoErrors();
1752 verify([source]);
1753 }
1496 void test_undefinedConstructorInInitializer_explicit_named() { 1754 void test_undefinedConstructorInInitializer_explicit_named() {
1497 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam ed() {}", "}", "class B extends A {", " B() : super.named();", "}"])); 1755 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam ed() {}", "}", "class B extends A {", " B() : super.named();", "}"]));
1498 resolve(source); 1756 resolve(source);
1499 assertNoErrors(); 1757 assertNoErrors();
1500 verify([source]); 1758 verify([source]);
1501 } 1759 }
1502 void test_undefinedConstructorInInitializer_explicit_unnamed() { 1760 void test_undefinedConstructorInInitializer_explicit_unnamed() {
1503 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " B() : super();", "}"])); 1761 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " B() : super();", "}"]));
1504 resolve(source); 1762 resolve(source);
1505 assertNoErrors(); 1763 assertNoErrors();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 resolve(source); 1815 resolve(source);
1558 assertNoErrors(); 1816 assertNoErrors();
1559 } 1817 }
1560 void test_undefinedIdentifier_show() { 1818 void test_undefinedIdentifier_show() {
1561 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' show a;"])); 1819 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' show a;"]));
1562 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); 1820 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
1563 resolve(source); 1821 resolve(source);
1564 assertNoErrors(); 1822 assertNoErrors();
1565 verify([source]); 1823 verify([source]);
1566 } 1824 }
1825 void test_undefinedMethod_functionExpression_callMethod() {
1826 Source source = addSource(EngineTestCase.createSource(["main() {", " (() => null).call();", "}"]));
1827 resolve(source);
1828 assertNoErrors();
1829 }
1830 void test_undefinedMethod_functionExpression_directCall() {
1831 Source source = addSource(EngineTestCase.createSource(["main() {", " (() => null)();", "}"]));
1832 resolve(source);
1833 assertNoErrors();
1834 }
1567 void test_undefinedMethod_noSuchMethod() { 1835 void test_undefinedMethod_noSuchMethod() {
1568 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", "}", "f() {", " (new A()).m();", "}"])); 1836 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", "}", "f() {", " (new A()).m();", "}"]));
1569 resolve(source); 1837 resolve(source);
1570 assertNoErrors(); 1838 assertNoErrors();
1571 } 1839 }
1572 void test_undefinedOperator_index() { 1840 void test_undefinedOperator_index() {
1573 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor [](a) {}", " operator []=(a, b) {}", "}", "f(A a) {", " a[0];", " a[0] = 1;", "}"])); 1841 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor [](a) {}", " operator []=(a, b) {}", "}", "f(A a) {", " a[0];", " a[0] = 1;", "}"]));
1574 resolve(source); 1842 resolve(source);
1575 assertNoErrors(); 1843 assertNoErrors();
1576 verify([source]); 1844 verify([source]);
1577 } 1845 }
1578 void test_undefinedOperator_tilde() { 1846 void test_undefinedOperator_tilde() {
1579 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons t B = ~((1 << A) - 1);"])); 1847 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons t B = ~((1 << A) - 1);"]));
1580 resolve(source); 1848 resolve(source);
1581 assertNoErrors(); 1849 assertNoErrors();
1582 verify([source]); 1850 verify([source]);
1583 } 1851 }
1584 void test_undefinedSetter_noSuchMethod() { 1852 void test_undefinedSetter_noSuchMethod() {
1585 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", "}", "f() {", " (new A()).s = 1;", "}"])); 1853 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", "}", "f() {", " (new A()).s = 1;", "}"]));
1586 resolve(source); 1854 resolve(source);
1587 assertNoErrors(); 1855 assertNoErrors();
1588 } 1856 }
1857 void test_undefinedSuperMethod_field() {
1858 Source source = addSource(EngineTestCase.createSource(["class A {", " var m ;", "}", "class B extends A {", " f() {", " super.m();", " }", "}"]));
1859 resolve(source);
1860 assertNoErrors();
1861 verify([source]);
1862 }
1863 void test_undefinedSuperMethod_method() {
1864 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "class B extends A {", " f() {", " super.m();", " }", "}"]));
1865 resolve(source);
1866 assertNoErrors();
1867 verify([source]);
1868 }
1589 void test_wrongNumberOfParametersForOperator_index() { 1869 void test_wrongNumberOfParametersForOperator_index() {
1590 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor []=(a, b) {}", "}"])); 1870 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor []=(a, b) {}", "}"]));
1591 resolve(source); 1871 resolve(source);
1592 assertNoErrors(); 1872 assertNoErrors();
1593 verify([source]); 1873 verify([source]);
1594 } 1874 }
1595 void test_wrongNumberOfParametersForOperator_minus() { 1875 void test_wrongNumberOfParametersForOperator_minus() {
1596 check_wrongNumberOfParametersForOperator("-", ""); 1876 check_wrongNumberOfParametersForOperator("-", "");
1597 check_wrongNumberOfParametersForOperator("-", "a"); 1877 check_wrongNumberOfParametersForOperator("-", "a");
1598 } 1878 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField); 2028 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField);
1749 }); 2029 });
1750 _ut.test('test_constEvalTypeBoolNumString_equal', () { 2030 _ut.test('test_constEvalTypeBoolNumString_equal', () {
1751 final __test = new NonErrorResolverTest(); 2031 final __test = new NonErrorResolverTest();
1752 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal); 2032 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal);
1753 }); 2033 });
1754 _ut.test('test_constEvalTypeBoolNumString_notEqual', () { 2034 _ut.test('test_constEvalTypeBoolNumString_notEqual', () {
1755 final __test = new NonErrorResolverTest(); 2035 final __test = new NonErrorResolverTest();
1756 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual); 2036 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual);
1757 }); 2037 });
2038 _ut.test('test_constEval_propertyExtraction_fieldStatic_targetType', () {
2039 final __test = new NonErrorResolverTest();
2040 runJUnitTest(__test, __test.test_constEval_propertyExtraction_fieldStati c_targetType);
2041 });
2042 _ut.test('test_constEval_propertyExtraction_methodStatic_targetType', () {
2043 final __test = new NonErrorResolverTest();
2044 runJUnitTest(__test, __test.test_constEval_propertyExtraction_methodStat ic_targetType);
2045 });
1758 _ut.test('test_constWithNonConstantArgument_literals', () { 2046 _ut.test('test_constWithNonConstantArgument_literals', () {
1759 final __test = new NonErrorResolverTest(); 2047 final __test = new NonErrorResolverTest();
1760 runJUnitTest(__test, __test.test_constWithNonConstantArgument_literals); 2048 runJUnitTest(__test, __test.test_constWithNonConstantArgument_literals);
1761 }); 2049 });
1762 _ut.test('test_constWithTypeParameters_direct', () { 2050 _ut.test('test_constWithTypeParameters_direct', () {
1763 final __test = new NonErrorResolverTest(); 2051 final __test = new NonErrorResolverTest();
1764 runJUnitTest(__test, __test.test_constWithTypeParameters_direct); 2052 runJUnitTest(__test, __test.test_constWithTypeParameters_direct);
1765 }); 2053 });
1766 _ut.test('test_constWithUndefinedConstructor', () { 2054 _ut.test('test_constWithUndefinedConstructor', () {
1767 final __test = new NonErrorResolverTest(); 2055 final __test = new NonErrorResolverTest();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared); 2200 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared);
1913 }); 2201 });
1914 _ut.test('test_inconsistentCaseExpressionTypes', () { 2202 _ut.test('test_inconsistentCaseExpressionTypes', () {
1915 final __test = new NonErrorResolverTest(); 2203 final __test = new NonErrorResolverTest();
1916 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes); 2204 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes);
1917 }); 2205 });
1918 _ut.test('test_initializingFormalForNonExistantField', () { 2206 _ut.test('test_initializingFormalForNonExistantField', () {
1919 final __test = new NonErrorResolverTest(); 2207 final __test = new NonErrorResolverTest();
1920 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField); 2208 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField);
1921 }); 2209 });
2210 _ut.test('test_instanceMemberAccessFromStatic_fromComment', () {
2211 final __test = new NonErrorResolverTest();
2212 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_fromComm ent);
2213 });
1922 _ut.test('test_invalidAssignment', () { 2214 _ut.test('test_invalidAssignment', () {
1923 final __test = new NonErrorResolverTest(); 2215 final __test = new NonErrorResolverTest();
1924 runJUnitTest(__test, __test.test_invalidAssignment); 2216 runJUnitTest(__test, __test.test_invalidAssignment);
1925 }); 2217 });
1926 _ut.test('test_invalidAssignment_compoundAssignment', () { 2218 _ut.test('test_invalidAssignment_compoundAssignment', () {
1927 final __test = new NonErrorResolverTest(); 2219 final __test = new NonErrorResolverTest();
1928 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment); 2220 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment);
1929 }); 2221 });
1930 _ut.test('test_invalidAssignment_toDynamic', () { 2222 _ut.test('test_invalidAssignment_toDynamic', () {
1931 final __test = new NonErrorResolverTest(); 2223 final __test = new NonErrorResolverTest();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 runJUnitTest(__test, __test.test_invalidReferenceToThis_instanceMethod); 2288 runJUnitTest(__test, __test.test_invalidReferenceToThis_instanceMethod);
1997 }); 2289 });
1998 _ut.test('test_invalidTypeArgumentInConstList', () { 2290 _ut.test('test_invalidTypeArgumentInConstList', () {
1999 final __test = new NonErrorResolverTest(); 2291 final __test = new NonErrorResolverTest();
2000 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList); 2292 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList);
2001 }); 2293 });
2002 _ut.test('test_invalidTypeArgumentInConstMap', () { 2294 _ut.test('test_invalidTypeArgumentInConstMap', () {
2003 final __test = new NonErrorResolverTest(); 2295 final __test = new NonErrorResolverTest();
2004 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstMap); 2296 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstMap);
2005 }); 2297 });
2298 _ut.test('test_invocationOfNonFunction_Object', () {
2299 final __test = new NonErrorResolverTest();
2300 runJUnitTest(__test, __test.test_invocationOfNonFunction_Object);
2301 });
2006 _ut.test('test_invocationOfNonFunction_dynamic', () { 2302 _ut.test('test_invocationOfNonFunction_dynamic', () {
2007 final __test = new NonErrorResolverTest(); 2303 final __test = new NonErrorResolverTest();
2008 runJUnitTest(__test, __test.test_invocationOfNonFunction_dynamic); 2304 runJUnitTest(__test, __test.test_invocationOfNonFunction_dynamic);
2009 }); 2305 });
2010 _ut.test('test_invocationOfNonFunction_getter', () { 2306 _ut.test('test_invocationOfNonFunction_getter', () {
2011 final __test = new NonErrorResolverTest(); 2307 final __test = new NonErrorResolverTest();
2012 runJUnitTest(__test, __test.test_invocationOfNonFunction_getter); 2308 runJUnitTest(__test, __test.test_invocationOfNonFunction_getter);
2013 }); 2309 });
2014 _ut.test('test_invocationOfNonFunction_localVariable', () { 2310 _ut.test('test_invocationOfNonFunction_localVariable', () {
2015 final __test = new NonErrorResolverTest(); 2311 final __test = new NonErrorResolverTest();
2016 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable); 2312 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable);
2017 }); 2313 });
2314 _ut.test('test_invocationOfNonFunction_localVariable_dynamic', () {
2315 final __test = new NonErrorResolverTest();
2316 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable_d ynamic);
2317 });
2318 _ut.test('test_invocationOfNonFunction_localVariable_dynamic2', () {
2319 final __test = new NonErrorResolverTest();
2320 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable_d ynamic2);
2321 });
2018 _ut.test('test_memberWithClassName_setter', () { 2322 _ut.test('test_memberWithClassName_setter', () {
2019 final __test = new NonErrorResolverTest(); 2323 final __test = new NonErrorResolverTest();
2020 runJUnitTest(__test, __test.test_memberWithClassName_setter); 2324 runJUnitTest(__test, __test.test_memberWithClassName_setter);
2021 }); 2325 });
2022 _ut.test('test_misMatchedGetterAndSetterTypes_instance_sameTypes', () { 2326 _ut.test('test_misMatchedGetterAndSetterTypes_instance_sameTypes', () {
2023 final __test = new NonErrorResolverTest(); 2327 final __test = new NonErrorResolverTest();
2024 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance _sameTypes); 2328 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance _sameTypes);
2025 }); 2329 });
2026 _ut.test('test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter', () { 2330 _ut.test('test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter', () {
2027 final __test = new NonErrorResolverTest(); 2331 final __test = new NonErrorResolverTest();
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 runJUnitTest(__test, __test.test_returnOfInvalidType_void); 2568 runJUnitTest(__test, __test.test_returnOfInvalidType_void);
2265 }); 2569 });
2266 _ut.test('test_returnWithoutValue_noReturnType', () { 2570 _ut.test('test_returnWithoutValue_noReturnType', () {
2267 final __test = new NonErrorResolverTest(); 2571 final __test = new NonErrorResolverTest();
2268 runJUnitTest(__test, __test.test_returnWithoutValue_noReturnType); 2572 runJUnitTest(__test, __test.test_returnWithoutValue_noReturnType);
2269 }); 2573 });
2270 _ut.test('test_returnWithoutValue_void', () { 2574 _ut.test('test_returnWithoutValue_void', () {
2271 final __test = new NonErrorResolverTest(); 2575 final __test = new NonErrorResolverTest();
2272 runJUnitTest(__test, __test.test_returnWithoutValue_void); 2576 runJUnitTest(__test, __test.test_returnWithoutValue_void);
2273 }); 2577 });
2578 _ut.test('test_staticAccessToInstanceMember_annotation', () {
2579 final __test = new NonErrorResolverTest();
2580 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_annotation );
2581 });
2274 _ut.test('test_staticAccessToInstanceMember_method', () { 2582 _ut.test('test_staticAccessToInstanceMember_method', () {
2275 final __test = new NonErrorResolverTest(); 2583 final __test = new NonErrorResolverTest();
2276 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method); 2584 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method);
2277 }); 2585 });
2278 _ut.test('test_staticAccessToInstanceMember_propertyAccess_field', () { 2586 _ut.test('test_staticAccessToInstanceMember_propertyAccess_field', () {
2279 final __test = new NonErrorResolverTest(); 2587 final __test = new NonErrorResolverTest();
2280 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_field); 2588 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_field);
2281 }); 2589 });
2282 _ut.test('test_staticAccessToInstanceMember_propertyAccess_propertyAccesso r', () { 2590 _ut.test('test_staticAccessToInstanceMember_propertyAccess_propertyAccesso r', () {
2283 final __test = new NonErrorResolverTest(); 2591 final __test = new NonErrorResolverTest();
2284 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_propertyAccessor); 2592 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_propertyAccessor);
2285 }); 2593 });
2286 _ut.test('test_superInInvalidContext', () { 2594 _ut.test('test_superInInvalidContext', () {
2287 final __test = new NonErrorResolverTest(); 2595 final __test = new NonErrorResolverTest();
2288 runJUnitTest(__test, __test.test_superInInvalidContext); 2596 runJUnitTest(__test, __test.test_superInInvalidContext);
2289 }); 2597 });
2290 _ut.test('test_typeArgumentNotMatchingBounds_const', () { 2598 _ut.test('test_typeArgumentNotMatchingBounds_const', () {
2291 final __test = new NonErrorResolverTest(); 2599 final __test = new NonErrorResolverTest();
2292 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const); 2600 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
2293 }); 2601 });
2294 _ut.test('test_typeArgumentNotMatchingBounds_new', () { 2602 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
2295 final __test = new NonErrorResolverTest(); 2603 final __test = new NonErrorResolverTest();
2296 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new); 2604 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
2297 }); 2605 });
2606 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList_0', () {
2607 final __test = new NonErrorResolverTest();
2608 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum entList_0);
2609 });
2610 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList_1', () {
2611 final __test = new NonErrorResolverTest();
2612 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum entList_1);
2613 });
2614 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList_20', () {
2615 final __test = new NonErrorResolverTest();
2616 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum entList_20);
2617 });
2298 _ut.test('test_undefinedConstructorInInitializer_explicit_named', () { 2618 _ut.test('test_undefinedConstructorInInitializer_explicit_named', () {
2299 final __test = new NonErrorResolverTest(); 2619 final __test = new NonErrorResolverTest();
2300 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_named); 2620 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_named);
2301 }); 2621 });
2302 _ut.test('test_undefinedConstructorInInitializer_explicit_unnamed', () { 2622 _ut.test('test_undefinedConstructorInInitializer_explicit_unnamed', () {
2303 final __test = new NonErrorResolverTest(); 2623 final __test = new NonErrorResolverTest();
2304 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_unnamed); 2624 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_unnamed);
2305 }); 2625 });
2306 _ut.test('test_undefinedConstructorInInitializer_hasOptionalParameters', ( ) { 2626 _ut.test('test_undefinedConstructorInInitializer_hasOptionalParameters', ( ) {
2307 final __test = new NonErrorResolverTest(); 2627 final __test = new NonErrorResolverTest();
(...skipping 28 matching lines...) Expand all
2336 runJUnitTest(__test, __test.test_undefinedIdentifier_hide); 2656 runJUnitTest(__test, __test.test_undefinedIdentifier_hide);
2337 }); 2657 });
2338 _ut.test('test_undefinedIdentifier_noSuchMethod', () { 2658 _ut.test('test_undefinedIdentifier_noSuchMethod', () {
2339 final __test = new NonErrorResolverTest(); 2659 final __test = new NonErrorResolverTest();
2340 runJUnitTest(__test, __test.test_undefinedIdentifier_noSuchMethod); 2660 runJUnitTest(__test, __test.test_undefinedIdentifier_noSuchMethod);
2341 }); 2661 });
2342 _ut.test('test_undefinedIdentifier_show', () { 2662 _ut.test('test_undefinedIdentifier_show', () {
2343 final __test = new NonErrorResolverTest(); 2663 final __test = new NonErrorResolverTest();
2344 runJUnitTest(__test, __test.test_undefinedIdentifier_show); 2664 runJUnitTest(__test, __test.test_undefinedIdentifier_show);
2345 }); 2665 });
2666 _ut.test('test_undefinedMethod_functionExpression_callMethod', () {
2667 final __test = new NonErrorResolverTest();
2668 runJUnitTest(__test, __test.test_undefinedMethod_functionExpression_call Method);
2669 });
2670 _ut.test('test_undefinedMethod_functionExpression_directCall', () {
2671 final __test = new NonErrorResolverTest();
2672 runJUnitTest(__test, __test.test_undefinedMethod_functionExpression_dire ctCall);
2673 });
2346 _ut.test('test_undefinedMethod_noSuchMethod', () { 2674 _ut.test('test_undefinedMethod_noSuchMethod', () {
2347 final __test = new NonErrorResolverTest(); 2675 final __test = new NonErrorResolverTest();
2348 runJUnitTest(__test, __test.test_undefinedMethod_noSuchMethod); 2676 runJUnitTest(__test, __test.test_undefinedMethod_noSuchMethod);
2349 }); 2677 });
2350 _ut.test('test_undefinedOperator_index', () { 2678 _ut.test('test_undefinedOperator_index', () {
2351 final __test = new NonErrorResolverTest(); 2679 final __test = new NonErrorResolverTest();
2352 runJUnitTest(__test, __test.test_undefinedOperator_index); 2680 runJUnitTest(__test, __test.test_undefinedOperator_index);
2353 }); 2681 });
2354 _ut.test('test_undefinedOperator_tilde', () { 2682 _ut.test('test_undefinedOperator_tilde', () {
2355 final __test = new NonErrorResolverTest(); 2683 final __test = new NonErrorResolverTest();
2356 runJUnitTest(__test, __test.test_undefinedOperator_tilde); 2684 runJUnitTest(__test, __test.test_undefinedOperator_tilde);
2357 }); 2685 });
2358 _ut.test('test_undefinedSetter_noSuchMethod', () { 2686 _ut.test('test_undefinedSetter_noSuchMethod', () {
2359 final __test = new NonErrorResolverTest(); 2687 final __test = new NonErrorResolverTest();
2360 runJUnitTest(__test, __test.test_undefinedSetter_noSuchMethod); 2688 runJUnitTest(__test, __test.test_undefinedSetter_noSuchMethod);
2361 }); 2689 });
2690 _ut.test('test_undefinedSuperMethod_field', () {
2691 final __test = new NonErrorResolverTest();
2692 runJUnitTest(__test, __test.test_undefinedSuperMethod_field);
2693 });
2694 _ut.test('test_undefinedSuperMethod_method', () {
2695 final __test = new NonErrorResolverTest();
2696 runJUnitTest(__test, __test.test_undefinedSuperMethod_method);
2697 });
2362 _ut.test('test_wrongNumberOfParametersForOperator1', () { 2698 _ut.test('test_wrongNumberOfParametersForOperator1', () {
2363 final __test = new NonErrorResolverTest(); 2699 final __test = new NonErrorResolverTest();
2364 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator1); 2700 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator1);
2365 }); 2701 });
2366 _ut.test('test_wrongNumberOfParametersForOperator_index', () { 2702 _ut.test('test_wrongNumberOfParametersForOperator_index', () {
2367 final __test = new NonErrorResolverTest(); 2703 final __test = new NonErrorResolverTest();
2368 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_inde x); 2704 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_inde x);
2369 }); 2705 });
2370 _ut.test('test_wrongNumberOfParametersForOperator_minus', () { 2706 _ut.test('test_wrongNumberOfParametersForOperator_minus', () {
2371 final __test = new NonErrorResolverTest(); 2707 final __test = new NonErrorResolverTest();
(...skipping 27 matching lines...) Expand all
2399 * The library used by the tests. 2735 * The library used by the tests.
2400 */ 2736 */
2401 Library _library5; 2737 Library _library5;
2402 void setUp() { 2738 void setUp() {
2403 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); 2739 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
2404 _analysisContext = new AnalysisContextImpl(); 2740 _analysisContext = new AnalysisContextImpl();
2405 _analysisContext.sourceFactory = _sourceFactory; 2741 _analysisContext.sourceFactory = _sourceFactory;
2406 _errorListener = new GatheringErrorListener(); 2742 _errorListener = new GatheringErrorListener();
2407 _library5 = library("/lib.dart"); 2743 _library5 = library("/lib.dart");
2408 } 2744 }
2409 void test_addExport() {
2410 Library exportLibrary = library("/exported.dart");
2411 _library5.addExport(ASTFactory.exportDirective2("exported.dart", []), export Library);
2412 List<Library> exports = _library5.exports;
2413 EngineTestCase.assertLength(1, exports);
2414 JUnitTestCase.assertSame(exportLibrary, exports[0]);
2415 _errorListener.assertNoErrors();
2416 }
2417 void test_addImport() {
2418 Library importLibrary = library("/imported.dart");
2419 _library5.addImport(ASTFactory.importDirective2("imported.dart", null, []), importLibrary);
2420 List<Library> imports = _library5.imports;
2421 EngineTestCase.assertLength(1, imports);
2422 JUnitTestCase.assertSame(importLibrary, imports[0]);
2423 _errorListener.assertNoErrors();
2424 }
2425 void test_getExplicitlyImportsCore() { 2745 void test_getExplicitlyImportsCore() {
2426 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore); 2746 JUnitTestCase.assertFalse(_library5.explicitlyImportsCore);
2427 _errorListener.assertNoErrors(); 2747 _errorListener.assertNoErrors();
2428 } 2748 }
2429 void test_getExport() {
2430 ExportDirective directive = ASTFactory.exportDirective2("exported.dart", []) ;
2431 Library exportLibrary = library("/exported.dart");
2432 _library5.addExport(directive, exportLibrary);
2433 JUnitTestCase.assertSame(exportLibrary, _library5.getExport(directive));
2434 _errorListener.assertNoErrors();
2435 }
2436 void test_getExports() { 2749 void test_getExports() {
2437 EngineTestCase.assertLength(0, _library5.exports); 2750 EngineTestCase.assertLength(0, _library5.exports);
2438 _errorListener.assertNoErrors(); 2751 _errorListener.assertNoErrors();
2439 } 2752 }
2440 void test_getImport() {
2441 ImportDirective directive = ASTFactory.importDirective2("imported.dart", nul l, []);
2442 Library importLibrary = library("/imported.dart");
2443 _library5.addImport(directive, importLibrary);
2444 JUnitTestCase.assertSame(importLibrary, _library5.getImport(directive));
2445 _errorListener.assertNoErrors();
2446 }
2447 void test_getImports() { 2753 void test_getImports() {
2448 EngineTestCase.assertLength(0, _library5.imports); 2754 EngineTestCase.assertLength(0, _library5.imports);
2449 _errorListener.assertNoErrors(); 2755 _errorListener.assertNoErrors();
2450 } 2756 }
2451 void test_getImportsAndExports() { 2757 void test_getImportsAndExports() {
2452 _library5.addImport(ASTFactory.importDirective2("imported.dart", null, []), library("/imported.dart")); 2758 _library5.importedLibraries = <Library> [library("/imported.dart")];
2453 _library5.addExport(ASTFactory.exportDirective2("exported.dart", []), librar y("/exported.dart")); 2759 _library5.exportedLibraries = <Library> [library("/exported.dart")];
2454 EngineTestCase.assertLength(2, _library5.importsAndExports); 2760 EngineTestCase.assertLength(2, _library5.importsAndExports);
2455 _errorListener.assertNoErrors(); 2761 _errorListener.assertNoErrors();
2456 } 2762 }
2457 void test_getLibraryScope() { 2763 void test_getLibraryScope() {
2458 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac tory.libraryIdentifier2(["lib"])); 2764 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac tory.libraryIdentifier2(["lib"]));
2459 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart") ; 2765 element.definingCompilationUnit = new CompilationUnitElementImpl("lib.dart") ;
2460 _library5.libraryElement = element; 2766 _library5.libraryElement = element;
2461 JUnitTestCase.assertNotNull(_library5.libraryScope); 2767 JUnitTestCase.assertNotNull(_library5.libraryScope);
2462 _errorListener.assertNoErrors(); 2768 _errorListener.assertNoErrors();
2463 } 2769 }
2464 void test_getLibrarySource() { 2770 void test_getLibrarySource() {
2465 JUnitTestCase.assertNotNull(_library5.librarySource); 2771 JUnitTestCase.assertNotNull(_library5.librarySource);
2466 } 2772 }
2467 void test_setExplicitlyImportsCore() { 2773 void test_setExplicitlyImportsCore() {
2468 _library5.explicitlyImportsCore = true; 2774 _library5.explicitlyImportsCore = true;
2469 JUnitTestCase.assertTrue(_library5.explicitlyImportsCore); 2775 JUnitTestCase.assertTrue(_library5.explicitlyImportsCore);
2470 _errorListener.assertNoErrors(); 2776 _errorListener.assertNoErrors();
2471 } 2777 }
2778 void test_setExportedLibraries() {
2779 Library exportLibrary = library("/exported.dart");
2780 _library5.exportedLibraries = <Library> [exportLibrary];
2781 List<Library> exports = _library5.exports;
2782 EngineTestCase.assertLength(1, exports);
2783 JUnitTestCase.assertSame(exportLibrary, exports[0]);
2784 _errorListener.assertNoErrors();
2785 }
2786 void test_setImportedLibraries() {
2787 Library importLibrary = library("/imported.dart");
2788 _library5.importedLibraries = <Library> [importLibrary];
2789 List<Library> imports = _library5.imports;
2790 EngineTestCase.assertLength(1, imports);
2791 JUnitTestCase.assertSame(importLibrary, imports[0]);
2792 _errorListener.assertNoErrors();
2793 }
2472 void test_setLibraryElement() { 2794 void test_setLibraryElement() {
2473 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac tory.libraryIdentifier2(["lib"])); 2795 LibraryElementImpl element = new LibraryElementImpl(_analysisContext, ASTFac tory.libraryIdentifier2(["lib"]));
2474 _library5.libraryElement = element; 2796 _library5.libraryElement = element;
2475 JUnitTestCase.assertSame(element, _library5.libraryElement); 2797 JUnitTestCase.assertSame(element, _library5.libraryElement);
2476 } 2798 }
2477 Library library(String definingCompilationUnitPath) => new Library(_analysisCo ntext, _errorListener, new FileBasedSource.con1(_sourceFactory.contentCache, Fil eUtilities2.createFile(definingCompilationUnitPath))); 2799 Library library(String definingCompilationUnitPath) => new Library(_analysisCo ntext, _errorListener, new FileBasedSource.con1(_sourceFactory.contentCache, Fil eUtilities2.createFile(definingCompilationUnitPath)));
2478 static dartSuite() { 2800 static dartSuite() {
2479 _ut.group('LibraryTest', () { 2801 _ut.group('LibraryTest', () {
2480 _ut.test('test_addExport', () {
2481 final __test = new LibraryTest();
2482 runJUnitTest(__test, __test.test_addExport);
2483 });
2484 _ut.test('test_addImport', () {
2485 final __test = new LibraryTest();
2486 runJUnitTest(__test, __test.test_addImport);
2487 });
2488 _ut.test('test_getExplicitlyImportsCore', () { 2802 _ut.test('test_getExplicitlyImportsCore', () {
2489 final __test = new LibraryTest(); 2803 final __test = new LibraryTest();
2490 runJUnitTest(__test, __test.test_getExplicitlyImportsCore); 2804 runJUnitTest(__test, __test.test_getExplicitlyImportsCore);
2491 }); 2805 });
2492 _ut.test('test_getExport', () {
2493 final __test = new LibraryTest();
2494 runJUnitTest(__test, __test.test_getExport);
2495 });
2496 _ut.test('test_getExports', () { 2806 _ut.test('test_getExports', () {
2497 final __test = new LibraryTest(); 2807 final __test = new LibraryTest();
2498 runJUnitTest(__test, __test.test_getExports); 2808 runJUnitTest(__test, __test.test_getExports);
2499 }); 2809 });
2500 _ut.test('test_getImport', () {
2501 final __test = new LibraryTest();
2502 runJUnitTest(__test, __test.test_getImport);
2503 });
2504 _ut.test('test_getImports', () { 2810 _ut.test('test_getImports', () {
2505 final __test = new LibraryTest(); 2811 final __test = new LibraryTest();
2506 runJUnitTest(__test, __test.test_getImports); 2812 runJUnitTest(__test, __test.test_getImports);
2507 }); 2813 });
2508 _ut.test('test_getImportsAndExports', () { 2814 _ut.test('test_getImportsAndExports', () {
2509 final __test = new LibraryTest(); 2815 final __test = new LibraryTest();
2510 runJUnitTest(__test, __test.test_getImportsAndExports); 2816 runJUnitTest(__test, __test.test_getImportsAndExports);
2511 }); 2817 });
2512 _ut.test('test_getLibraryScope', () { 2818 _ut.test('test_getLibraryScope', () {
2513 final __test = new LibraryTest(); 2819 final __test = new LibraryTest();
2514 runJUnitTest(__test, __test.test_getLibraryScope); 2820 runJUnitTest(__test, __test.test_getLibraryScope);
2515 }); 2821 });
2516 _ut.test('test_getLibrarySource', () { 2822 _ut.test('test_getLibrarySource', () {
2517 final __test = new LibraryTest(); 2823 final __test = new LibraryTest();
2518 runJUnitTest(__test, __test.test_getLibrarySource); 2824 runJUnitTest(__test, __test.test_getLibrarySource);
2519 }); 2825 });
2520 _ut.test('test_setExplicitlyImportsCore', () { 2826 _ut.test('test_setExplicitlyImportsCore', () {
2521 final __test = new LibraryTest(); 2827 final __test = new LibraryTest();
2522 runJUnitTest(__test, __test.test_setExplicitlyImportsCore); 2828 runJUnitTest(__test, __test.test_setExplicitlyImportsCore);
2523 }); 2829 });
2830 _ut.test('test_setExportedLibraries', () {
2831 final __test = new LibraryTest();
2832 runJUnitTest(__test, __test.test_setExportedLibraries);
2833 });
2834 _ut.test('test_setImportedLibraries', () {
2835 final __test = new LibraryTest();
2836 runJUnitTest(__test, __test.test_setImportedLibraries);
2837 });
2524 _ut.test('test_setLibraryElement', () { 2838 _ut.test('test_setLibraryElement', () {
2525 final __test = new LibraryTest(); 2839 final __test = new LibraryTest();
2526 runJUnitTest(__test, __test.test_setLibraryElement); 2840 runJUnitTest(__test, __test.test_setLibraryElement);
2527 }); 2841 });
2528 }); 2842 });
2529 } 2843 }
2530 } 2844 }
2531 class StaticTypeWarningCodeTest extends ResolverTestCase { 2845 class StaticTypeWarningCodeTest extends ResolverTestCase {
2532 void fail_inaccessibleSetter() { 2846 void fail_inaccessibleSetter() {
2533 Source source = addSource(EngineTestCase.createSource([])); 2847 Source source = addSource(EngineTestCase.createSource([]));
2534 resolve(source); 2848 resolve(source);
2535 assertErrors([StaticTypeWarningCode.INACCESSIBLE_SETTER]); 2849 assertErrors([StaticTypeWarningCode.INACCESSIBLE_SETTER]);
2536 verify([source]); 2850 verify([source]);
2537 } 2851 }
2538 void fail_nonTypeAsTypeArgument() {
2539 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"]));
2540 resolve(source);
2541 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
2542 verify([source]);
2543 }
2544 void fail_redirectWithInvalidTypeParameters() { 2852 void fail_redirectWithInvalidTypeParameters() {
2545 Source source = addSource(EngineTestCase.createSource([])); 2853 Source source = addSource(EngineTestCase.createSource([]));
2546 resolve(source); 2854 resolve(source);
2547 assertErrors([StaticTypeWarningCode.REDIRECT_WITH_INVALID_TYPE_PARAMETERS]); 2855 assertErrors([StaticTypeWarningCode.REDIRECT_WITH_INVALID_TYPE_PARAMETERS]);
2548 verify([source]); 2856 verify([source]);
2549 } 2857 }
2550 void fail_typeArgumentViolatesBounds() {
2551 Source source = addSource(EngineTestCase.createSource([]));
2552 resolve(source);
2553 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_VIOLATES_BOUNDS]);
2554 verify([source]);
2555 }
2556 void test_inconsistentMethodInheritance_paramCount() { 2858 void test_inconsistentMethodInheritance_paramCount() {
2557 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " int x();", "}", "abstract class B {", " int x(int y);", "}", "class C imple ments A, B {", "}"])); 2859 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " int x();", "}", "abstract class B {", " int x(int y);", "}", "class C imple ments A, B {", "}"]));
2558 resolve(source); 2860 resolve(source);
2559 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); 2861 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
2560 verify([source]); 2862 verify([source]);
2561 } 2863 }
2562 void test_inconsistentMethodInheritance_paramType() { 2864 void test_inconsistentMethodInheritance_paramType() {
2563 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " x(int i);", "}", "abstract class B {", " x(String s);", "}", "abstract clas s C implements A, B {}"])); 2865 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " x(int i);", "}", "abstract class B {", " x(String s);", "}", "abstract clas s C implements A, B {}"]));
2564 resolve(source); 2866 resolve(source);
2565 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]); 2867 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2651 resolve(source); 2953 resolve(source);
2652 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); 2954 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
2653 verify([source]); 2955 verify([source]);
2654 } 2956 }
2655 void test_nonBoolExpression() { 2957 void test_nonBoolExpression() {
2656 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"])); 2958 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"]));
2657 resolve(source); 2959 resolve(source);
2658 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]); 2960 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
2659 verify([source]); 2961 verify([source]);
2660 } 2962 }
2963 void test_nonTypeAsTypeArgument_notAType() {
2964 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"]));
2965 resolve(source);
2966 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
2967 verify([source]);
2968 }
2969 void test_nonTypeAsTypeArgument_undefinedIdentifier() {
2970 Source source = addSource(EngineTestCase.createSource(["class B<E> {}", "f(B <A> b) {}"]));
2971 resolve(source);
2972 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
2973 verify([source]);
2974 }
2661 void test_returnOfInvalidType_expressionFunctionBody_function() { 2975 void test_returnOfInvalidType_expressionFunctionBody_function() {
2662 Source source = addSource(EngineTestCase.createSource(["int f() => '0';"])); 2976 Source source = addSource(EngineTestCase.createSource(["int f() => '0';"]));
2663 resolve(source); 2977 resolve(source);
2664 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 2978 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2665 verify([source]); 2979 verify([source]);
2666 } 2980 }
2667 void test_returnOfInvalidType_expressionFunctionBody_getter() { 2981 void test_returnOfInvalidType_expressionFunctionBody_getter() {
2668 Source source = addSource(EngineTestCase.createSource(["int get g => '0';"]) ); 2982 Source source = addSource(EngineTestCase.createSource(["int get g => '0';"]) );
2669 resolve(source); 2983 resolve(source);
2670 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 2984 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 resolve(source); 3025 resolve(source);
2712 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 3026 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2713 verify([source]); 3027 verify([source]);
2714 } 3028 }
2715 void test_returnOfInvalidType_void() { 3029 void test_returnOfInvalidType_void() {
2716 Source source = addSource(EngineTestCase.createSource(["void f() { return 42 ; }"])); 3030 Source source = addSource(EngineTestCase.createSource(["void f() { return 42 ; }"]));
2717 resolve(source); 3031 resolve(source);
2718 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 3032 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2719 verify([source]); 3033 verify([source]);
2720 } 3034 }
3035 void test_typeArgumentNotMatchingBounds_classTypeAlias() {
3036 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class C {}", "class G<E extends A> {}", "typedef D = G<B> with C;"]));
3037 resolve(source);
3038 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3039 verify([source]);
3040 }
2721 void test_typeArgumentNotMatchingBounds_const() { 3041 void test_typeArgumentNotMatchingBounds_const() {
2722 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {", " const G();", "}", "f() { return const G<B>() ; }"])); 3042 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {", " const G();", "}", "f() { return const G<B>() ; }"]));
2723 resolve(source); 3043 resolve(source);
2724 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); 3044 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
2725 verify([source]); 3045 verify([source]);
2726 } 3046 }
3047 void test_typeArgumentNotMatchingBounds_extends() {
3048 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "class C extends G<B>{}"]));
3049 resolve(source);
3050 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3051 verify([source]);
3052 }
3053 void test_typeArgumentNotMatchingBounds_fieldFormalParameter() {
3054 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "class C {", " var f;", " C(G<B> this.f) {}" , "}"]));
3055 resolve(source);
3056 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3057 verify([source]);
3058 }
3059 void test_typeArgumentNotMatchingBounds_functionReturnType() {
3060 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "G<B> f() {}"]));
3061 resolve(source);
3062 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3063 verify([source]);
3064 }
3065 void test_typeArgumentNotMatchingBounds_functionTypeAlias() {
3066 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "typedef G<B> f();"]));
3067 resolve(source);
3068 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3069 verify([source]);
3070 }
3071 void test_typeArgumentNotMatchingBounds_functionTypedFormalParameter() {
3072 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "f(G<B> h()) {}"]));
3073 resolve(source);
3074 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3075 verify([source]);
3076 }
3077 void test_typeArgumentNotMatchingBounds_implements() {
3078 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "class C implements G<B>{}"]));
3079 resolve(source);
3080 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3081 verify([source]);
3082 }
3083 void test_typeArgumentNotMatchingBounds_is() {
3084 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "var b = 1 is G<B>;"]));
3085 resolve(source);
3086 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3087 verify([source]);
3088 }
3089 void test_typeArgumentNotMatchingBounds_methodReturnType() {
3090 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "class C {", " G<B> m() {}", "}"]));
3091 resolve(source);
3092 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3093 verify([source]);
3094 }
2727 void test_typeArgumentNotMatchingBounds_new() { 3095 void test_typeArgumentNotMatchingBounds_new() {
2728 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "f() { return new G<B>(); }"])); 3096 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "f() { return new G<B>(); }"]));
2729 resolve(source); 3097 resolve(source);
2730 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); 3098 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
2731 verify([source]); 3099 verify([source]);
2732 } 3100 }
3101 void test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound() {
3102 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class C extends B {}", "class G<E extends B> {}", "f() { retur n new G<A>(); }"]));
3103 resolve(source);
3104 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3105 verify([source]);
3106 }
3107 void test_typeArgumentNotMatchingBounds_parameter() {
3108 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "f(G<B> g) {}"]));
3109 resolve(source);
3110 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3111 verify([source]);
3112 }
3113 void test_typeArgumentNotMatchingBounds_typeArgumentList() {
3114 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class C<E> {}", "class D<E extends A> {}", "C<D<B>> Var;"]));
3115 resolve(source);
3116 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3117 verify([source]);
3118 }
3119 void test_typeArgumentNotMatchingBounds_typeParameter() {
3120 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class C {}", "class G<E extends A> {}", "class D<F extends G<B>> {}"]));
3121 resolve(source);
3122 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3123 verify([source]);
3124 }
3125 void test_typeArgumentNotMatchingBounds_variableDeclaration() {
3126 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "G<B> g;"]));
3127 resolve(source);
3128 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3129 verify([source]);
3130 }
3131 void test_typeArgumentNotMatchingBounds_with() {
3132 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "class C extends Object with G<B>{}"]));
3133 resolve(source);
3134 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
3135 verify([source]);
3136 }
2733 void test_undefinedFunction() { 3137 void test_undefinedFunction() {
2734 Source source = addSource(EngineTestCase.createSource(["void f() {", " g(); ", "}"])); 3138 Source source = addSource(EngineTestCase.createSource(["void f() {", " g(); ", "}"]));
2735 resolve(source); 3139 resolve(source);
2736 assertErrors([StaticTypeWarningCode.UNDEFINED_FUNCTION]); 3140 assertErrors([StaticTypeWarningCode.UNDEFINED_FUNCTION]);
2737 } 3141 }
2738 void test_undefinedGetter() { 3142 void test_undefinedGetter() {
2739 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e) { return e.m; }"])); 3143 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e) { return e.m; }"]));
2740 resolve(source); 3144 resolve(source);
2741 assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]); 3145 assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]);
2742 } 3146 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 resolve(source); 3199 resolve(source);
2796 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 3200 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
2797 verify([source]); 3201 verify([source]);
2798 } 3202 }
2799 void test_wrongNumberOfTypeArguments_tooMany() { 3203 void test_wrongNumberOfTypeArguments_tooMany() {
2800 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A , A> a = null;"])); 3204 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A , A> a = null;"]));
2801 resolve(source); 3205 resolve(source);
2802 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 3206 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
2803 verify([source]); 3207 verify([source]);
2804 } 3208 }
3209 void test_wrongNumberOfTypeArguments_typeTest_tooFew() {
3210 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return p is C<A>;", "}"]));
3211 resolve(source);
3212 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
3213 verify([source]);
3214 }
3215 void test_wrongNumberOfTypeArguments_typeTest_tooMany() {
3216 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return p is C<A, A>;", "}"]));
3217 resolve(source);
3218 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
3219 verify([source]);
3220 }
2805 static dartSuite() { 3221 static dartSuite() {
2806 _ut.group('StaticTypeWarningCodeTest', () { 3222 _ut.group('StaticTypeWarningCodeTest', () {
2807 _ut.test('test_inconsistentMethodInheritance_paramCount', () { 3223 _ut.test('test_inconsistentMethodInheritance_paramCount', () {
2808 final __test = new StaticTypeWarningCodeTest(); 3224 final __test = new StaticTypeWarningCodeTest();
2809 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_paramCoun t); 3225 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_paramCoun t);
2810 }); 3226 });
2811 _ut.test('test_inconsistentMethodInheritance_paramType', () { 3227 _ut.test('test_inconsistentMethodInheritance_paramType', () {
2812 final __test = new StaticTypeWarningCodeTest(); 3228 final __test = new StaticTypeWarningCodeTest();
2813 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_paramType ); 3229 runJUnitTest(__test, __test.test_inconsistentMethodInheritance_paramType );
2814 }); 3230 });
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2869 runJUnitTest(__test, __test.test_nonBoolCondition_if); 3285 runJUnitTest(__test, __test.test_nonBoolCondition_if);
2870 }); 3286 });
2871 _ut.test('test_nonBoolCondition_while', () { 3287 _ut.test('test_nonBoolCondition_while', () {
2872 final __test = new StaticTypeWarningCodeTest(); 3288 final __test = new StaticTypeWarningCodeTest();
2873 runJUnitTest(__test, __test.test_nonBoolCondition_while); 3289 runJUnitTest(__test, __test.test_nonBoolCondition_while);
2874 }); 3290 });
2875 _ut.test('test_nonBoolExpression', () { 3291 _ut.test('test_nonBoolExpression', () {
2876 final __test = new StaticTypeWarningCodeTest(); 3292 final __test = new StaticTypeWarningCodeTest();
2877 runJUnitTest(__test, __test.test_nonBoolExpression); 3293 runJUnitTest(__test, __test.test_nonBoolExpression);
2878 }); 3294 });
3295 _ut.test('test_nonTypeAsTypeArgument_notAType', () {
3296 final __test = new StaticTypeWarningCodeTest();
3297 runJUnitTest(__test, __test.test_nonTypeAsTypeArgument_notAType);
3298 });
3299 _ut.test('test_nonTypeAsTypeArgument_undefinedIdentifier', () {
3300 final __test = new StaticTypeWarningCodeTest();
3301 runJUnitTest(__test, __test.test_nonTypeAsTypeArgument_undefinedIdentifi er);
3302 });
2879 _ut.test('test_returnOfInvalidType_expressionFunctionBody_function', () { 3303 _ut.test('test_returnOfInvalidType_expressionFunctionBody_function', () {
2880 final __test = new StaticTypeWarningCodeTest(); 3304 final __test = new StaticTypeWarningCodeTest();
2881 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_function); 3305 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_function);
2882 }); 3306 });
2883 _ut.test('test_returnOfInvalidType_expressionFunctionBody_getter', () { 3307 _ut.test('test_returnOfInvalidType_expressionFunctionBody_getter', () {
2884 final __test = new StaticTypeWarningCodeTest(); 3308 final __test = new StaticTypeWarningCodeTest();
2885 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_getter); 3309 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_getter);
2886 }); 3310 });
2887 _ut.test('test_returnOfInvalidType_expressionFunctionBody_localFunction', () { 3311 _ut.test('test_returnOfInvalidType_expressionFunctionBody_localFunction', () {
2888 final __test = new StaticTypeWarningCodeTest(); 3312 final __test = new StaticTypeWarningCodeTest();
(...skipping 20 matching lines...) Expand all
2909 runJUnitTest(__test, __test.test_returnOfInvalidType_localFunction); 3333 runJUnitTest(__test, __test.test_returnOfInvalidType_localFunction);
2910 }); 3334 });
2911 _ut.test('test_returnOfInvalidType_method', () { 3335 _ut.test('test_returnOfInvalidType_method', () {
2912 final __test = new StaticTypeWarningCodeTest(); 3336 final __test = new StaticTypeWarningCodeTest();
2913 runJUnitTest(__test, __test.test_returnOfInvalidType_method); 3337 runJUnitTest(__test, __test.test_returnOfInvalidType_method);
2914 }); 3338 });
2915 _ut.test('test_returnOfInvalidType_void', () { 3339 _ut.test('test_returnOfInvalidType_void', () {
2916 final __test = new StaticTypeWarningCodeTest(); 3340 final __test = new StaticTypeWarningCodeTest();
2917 runJUnitTest(__test, __test.test_returnOfInvalidType_void); 3341 runJUnitTest(__test, __test.test_returnOfInvalidType_void);
2918 }); 3342 });
3343 _ut.test('test_typeArgumentNotMatchingBounds_classTypeAlias', () {
3344 final __test = new StaticTypeWarningCodeTest();
3345 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_classType Alias);
3346 });
2919 _ut.test('test_typeArgumentNotMatchingBounds_const', () { 3347 _ut.test('test_typeArgumentNotMatchingBounds_const', () {
2920 final __test = new StaticTypeWarningCodeTest(); 3348 final __test = new StaticTypeWarningCodeTest();
2921 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const); 3349 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
2922 }); 3350 });
3351 _ut.test('test_typeArgumentNotMatchingBounds_extends', () {
3352 final __test = new StaticTypeWarningCodeTest();
3353 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_extends);
3354 });
3355 _ut.test('test_typeArgumentNotMatchingBounds_fieldFormalParameter', () {
3356 final __test = new StaticTypeWarningCodeTest();
3357 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_fieldForm alParameter);
3358 });
3359 _ut.test('test_typeArgumentNotMatchingBounds_functionReturnType', () {
3360 final __test = new StaticTypeWarningCodeTest();
3361 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_functionR eturnType);
3362 });
3363 _ut.test('test_typeArgumentNotMatchingBounds_functionTypeAlias', () {
3364 final __test = new StaticTypeWarningCodeTest();
3365 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_functionT ypeAlias);
3366 });
3367 _ut.test('test_typeArgumentNotMatchingBounds_functionTypedFormalParameter' , () {
3368 final __test = new StaticTypeWarningCodeTest();
3369 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_functionT ypedFormalParameter);
3370 });
3371 _ut.test('test_typeArgumentNotMatchingBounds_implements', () {
3372 final __test = new StaticTypeWarningCodeTest();
3373 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_implement s);
3374 });
3375 _ut.test('test_typeArgumentNotMatchingBounds_is', () {
3376 final __test = new StaticTypeWarningCodeTest();
3377 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_is);
3378 });
3379 _ut.test('test_typeArgumentNotMatchingBounds_methodReturnType', () {
3380 final __test = new StaticTypeWarningCodeTest();
3381 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_methodRet urnType);
3382 });
2923 _ut.test('test_typeArgumentNotMatchingBounds_new', () { 3383 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
2924 final __test = new StaticTypeWarningCodeTest(); 3384 final __test = new StaticTypeWarningCodeTest();
2925 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new); 3385 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
2926 }); 3386 });
3387 _ut.test('test_typeArgumentNotMatchingBounds_new_superTypeOfUpperBound', ( ) {
3388 final __test = new StaticTypeWarningCodeTest();
3389 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new_super TypeOfUpperBound);
3390 });
3391 _ut.test('test_typeArgumentNotMatchingBounds_parameter', () {
3392 final __test = new StaticTypeWarningCodeTest();
3393 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_parameter );
3394 });
3395 _ut.test('test_typeArgumentNotMatchingBounds_typeArgumentList', () {
3396 final __test = new StaticTypeWarningCodeTest();
3397 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeArgum entList);
3398 });
3399 _ut.test('test_typeArgumentNotMatchingBounds_typeParameter', () {
3400 final __test = new StaticTypeWarningCodeTest();
3401 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_typeParam eter);
3402 });
3403 _ut.test('test_typeArgumentNotMatchingBounds_variableDeclaration', () {
3404 final __test = new StaticTypeWarningCodeTest();
3405 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_variableD eclaration);
3406 });
3407 _ut.test('test_typeArgumentNotMatchingBounds_with', () {
3408 final __test = new StaticTypeWarningCodeTest();
3409 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_with);
3410 });
2927 _ut.test('test_undefinedFunction', () { 3411 _ut.test('test_undefinedFunction', () {
2928 final __test = new StaticTypeWarningCodeTest(); 3412 final __test = new StaticTypeWarningCodeTest();
2929 runJUnitTest(__test, __test.test_undefinedFunction); 3413 runJUnitTest(__test, __test.test_undefinedFunction);
2930 }); 3414 });
2931 _ut.test('test_undefinedGetter', () { 3415 _ut.test('test_undefinedGetter', () {
2932 final __test = new StaticTypeWarningCodeTest(); 3416 final __test = new StaticTypeWarningCodeTest();
2933 runJUnitTest(__test, __test.test_undefinedGetter); 3417 runJUnitTest(__test, __test.test_undefinedGetter);
2934 }); 3418 });
2935 _ut.test('test_undefinedGetter_static', () { 3419 _ut.test('test_undefinedGetter_static', () {
2936 final __test = new StaticTypeWarningCodeTest(); 3420 final __test = new StaticTypeWarningCodeTest();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 runJUnitTest(__test, __test.test_undefinedSuperMethod); 3457 runJUnitTest(__test, __test.test_undefinedSuperMethod);
2974 }); 3458 });
2975 _ut.test('test_wrongNumberOfTypeArguments_tooFew', () { 3459 _ut.test('test_wrongNumberOfTypeArguments_tooFew', () {
2976 final __test = new StaticTypeWarningCodeTest(); 3460 final __test = new StaticTypeWarningCodeTest();
2977 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooFew); 3461 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooFew);
2978 }); 3462 });
2979 _ut.test('test_wrongNumberOfTypeArguments_tooMany', () { 3463 _ut.test('test_wrongNumberOfTypeArguments_tooMany', () {
2980 final __test = new StaticTypeWarningCodeTest(); 3464 final __test = new StaticTypeWarningCodeTest();
2981 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooMany); 3465 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooMany);
2982 }); 3466 });
3467 _ut.test('test_wrongNumberOfTypeArguments_typeTest_tooFew', () {
3468 final __test = new StaticTypeWarningCodeTest();
3469 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too Few);
3470 });
3471 _ut.test('test_wrongNumberOfTypeArguments_typeTest_tooMany', () {
3472 final __test = new StaticTypeWarningCodeTest();
3473 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_typeTest_too Many);
3474 });
2983 }); 3475 });
2984 } 3476 }
2985 } 3477 }
2986 class TypeResolverVisitorTest extends EngineTestCase { 3478 class TypeResolverVisitorTest extends EngineTestCase {
2987 3479
2988 /** 3480 /**
2989 * The error listener to which errors will be reported. 3481 * The error listener to which errors will be reported.
2990 */ 3482 */
2991 GatheringErrorListener _listener; 3483 GatheringErrorListener _listener;
2992 3484
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 TypeName typeName = ASTFactory.typeName4("void", []); 3678 TypeName typeName = ASTFactory.typeName4("void", []);
3187 resolveNode(typeName, [classA]); 3679 resolveNode(typeName, [classA]);
3188 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type); 3680 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type);
3189 _listener.assertNoErrors(); 3681 _listener.assertNoErrors();
3190 } 3682 }
3191 3683
3192 /** 3684 /**
3193 * Analyze the given catch clause and assert that the types of the parameters have been set to the 3685 * Analyze the given catch clause and assert that the types of the parameters have been set to the
3194 * given types. The types can be null if the catch clause does not have the co rresponding 3686 * given types. The types can be null if the catch clause does not have the co rresponding
3195 * parameter. 3687 * parameter.
3688 *
3196 * @param node the catch clause to be analyzed 3689 * @param node the catch clause to be analyzed
3197 * @param exceptionType the expected type of the exception parameter 3690 * @param exceptionType the expected type of the exception parameter
3198 * @param stackTraceType the expected type of the stack trace parameter 3691 * @param stackTraceType the expected type of the stack trace parameter
3199 * @param definedElements the elements that are to be defined in the scope in which the element is 3692 * @param definedElements the elements that are to be defined in the scope in which the element is
3200 * being resolved 3693 * being resolved
3201 */ 3694 */
3202 void resolve(CatchClause node, InterfaceType exceptionType, InterfaceType stac kTraceType, List<Element> definedElements) { 3695 void resolve(CatchClause node, InterfaceType exceptionType, InterfaceType stac kTraceType, List<Element> definedElements) {
3203 resolveNode(node, definedElements); 3696 resolveNode(node, definedElements);
3204 SimpleIdentifier exceptionParameter = node.exceptionParameter; 3697 SimpleIdentifier exceptionParameter = node.exceptionParameter;
3205 if (exceptionParameter != null) { 3698 if (exceptionParameter != null) {
3206 JUnitTestCase.assertSame(exceptionType, exceptionParameter.staticType); 3699 JUnitTestCase.assertSame(exceptionType, exceptionParameter.staticType);
3207 } 3700 }
3208 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; 3701 SimpleIdentifier stackTraceParameter = node.stackTraceParameter;
3209 if (stackTraceParameter != null) { 3702 if (stackTraceParameter != null) {
3210 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter.staticType); 3703 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter.staticType);
3211 } 3704 }
3212 } 3705 }
3213 3706
3214 /** 3707 /**
3215 * Return the type associated with the given parameter after the static type a nalyzer has computed 3708 * Return the type associated with the given parameter after the static type a nalyzer has computed
3216 * a type for it. 3709 * a type for it.
3710 *
3217 * @param node the parameter with which the type is associated 3711 * @param node the parameter with which the type is associated
3218 * @param definedElements the elements that are to be defined in the scope in which the element is 3712 * @param definedElements the elements that are to be defined in the scope in which the element is
3219 * being resolved 3713 * being resolved
3220 * @return the type associated with the parameter 3714 * @return the type associated with the parameter
3221 */ 3715 */
3222 Type2 resolve6(FormalParameter node, List<Element> definedElements) { 3716 Type2 resolve6(FormalParameter node, List<Element> definedElements) {
3223 resolveNode(node, definedElements); 3717 resolveNode(node, definedElements);
3224 return ((node.identifier.element as ParameterElement)).type; 3718 return ((node.identifier.element as ParameterElement)).type;
3225 } 3719 }
3226 3720
3227 /** 3721 /**
3228 * Return the element associated with the given identifier after the resolver has resolved the 3722 * Return the element associated with the given identifier after the resolver has resolved the
3229 * identifier. 3723 * identifier.
3724 *
3230 * @param node the expression to be resolved 3725 * @param node the expression to be resolved
3231 * @param definedElements the elements that are to be defined in the scope in which the element is 3726 * @param definedElements the elements that are to be defined in the scope in which the element is
3232 * being resolved 3727 * being resolved
3233 * @return the element to which the expression was resolved 3728 * @return the element to which the expression was resolved
3234 */ 3729 */
3235 void resolveNode(ASTNode node, List<Element> definedElements) { 3730 void resolveNode(ASTNode node, List<Element> definedElements) {
3236 for (Element element in definedElements) { 3731 for (Element element in definedElements) {
3237 _library.libraryScope.define(element); 3732 _library.libraryScope.define(element);
3238 } 3733 }
3239 node.accept(_visitor); 3734 node.accept(_visitor);
3240 } 3735 }
3241 static dartSuite() { 3736 static dartSuite() {
3242 _ut.group('TypeResolverVisitorTest', () { 3737 _ut.group('TypeResolverVisitorTest', () {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3287 _ut.test('test_visitTypeName_void', () { 3782 _ut.test('test_visitTypeName_void', () {
3288 final __test = new TypeResolverVisitorTest(); 3783 final __test = new TypeResolverVisitorTest();
3289 runJUnitTest(__test, __test.test_visitTypeName_void); 3784 runJUnitTest(__test, __test.test_visitTypeName_void);
3290 }); 3785 });
3291 }); 3786 });
3292 } 3787 }
3293 } 3788 }
3294 class ResolverTestCase extends EngineTestCase { 3789 class ResolverTestCase extends EngineTestCase {
3295 3790
3296 /** 3791 /**
3297 * The source factory used to create [Source sources]. 3792 * The source factory used to create [Source].
3298 */ 3793 */
3299 SourceFactory _sourceFactory; 3794 SourceFactory _sourceFactory;
3300 3795
3301 /** 3796 /**
3302 * The analysis context used to parse the compilation units being resolved. 3797 * The analysis context used to parse the compilation units being resolved.
3303 */ 3798 */
3304 AnalysisContextImpl _analysisContext; 3799 AnalysisContextImpl _analysisContext;
3305 void setUp() { 3800 void setUp() {
3306 reset(); 3801 reset();
3307 } 3802 }
3308 3803
3309 /** 3804 /**
3310 * Add a source file to the content provider. 3805 * Add a source file to the content provider.
3806 *
3311 * @param contents the contents to be returned by the content provider for the specified file 3807 * @param contents the contents to be returned by the content provider for the specified file
3312 * @return the source object representing the added file 3808 * @return the source object representing the added file
3313 */ 3809 */
3314 Source addSource(String contents) => addSource2("/test.dart", contents); 3810 Source addSource(String contents) => addSource2("/test.dart", contents);
3315 3811
3316 /** 3812 /**
3317 * Add a source file to the content provider. The file path should be absolute . 3813 * Add a source file to the content provider. The file path should be absolute .
3814 *
3318 * @param filePath the path of the file being added 3815 * @param filePath the path of the file being added
3319 * @param contents the contents to be returned by the content provider for the specified file 3816 * @param contents the contents to be returned by the content provider for the specified file
3320 * @return the source object representing the added file 3817 * @return the source object representing the added file
3321 */ 3818 */
3322 Source addSource2(String filePath, String contents) { 3819 Source addSource2(String filePath, String contents) {
3323 Source source = cacheSource(filePath, contents); 3820 Source source = cacheSource(filePath, contents);
3324 ChangeSet changeSet = new ChangeSet(); 3821 ChangeSet changeSet = new ChangeSet();
3325 changeSet.added(source); 3822 changeSet.added(source);
3326 _analysisContext.applyChanges(changeSet); 3823 _analysisContext.applyChanges(changeSet);
3327 return source; 3824 return source;
3328 } 3825 }
3329 3826
3330 /** 3827 /**
3331 * Assert that the number of errors that have been gathered matches the number of errors that are 3828 * Assert that the number of errors that have been gathered matches the number of errors that are
3332 * given and that they have the expected error codes. The order in which the e rrors were gathered 3829 * given and that they have the expected error codes. The order in which the e rrors were gathered
3333 * is ignored. 3830 * is ignored.
3831 *
3334 * @param expectedErrorCodes the error codes of the errors that should have be en gathered 3832 * @param expectedErrorCodes the error codes of the errors that should have be en gathered
3335 * @throws AssertionFailedError if a different number of errors have been gath ered than were 3833 * @throws AssertionFailedError if a different number of errors have been gath ered than were
3336 * expected 3834 * expected
3337 */ 3835 */
3338 void assertErrors(List<ErrorCode> expectedErrorCodes) { 3836 void assertErrors(List<ErrorCode> expectedErrorCodes) {
3339 GatheringErrorListener errorListener = new GatheringErrorListener(); 3837 GatheringErrorListener errorListener = new GatheringErrorListener();
3340 for (ChangeNotice notice in _analysisContext.performAnalysisTask()) { 3838 for (ChangeNotice notice in _analysisContext.performAnalysisTask()) {
3341 for (AnalysisError error in notice.errors) { 3839 for (AnalysisError error in notice.errors) {
3342 errorListener.onError(error); 3840 errorListener.onError(error);
3343 } 3841 }
3344 } 3842 }
3345 errorListener.assertErrors2(expectedErrorCodes); 3843 errorListener.assertErrors2(expectedErrorCodes);
3346 } 3844 }
3347 3845
3348 /** 3846 /**
3349 * Assert that no errors have been gathered. 3847 * Assert that no errors have been gathered.
3848 *
3350 * @throws AssertionFailedError if any errors have been gathered 3849 * @throws AssertionFailedError if any errors have been gathered
3351 */ 3850 */
3352 void assertNoErrors() { 3851 void assertNoErrors() {
3353 GatheringErrorListener errorListener = new GatheringErrorListener(); 3852 GatheringErrorListener errorListener = new GatheringErrorListener();
3354 for (ChangeNotice notice in _analysisContext.performAnalysisTask()) { 3853 for (ChangeNotice notice in _analysisContext.performAnalysisTask()) {
3355 for (AnalysisError error in notice.errors) { 3854 for (AnalysisError error in notice.errors) {
3356 errorListener.onError(error); 3855 errorListener.onError(error);
3357 } 3856 }
3358 } 3857 }
3359 errorListener.assertNoErrors(); 3858 errorListener.assertNoErrors();
3360 } 3859 }
3361 3860
3362 /** 3861 /**
3363 * Cache the source file content in the source factory but don't add the sourc e to the analysis 3862 * Cache the source file content in the source factory but don't add the sourc e to the analysis
3364 * context. The file path should be absolute. 3863 * context. The file path should be absolute.
3864 *
3365 * @param filePath the path of the file being cached 3865 * @param filePath the path of the file being cached
3366 * @param contents the contents to be returned by the content provider for the specified file 3866 * @param contents the contents to be returned by the content provider for the specified file
3367 * @return the source object representing the cached file 3867 * @return the source object representing the cached file
3368 */ 3868 */
3369 Source cacheSource(String filePath, String contents) { 3869 Source cacheSource(String filePath, String contents) {
3370 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath)); 3870 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath));
3371 _sourceFactory.setContents(source, contents); 3871 _sourceFactory.setContents(source, contents);
3372 return source; 3872 return source;
3373 } 3873 }
3374 3874
3375 /** 3875 /**
3376 * Create a library element that represents a library named `"test"` containin g a single 3876 * Create a library element that represents a library named `"test"` containin g a single
3377 * empty compilation unit. 3877 * empty compilation unit.
3878 *
3378 * @return the library element that was created 3879 * @return the library element that was created
3379 */ 3880 */
3380 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []); 3881 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []);
3381 3882
3382 /** 3883 /**
3383 * Create a library element that represents a library with the given name cont aining a single 3884 * Create a library element that represents a library with the given name cont aining a single
3384 * empty compilation unit. 3885 * empty compilation unit.
3886 *
3385 * @param libraryName the name of the library to be created 3887 * @param libraryName the name of the library to be created
3386 * @return the library element that was created 3888 * @return the library element that was created
3387 */ 3889 */
3388 LibraryElementImpl createTestLibrary2(AnalysisContext context, String libraryN ame, List<String> typeNames) { 3890 LibraryElementImpl createTestLibrary2(AnalysisContext context, String libraryN ame, List<String> typeNames) {
3389 int count = typeNames.length; 3891 int count = typeNames.length;
3390 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat ionUnitElementImpl>(count); 3892 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat ionUnitElementImpl>(count);
3391 for (int i = 0; i < count; i++) { 3893 for (int i = 0; i < count; i++) {
3392 String typeName = typeNames[i]; 3894 String typeName = typeNames[i];
3393 ClassElementImpl type = new ClassElementImpl(ASTFactory.identifier3(typeNa me)); 3895 ClassElementImpl type = new ClassElementImpl(ASTFactory.identifier3(typeNa me));
3394 String fileName = "${typeName}.dart"; 3896 String fileName = "${typeName}.dart";
3395 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImp l(fileName); 3897 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImp l(fileName);
3396 compilationUnit.source = createSource2(fileName); 3898 compilationUnit.source = createSource2(fileName);
3397 compilationUnit.types = <ClassElement> [type]; 3899 compilationUnit.types = <ClassElement> [type];
3398 sourcedCompilationUnits[i] = compilationUnit; 3900 sourcedCompilationUnits[i] = compilationUnit;
3399 } 3901 }
3400 String fileName = "${libraryName}.dart"; 3902 String fileName = "${libraryName}.dart";
3401 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName); 3903 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName);
3402 compilationUnit.source = createSource2(fileName); 3904 compilationUnit.source = createSource2(fileName);
3403 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName])); 3905 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName]));
3404 library.definingCompilationUnit = compilationUnit; 3906 library.definingCompilationUnit = compilationUnit;
3405 library.parts = sourcedCompilationUnits; 3907 library.parts = sourcedCompilationUnits;
3406 return library; 3908 return library;
3407 } 3909 }
3408 AnalysisContext get analysisContext => _analysisContext; 3910 AnalysisContext get analysisContext => _analysisContext;
3409 SourceFactory get sourceFactory => _sourceFactory; 3911 SourceFactory get sourceFactory => _sourceFactory;
3410 3912
3411 /** 3913 /**
3412 * Return a type provider that can be used to test the results of resolution. 3914 * Return a type provider that can be used to test the results of resolution.
3915 *
3413 * @return a type provider 3916 * @return a type provider
3414 */ 3917 */
3415 TypeProvider get typeProvider { 3918 TypeProvider get typeProvider {
3416 Source coreSource = _analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ; 3919 Source coreSource = _analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ;
3417 LibraryElement coreElement = _analysisContext.getLibraryElement(coreSource); 3920 LibraryElement coreElement = _analysisContext.getLibraryElement(coreSource);
3418 return new TypeProviderImpl(coreElement); 3921 return new TypeProviderImpl(coreElement);
3419 } 3922 }
3420 3923
3421 /** 3924 /**
3422 * In the rare cases we want to group several tests into single "test_" method , so need a way to 3925 * In the rare cases we want to group several tests into single "test_" method , so need a way to
3423 * reset test instance to reuse it. 3926 * reset test instance to reuse it.
3424 */ 3927 */
3425 void reset() { 3928 void reset() {
3426 _analysisContext = AnalysisContextFactory.contextWithCore(); 3929 _analysisContext = AnalysisContextFactory.contextWithCore();
3427 _sourceFactory = _analysisContext.sourceFactory; 3930 _sourceFactory = _analysisContext.sourceFactory;
3428 } 3931 }
3429 3932
3430 /** 3933 /**
3431 * Given a library and all of its parts, resolve the contents of the library a nd the contents of 3934 * Given a library and all of its parts, resolve the contents of the library a nd the contents of
3432 * the parts. This assumes that the sources for the library and its parts have already been added 3935 * the parts. This assumes that the sources for the library and its parts have already been added
3433 * to the content provider using the method [addSource]. 3936 * to the content provider using the method [addSource].
3937 *
3434 * @param librarySource the source for the compilation unit that defines the l ibrary 3938 * @param librarySource the source for the compilation unit that defines the l ibrary
3435 * @return the element representing the resolved library 3939 * @return the element representing the resolved library
3436 * @throws AnalysisException if the analysis could not be performed 3940 * @throws AnalysisException if the analysis could not be performed
3437 */ 3941 */
3438 LibraryElement resolve(Source librarySource) => _analysisContext.computeLibrar yElement(librarySource); 3942 LibraryElement resolve(Source librarySource) => _analysisContext.computeLibrar yElement(librarySource);
3439 3943
3440 /** 3944 /**
3441 * Return the resolved compilation unit corresponding to the given source in t he given library. 3945 * Return the resolved compilation unit corresponding to the given source in t he given library.
3946 *
3442 * @param source the source of the compilation unit to be returned 3947 * @param source the source of the compilation unit to be returned
3443 * @param library the library in which the compilation unit is to be resolved 3948 * @param library the library in which the compilation unit is to be resolved
3444 * @return the resolved compilation unit 3949 * @return the resolved compilation unit
3445 * @throws Exception if the compilation unit could not be resolved 3950 * @throws Exception if the compilation unit could not be resolved
3446 */ 3951 */
3447 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) => _analysisContext.resolveCompilationUnit(source, library); 3952 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) => _analysisContext.resolveCompilationUnit(source, library);
3448 3953
3449 /** 3954 /**
3450 * Verify that all of the identifiers in the compilation units associated with the given sources 3955 * Verify that all of the identifiers in the compilation units associated with the given sources
3451 * have been resolved. 3956 * have been resolved.
3957 *
3452 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element 3958 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element
3453 * to which they were resolved 3959 * to which they were resolved
3454 * @param sources the sources identifying the compilation units to be verified 3960 * @param sources the sources identifying the compilation units to be verified
3455 * @throws Exception if the contents of the compilation unit cannot be accesse d 3961 * @throws Exception if the contents of the compilation unit cannot be accesse d
3456 */ 3962 */
3457 void verify(List<Source> sources) { 3963 void verify(List<Source> sources) {
3458 ResolutionVerifier verifier = new ResolutionVerifier(); 3964 ResolutionVerifier verifier = new ResolutionVerifier();
3459 for (Source source in sources) { 3965 for (Source source in sources) {
3460 _analysisContext.parseCompilationUnit(source).accept(verifier); 3966 _analysisContext.parseCompilationUnit(source).accept(verifier);
3461 } 3967 }
3462 verifier.assertResolved(); 3968 verifier.assertResolved();
3463 } 3969 }
3464 3970
3465 /** 3971 /**
3466 * Create a source object representing a file with the given name and give it an empty content. 3972 * Create a source object representing a file with the given name and give it an empty content.
3973 *
3467 * @param fileName the name of the file for which a source is to be created 3974 * @param fileName the name of the file for which a source is to be created
3468 * @return the source that was created 3975 * @return the source that was created
3469 */ 3976 */
3470 FileBasedSource createSource2(String fileName) { 3977 FileBasedSource createSource2(String fileName) {
3471 FileBasedSource source = new FileBasedSource.con1(_sourceFactory.contentCach e, FileUtilities2.createFile(fileName)); 3978 FileBasedSource source = new FileBasedSource.con1(_sourceFactory.contentCach e, FileUtilities2.createFile(fileName));
3472 _sourceFactory.setContents(source, ""); 3979 _sourceFactory.setContents(source, "");
3473 return source; 3980 return source;
3474 } 3981 }
3475 static dartSuite() { 3982 static dartSuite() {
3476 _ut.group('ResolverTestCase', () { 3983 _ut.group('ResolverTestCase', () {
3477 }); 3984 });
3478 } 3985 }
3479 } 3986 }
3480 class TypeProviderImplTest extends EngineTestCase { 3987 class TypeProviderImplTest extends EngineTestCase {
3481 void test_creation() { 3988 void test_creation() {
3482 InterfaceType objectType = classElement("Object", null, []).type; 3989 InterfaceType objectType = classElement("Object", null, []).type;
3483 InterfaceType boolType = classElement("bool", objectType, []).type; 3990 InterfaceType boolType = classElement("bool", objectType, []).type;
3484 InterfaceType numType = classElement("num", objectType, []).type; 3991 InterfaceType numType = classElement("num", objectType, []).type;
3485 InterfaceType doubleType = classElement("double", numType, []).type; 3992 InterfaceType doubleType = classElement("double", numType, []).type;
3486 InterfaceType functionType = classElement("Function", objectType, []).type; 3993 InterfaceType functionType = classElement("Function", objectType, []).type;
3487 InterfaceType intType = classElement("int", numType, []).type; 3994 InterfaceType intType = classElement("int", numType, []).type;
3488 InterfaceType listType = classElement("List", objectType, ["E"]).type; 3995 InterfaceType listType = classElement("List", objectType, ["E"]).type;
3489 InterfaceType mapType = classElement("Map", objectType, ["K", "V"]).type; 3996 InterfaceType mapType = classElement("Map", objectType, ["K", "V"]).type;
3490 InterfaceType stackTraceType = classElement("StackTrace", objectType, []).ty pe; 3997 InterfaceType stackTraceType = classElement("StackTrace", objectType, []).ty pe;
3491 InterfaceType stringType = classElement("String", objectType, []).type; 3998 InterfaceType stringType = classElement("String", objectType, []).type;
3999 InterfaceType symbolType = classElement("Symbol", objectType, []).type;
3492 InterfaceType typeType = classElement("Type", objectType, []).type; 4000 InterfaceType typeType = classElement("Type", objectType, []).type;
3493 CompilationUnitElementImpl unit = new CompilationUnitElementImpl("lib.dart") ; 4001 CompilationUnitElementImpl unit = new CompilationUnitElementImpl("lib.dart") ;
3494 unit.types = <ClassElement> [boolType.element, doubleType.element, functionT ype.element, intType.element, listType.element, mapType.element, objectType.elem ent, stackTraceType.element, stringType.element, typeType.element]; 4002 unit.types = <ClassElement> [boolType.element, doubleType.element, functionT ype.element, intType.element, listType.element, mapType.element, objectType.elem ent, stackTraceType.element, stringType.element, symbolType.element, typeType.el ement];
3495 LibraryElementImpl library = new LibraryElementImpl(new AnalysisContextImpl( ), ASTFactory.libraryIdentifier2(["lib"])); 4003 LibraryElementImpl library = new LibraryElementImpl(new AnalysisContextImpl( ), ASTFactory.libraryIdentifier2(["lib"]));
3496 library.definingCompilationUnit = unit; 4004 library.definingCompilationUnit = unit;
3497 TypeProviderImpl provider = new TypeProviderImpl(library); 4005 TypeProviderImpl provider = new TypeProviderImpl(library);
3498 JUnitTestCase.assertSame(boolType, provider.boolType); 4006 JUnitTestCase.assertSame(boolType, provider.boolType);
3499 JUnitTestCase.assertNotNull(provider.bottomType); 4007 JUnitTestCase.assertNotNull(provider.bottomType);
3500 JUnitTestCase.assertSame(doubleType, provider.doubleType); 4008 JUnitTestCase.assertSame(doubleType, provider.doubleType);
3501 JUnitTestCase.assertNotNull(provider.dynamicType); 4009 JUnitTestCase.assertNotNull(provider.dynamicType);
3502 JUnitTestCase.assertSame(functionType, provider.functionType); 4010 JUnitTestCase.assertSame(functionType, provider.functionType);
3503 JUnitTestCase.assertSame(intType, provider.intType); 4011 JUnitTestCase.assertSame(intType, provider.intType);
3504 JUnitTestCase.assertSame(listType, provider.listType); 4012 JUnitTestCase.assertSame(listType, provider.listType);
3505 JUnitTestCase.assertSame(mapType, provider.mapType); 4013 JUnitTestCase.assertSame(mapType, provider.mapType);
3506 JUnitTestCase.assertSame(objectType, provider.objectType); 4014 JUnitTestCase.assertSame(objectType, provider.objectType);
3507 JUnitTestCase.assertSame(stackTraceType, provider.stackTraceType); 4015 JUnitTestCase.assertSame(stackTraceType, provider.stackTraceType);
3508 JUnitTestCase.assertSame(stringType, provider.stringType); 4016 JUnitTestCase.assertSame(stringType, provider.stringType);
4017 JUnitTestCase.assertSame(symbolType, provider.symbolType);
3509 JUnitTestCase.assertSame(typeType, provider.typeType); 4018 JUnitTestCase.assertSame(typeType, provider.typeType);
3510 } 4019 }
3511 ClassElement classElement(String typeName, InterfaceType superclassType, List< String> parameterNames) { 4020 ClassElement classElement(String typeName, InterfaceType superclassType, List< String> parameterNames) {
3512 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN ame)); 4021 ClassElementImpl element = new ClassElementImpl(ASTFactory.identifier3(typeN ame));
3513 element.supertype = superclassType; 4022 element.supertype = superclassType;
3514 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); 4023 InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element);
3515 element.type = type; 4024 element.type = type;
3516 int count = parameterNames.length; 4025 int count = parameterNames.length;
3517 if (count > 0) { 4026 if (count > 0) {
3518 List<TypeVariableElementImpl> typeVariables = new List<TypeVariableElement Impl>(count); 4027 List<TypeVariableElementImpl> typeVariables = new List<TypeVariableElement Impl>(count);
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
3851 } 4360 }
3852 } 4361 }
3853 errorListener.assertErrors2(expectedErrorCodes); 4362 errorListener.assertErrors2(expectedErrorCodes);
3854 } 4363 }
3855 void assertNoErrors(ClassElement classElt) { 4364 void assertNoErrors(ClassElement classElt) {
3856 assertErrors(classElt, []); 4365 assertErrors(classElt, []);
3857 } 4366 }
3858 4367
3859 /** 4368 /**
3860 * Create the inheritance manager used by the tests. 4369 * Create the inheritance manager used by the tests.
4370 *
3861 * @return the inheritance manager that was created 4371 * @return the inheritance manager that was created
3862 */ 4372 */
3863 InheritanceManager createInheritanceManager() { 4373 InheritanceManager createInheritanceManager() {
3864 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore(); 4374 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
3865 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt ilities2.createFile("/test.dart")); 4375 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt ilities2.createFile("/test.dart"));
3866 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart"); 4376 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart");
3867 definingCompilationUnit.source = source; 4377 definingCompilationUnit.source = source;
3868 _definingLibrary = ElementFactory.library(context, "test"); 4378 _definingLibrary = ElementFactory.library(context, "test");
3869 _definingLibrary.definingCompilationUnit = definingCompilationUnit; 4379 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
3870 return new InheritanceManager(_definingLibrary); 4380 return new InheritanceManager(_definingLibrary);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 resolve(source); 4502 resolve(source);
3993 assertErrors([CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]); 4503 assertErrors([CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]);
3994 verify([source]); 4504 verify([source]);
3995 } 4505 }
3996 void fail_constEvalThrowsException() { 4506 void fail_constEvalThrowsException() {
3997 Source source = addSource(EngineTestCase.createSource(["class C {", " const C();", "}", "f() { return const C(); }"])); 4507 Source source = addSource(EngineTestCase.createSource(["class C {", " const C();", "}", "f() { return const C(); }"]));
3998 resolve(source); 4508 resolve(source);
3999 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION]); 4509 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION]);
4000 verify([source]); 4510 verify([source]);
4001 } 4511 }
4002 void fail_duplicateDefinition() {
4003 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0 ;", " m(a) {}", "}"]));
4004 resolve(source);
4005 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
4006 verify([source]);
4007 }
4008 void fail_duplicateMemberError_classMembers_fields() {
4009 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " int a;", " int a;", "}"]));
4010 resolve(librarySource);
4011 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
4012 verify([librarySource]);
4013 }
4014 void fail_duplicateMemberError_localFields() {
4015 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {", " int a;", " int a;", " }", "}"]));
4016 resolve(librarySource);
4017 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
4018 verify([librarySource]);
4019 }
4020 void fail_duplicateMemberName() {
4021 Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 0;", " int x() {}", "}"]));
4022 resolve(source);
4023 assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME]);
4024 verify([source]);
4025 }
4026 void fail_duplicateMemberNameInstanceStatic() {
4027 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " static int x;", "}"]));
4028 resolve(source);
4029 assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME_INSTANCE_STATIC]);
4030 verify([source]);
4031 }
4032 void fail_extendsOrImplementsDisallowedClass_extends_null() { 4512 void fail_extendsOrImplementsDisallowedClass_extends_null() {
4033 Source source = addSource(EngineTestCase.createSource(["class A extends Null {}"])); 4513 Source source = addSource(EngineTestCase.createSource(["class A extends Null {}"]));
4034 resolve(source); 4514 resolve(source);
4035 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4515 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
4036 verify([source]); 4516 verify([source]);
4037 } 4517 }
4038 void fail_extendsOrImplementsDisallowedClass_implements_null() { 4518 void fail_extendsOrImplementsDisallowedClass_implements_null() {
4039 Source source = addSource(EngineTestCase.createSource(["class A implements N ull {}"])); 4519 Source source = addSource(EngineTestCase.createSource(["class A implements N ull {}"]));
4040 resolve(source); 4520 resolve(source);
4041 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 4521 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
4042 verify([source]); 4522 verify([source]);
4043 } 4523 }
4044 void fail_invalidOverrideDefaultValue() {
4045 Source source = addSource(EngineTestCase.createSource(["class A {", " m([a = 0]) {}", "}", "class B extends A {", " m([a = 1]) {}", "}"]));
4046 resolve(source);
4047 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_DEFAULT_VALUE]);
4048 verify([source]);
4049 }
4050 void fail_mixinDeclaresConstructor() { 4524 void fail_mixinDeclaresConstructor() {
4051 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends Object mixin A {}"])); 4525 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends Object mixin A {}"]));
4052 resolve(source); 4526 resolve(source);
4053 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); 4527 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
4054 verify([source]); 4528 verify([source]);
4055 } 4529 }
4056 void fail_mixinOfNonClass() { 4530 void fail_mixinOfNonClass() {
4057 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex tends Object mixin A {}"])); 4531 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex tends Object mixin A {}"]));
4058 resolve(source); 4532 resolve(source);
4059 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); 4533 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4106 resolve(source); 4580 resolve(source);
4107 assertErrors([CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]); 4581 assertErrors([CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]);
4108 verify([source]); 4582 verify([source]);
4109 } 4583 }
4110 void fail_uninitializedFinalField() { 4584 void fail_uninitializedFinalField() {
4111 Source source = addSource(EngineTestCase.createSource(["class A {", " final int i;", "}"])); 4585 Source source = addSource(EngineTestCase.createSource(["class A {", " final int i;", "}"]));
4112 resolve(source); 4586 resolve(source);
4113 assertErrors([CompileTimeErrorCode.UNINITIALIZED_FINAL_FIELD]); 4587 assertErrors([CompileTimeErrorCode.UNINITIALIZED_FINAL_FIELD]);
4114 verify([source]); 4588 verify([source]);
4115 } 4589 }
4116 void fail_wrongNumberOfTypeArguments_creation_const_tooFew() {
4117 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return const C<A>();", "}"]));
4118 resolve(source);
4119 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
4120 verify([source]);
4121 }
4122 void fail_wrongNumberOfTypeArguments_creation_const_tooMany() {
4123 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return const C<A, A>();", "}"]));
4124 resolve(source);
4125 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
4126 verify([source]);
4127 }
4128 void fail_wrongNumberOfTypeArguments_creation_new_tooFew() {
4129 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return new C<A>();", "}"]));
4130 resolve(source);
4131 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
4132 verify([source]);
4133 }
4134 void fail_wrongNumberOfTypeArguments_creation_new_tooMany() {
4135 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return new C<A, A>();", "}"]));
4136 resolve(source);
4137 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
4138 verify([source]);
4139 }
4140 void fail_wrongNumberOfTypeArguments_typeTest_tooFew() {
4141 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return p is C<A>;", "}"]));
4142 resolve(source);
4143 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
4144 verify([source]);
4145 }
4146 void fail_wrongNumberOfTypeArguments_typeTest_tooMany() {
4147 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return p is C<A, A>;", "}"]));
4148 resolve(source);
4149 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
4150 verify([source]);
4151 }
4152 void test_ambiguousExport() { 4590 void test_ambiguousExport() {
4153 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"])); 4591 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"]));
4154 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"])); 4592 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
4155 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"])); 4593 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
4156 resolve(source); 4594 resolve(source);
4157 assertErrors([CompileTimeErrorCode.AMBIGUOUS_EXPORT]); 4595 assertErrors([CompileTimeErrorCode.AMBIGUOUS_EXPORT]);
4158 verify([source]); 4596 verify([source]);
4159 } 4597 }
4160 void test_ambiguousImport_as() { 4598 void test_ambiguousImport_as() {
4161 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "f(p) {p as N;}"])); 4599 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "f(p) {p as N;}"]));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]); 4695 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]);
4258 verify([source]); 4696 verify([source]);
4259 } 4697 }
4260 void test_builtInIdentifierAsTypeVariableName() { 4698 void test_builtInIdentifierAsTypeVariableName() {
4261 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"])); 4699 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"]));
4262 resolve(source); 4700 resolve(source);
4263 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME ]); 4701 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME ]);
4264 verify([source]); 4702 verify([source]);
4265 } 4703 }
4266 void test_caseExpressionTypeImplementsEquals() { 4704 void test_caseExpressionTypeImplementsEquals() {
4267 Source source = addSource(EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", " bool operator ==(In tWrapper x) {", " return value == x.value;", " }", "}", "", "f(IntWrapper a) {", " switch(a) {", " case(const IntWrapper(1)) : return 1;", " default: return 0;", " }", "}"])); 4705 Source source = addSource(EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", " bool operator ==(In tWrapper x) {", " return value == x.value;", " }", "}", "", "f(var a) {", " switch(a) {", " case(const IntWrapper(1)) : return 1;", " default: return 0;", " }", "}"]));
4268 resolve(source); 4706 resolve(source);
4269 assertErrors([CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 4707 assertErrors([CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
4270 verify([source]); 4708 verify([source]);
4271 } 4709 }
4272 void test_conflictingConstructorNameAndMember_field() { 4710 void test_conflictingConstructorNameAndMember_field() {
4273 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.x() {}", "}"])); 4711 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.x() {}", "}"]));
4274 resolve(source); 4712 resolve(source);
4275 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]); 4713 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]);
4276 verify([source]); 4714 verify([source]);
4277 } 4715 }
4278 void test_conflictingConstructorNameAndMember_method() { 4716 void test_conflictingConstructorNameAndMember_method() {
4279 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.x();", " void x() {}", "}"])); 4717 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.x();", " void x() {}", "}"]));
4280 resolve(source); 4718 resolve(source);
4281 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]) ; 4719 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]) ;
4282 verify([source]); 4720 verify([source]);
4283 } 4721 }
4722 void test_conflictingGetterAndMethod_field_method() {
4723 Source source = addSource(EngineTestCase.createSource(["class A {", " int m ;", "}", "class B extends A {", " m() {}", "}"]));
4724 resolve(source);
4725 assertErrors([CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]);
4726 verify([source]);
4727 }
4728 void test_conflictingGetterAndMethod_getter_method() {
4729 Source source = addSource(EngineTestCase.createSource(["class A {", " get m => 0;", "}", "class B extends A {", " m() {}", "}"]));
4730 resolve(source);
4731 assertErrors([CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD]);
4732 verify([source]);
4733 }
4734 void test_conflictingGetterAndMethod_method_field() {
4735 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "class B extends A {", " int m;", "}"]));
4736 resolve(source);
4737 assertErrors([CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]);
4738 verify([source]);
4739 }
4740 void test_conflictingGetterAndMethod_method_getter() {
4741 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "class B extends A {", " get m => 0;", "}"]));
4742 resolve(source);
4743 assertErrors([CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER]);
4744 verify([source]);
4745 }
4284 void test_constConstructorWithNonFinalField_mixin() { 4746 void test_constConstructorWithNonFinalField_mixin() {
4285 Source source = addSource(EngineTestCase.createSource(["class A {", " var a ;", "}", "class B extends Object with A {", " const B();", "}"])); 4747 Source source = addSource(EngineTestCase.createSource(["class A {", " var a ;", "}", "class B extends Object with A {", " const B();", "}"]));
4286 resolve(source); 4748 resolve(source);
4287 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); 4749 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
4288 verify([source]); 4750 verify([source]);
4289 } 4751 }
4290 void test_constConstructorWithNonFinalField_super() { 4752 void test_constConstructorWithNonFinalField_super() {
4291 Source source = addSource(EngineTestCase.createSource(["class A {", " var a ;", "}", "class B extends A {", " const B();", "}"])); 4753 Source source = addSource(EngineTestCase.createSource(["class A {", " var a ;", "}", "class B extends A {", " const B();", "}"]));
4292 resolve(source); 4754 resolve(source);
4293 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); 4755 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
4294 verify([source]); 4756 verify([source]);
4295 } 4757 }
4296 void test_constConstructorWithNonFinalField_this() { 4758 void test_constConstructorWithNonFinalField_this() {
4297 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " const A();", "}"])); 4759 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " const A();", "}"]));
4298 resolve(source); 4760 resolve(source);
4299 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); 4761 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
4300 verify([source]); 4762 verify([source]);
4301 } 4763 }
4764 void test_constEval_newInstance_constConstructor() {
4765 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "const a = new A();"]));
4766 resolve(source);
4767 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]);
4768 verify([source]);
4769 }
4770 void test_constEval_propertyExtraction_methodInstance() {
4771 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", " m() {}", "}", "final a = const A();", "const C = a.m;"]));
4772 resolve(source);
4773 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]);
4774 verify([source]);
4775 }
4776 void test_constEval_propertyExtraction_methodStatic_targetInstance() {
4777 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", " static m() {}", "}", "final a = const A();", "const C = a.m;"]));
4778 resolve(source);
4779 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]);
4780 verify([source]);
4781 }
4302 void test_constEvalThrowsException_binaryMinus_null() { 4782 void test_constEvalThrowsException_binaryMinus_null() {
4303 check_constEvalThrowsException_binary_null("null - 5", false); 4783 check_constEvalThrowsException_binary_null("null - 5", false);
4304 check_constEvalThrowsException_binary_null("5 - null", true); 4784 check_constEvalThrowsException_binary_null("5 - null", true);
4305 } 4785 }
4306 void test_constEvalThrowsException_binaryPlus_null() { 4786 void test_constEvalThrowsException_binaryPlus_null() {
4307 check_constEvalThrowsException_binary_null("null + 5", false); 4787 check_constEvalThrowsException_binary_null("null + 5", false);
4308 check_constEvalThrowsException_binary_null("5 + null", true); 4788 check_constEvalThrowsException_binary_null("5 + null", true);
4309 } 4789 }
4790 void test_constEvalThrowsException_divisionByZero() {
4791 Source source = addSource("const C = 1 ~/ 0;");
4792 resolve(source);
4793 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE]);
4794 verify([source]);
4795 }
4310 void test_constEvalThrowsException_unaryBitNot_null() { 4796 void test_constEvalThrowsException_unaryBitNot_null() {
4311 Source source = addSource("const C = ~null;"); 4797 Source source = addSource("const C = ~null;");
4312 resolve(source); 4798 resolve(source);
4313 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, StaticTypeWa rningCode.UNDEFINED_OPERATOR]); 4799 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, StaticTypeWa rningCode.UNDEFINED_OPERATOR]);
4314 } 4800 }
4315 void test_constEvalThrowsException_unaryNegated_null() { 4801 void test_constEvalThrowsException_unaryNegated_null() {
4316 Source source = addSource("const C = -null;"); 4802 Source source = addSource("const C = -null;");
4317 resolve(source); 4803 resolve(source);
4318 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, StaticTypeWa rningCode.UNDEFINED_OPERATOR]); 4804 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, StaticTypeWa rningCode.UNDEFINED_OPERATOR]);
4319 } 4805 }
4320 void test_constEvalThrowsException_unaryNot_null() { 4806 void test_constEvalThrowsException_unaryNot_null() {
4321 Source source = addSource("const C = !null;"); 4807 Source source = addSource("const C = !null;");
4322 resolve(source); 4808 resolve(source);
4323 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); 4809 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
4324 verify([source]); 4810 verify([source]);
4325 } 4811 }
4326 void test_constEvalTypeBool_binary() { 4812 void test_constEvalTypeBool_binary() {
4327 check_constEvalTypeBool_withParameter_binary("p && ''"); 4813 check_constEvalTypeBool_withParameter_binary("p && ''");
4328 check_constEvalTypeBool_withParameter_binary("p || ''"); 4814 check_constEvalTypeBool_withParameter_binary("p || ''");
4329 } 4815 }
4816 void test_constEvalTypeBool_binary_leftTrue() {
4817 Source source = addSource("const C = (true || 0);");
4818 resolve(source);
4819 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]);
4820 verify([source]);
4821 }
4330 void test_constEvalTypeBoolNumString_equal() { 4822 void test_constEvalTypeBoolNumString_equal() {
4331 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final a;", " const B(num p) : a = p == const A();" , "}"])); 4823 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final a;", " const B(num p) : a = p == const A();" , "}"]));
4332 resolve(source); 4824 resolve(source);
4333 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]); 4825 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]);
4334 verify([source]); 4826 verify([source]);
4335 } 4827 }
4336 void test_constEvalTypeBoolNumString_notEqual() { 4828 void test_constEvalTypeBoolNumString_notEqual() {
4337 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final a;", " const B(String p) : a = p != const A( );", "}"])); 4829 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final a;", " const B(String p) : a = p != const A( );", "}"]));
4338 resolve(source); 4830 resolve(source);
4339 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]); 4831 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4393 resolve(source); 4885 resolve(source);
4394 assertErrors([CompileTimeErrorCode.CONST_INSTANCE_FIELD]); 4886 assertErrors([CompileTimeErrorCode.CONST_INSTANCE_FIELD]);
4395 verify([source]); 4887 verify([source]);
4396 } 4888 }
4397 void test_constWithInvalidTypeParameters() { 4889 void test_constWithInvalidTypeParameters() {
4398 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "f() { return const A<A>(); }"])); 4890 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "f() { return const A<A>(); }"]));
4399 resolve(source); 4891 resolve(source);
4400 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); 4892 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
4401 verify([source]); 4893 verify([source]);
4402 } 4894 }
4895 void test_constWithInvalidTypeParameters_tooFew() {
4896 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {", " const C();", "}", "f(p) {", " return const C<A>();", "}"]));
4897 resolve(source);
4898 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
4899 verify([source]);
4900 }
4901 void test_constWithInvalidTypeParameters_tooMany() {
4902 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {", " const C();", "}", "f(p) {", " return const C<A, A>();", "}"]));
4903 resolve(source);
4904 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
4905 verify([source]);
4906 }
4403 void test_constWithNonConst() { 4907 void test_constWithNonConst() {
4404 Source source = addSource(EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"])); 4908 Source source = addSource(EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"]));
4405 resolve(source); 4909 resolve(source);
4406 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]); 4910 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]);
4407 verify([source]); 4911 verify([source]);
4408 } 4912 }
4409 void test_constWithNonConstantArgument() { 4913 void test_constWithNonConstantArgument() {
4410 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(a);", "}", "f(p) { return const A(p); }"])); 4914 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(a);", "}", "f(p) { return const A(p); }"]));
4411 resolve(source); 4915 resolve(source);
4412 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]); 4916 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]);
4413 verify([source]); 4917 verify([source]);
4414 } 4918 }
4415 void test_constWithNonType() { 4919 void test_constWithNonType() {
4416 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", " return const A();", "}"])); 4920 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", " return const A();", "}"]));
4417 resolve(source); 4921 resolve(source);
4418 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]); 4922 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
4419 verify([source]); 4923 verify([source]);
4420 } 4924 }
4925 void test_constWithNonType_fromLibrary() {
4926 Source source1 = addSource2("lib.dart", "");
4927 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource(["impor t 'lib.dart' as lib;", "void f() {", " const lib.A();", "}"]));
4928 resolve(source1);
4929 resolve(source2);
4930 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
4931 verify([source1]);
4932 }
4421 void test_constWithTypeParameters_direct() { 4933 void test_constWithTypeParameters_direct() {
4422 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " st atic const V = const A<T>();", " const A();", "}"])); 4934 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " st atic const V = const A<T>();", " const A();", "}"]));
4423 resolve(source); 4935 resolve(source);
4424 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]); 4936 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]);
4425 verify([source]); 4937 verify([source]);
4426 } 4938 }
4427 void test_constWithTypeParameters_indirect() { 4939 void test_constWithTypeParameters_indirect() {
4428 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " st atic const V = const A<List<T>>();", " const A();", "}"])); 4940 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " st atic const V = const A<List<T>>();", " const A();", "}"]));
4429 resolve(source); 4941 resolve(source);
4430 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]); 4942 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]);
(...skipping 21 matching lines...) Expand all
4452 resolve(source); 4964 resolve(source);
4453 assertErrors([CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, CompileTimeEr rorCode.DUPLICATE_CONSTRUCTOR_NAME]); 4965 assertErrors([CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, CompileTimeEr rorCode.DUPLICATE_CONSTRUCTOR_NAME]);
4454 verify([source]); 4966 verify([source]);
4455 } 4967 }
4456 void test_duplicateConstructorName_unnamed() { 4968 void test_duplicateConstructorName_unnamed() {
4457 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", " A() {}", "}"])); 4969 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", " A() {}", "}"]));
4458 resolve(source); 4970 resolve(source);
4459 assertErrors([CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, CompileTim eErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT]); 4971 assertErrors([CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, CompileTim eErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT]);
4460 verify([source]); 4972 verify([source]);
4461 } 4973 }
4974 void test_duplicateDefinition() {
4975 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0 ;", " m(a) {}", "}"]));
4976 resolve(source);
4977 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]);
4978 verify([source]);
4979 }
4980 void test_duplicateDefinition_acrossLibraries() {
4981 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([ "library lib;", "", "part 'a.dart';", "part 'b.dart';"]));
4982 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
4983 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
4984 resolve(librarySource);
4985 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
4986 verify([librarySource, sourceA, sourceB]);
4987 }
4988 void test_duplicateDefinition_classMembers_fields() {
4989 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " int a;", " int a;", "}"]));
4990 resolve(librarySource);
4991 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION, CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeEr rorCode.DUPLICATE_DEFINITION]);
4992 verify([librarySource]);
4993 }
4994 void test_duplicateDefinition_classMembers_fields_oneStatic() {
4995 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " static int x;", "}"]));
4996 resolve(source);
4997 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION, CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeEr rorCode.DUPLICATE_DEFINITION]);
4998 verify([source]);
4999 }
5000 void test_duplicateDefinition_classMembers_methods() {
5001 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {}", " m() {}", "}"]));
5002 resolve(librarySource);
5003 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]);
5004 verify([librarySource]);
5005 }
5006 void test_duplicateDefinition_localFields() {
5007 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {", " int a;", " int a;", " }", "}"]));
5008 resolve(librarySource);
5009 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]);
5010 verify([librarySource]);
5011 }
4462 void test_duplicateDefinition_parameterWithFunctionName_local() { 5012 void test_duplicateDefinition_parameterWithFunctionName_local() {
4463 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) { }", "}"])); 5013 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) { }", "}"]));
4464 resolve(source); 5014 resolve(source);
4465 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]); 5015 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]);
4466 verify([source]); 5016 verify([source]);
4467 } 5017 }
4468 void test_duplicateDefinition_parameterWithFunctionName_topLevel() { 5018 void test_duplicateDefinition_parameterWithFunctionName_topLevel() {
4469 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) { }", "}"])); 5019 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) { }", "}"]));
4470 resolve(source); 5020 resolve(source);
4471 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]); 5021 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]);
4472 verify([source]); 5022 verify([source]);
4473 } 5023 }
4474 void test_duplicateMemberError() { 5024 void test_duplicateDefinitionInheritance_instanceMethod_staticMethod() {
4475 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([ "library lib;", "", "part 'a.dart';", "part 'b.dart';"])); 5025 Source source = addSource(EngineTestCase.createSource(["class A {", " x() { }", "}", "class B extends A {", " static x() {}", "}"]));
4476 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"])); 5026 resolve(source);
4477 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"])); 5027 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
4478 resolve(librarySource); 5028 verify([source]);
4479 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
4480 verify([librarySource, sourceA, sourceB]);
4481 } 5029 }
4482 void test_duplicateMemberError_classMembers_methods() { 5030 void test_duplicateDefinitionInheritance_instanceMethodAbstract_staticMethod() {
4483 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {}", " m() {}", "}"])); 5031 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " x();", "}", "abstract class B extends A {", " static x() {}", "}"]));
4484 resolve(librarySource); 5032 resolve(source);
4485 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]); 5033 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE]);
4486 verify([librarySource]); 5034 verify([source]);
4487 } 5035 }
4488 void test_duplicateNamedArgument() { 5036 void test_duplicateNamedArgument() {
4489 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main () {", " f(a: 1, a: 2);", "}"])); 5037 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main () {", " f(a: 1, a: 2);", "}"]));
4490 resolve(source); 5038 resolve(source);
4491 assertErrors([CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]); 5039 assertErrors([CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]);
4492 verify([source]); 5040 verify([source]);
4493 } 5041 }
4494 void test_exportInternalLibrary() { 5042 void test_exportInternalLibrary() {
4495 Source source = addSource(EngineTestCase.createSource(["export 'dart:_interc eptors';"])); 5043 Source source = addSource(EngineTestCase.createSource(["export 'dart:_interc eptors';"]));
4496 resolve(source); 5044 resolve(source);
4497 assertErrors([CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]); 5045 assertErrors([CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]);
4498 verify([source]); 5046 verify([source]);
4499 } 5047 }
4500 void test_exportOfNonLibrary() { 5048 void test_exportOfNonLibrary() {
4501 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"])); 5049 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
4502 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"])); 5050 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"]));
4503 resolve(source); 5051 resolve(source);
4504 assertErrors([CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); 5052 assertErrors([CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]);
4505 verify([source]); 5053 verify([source]);
4506 } 5054 }
4507 void test_extendsNonClass_class() { 5055 void test_extendsNonClass_class() {
4508 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends A {}"])); 5056 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends A {}"]));
4509 resolve(source); 5057 resolve(source);
4510 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]); 5058 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]);
4511 verify([source]); 5059 verify([source]);
4512 } 5060 }
4513 void test_extendsOrImplementsDisallowedClass_extends_bool() { 5061 void test_extendsOrImplementsDisallowedClass_extends_bool() {
4514 Source source = addSource(EngineTestCase.createSource(["class A extends bool {}"])); 5062 Source source = addSource(EngineTestCase.createSource(["class A extends bool {}"]));
4515 resolve(source); 5063 resolve(source);
4516 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 5064 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, CompileTimeErro rCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4517 verify([source]); 5065 verify([source]);
4518 } 5066 }
4519 void test_extendsOrImplementsDisallowedClass_extends_double() { 5067 void test_extendsOrImplementsDisallowedClass_extends_double() {
4520 Source source = addSource(EngineTestCase.createSource(["class A extends doub le {}"])); 5068 Source source = addSource(EngineTestCase.createSource(["class A extends doub le {}"]));
4521 resolve(source); 5069 resolve(source);
4522 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 5070 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, CompileTimeErro rCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4523 verify([source]); 5071 verify([source]);
4524 } 5072 }
4525 void test_extendsOrImplementsDisallowedClass_extends_int() { 5073 void test_extendsOrImplementsDisallowedClass_extends_int() {
4526 Source source = addSource(EngineTestCase.createSource(["class A extends int {}"])); 5074 Source source = addSource(EngineTestCase.createSource(["class A extends int {}"]));
4527 resolve(source); 5075 resolve(source);
4528 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 5076 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, CompileTimeErro rCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4529 verify([source]); 5077 verify([source]);
4530 } 5078 }
4531 void test_extendsOrImplementsDisallowedClass_extends_num() { 5079 void test_extendsOrImplementsDisallowedClass_extends_num() {
4532 Source source = addSource(EngineTestCase.createSource(["class A extends num {}"])); 5080 Source source = addSource(EngineTestCase.createSource(["class A extends num {}"]));
4533 resolve(source); 5081 resolve(source);
4534 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 5082 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, CompileTimeErro rCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4535 verify([source]); 5083 verify([source]);
4536 } 5084 }
4537 void test_extendsOrImplementsDisallowedClass_extends_String() { 5085 void test_extendsOrImplementsDisallowedClass_extends_String() {
4538 Source source = addSource(EngineTestCase.createSource(["class A extends Stri ng {}"])); 5086 Source source = addSource(EngineTestCase.createSource(["class A extends Stri ng {}"]));
4539 resolve(source); 5087 resolve(source);
4540 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]); 5088 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, CompileTimeErro rCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4541 verify([source]); 5089 verify([source]);
4542 } 5090 }
4543 void test_extendsOrImplementsDisallowedClass_implements_bool() { 5091 void test_extendsOrImplementsDisallowedClass_implements_bool() {
4544 Source source = addSource(EngineTestCase.createSource(["class A implements b ool {}"])); 5092 Source source = addSource(EngineTestCase.createSource(["class A implements b ool {}"]));
4545 resolve(source); 5093 resolve(source);
4546 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 5094 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
4547 verify([source]); 5095 verify([source]);
4548 } 5096 }
4549 void test_extendsOrImplementsDisallowedClass_implements_double() { 5097 void test_extendsOrImplementsDisallowedClass_implements_double() {
4550 Source source = addSource(EngineTestCase.createSource(["class A implements d ouble {}"])); 5098 Source source = addSource(EngineTestCase.createSource(["class A implements d ouble {}"]));
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
4732 resolve(source); 5280 resolve(source);
4733 assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED, CompileTimeErrorCode .IMPLEMENTS_REPEATED, CompileTimeErrorCode.IMPLEMENTS_REPEATED]); 5281 assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED, CompileTimeErrorCode .IMPLEMENTS_REPEATED, CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
4734 verify([source]); 5282 verify([source]);
4735 } 5283 }
4736 void test_implicitThisReferenceInInitializer_field() { 5284 void test_implicitThisReferenceInInitializer_field() {
4737 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f;", " var f;", "}"])); 5285 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f;", " var f;", "}"]));
4738 resolve(source); 5286 resolve(source);
4739 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 5287 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
4740 verify([source]); 5288 verify([source]);
4741 } 5289 }
5290 void test_implicitThisReferenceInInitializer_field2() {
5291 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " final y = x;", "}"]));
5292 resolve(source);
5293 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
5294 verify([source]);
5295 }
4742 void test_implicitThisReferenceInInitializer_invocation() { 5296 void test_implicitThisReferenceInInitializer_invocation() {
4743 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f();", " f() {}", "}"])); 5297 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f();", " f() {}", "}"]));
4744 resolve(source); 5298 resolve(source);
4745 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 5299 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
4746 verify([source]); 5300 verify([source]);
4747 } 5301 }
4748 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation( ) { 5302 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation( ) {
4749 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p) {}", " A.named() : this(f);", " var f;", "}"])); 5303 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p) {}", " A.named() : this(f);", " var f;", "}"]));
4750 resolve(source); 5304 resolve(source);
4751 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]); 5305 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
4816 resolve(source); 5370 resolve(source);
4817 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]); 5371 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
4818 verify([source]); 5372 verify([source]);
4819 } 5373 }
4820 void test_initializingFormalForNonExistantField_static() { 5374 void test_initializingFormalForNonExistantField_static() {
4821 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " A([this.x]) {}", "}"])); 5375 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " A([this.x]) {}", "}"]));
4822 resolve(source); 5376 resolve(source);
4823 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]); 5377 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]);
4824 verify([source]); 5378 verify([source]);
4825 } 5379 }
5380 void test_instanceMemberAccessFromStatic_field() {
5381 Source source = addSource(EngineTestCase.createSource(["class A {", " int f ;", " static foo() {", " f;", " }", "}"]));
5382 resolve(source);
5383 assertErrors([CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
5384 verify([source]);
5385 }
5386 void test_instanceMemberAccessFromStatic_getter() {
5387 Source source = addSource(EngineTestCase.createSource(["class A {", " get g => null;", " static foo() {", " g;", " }", "}"]));
5388 resolve(source);
5389 assertErrors([CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
5390 verify([source]);
5391 }
5392 void test_instanceMemberAccessFromStatic_method() {
5393 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", " static foo() {", " m();", " }", "}"]));
5394 resolve(source);
5395 assertErrors([CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
5396 verify([source]);
5397 }
4826 void test_invalidConstructorName_notEnclosingClassName() { 5398 void test_invalidConstructorName_notEnclosingClassName() {
4827 Source source = addSource(EngineTestCase.createSource(["class A {", " B() : super();", "}"])); 5399 Source source = addSource(EngineTestCase.createSource(["class A {", " B() : super();", "}"]));
4828 resolve(source); 5400 resolve(source);
4829 assertErrors([CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]); 5401 assertErrors([CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
4830 } 5402 }
4831 void test_invalidFactoryNameNotAClass_notClassName() { 5403 void test_invalidFactoryNameNotAClass_notClassName() {
4832 Source source = addSource(EngineTestCase.createSource(["int B;", "class A {" , " factory B() {}", "}"])); 5404 Source source = addSource(EngineTestCase.createSource(["int B;", "class A {" , " factory B() {}", "}"]));
4833 resolve(source); 5405 resolve(source);
4834 assertErrors([CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]); 5406 assertErrors([CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
4835 verify([source]); 5407 verify([source]);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
5068 resolve(source); 5640 resolve(source);
5069 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]); 5641 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
5070 verify([source]); 5642 verify([source]);
5071 } 5643 }
5072 void test_newWithInvalidTypeParameters() { 5644 void test_newWithInvalidTypeParameters() {
5073 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"])); 5645 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"]));
5074 resolve(source); 5646 resolve(source);
5075 assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); 5647 assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
5076 verify([source]); 5648 verify([source]);
5077 } 5649 }
5650 void test_newWithInvalidTypeParameters_tooFew() {
5651 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return new C<A>();", "}"]));
5652 resolve(source);
5653 assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
5654 verify([source]);
5655 }
5656 void test_newWithInvalidTypeParameters_tooMany() {
5657 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return new C<A, A>();", "}"]));
5658 resolve(source);
5659 assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
5660 verify([source]);
5661 }
5662 void test_noDefaultSuperConstructorExplicit() {
5663 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p); ", "}", "class B extends A {", " B() {}", "}"]));
5664 resolve(source);
5665 assertErrors([CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
5666 verify([source]);
5667 }
5668 void test_noDefaultSuperConstructorImplicit_superHasParameters() {
5669 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p); ", "}", "class B extends A {", "}"]));
5670 resolve(source);
5671 assertErrors([CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
5672 verify([source]);
5673 }
5674 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() {
5675 Source source = addSource(EngineTestCase.createSource(["class A { A.named() {} }", "class B extends A {}"]));
5676 resolve(source);
5677 assertErrors([CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
5678 verify([source]);
5679 }
5078 void test_nonConstantDefaultValue_function_named() { 5680 void test_nonConstantDefaultValue_function_named() {
5079 Source source = addSource(EngineTestCase.createSource(["int y;", "f({x : y}) {}"])); 5681 Source source = addSource(EngineTestCase.createSource(["int y;", "f({x : y}) {}"]));
5080 resolve(source); 5682 resolve(source);
5081 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 5683 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
5082 verify([source]); 5684 verify([source]);
5083 } 5685 }
5084 void test_nonConstantDefaultValue_function_positional() { 5686 void test_nonConstantDefaultValue_function_positional() {
5085 Source source = addSource(EngineTestCase.createSource(["int y;", "f([x = y]) {}"])); 5687 Source source = addSource(EngineTestCase.createSource(["int y;", "f([x = y]) {}"]));
5086 resolve(source); 5688 resolve(source);
5087 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 5689 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5194 resolve(source); 5796 resolve(source);
5195 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); 5797 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
5196 verify([source]); 5798 verify([source]);
5197 } 5799 }
5198 void test_nonGenerativeConstructor_implicit() { 5800 void test_nonGenerativeConstructor_implicit() {
5199 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}", "class B extends A {", " B();", "}"])); 5801 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}", "class B extends A {", " B();", "}"]));
5200 resolve(source); 5802 resolve(source);
5201 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]); 5803 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
5202 verify([source]); 5804 verify([source]);
5203 } 5805 }
5806 void test_nonGenerativeConstructor_implicit2() {
5807 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}", "class B extends A {", "}"]));
5808 resolve(source);
5809 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
5810 verify([source]);
5811 }
5204 void test_notEnoughRequiredArguments_const() { 5812 void test_notEnoughRequiredArguments_const() {
5205 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(int p);", "}", "main() {", " const A();", "}"])); 5813 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(int p);", "}", "main() {", " const A();", "}"]));
5206 resolve(source); 5814 resolve(source);
5207 assertErrors([CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]); 5815 assertErrors([CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
5208 verify([source]); 5816 verify([source]);
5209 } 5817 }
5210 void test_optionalParameterInOperator_named() { 5818 void test_optionalParameterInOperator_named() {
5211 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +({p}) {}", "}"])); 5819 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +({p}) {}", "}"]));
5212 resolve(source); 5820 resolve(source);
5213 assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); 5821 assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
5529 check_wrongNumberOfParametersForOperator1("~/"); 6137 check_wrongNumberOfParametersForOperator1("~/");
5530 check_wrongNumberOfParametersForOperator1("*"); 6138 check_wrongNumberOfParametersForOperator1("*");
5531 check_wrongNumberOfParametersForOperator1("%"); 6139 check_wrongNumberOfParametersForOperator1("%");
5532 check_wrongNumberOfParametersForOperator1("|"); 6140 check_wrongNumberOfParametersForOperator1("|");
5533 check_wrongNumberOfParametersForOperator1("^"); 6141 check_wrongNumberOfParametersForOperator1("^");
5534 check_wrongNumberOfParametersForOperator1("&"); 6142 check_wrongNumberOfParametersForOperator1("&");
5535 check_wrongNumberOfParametersForOperator1("<<"); 6143 check_wrongNumberOfParametersForOperator1("<<");
5536 check_wrongNumberOfParametersForOperator1(">>"); 6144 check_wrongNumberOfParametersForOperator1(">>");
5537 check_wrongNumberOfParametersForOperator1("[]"); 6145 check_wrongNumberOfParametersForOperator1("[]");
5538 } 6146 }
6147 void test_wrongNumberOfParametersForSetter_function_named() {
6148 Source source = addSource("set x({p}) {}");
6149 resolve(source);
6150 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
6151 verify([source]);
6152 }
6153 void test_wrongNumberOfParametersForSetter_function_optional() {
6154 Source source = addSource("set x([p]) {}");
6155 resolve(source);
6156 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
6157 verify([source]);
6158 }
5539 void test_wrongNumberOfParametersForSetter_function_tooFew() { 6159 void test_wrongNumberOfParametersForSetter_function_tooFew() {
5540 Source source = addSource("set x() {}"); 6160 Source source = addSource("set x() {}");
5541 resolve(source); 6161 resolve(source);
5542 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 6162 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5543 verify([source]); 6163 verify([source]);
5544 } 6164 }
5545 void test_wrongNumberOfParametersForSetter_function_tooMany() { 6165 void test_wrongNumberOfParametersForSetter_function_tooMany() {
5546 Source source = addSource("set x(a, b) {}"); 6166 Source source = addSource("set x(a, b) {}");
5547 resolve(source); 6167 resolve(source);
5548 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 6168 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5549 verify([source]); 6169 verify([source]);
5550 } 6170 }
6171 void test_wrongNumberOfParametersForSetter_method_named() {
6172 Source source = addSource(EngineTestCase.createSource(["class A {", " set x ({p}) {}", "}"]));
6173 resolve(source);
6174 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
6175 verify([source]);
6176 }
6177 void test_wrongNumberOfParametersForSetter_method_optional() {
6178 Source source = addSource(EngineTestCase.createSource(["class A {", " set x ([p]) {}", "}"]));
6179 resolve(source);
6180 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
6181 verify([source]);
6182 }
5551 void test_wrongNumberOfParametersForSetter_method_tooFew() { 6183 void test_wrongNumberOfParametersForSetter_method_tooFew() {
5552 Source source = addSource(EngineTestCase.createSource(["class A {", " set x () {}", "}"])); 6184 Source source = addSource(EngineTestCase.createSource(["class A {", " set x () {}", "}"]));
5553 resolve(source); 6185 resolve(source);
5554 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 6186 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5555 verify([source]); 6187 verify([source]);
5556 } 6188 }
5557 void test_wrongNumberOfParametersForSetter_method_tooMany() { 6189 void test_wrongNumberOfParametersForSetter_method_tooMany() {
5558 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (a, b) {}", "}"])); 6190 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (a, b) {}", "}"]));
5559 resolve(source); 6191 resolve(source);
5560 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 6192 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
5678 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals); 6310 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals);
5679 }); 6311 });
5680 _ut.test('test_conflictingConstructorNameAndMember_field', () { 6312 _ut.test('test_conflictingConstructorNameAndMember_field', () {
5681 final __test = new CompileTimeErrorCodeTest(); 6313 final __test = new CompileTimeErrorCodeTest();
5682 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_fie ld); 6314 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_fie ld);
5683 }); 6315 });
5684 _ut.test('test_conflictingConstructorNameAndMember_method', () { 6316 _ut.test('test_conflictingConstructorNameAndMember_method', () {
5685 final __test = new CompileTimeErrorCodeTest(); 6317 final __test = new CompileTimeErrorCodeTest();
5686 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_met hod); 6318 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_met hod);
5687 }); 6319 });
6320 _ut.test('test_conflictingGetterAndMethod_field_method', () {
6321 final __test = new CompileTimeErrorCodeTest();
6322 runJUnitTest(__test, __test.test_conflictingGetterAndMethod_field_method );
6323 });
6324 _ut.test('test_conflictingGetterAndMethod_getter_method', () {
6325 final __test = new CompileTimeErrorCodeTest();
6326 runJUnitTest(__test, __test.test_conflictingGetterAndMethod_getter_metho d);
6327 });
6328 _ut.test('test_conflictingGetterAndMethod_method_field', () {
6329 final __test = new CompileTimeErrorCodeTest();
6330 runJUnitTest(__test, __test.test_conflictingGetterAndMethod_method_field );
6331 });
6332 _ut.test('test_conflictingGetterAndMethod_method_getter', () {
6333 final __test = new CompileTimeErrorCodeTest();
6334 runJUnitTest(__test, __test.test_conflictingGetterAndMethod_method_gette r);
6335 });
5688 _ut.test('test_constConstructorWithNonFinalField_mixin', () { 6336 _ut.test('test_constConstructorWithNonFinalField_mixin', () {
5689 final __test = new CompileTimeErrorCodeTest(); 6337 final __test = new CompileTimeErrorCodeTest();
5690 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_mixin ); 6338 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_mixin );
5691 }); 6339 });
5692 _ut.test('test_constConstructorWithNonFinalField_super', () { 6340 _ut.test('test_constConstructorWithNonFinalField_super', () {
5693 final __test = new CompileTimeErrorCodeTest(); 6341 final __test = new CompileTimeErrorCodeTest();
5694 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_super ); 6342 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_super );
5695 }); 6343 });
5696 _ut.test('test_constConstructorWithNonFinalField_this', () { 6344 _ut.test('test_constConstructorWithNonFinalField_this', () {
5697 final __test = new CompileTimeErrorCodeTest(); 6345 final __test = new CompileTimeErrorCodeTest();
5698 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_this) ; 6346 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_this) ;
5699 }); 6347 });
5700 _ut.test('test_constEvalThrowsException_binaryMinus_null', () { 6348 _ut.test('test_constEvalThrowsException_binaryMinus_null', () {
5701 final __test = new CompileTimeErrorCodeTest(); 6349 final __test = new CompileTimeErrorCodeTest();
5702 runJUnitTest(__test, __test.test_constEvalThrowsException_binaryMinus_nu ll); 6350 runJUnitTest(__test, __test.test_constEvalThrowsException_binaryMinus_nu ll);
5703 }); 6351 });
5704 _ut.test('test_constEvalThrowsException_binaryPlus_null', () { 6352 _ut.test('test_constEvalThrowsException_binaryPlus_null', () {
5705 final __test = new CompileTimeErrorCodeTest(); 6353 final __test = new CompileTimeErrorCodeTest();
5706 runJUnitTest(__test, __test.test_constEvalThrowsException_binaryPlus_nul l); 6354 runJUnitTest(__test, __test.test_constEvalThrowsException_binaryPlus_nul l);
5707 }); 6355 });
6356 _ut.test('test_constEvalThrowsException_divisionByZero', () {
6357 final __test = new CompileTimeErrorCodeTest();
6358 runJUnitTest(__test, __test.test_constEvalThrowsException_divisionByZero );
6359 });
5708 _ut.test('test_constEvalThrowsException_unaryBitNot_null', () { 6360 _ut.test('test_constEvalThrowsException_unaryBitNot_null', () {
5709 final __test = new CompileTimeErrorCodeTest(); 6361 final __test = new CompileTimeErrorCodeTest();
5710 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryBitNot_nu ll); 6362 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryBitNot_nu ll);
5711 }); 6363 });
5712 _ut.test('test_constEvalThrowsException_unaryNegated_null', () { 6364 _ut.test('test_constEvalThrowsException_unaryNegated_null', () {
5713 final __test = new CompileTimeErrorCodeTest(); 6365 final __test = new CompileTimeErrorCodeTest();
5714 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryNegated_n ull); 6366 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryNegated_n ull);
5715 }); 6367 });
5716 _ut.test('test_constEvalThrowsException_unaryNot_null', () { 6368 _ut.test('test_constEvalThrowsException_unaryNot_null', () {
5717 final __test = new CompileTimeErrorCodeTest(); 6369 final __test = new CompileTimeErrorCodeTest();
5718 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryNot_null) ; 6370 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryNot_null) ;
5719 }); 6371 });
5720 _ut.test('test_constEvalTypeBoolNumString_equal', () { 6372 _ut.test('test_constEvalTypeBoolNumString_equal', () {
5721 final __test = new CompileTimeErrorCodeTest(); 6373 final __test = new CompileTimeErrorCodeTest();
5722 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal); 6374 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal);
5723 }); 6375 });
5724 _ut.test('test_constEvalTypeBoolNumString_notEqual', () { 6376 _ut.test('test_constEvalTypeBoolNumString_notEqual', () {
5725 final __test = new CompileTimeErrorCodeTest(); 6377 final __test = new CompileTimeErrorCodeTest();
5726 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual); 6378 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual);
5727 }); 6379 });
5728 _ut.test('test_constEvalTypeBool_binary', () { 6380 _ut.test('test_constEvalTypeBool_binary', () {
5729 final __test = new CompileTimeErrorCodeTest(); 6381 final __test = new CompileTimeErrorCodeTest();
5730 runJUnitTest(__test, __test.test_constEvalTypeBool_binary); 6382 runJUnitTest(__test, __test.test_constEvalTypeBool_binary);
5731 }); 6383 });
6384 _ut.test('test_constEvalTypeBool_binary_leftTrue', () {
6385 final __test = new CompileTimeErrorCodeTest();
6386 runJUnitTest(__test, __test.test_constEvalTypeBool_binary_leftTrue);
6387 });
5732 _ut.test('test_constEvalTypeInt_binary', () { 6388 _ut.test('test_constEvalTypeInt_binary', () {
5733 final __test = new CompileTimeErrorCodeTest(); 6389 final __test = new CompileTimeErrorCodeTest();
5734 runJUnitTest(__test, __test.test_constEvalTypeInt_binary); 6390 runJUnitTest(__test, __test.test_constEvalTypeInt_binary);
5735 }); 6391 });
5736 _ut.test('test_constEvalTypeNum_binary', () { 6392 _ut.test('test_constEvalTypeNum_binary', () {
5737 final __test = new CompileTimeErrorCodeTest(); 6393 final __test = new CompileTimeErrorCodeTest();
5738 runJUnitTest(__test, __test.test_constEvalTypeNum_binary); 6394 runJUnitTest(__test, __test.test_constEvalTypeNum_binary);
5739 }); 6395 });
6396 _ut.test('test_constEval_newInstance_constConstructor', () {
6397 final __test = new CompileTimeErrorCodeTest();
6398 runJUnitTest(__test, __test.test_constEval_newInstance_constConstructor) ;
6399 });
6400 _ut.test('test_constEval_propertyExtraction_methodInstance', () {
6401 final __test = new CompileTimeErrorCodeTest();
6402 runJUnitTest(__test, __test.test_constEval_propertyExtraction_methodInst ance);
6403 });
6404 _ut.test('test_constEval_propertyExtraction_methodStatic_targetInstance', () {
6405 final __test = new CompileTimeErrorCodeTest();
6406 runJUnitTest(__test, __test.test_constEval_propertyExtraction_methodStat ic_targetInstance);
6407 });
5740 _ut.test('test_constFormalParameter_fieldFormalParameter', () { 6408 _ut.test('test_constFormalParameter_fieldFormalParameter', () {
5741 final __test = new CompileTimeErrorCodeTest(); 6409 final __test = new CompileTimeErrorCodeTest();
5742 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er); 6410 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er);
5743 }); 6411 });
5744 _ut.test('test_constFormalParameter_simpleFormalParameter', () { 6412 _ut.test('test_constFormalParameter_simpleFormalParameter', () {
5745 final __test = new CompileTimeErrorCodeTest(); 6413 final __test = new CompileTimeErrorCodeTest();
5746 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter); 6414 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter);
5747 }); 6415 });
5748 _ut.test('test_constInitializedWithNonConstValue', () { 6416 _ut.test('test_constInitializedWithNonConstValue', () {
5749 final __test = new CompileTimeErrorCodeTest(); 6417 final __test = new CompileTimeErrorCodeTest();
5750 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue); 6418 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue);
5751 }); 6419 });
5752 _ut.test('test_constInitializedWithNonConstValue_missingConstInListLiteral ', () { 6420 _ut.test('test_constInitializedWithNonConstValue_missingConstInListLiteral ', () {
5753 final __test = new CompileTimeErrorCodeTest(); 6421 final __test = new CompileTimeErrorCodeTest();
5754 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue_missi ngConstInListLiteral); 6422 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue_missi ngConstInListLiteral);
5755 }); 6423 });
5756 _ut.test('test_constInitializedWithNonConstValue_missingConstInMapLiteral' , () { 6424 _ut.test('test_constInitializedWithNonConstValue_missingConstInMapLiteral' , () {
5757 final __test = new CompileTimeErrorCodeTest(); 6425 final __test = new CompileTimeErrorCodeTest();
5758 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue_missi ngConstInMapLiteral); 6426 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue_missi ngConstInMapLiteral);
5759 }); 6427 });
5760 _ut.test('test_constInstanceField', () { 6428 _ut.test('test_constInstanceField', () {
5761 final __test = new CompileTimeErrorCodeTest(); 6429 final __test = new CompileTimeErrorCodeTest();
5762 runJUnitTest(__test, __test.test_constInstanceField); 6430 runJUnitTest(__test, __test.test_constInstanceField);
5763 }); 6431 });
5764 _ut.test('test_constWithInvalidTypeParameters', () { 6432 _ut.test('test_constWithInvalidTypeParameters', () {
5765 final __test = new CompileTimeErrorCodeTest(); 6433 final __test = new CompileTimeErrorCodeTest();
5766 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters); 6434 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters);
5767 }); 6435 });
6436 _ut.test('test_constWithInvalidTypeParameters_tooFew', () {
6437 final __test = new CompileTimeErrorCodeTest();
6438 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters_tooFew);
6439 });
6440 _ut.test('test_constWithInvalidTypeParameters_tooMany', () {
6441 final __test = new CompileTimeErrorCodeTest();
6442 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters_tooMany) ;
6443 });
5768 _ut.test('test_constWithNonConst', () { 6444 _ut.test('test_constWithNonConst', () {
5769 final __test = new CompileTimeErrorCodeTest(); 6445 final __test = new CompileTimeErrorCodeTest();
5770 runJUnitTest(__test, __test.test_constWithNonConst); 6446 runJUnitTest(__test, __test.test_constWithNonConst);
5771 }); 6447 });
5772 _ut.test('test_constWithNonConstantArgument', () { 6448 _ut.test('test_constWithNonConstantArgument', () {
5773 final __test = new CompileTimeErrorCodeTest(); 6449 final __test = new CompileTimeErrorCodeTest();
5774 runJUnitTest(__test, __test.test_constWithNonConstantArgument); 6450 runJUnitTest(__test, __test.test_constWithNonConstantArgument);
5775 }); 6451 });
5776 _ut.test('test_constWithNonType', () { 6452 _ut.test('test_constWithNonType', () {
5777 final __test = new CompileTimeErrorCodeTest(); 6453 final __test = new CompileTimeErrorCodeTest();
5778 runJUnitTest(__test, __test.test_constWithNonType); 6454 runJUnitTest(__test, __test.test_constWithNonType);
5779 }); 6455 });
6456 _ut.test('test_constWithNonType_fromLibrary', () {
6457 final __test = new CompileTimeErrorCodeTest();
6458 runJUnitTest(__test, __test.test_constWithNonType_fromLibrary);
6459 });
5780 _ut.test('test_constWithTypeParameters_direct', () { 6460 _ut.test('test_constWithTypeParameters_direct', () {
5781 final __test = new CompileTimeErrorCodeTest(); 6461 final __test = new CompileTimeErrorCodeTest();
5782 runJUnitTest(__test, __test.test_constWithTypeParameters_direct); 6462 runJUnitTest(__test, __test.test_constWithTypeParameters_direct);
5783 }); 6463 });
5784 _ut.test('test_constWithTypeParameters_indirect', () { 6464 _ut.test('test_constWithTypeParameters_indirect', () {
5785 final __test = new CompileTimeErrorCodeTest(); 6465 final __test = new CompileTimeErrorCodeTest();
5786 runJUnitTest(__test, __test.test_constWithTypeParameters_indirect); 6466 runJUnitTest(__test, __test.test_constWithTypeParameters_indirect);
5787 }); 6467 });
5788 _ut.test('test_constWithUndefinedConstructor', () { 6468 _ut.test('test_constWithUndefinedConstructor', () {
5789 final __test = new CompileTimeErrorCodeTest(); 6469 final __test = new CompileTimeErrorCodeTest();
5790 runJUnitTest(__test, __test.test_constWithUndefinedConstructor); 6470 runJUnitTest(__test, __test.test_constWithUndefinedConstructor);
5791 }); 6471 });
5792 _ut.test('test_constWithUndefinedConstructorDefault', () { 6472 _ut.test('test_constWithUndefinedConstructorDefault', () {
5793 final __test = new CompileTimeErrorCodeTest(); 6473 final __test = new CompileTimeErrorCodeTest();
5794 runJUnitTest(__test, __test.test_constWithUndefinedConstructorDefault); 6474 runJUnitTest(__test, __test.test_constWithUndefinedConstructorDefault);
5795 }); 6475 });
5796 _ut.test('test_defaultValueInFunctionTypeAlias', () { 6476 _ut.test('test_defaultValueInFunctionTypeAlias', () {
5797 final __test = new CompileTimeErrorCodeTest(); 6477 final __test = new CompileTimeErrorCodeTest();
5798 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias); 6478 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
5799 }); 6479 });
5800 _ut.test('test_duplicateConstructorName_named', () { 6480 _ut.test('test_duplicateConstructorName_named', () {
5801 final __test = new CompileTimeErrorCodeTest(); 6481 final __test = new CompileTimeErrorCodeTest();
5802 runJUnitTest(__test, __test.test_duplicateConstructorName_named); 6482 runJUnitTest(__test, __test.test_duplicateConstructorName_named);
5803 }); 6483 });
5804 _ut.test('test_duplicateConstructorName_unnamed', () { 6484 _ut.test('test_duplicateConstructorName_unnamed', () {
5805 final __test = new CompileTimeErrorCodeTest(); 6485 final __test = new CompileTimeErrorCodeTest();
5806 runJUnitTest(__test, __test.test_duplicateConstructorName_unnamed); 6486 runJUnitTest(__test, __test.test_duplicateConstructorName_unnamed);
5807 }); 6487 });
6488 _ut.test('test_duplicateDefinition', () {
6489 final __test = new CompileTimeErrorCodeTest();
6490 runJUnitTest(__test, __test.test_duplicateDefinition);
6491 });
6492 _ut.test('test_duplicateDefinitionInheritance_instanceMethodAbstract_stati cMethod', () {
6493 final __test = new CompileTimeErrorCodeTest();
6494 runJUnitTest(__test, __test.test_duplicateDefinitionInheritance_instance MethodAbstract_staticMethod);
6495 });
6496 _ut.test('test_duplicateDefinitionInheritance_instanceMethod_staticMethod' , () {
6497 final __test = new CompileTimeErrorCodeTest();
6498 runJUnitTest(__test, __test.test_duplicateDefinitionInheritance_instance Method_staticMethod);
6499 });
6500 _ut.test('test_duplicateDefinition_acrossLibraries', () {
6501 final __test = new CompileTimeErrorCodeTest();
6502 runJUnitTest(__test, __test.test_duplicateDefinition_acrossLibraries);
6503 });
6504 _ut.test('test_duplicateDefinition_classMembers_fields', () {
6505 final __test = new CompileTimeErrorCodeTest();
6506 runJUnitTest(__test, __test.test_duplicateDefinition_classMembers_fields );
6507 });
6508 _ut.test('test_duplicateDefinition_classMembers_fields_oneStatic', () {
6509 final __test = new CompileTimeErrorCodeTest();
6510 runJUnitTest(__test, __test.test_duplicateDefinition_classMembers_fields _oneStatic);
6511 });
6512 _ut.test('test_duplicateDefinition_classMembers_methods', () {
6513 final __test = new CompileTimeErrorCodeTest();
6514 runJUnitTest(__test, __test.test_duplicateDefinition_classMembers_method s);
6515 });
6516 _ut.test('test_duplicateDefinition_localFields', () {
6517 final __test = new CompileTimeErrorCodeTest();
6518 runJUnitTest(__test, __test.test_duplicateDefinition_localFields);
6519 });
5808 _ut.test('test_duplicateDefinition_parameterWithFunctionName_local', () { 6520 _ut.test('test_duplicateDefinition_parameterWithFunctionName_local', () {
5809 final __test = new CompileTimeErrorCodeTest(); 6521 final __test = new CompileTimeErrorCodeTest();
5810 runJUnitTest(__test, __test.test_duplicateDefinition_parameterWithFuncti onName_local); 6522 runJUnitTest(__test, __test.test_duplicateDefinition_parameterWithFuncti onName_local);
5811 }); 6523 });
5812 _ut.test('test_duplicateDefinition_parameterWithFunctionName_topLevel', () { 6524 _ut.test('test_duplicateDefinition_parameterWithFunctionName_topLevel', () {
5813 final __test = new CompileTimeErrorCodeTest(); 6525 final __test = new CompileTimeErrorCodeTest();
5814 runJUnitTest(__test, __test.test_duplicateDefinition_parameterWithFuncti onName_topLevel); 6526 runJUnitTest(__test, __test.test_duplicateDefinition_parameterWithFuncti onName_topLevel);
5815 }); 6527 });
5816 _ut.test('test_duplicateMemberError', () {
5817 final __test = new CompileTimeErrorCodeTest();
5818 runJUnitTest(__test, __test.test_duplicateMemberError);
5819 });
5820 _ut.test('test_duplicateMemberError_classMembers_methods', () {
5821 final __test = new CompileTimeErrorCodeTest();
5822 runJUnitTest(__test, __test.test_duplicateMemberError_classMembers_metho ds);
5823 });
5824 _ut.test('test_duplicateNamedArgument', () { 6528 _ut.test('test_duplicateNamedArgument', () {
5825 final __test = new CompileTimeErrorCodeTest(); 6529 final __test = new CompileTimeErrorCodeTest();
5826 runJUnitTest(__test, __test.test_duplicateNamedArgument); 6530 runJUnitTest(__test, __test.test_duplicateNamedArgument);
5827 }); 6531 });
5828 _ut.test('test_exportInternalLibrary', () { 6532 _ut.test('test_exportInternalLibrary', () {
5829 final __test = new CompileTimeErrorCodeTest(); 6533 final __test = new CompileTimeErrorCodeTest();
5830 runJUnitTest(__test, __test.test_exportInternalLibrary); 6534 runJUnitTest(__test, __test.test_exportInternalLibrary);
5831 }); 6535 });
5832 _ut.test('test_exportOfNonLibrary', () { 6536 _ut.test('test_exportOfNonLibrary', () {
5833 final __test = new CompileTimeErrorCodeTest(); 6537 final __test = new CompileTimeErrorCodeTest();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
5970 runJUnitTest(__test, __test.test_implementsRepeated); 6674 runJUnitTest(__test, __test.test_implementsRepeated);
5971 }); 6675 });
5972 _ut.test('test_implementsRepeated_3times', () { 6676 _ut.test('test_implementsRepeated_3times', () {
5973 final __test = new CompileTimeErrorCodeTest(); 6677 final __test = new CompileTimeErrorCodeTest();
5974 runJUnitTest(__test, __test.test_implementsRepeated_3times); 6678 runJUnitTest(__test, __test.test_implementsRepeated_3times);
5975 }); 6679 });
5976 _ut.test('test_implicitThisReferenceInInitializer_field', () { 6680 _ut.test('test_implicitThisReferenceInInitializer_field', () {
5977 final __test = new CompileTimeErrorCodeTest(); 6681 final __test = new CompileTimeErrorCodeTest();
5978 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_fiel d); 6682 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_fiel d);
5979 }); 6683 });
6684 _ut.test('test_implicitThisReferenceInInitializer_field2', () {
6685 final __test = new CompileTimeErrorCodeTest();
6686 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_fiel d2);
6687 });
5980 _ut.test('test_implicitThisReferenceInInitializer_invocation', () { 6688 _ut.test('test_implicitThisReferenceInInitializer_invocation', () {
5981 final __test = new CompileTimeErrorCodeTest(); 6689 final __test = new CompileTimeErrorCodeTest();
5982 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_invo cation); 6690 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_invo cation);
5983 }); 6691 });
5984 _ut.test('test_implicitThisReferenceInInitializer_redirectingConstructorIn vocation', () { 6692 _ut.test('test_implicitThisReferenceInInitializer_redirectingConstructorIn vocation', () {
5985 final __test = new CompileTimeErrorCodeTest(); 6693 final __test = new CompileTimeErrorCodeTest();
5986 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_redi rectingConstructorInvocation); 6694 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_redi rectingConstructorInvocation);
5987 }); 6695 });
5988 _ut.test('test_implicitThisReferenceInInitializer_superConstructorInvocati on', () { 6696 _ut.test('test_implicitThisReferenceInInitializer_superConstructorInvocati on', () {
5989 final __test = new CompileTimeErrorCodeTest(); 6697 final __test = new CompileTimeErrorCodeTest();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
6026 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass); 6734 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass);
6027 }); 6735 });
6028 _ut.test('test_initializingFormalForNonExistantField_optional', () { 6736 _ut.test('test_initializingFormalForNonExistantField_optional', () {
6029 final __test = new CompileTimeErrorCodeTest(); 6737 final __test = new CompileTimeErrorCodeTest();
6030 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_o ptional); 6738 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_o ptional);
6031 }); 6739 });
6032 _ut.test('test_initializingFormalForNonExistantField_static', () { 6740 _ut.test('test_initializingFormalForNonExistantField_static', () {
6033 final __test = new CompileTimeErrorCodeTest(); 6741 final __test = new CompileTimeErrorCodeTest();
6034 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_s tatic); 6742 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_s tatic);
6035 }); 6743 });
6744 _ut.test('test_instanceMemberAccessFromStatic_field', () {
6745 final __test = new CompileTimeErrorCodeTest();
6746 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_field);
6747 });
6748 _ut.test('test_instanceMemberAccessFromStatic_getter', () {
6749 final __test = new CompileTimeErrorCodeTest();
6750 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_getter);
6751 });
6752 _ut.test('test_instanceMemberAccessFromStatic_method', () {
6753 final __test = new CompileTimeErrorCodeTest();
6754 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_method);
6755 });
6036 _ut.test('test_invalidConstructorName_notEnclosingClassName', () { 6756 _ut.test('test_invalidConstructorName_notEnclosingClassName', () {
6037 final __test = new CompileTimeErrorCodeTest(); 6757 final __test = new CompileTimeErrorCodeTest();
6038 runJUnitTest(__test, __test.test_invalidConstructorName_notEnclosingClas sName); 6758 runJUnitTest(__test, __test.test_invalidConstructorName_notEnclosingClas sName);
6039 }); 6759 });
6040 _ut.test('test_invalidFactoryNameNotAClass_notClassName', () { 6760 _ut.test('test_invalidFactoryNameNotAClass_notClassName', () {
6041 final __test = new CompileTimeErrorCodeTest(); 6761 final __test = new CompileTimeErrorCodeTest();
6042 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass_notClassNam e); 6762 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass_notClassNam e);
6043 }); 6763 });
6044 _ut.test('test_invalidFactoryNameNotAClass_notEnclosingClassName', () { 6764 _ut.test('test_invalidFactoryNameNotAClass_notEnclosingClassName', () {
6045 final __test = new CompileTimeErrorCodeTest(); 6765 final __test = new CompileTimeErrorCodeTest();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
6202 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_function ); 6922 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_function );
6203 }); 6923 });
6204 _ut.test('test_nativeFunctionBodyInNonSDKCode_method', () { 6924 _ut.test('test_nativeFunctionBodyInNonSDKCode_method', () {
6205 final __test = new CompileTimeErrorCodeTest(); 6925 final __test = new CompileTimeErrorCodeTest();
6206 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_method); 6926 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_method);
6207 }); 6927 });
6208 _ut.test('test_newWithInvalidTypeParameters', () { 6928 _ut.test('test_newWithInvalidTypeParameters', () {
6209 final __test = new CompileTimeErrorCodeTest(); 6929 final __test = new CompileTimeErrorCodeTest();
6210 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters); 6930 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters);
6211 }); 6931 });
6932 _ut.test('test_newWithInvalidTypeParameters_tooFew', () {
6933 final __test = new CompileTimeErrorCodeTest();
6934 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters_tooFew);
6935 });
6936 _ut.test('test_newWithInvalidTypeParameters_tooMany', () {
6937 final __test = new CompileTimeErrorCodeTest();
6938 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters_tooMany);
6939 });
6940 _ut.test('test_noDefaultSuperConstructorExplicit', () {
6941 final __test = new CompileTimeErrorCodeTest();
6942 runJUnitTest(__test, __test.test_noDefaultSuperConstructorExplicit);
6943 });
6944 _ut.test('test_noDefaultSuperConstructorImplicit_superHasParameters', () {
6945 final __test = new CompileTimeErrorCodeTest();
6946 runJUnitTest(__test, __test.test_noDefaultSuperConstructorImplicit_super HasParameters);
6947 });
6948 _ut.test('test_noDefaultSuperConstructorImplicit_superOnlyNamed', () {
6949 final __test = new CompileTimeErrorCodeTest();
6950 runJUnitTest(__test, __test.test_noDefaultSuperConstructorImplicit_super OnlyNamed);
6951 });
6212 _ut.test('test_nonConstCaseExpression', () { 6952 _ut.test('test_nonConstCaseExpression', () {
6213 final __test = new CompileTimeErrorCodeTest(); 6953 final __test = new CompileTimeErrorCodeTest();
6214 runJUnitTest(__test, __test.test_nonConstCaseExpression); 6954 runJUnitTest(__test, __test.test_nonConstCaseExpression);
6215 }); 6955 });
6216 _ut.test('test_nonConstListElement', () { 6956 _ut.test('test_nonConstListElement', () {
6217 final __test = new CompileTimeErrorCodeTest(); 6957 final __test = new CompileTimeErrorCodeTest();
6218 runJUnitTest(__test, __test.test_nonConstListElement); 6958 runJUnitTest(__test, __test.test_nonConstListElement);
6219 }); 6959 });
6220 _ut.test('test_nonConstMapAsExpressionStatement_begin', () { 6960 _ut.test('test_nonConstMapAsExpressionStatement_begin', () {
6221 final __test = new CompileTimeErrorCodeTest(); 6961 final __test = new CompileTimeErrorCodeTest();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
6286 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_position al); 7026 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_position al);
6287 }); 7027 });
6288 _ut.test('test_nonGenerativeConstructor_explicit', () { 7028 _ut.test('test_nonGenerativeConstructor_explicit', () {
6289 final __test = new CompileTimeErrorCodeTest(); 7029 final __test = new CompileTimeErrorCodeTest();
6290 runJUnitTest(__test, __test.test_nonGenerativeConstructor_explicit); 7030 runJUnitTest(__test, __test.test_nonGenerativeConstructor_explicit);
6291 }); 7031 });
6292 _ut.test('test_nonGenerativeConstructor_implicit', () { 7032 _ut.test('test_nonGenerativeConstructor_implicit', () {
6293 final __test = new CompileTimeErrorCodeTest(); 7033 final __test = new CompileTimeErrorCodeTest();
6294 runJUnitTest(__test, __test.test_nonGenerativeConstructor_implicit); 7034 runJUnitTest(__test, __test.test_nonGenerativeConstructor_implicit);
6295 }); 7035 });
7036 _ut.test('test_nonGenerativeConstructor_implicit2', () {
7037 final __test = new CompileTimeErrorCodeTest();
7038 runJUnitTest(__test, __test.test_nonGenerativeConstructor_implicit2);
7039 });
6296 _ut.test('test_notEnoughRequiredArguments_const', () { 7040 _ut.test('test_notEnoughRequiredArguments_const', () {
6297 final __test = new CompileTimeErrorCodeTest(); 7041 final __test = new CompileTimeErrorCodeTest();
6298 runJUnitTest(__test, __test.test_notEnoughRequiredArguments_const); 7042 runJUnitTest(__test, __test.test_notEnoughRequiredArguments_const);
6299 }); 7043 });
6300 _ut.test('test_optionalParameterInOperator_named', () { 7044 _ut.test('test_optionalParameterInOperator_named', () {
6301 final __test = new CompileTimeErrorCodeTest(); 7045 final __test = new CompileTimeErrorCodeTest();
6302 runJUnitTest(__test, __test.test_optionalParameterInOperator_named); 7046 runJUnitTest(__test, __test.test_optionalParameterInOperator_named);
6303 }); 7047 });
6304 _ut.test('test_optionalParameterInOperator_positional', () { 7048 _ut.test('test_optionalParameterInOperator_positional', () {
6305 final __test = new CompileTimeErrorCodeTest(); 7049 final __test = new CompileTimeErrorCodeTest();
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
6506 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator1); 7250 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator1);
6507 }); 7251 });
6508 _ut.test('test_wrongNumberOfParametersForOperator_minus', () { 7252 _ut.test('test_wrongNumberOfParametersForOperator_minus', () {
6509 final __test = new CompileTimeErrorCodeTest(); 7253 final __test = new CompileTimeErrorCodeTest();
6510 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_minu s); 7254 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_minu s);
6511 }); 7255 });
6512 _ut.test('test_wrongNumberOfParametersForOperator_tilde', () { 7256 _ut.test('test_wrongNumberOfParametersForOperator_tilde', () {
6513 final __test = new CompileTimeErrorCodeTest(); 7257 final __test = new CompileTimeErrorCodeTest();
6514 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_tild e); 7258 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_tild e);
6515 }); 7259 });
7260 _ut.test('test_wrongNumberOfParametersForSetter_function_named', () {
7261 final __test = new CompileTimeErrorCodeTest();
7262 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_named);
7263 });
7264 _ut.test('test_wrongNumberOfParametersForSetter_function_optional', () {
7265 final __test = new CompileTimeErrorCodeTest();
7266 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_optional);
7267 });
6516 _ut.test('test_wrongNumberOfParametersForSetter_function_tooFew', () { 7268 _ut.test('test_wrongNumberOfParametersForSetter_function_tooFew', () {
6517 final __test = new CompileTimeErrorCodeTest(); 7269 final __test = new CompileTimeErrorCodeTest();
6518 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_tooFew); 7270 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_tooFew);
6519 }); 7271 });
6520 _ut.test('test_wrongNumberOfParametersForSetter_function_tooMany', () { 7272 _ut.test('test_wrongNumberOfParametersForSetter_function_tooMany', () {
6521 final __test = new CompileTimeErrorCodeTest(); 7273 final __test = new CompileTimeErrorCodeTest();
6522 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_tooMany); 7274 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_tooMany);
6523 }); 7275 });
7276 _ut.test('test_wrongNumberOfParametersForSetter_method_named', () {
7277 final __test = new CompileTimeErrorCodeTest();
7278 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _named);
7279 });
7280 _ut.test('test_wrongNumberOfParametersForSetter_method_optional', () {
7281 final __test = new CompileTimeErrorCodeTest();
7282 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _optional);
7283 });
6524 _ut.test('test_wrongNumberOfParametersForSetter_method_tooFew', () { 7284 _ut.test('test_wrongNumberOfParametersForSetter_method_tooFew', () {
6525 final __test = new CompileTimeErrorCodeTest(); 7285 final __test = new CompileTimeErrorCodeTest();
6526 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooFew); 7286 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooFew);
6527 }); 7287 });
6528 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () { 7288 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () {
6529 final __test = new CompileTimeErrorCodeTest(); 7289 final __test = new CompileTimeErrorCodeTest();
6530 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooMany); 7290 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooMany);
6531 }); 7291 });
6532 }); 7292 });
6533 } 7293 }
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
7196 subclass.constructors = <ConstructorElement> [subConstructor]; 7956 subclass.constructors = <ConstructorElement> [subConstructor];
7197 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); 7957 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]);
7198 resolveInClass(invocation, subclass); 7958 resolveInClass(invocation, subclass);
7199 JUnitTestCase.assertEquals(superConstructor, invocation.element); 7959 JUnitTestCase.assertEquals(superConstructor, invocation.element);
7200 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a s NamedExpression)).name.label.element); 7960 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a s NamedExpression)).name.label.element);
7201 _listener.assertNoErrors(); 7961 _listener.assertNoErrors();
7202 } 7962 }
7203 7963
7204 /** 7964 /**
7205 * Create the resolver used by the tests. 7965 * Create the resolver used by the tests.
7966 *
7206 * @return the resolver that was created 7967 * @return the resolver that was created
7207 */ 7968 */
7208 ElementResolver createResolver() { 7969 ElementResolver createResolver() {
7209 AnalysisContextImpl context = new AnalysisContextImpl(); 7970 AnalysisContextImpl context = new AnalysisContextImpl();
7210 ContentCache contentCache = new ContentCache(); 7971 ContentCache contentCache = new ContentCache();
7211 SourceFactory sourceFactory = new SourceFactory.con1(contentCache, [new Dart UriResolver(DirectoryBasedDartSdk.defaultSdk)]); 7972 SourceFactory sourceFactory = new SourceFactory.con1(contentCache, [new Dart UriResolver(DirectoryBasedDartSdk.defaultSdk)]);
7212 context.sourceFactory = sourceFactory; 7973 context.sourceFactory = sourceFactory;
7213 FileBasedSource source = new FileBasedSource.con1(contentCache, FileUtilitie s2.createFile("/test.dart")); 7974 FileBasedSource source = new FileBasedSource.con1(contentCache, FileUtilitie s2.createFile("/test.dart"));
7214 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart"); 7975 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart");
7215 definingCompilationUnit.source = source; 7976 definingCompilationUnit.source = source;
7216 _definingLibrary = ElementFactory.library(context, "test"); 7977 _definingLibrary = ElementFactory.library(context, "test");
7217 _definingLibrary.definingCompilationUnit = definingCompilationUnit; 7978 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
7218 Library library = new Library(context, _listener, source); 7979 Library library = new Library(context, _listener, source);
7219 library.libraryElement = _definingLibrary; 7980 library.libraryElement = _definingLibrary;
7220 _visitor = new ResolverVisitor.con1(library, source, _typeProvider); 7981 _visitor = new ResolverVisitor.con1(library, source, _typeProvider);
7221 try { 7982 try {
7222 return _visitor.elementResolver_J2DAccessor as ElementResolver; 7983 return _visitor.elementResolver_J2DAccessor as ElementResolver;
7223 } catch (exception) { 7984 } catch (exception) {
7224 throw new IllegalArgumentException("Could not create resolver", exception) ; 7985 throw new IllegalArgumentException("Could not create resolver", exception) ;
7225 } 7986 }
7226 } 7987 }
7227 7988
7228 /** 7989 /**
7229 * Return the element associated with the label of the given statement after t he resolver has 7990 * Return the element associated with the label of the given statement after t he resolver has
7230 * resolved the statement. 7991 * resolved the statement.
7992 *
7231 * @param statement the statement to be resolved 7993 * @param statement the statement to be resolved
7232 * @param labelElement the label element to be defined in the statement's labe l scope 7994 * @param labelElement the label element to be defined in the statement's labe l scope
7233 * @return the element to which the statement's label was resolved 7995 * @return the element to which the statement's label was resolved
7234 */ 7996 */
7235 Element resolve(BreakStatement statement, LabelElementImpl labelElement) { 7997 Element resolve(BreakStatement statement, LabelElementImpl labelElement) {
7236 resolveStatement(statement, labelElement); 7998 resolveStatement(statement, labelElement);
7237 return statement.label.element; 7999 return statement.label.element;
7238 } 8000 }
7239 8001
7240 /** 8002 /**
7241 * Return the element associated with the label of the given statement after t he resolver has 8003 * Return the element associated with the label of the given statement after t he resolver has
7242 * resolved the statement. 8004 * resolved the statement.
8005 *
7243 * @param statement the statement to be resolved 8006 * @param statement the statement to be resolved
7244 * @param labelElement the label element to be defined in the statement's labe l scope 8007 * @param labelElement the label element to be defined in the statement's labe l scope
7245 * @return the element to which the statement's label was resolved 8008 * @return the element to which the statement's label was resolved
7246 */ 8009 */
7247 Element resolve3(ContinueStatement statement, LabelElementImpl labelElement) { 8010 Element resolve3(ContinueStatement statement, LabelElementImpl labelElement) {
7248 resolveStatement(statement, labelElement); 8011 resolveStatement(statement, labelElement);
7249 return statement.label.element; 8012 return statement.label.element;
7250 } 8013 }
7251 8014
7252 /** 8015 /**
7253 * Return the element associated with the given identifier after the resolver has resolved the 8016 * Return the element associated with the given identifier after the resolver has resolved the
7254 * identifier. 8017 * identifier.
8018 *
7255 * @param node the expression to be resolved 8019 * @param node the expression to be resolved
7256 * @param definedElements the elements that are to be defined in the scope in which the element is 8020 * @param definedElements the elements that are to be defined in the scope in which the element is
7257 * being resolved 8021 * being resolved
7258 * @return the element to which the expression was resolved 8022 * @return the element to which the expression was resolved
7259 */ 8023 */
7260 Element resolve4(Identifier node, List<Element> definedElements) { 8024 Element resolve4(Identifier node, List<Element> definedElements) {
7261 resolveNode(node, definedElements); 8025 resolveNode(node, definedElements);
7262 return node.element; 8026 return node.element;
7263 } 8027 }
7264 8028
7265 /** 8029 /**
7266 * Return the element associated with the given expression after the resolver has resolved the 8030 * Return the element associated with the given expression after the resolver has resolved the
7267 * expression. 8031 * expression.
8032 *
7268 * @param node the expression to be resolved 8033 * @param node the expression to be resolved
7269 * @param definedElements the elements that are to be defined in the scope in which the element is 8034 * @param definedElements the elements that are to be defined in the scope in which the element is
7270 * being resolved 8035 * being resolved
7271 * @return the element to which the expression was resolved 8036 * @return the element to which the expression was resolved
7272 */ 8037 */
7273 Element resolve5(IndexExpression node, List<Element> definedElements) { 8038 Element resolve5(IndexExpression node, List<Element> definedElements) {
7274 resolveNode(node, definedElements); 8039 resolveNode(node, definedElements);
7275 return node.element; 8040 return node.element;
7276 } 8041 }
7277 8042
7278 /** 8043 /**
7279 * Return the element associated with the given identifier after the resolver has resolved the 8044 * Return the element associated with the given identifier after the resolver has resolved the
7280 * identifier. 8045 * identifier.
8046 *
7281 * @param node the expression to be resolved 8047 * @param node the expression to be resolved
7282 * @param enclosingClass the element representing the class enclosing the iden tifier 8048 * @param enclosingClass the element representing the class enclosing the iden tifier
7283 * @return the element to which the expression was resolved 8049 * @return the element to which the expression was resolved
7284 */ 8050 */
7285 void resolveInClass(ASTNode node, ClassElement enclosingClass) { 8051 void resolveInClass(ASTNode node, ClassElement enclosingClass) {
7286 try { 8052 try {
7287 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope; 8053 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
7288 try { 8054 try {
7289 _visitor.enclosingClass_J2DAccessor = enclosingClass; 8055 _visitor.enclosingClass_J2DAccessor = enclosingClass;
7290 EnclosedScope innerScope = new ClassScope(outerScope, enclosingClass); 8056 EnclosedScope innerScope = new ClassScope(outerScope, enclosingClass);
7291 _visitor.nameScope_J2DAccessor = innerScope; 8057 _visitor.nameScope_J2DAccessor = innerScope;
7292 node.accept(_resolver); 8058 node.accept(_resolver);
7293 } finally { 8059 } finally {
7294 _visitor.enclosingClass_J2DAccessor = null; 8060 _visitor.enclosingClass_J2DAccessor = null;
7295 _visitor.nameScope_J2DAccessor = outerScope; 8061 _visitor.nameScope_J2DAccessor = outerScope;
7296 } 8062 }
7297 } catch (exception) { 8063 } catch (exception) {
7298 throw new IllegalArgumentException("Could not resolve node", exception); 8064 throw new IllegalArgumentException("Could not resolve node", exception);
7299 } 8065 }
7300 } 8066 }
7301 8067
7302 /** 8068 /**
7303 * Return the element associated with the given identifier after the resolver has resolved the 8069 * Return the element associated with the given identifier after the resolver has resolved the
7304 * identifier. 8070 * identifier.
8071 *
7305 * @param node the expression to be resolved 8072 * @param node the expression to be resolved
7306 * @param definedElements the elements that are to be defined in the scope in which the element is 8073 * @param definedElements the elements that are to be defined in the scope in which the element is
7307 * being resolved 8074 * being resolved
7308 * @return the element to which the expression was resolved 8075 * @return the element to which the expression was resolved
7309 */ 8076 */
7310 void resolveNode(ASTNode node, List<Element> definedElements) { 8077 void resolveNode(ASTNode node, List<Element> definedElements) {
7311 try { 8078 try {
7312 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope; 8079 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
7313 try { 8080 try {
7314 EnclosedScope innerScope = new EnclosedScope(outerScope); 8081 EnclosedScope innerScope = new EnclosedScope(outerScope);
7315 for (Element element in definedElements) { 8082 for (Element element in definedElements) {
7316 innerScope.define(element); 8083 innerScope.define(element);
7317 } 8084 }
7318 _visitor.nameScope_J2DAccessor = innerScope; 8085 _visitor.nameScope_J2DAccessor = innerScope;
7319 node.accept(_resolver); 8086 node.accept(_resolver);
7320 } finally { 8087 } finally {
7321 _visitor.nameScope_J2DAccessor = outerScope; 8088 _visitor.nameScope_J2DAccessor = outerScope;
7322 } 8089 }
7323 } catch (exception) { 8090 } catch (exception) {
7324 throw new IllegalArgumentException("Could not resolve node", exception); 8091 throw new IllegalArgumentException("Could not resolve node", exception);
7325 } 8092 }
7326 } 8093 }
7327 8094
7328 /** 8095 /**
7329 * Return the element associated with the label of the given statement after t he resolver has 8096 * Return the element associated with the label of the given statement after t he resolver has
7330 * resolved the statement. 8097 * resolved the statement.
8098 *
7331 * @param statement the statement to be resolved 8099 * @param statement the statement to be resolved
7332 * @param labelElement the label element to be defined in the statement's labe l scope 8100 * @param labelElement the label element to be defined in the statement's labe l scope
7333 * @return the element to which the statement's label was resolved 8101 * @return the element to which the statement's label was resolved
7334 */ 8102 */
7335 void resolveStatement(Statement statement, LabelElementImpl labelElement) { 8103 void resolveStatement(Statement statement, LabelElementImpl labelElement) {
7336 try { 8104 try {
7337 LabelScope outerScope = _visitor.labelScope_J2DAccessor as LabelScope; 8105 LabelScope outerScope = _visitor.labelScope_J2DAccessor as LabelScope;
7338 try { 8106 try {
7339 LabelScope innerScope; 8107 LabelScope innerScope;
7340 if (labelElement == null) { 8108 if (labelElement == null) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
7807 resolve(source); 8575 resolve(source);
7808 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOU S_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT , StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT, Static WarningCode.AMBIGUOUS_IMPORT]); 8576 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOU S_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT , StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT, Static WarningCode.AMBIGUOUS_IMPORT]);
7809 } 8577 }
7810 void test_ambiguousImport_typeArgument_annotation() { 8578 void test_ambiguousImport_typeArgument_annotation() {
7811 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "class A<T> {}", "A<N> f() {}"])); 8579 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "class A<T> {}", "A<N> f() {}"]));
7812 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"])); 8580 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
7813 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"])); 8581 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
7814 resolve(source); 8582 resolve(source);
7815 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]); 8583 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]);
7816 } 8584 }
8585 void test_argumentTypeNotAssignable_annotation_namedConstructor() {
8586 Source source = addSource(EngineTestCase.createSource(["class A {", " A.fro mInt(int p) {}", "}", "@A.fromInt('0')", "main() {", "}"]));
8587 resolve(source);
8588 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
8589 verify([source]);
8590 }
8591 void test_argumentTypeNotAssignable_annotation_unnamedConstructor() {
8592 Source source = addSource(EngineTestCase.createSource(["class A {", " A(int p) {}", "}", "@A('0')", "main() {", "}"]));
8593 resolve(source);
8594 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
8595 verify([source]);
8596 }
7817 void test_argumentTypeNotAssignable_binary() { 8597 void test_argumentTypeNotAssignable_binary() {
7818 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +(int p) {}", "}", "f(A a) {", " a + '0';", "}"])); 8598 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +(int p) {}", "}", "f(A a) {", " a + '0';", "}"]));
7819 resolve(source); 8599 resolve(source);
7820 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 8600 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7821 verify([source]); 8601 verify([source]);
7822 } 8602 }
7823 void test_argumentTypeNotAssignable_index() { 8603 void test_argumentTypeNotAssignable_index() {
7824 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor [](int index) {}", "}", "f(A a) {", " a['0'];", "}"])); 8604 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor [](int index) {}", "}", "f(A a) {", " a['0'];", "}"]));
7825 resolve(source); 8605 resolve(source);
7826 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 8606 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
8166 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]); 8946 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
8167 verify([source]); 8947 verify([source]);
8168 } 8948 }
8169 void test_instanceMethodNameCollidesWithSuperclassStatic_method2() { 8949 void test_instanceMethodNameCollidesWithSuperclassStatic_method2() {
8170 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c n () {}", "}", "class B extends A {", "}", "class C extends B {", " void n() {}", "}"])); 8950 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c n () {}", "}", "class B extends A {", "}", "class C extends B {", " void n() {}", "}"]));
8171 resolve(source); 8951 resolve(source);
8172 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]); 8952 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
8173 verify([source]); 8953 verify([source]);
8174 } 8954 }
8175 void test_instanceMethodNameCollidesWithSuperclassStatic_setter() { 8955 void test_instanceMethodNameCollidesWithSuperclassStatic_setter() {
8176 Source source = addSource(EngineTestCase.createSource(["class A {", " int i = 0;", " static set n(int x) {i = x;}", "}", "class B extends A {", " void n( ) {}", "}"])); 8956 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c set n(int x) {}", "}", "class B extends A {", " void n() {}", "}"]));
8177 resolve(source); 8957 resolve(source);
8178 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]); 8958 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
8179 verify([source]); 8959 verify([source]);
8180 } 8960 }
8181 void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() { 8961 void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() {
8182 Source source = addSource(EngineTestCase.createSource(["class A {", " int i = 0;", " static set n(int x) {i = x;}", "}", "class B extends A {", "}", "clas s C extends B {", " void n() {}", "}"])); 8962 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c set n(int x) {}", "}", "class B extends A {", "}", "class C extends B {", " v oid n() {}", "}"]));
8183 resolve(source); 8963 resolve(source);
8184 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]); 8964 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
8185 verify([source]); 8965 verify([source]);
8186 } 8966 }
8187 void test_invalidGetterOverrideReturnType() { 8967 void test_invalidGetterOverrideReturnType() {
8188 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", "}", "class B extends A {", " String get g { return 'a'; } ", "}"])); 8968 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", "}", "class B extends A {", " String get g { return 'a'; } ", "}"]));
8189 resolve(source); 8969 resolve(source);
8190 assertErrors([StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]); 8970 assertErrors([StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]);
8191 verify([source]); 8971 verify([source]);
8192 } 8972 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
8279 resolve(source); 9059 resolve(source);
8280 assertErrors([StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]); 9060 assertErrors([StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]);
8281 verify([source]); 9061 verify([source]);
8282 } 9062 }
8283 void test_newWithNonType() { 9063 void test_newWithNonType() {
8284 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f () {", " var a = new A();", "}"])); 9064 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f () {", " var a = new A();", "}"]));
8285 resolve(source); 9065 resolve(source);
8286 assertErrors([StaticWarningCode.NEW_WITH_NON_TYPE]); 9066 assertErrors([StaticWarningCode.NEW_WITH_NON_TYPE]);
8287 verify([source]); 9067 verify([source]);
8288 } 9068 }
9069 void test_newWithNonType_fromLibrary() {
9070 Source source1 = addSource2("lib.dart", "");
9071 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource(["impor t 'lib.dart' as lib;", "void f() {", " var a = new lib.A();", "}"]));
9072 resolve(source1);
9073 resolve(source2);
9074 assertErrors([StaticWarningCode.NEW_WITH_NON_TYPE]);
9075 verify([source1]);
9076 }
8289 void test_newWithUndefinedConstructor() { 9077 void test_newWithUndefinedConstructor() {
8290 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A.name();", "}"])); 9078 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A.name();", "}"]));
8291 resolve(source); 9079 resolve(source);
8292 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]); 9080 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]);
8293 } 9081 }
8294 void test_newWithUndefinedConstructorDefault() { 9082 void test_newWithUndefinedConstructorDefault() {
8295 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam e() {}", "}", "f() {", " new A();", "}"])); 9083 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam e() {}", "}", "f() {", " new A();", "}"]));
8296 resolve(source); 9084 resolve(source);
8297 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]); 9085 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]);
8298 verify([source]); 9086 verify([source]);
8299 } 9087 }
8300 void test_noDefaultSuperConstructorExplicit() {
8301 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p); ", "}", "class B extends A {", " B() {}", "}"]));
8302 resolve(source);
8303 assertErrors([StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
8304 verify([source]);
8305 }
8306 void test_noDefaultSuperConstructorImplicit_superHasParameters() {
8307 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p); ", "}", "class B extends A {", "}"]));
8308 resolve(source);
8309 assertErrors([StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
8310 verify([source]);
8311 }
8312 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() {
8313 Source source = addSource(EngineTestCase.createSource(["class A { A.named() {} }", "class B extends A {}"]));
8314 resolve(source);
8315 assertErrors([StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
8316 verify([source]);
8317 }
8318 void test_nonAbstractClassInheritsAbstractMemberFivePlus() { 9088 void test_nonAbstractClassInheritsAbstractMemberFivePlus() {
8319 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", " q();", "}", "class C extends A {", " }"])); 9089 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", " q();", "}", "class C extends A {", " }"]));
8320 resolve(source); 9090 resolve(source);
8321 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FIVE_PLUS]); 9091 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FIVE_PLUS]);
8322 verify([source]); 9092 verify([source]);
8323 } 9093 }
8324 void test_nonAbstractClassInheritsAbstractMemberFour() { 9094 void test_nonAbstractClassInheritsAbstractMemberFour() {
8325 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", "}", "class C extends A {", "}"])); 9095 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", "}", "class C extends A {", "}"]));
8326 resolve(source); 9096 resolve(source);
8327 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FOUR]); 9097 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FOUR]);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
8451 void test_redirectToMissingConstructor_named() { 9221 void test_redirectToMissingConstructor_named() {
8452 Source source = addSource(EngineTestCase.createSource(["class A implements B {", " A() {}", "}", "class B {", " B() = A.name;", "}"])); 9222 Source source = addSource(EngineTestCase.createSource(["class A implements B {", " A() {}", "}", "class B {", " B() = A.name;", "}"]));
8453 resolve(source); 9223 resolve(source);
8454 assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); 9224 assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
8455 } 9225 }
8456 void test_redirectToMissingConstructor_unnamed() { 9226 void test_redirectToMissingConstructor_unnamed() {
8457 Source source = addSource(EngineTestCase.createSource(["class A implements B {", " A.name() {}", "}", "class B {", " B() = A;", "}"])); 9227 Source source = addSource(EngineTestCase.createSource(["class A implements B {", " A.name() {}", "}", "class B {", " B() = A;", "}"]));
8458 resolve(source); 9228 resolve(source);
8459 assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); 9229 assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
8460 } 9230 }
8461 void test_redirectToNonClass() { 9231 void test_redirectToNonClass_notAType() {
9232 Source source = addSource(EngineTestCase.createSource(["class B {", " int A ;", " B() = A;", "}"]));
9233 resolve(source);
9234 assertErrors([StaticWarningCode.REDIRECT_TO_NON_CLASS]);
9235 verify([source]);
9236 }
9237 void test_redirectToNonClass_undefinedIdentifier() {
8462 Source source = addSource(EngineTestCase.createSource(["class B {", " B() = A;", "}"])); 9238 Source source = addSource(EngineTestCase.createSource(["class B {", " B() = A;", "}"]));
8463 resolve(source); 9239 resolve(source);
8464 assertErrors([StaticWarningCode.REDIRECT_TO_NON_CLASS]); 9240 assertErrors([StaticWarningCode.REDIRECT_TO_NON_CLASS]);
8465 verify([source]); 9241 verify([source]);
8466 } 9242 }
8467 void test_returnWithoutValue() { 9243 void test_returnWithoutValue() {
8468 Source source = addSource(EngineTestCase.createSource(["int f() { return; }" ])); 9244 Source source = addSource(EngineTestCase.createSource(["int f() { return; }" ]));
8469 resolve(source); 9245 resolve(source);
8470 assertErrors([StaticWarningCode.RETURN_WITHOUT_VALUE]); 9246 assertErrors([StaticWarningCode.RETURN_WITHOUT_VALUE]);
8471 verify([source]); 9247 verify([source]);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
8520 void test_undefinedClass_variableDeclaration() { 9296 void test_undefinedClass_variableDeclaration() {
8521 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"])); 9297 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"]));
8522 resolve(source); 9298 resolve(source);
8523 assertErrors([StaticWarningCode.UNDEFINED_CLASS]); 9299 assertErrors([StaticWarningCode.UNDEFINED_CLASS]);
8524 } 9300 }
8525 void test_undefinedClassBoolean_variableDeclaration() { 9301 void test_undefinedClassBoolean_variableDeclaration() {
8526 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"] )); 9302 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"] ));
8527 resolve(source); 9303 resolve(source);
8528 assertErrors([StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); 9304 assertErrors([StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]);
8529 } 9305 }
9306 void test_undefinedGetter_fromLibrary() {
9307 Source source1 = addSource2("lib.dart", "");
9308 Source source2 = addSource2("lib2.dart", EngineTestCase.createSource(["impor t 'lib.dart' as lib;", "void f() {", " var g = lib.gg;", "}"]));
9309 resolve(source1);
9310 resolve(source2);
9311 assertErrors([StaticWarningCode.UNDEFINED_GETTER]);
9312 verify([source1]);
9313 }
8530 void test_undefinedIdentifier_initializer() { 9314 void test_undefinedIdentifier_initializer() {
8531 Source source = addSource(EngineTestCase.createSource(["var a = b;"])); 9315 Source source = addSource(EngineTestCase.createSource(["var a = b;"]));
8532 resolve(source); 9316 resolve(source);
8533 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); 9317 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
8534 } 9318 }
8535 void test_undefinedIdentifier_metadata() { 9319 void test_undefinedIdentifier_metadata() {
8536 Source source = addSource(EngineTestCase.createSource(["@undefined class A { }"])); 9320 Source source = addSource(EngineTestCase.createSource(["@undefined class A { }"]));
8537 resolve(source); 9321 resolve(source);
8538 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); 9322 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
8539 } 9323 }
(...skipping 10 matching lines...) Expand all
8550 static dartSuite() { 9334 static dartSuite() {
8551 _ut.group('StaticWarningCodeTest', () { 9335 _ut.group('StaticWarningCodeTest', () {
8552 _ut.test('test_ambiguousImport_typeAnnotation', () { 9336 _ut.test('test_ambiguousImport_typeAnnotation', () {
8553 final __test = new StaticWarningCodeTest(); 9337 final __test = new StaticWarningCodeTest();
8554 runJUnitTest(__test, __test.test_ambiguousImport_typeAnnotation); 9338 runJUnitTest(__test, __test.test_ambiguousImport_typeAnnotation);
8555 }); 9339 });
8556 _ut.test('test_ambiguousImport_typeArgument_annotation', () { 9340 _ut.test('test_ambiguousImport_typeArgument_annotation', () {
8557 final __test = new StaticWarningCodeTest(); 9341 final __test = new StaticWarningCodeTest();
8558 runJUnitTest(__test, __test.test_ambiguousImport_typeArgument_annotation ); 9342 runJUnitTest(__test, __test.test_ambiguousImport_typeArgument_annotation );
8559 }); 9343 });
9344 _ut.test('test_argumentTypeNotAssignable_annotation_namedConstructor', () {
9345 final __test = new StaticWarningCodeTest();
9346 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_annotation_na medConstructor);
9347 });
9348 _ut.test('test_argumentTypeNotAssignable_annotation_unnamedConstructor', ( ) {
9349 final __test = new StaticWarningCodeTest();
9350 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_annotation_un namedConstructor);
9351 });
8560 _ut.test('test_argumentTypeNotAssignable_binary', () { 9352 _ut.test('test_argumentTypeNotAssignable_binary', () {
8561 final __test = new StaticWarningCodeTest(); 9353 final __test = new StaticWarningCodeTest();
8562 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_binary); 9354 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_binary);
8563 }); 9355 });
8564 _ut.test('test_argumentTypeNotAssignable_index', () { 9356 _ut.test('test_argumentTypeNotAssignable_index', () {
8565 final __test = new StaticWarningCodeTest(); 9357 final __test = new StaticWarningCodeTest();
8566 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_index); 9358 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_index);
8567 }); 9359 });
8568 _ut.test('test_argumentTypeNotAssignable_invocation_callParameter', () { 9360 _ut.test('test_argumentTypeNotAssignable_invocation_callParameter', () {
8569 final __test = new StaticWarningCodeTest(); 9361 final __test = new StaticWarningCodeTest();
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
8862 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_topLevel); 9654 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_topLevel);
8863 }); 9655 });
8864 _ut.test('test_newWithAbstractClass', () { 9656 _ut.test('test_newWithAbstractClass', () {
8865 final __test = new StaticWarningCodeTest(); 9657 final __test = new StaticWarningCodeTest();
8866 runJUnitTest(__test, __test.test_newWithAbstractClass); 9658 runJUnitTest(__test, __test.test_newWithAbstractClass);
8867 }); 9659 });
8868 _ut.test('test_newWithNonType', () { 9660 _ut.test('test_newWithNonType', () {
8869 final __test = new StaticWarningCodeTest(); 9661 final __test = new StaticWarningCodeTest();
8870 runJUnitTest(__test, __test.test_newWithNonType); 9662 runJUnitTest(__test, __test.test_newWithNonType);
8871 }); 9663 });
9664 _ut.test('test_newWithNonType_fromLibrary', () {
9665 final __test = new StaticWarningCodeTest();
9666 runJUnitTest(__test, __test.test_newWithNonType_fromLibrary);
9667 });
8872 _ut.test('test_newWithUndefinedConstructor', () { 9668 _ut.test('test_newWithUndefinedConstructor', () {
8873 final __test = new StaticWarningCodeTest(); 9669 final __test = new StaticWarningCodeTest();
8874 runJUnitTest(__test, __test.test_newWithUndefinedConstructor); 9670 runJUnitTest(__test, __test.test_newWithUndefinedConstructor);
8875 }); 9671 });
8876 _ut.test('test_newWithUndefinedConstructorDefault', () { 9672 _ut.test('test_newWithUndefinedConstructorDefault', () {
8877 final __test = new StaticWarningCodeTest(); 9673 final __test = new StaticWarningCodeTest();
8878 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault); 9674 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault);
8879 }); 9675 });
8880 _ut.test('test_noDefaultSuperConstructorExplicit', () {
8881 final __test = new StaticWarningCodeTest();
8882 runJUnitTest(__test, __test.test_noDefaultSuperConstructorExplicit);
8883 });
8884 _ut.test('test_noDefaultSuperConstructorImplicit_superHasParameters', () {
8885 final __test = new StaticWarningCodeTest();
8886 runJUnitTest(__test, __test.test_noDefaultSuperConstructorImplicit_super HasParameters);
8887 });
8888 _ut.test('test_noDefaultSuperConstructorImplicit_superOnlyNamed', () {
8889 final __test = new StaticWarningCodeTest();
8890 runJUnitTest(__test, __test.test_noDefaultSuperConstructorImplicit_super OnlyNamed);
8891 });
8892 _ut.test('test_nonAbstractClassInheritsAbstractMemberFivePlus', () { 9676 _ut.test('test_nonAbstractClassInheritsAbstractMemberFivePlus', () {
8893 final __test = new StaticWarningCodeTest(); 9677 final __test = new StaticWarningCodeTest();
8894 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF ivePlus); 9678 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF ivePlus);
8895 }); 9679 });
8896 _ut.test('test_nonAbstractClassInheritsAbstractMemberFour', () { 9680 _ut.test('test_nonAbstractClassInheritsAbstractMemberFour', () {
8897 final __test = new StaticWarningCodeTest(); 9681 final __test = new StaticWarningCodeTest();
8898 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF our); 9682 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF our);
8899 }); 9683 });
8900 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterf ace', () { 9684 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterf ace', () {
8901 final __test = new StaticWarningCodeTest(); 9685 final __test = new StaticWarningCodeTest();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
8978 runJUnitTest(__test, __test.test_redirectToInvalidReturnType); 9762 runJUnitTest(__test, __test.test_redirectToInvalidReturnType);
8979 }); 9763 });
8980 _ut.test('test_redirectToMissingConstructor_named', () { 9764 _ut.test('test_redirectToMissingConstructor_named', () {
8981 final __test = new StaticWarningCodeTest(); 9765 final __test = new StaticWarningCodeTest();
8982 runJUnitTest(__test, __test.test_redirectToMissingConstructor_named); 9766 runJUnitTest(__test, __test.test_redirectToMissingConstructor_named);
8983 }); 9767 });
8984 _ut.test('test_redirectToMissingConstructor_unnamed', () { 9768 _ut.test('test_redirectToMissingConstructor_unnamed', () {
8985 final __test = new StaticWarningCodeTest(); 9769 final __test = new StaticWarningCodeTest();
8986 runJUnitTest(__test, __test.test_redirectToMissingConstructor_unnamed); 9770 runJUnitTest(__test, __test.test_redirectToMissingConstructor_unnamed);
8987 }); 9771 });
8988 _ut.test('test_redirectToNonClass', () { 9772 _ut.test('test_redirectToNonClass_notAType', () {
8989 final __test = new StaticWarningCodeTest(); 9773 final __test = new StaticWarningCodeTest();
8990 runJUnitTest(__test, __test.test_redirectToNonClass); 9774 runJUnitTest(__test, __test.test_redirectToNonClass_notAType);
9775 });
9776 _ut.test('test_redirectToNonClass_undefinedIdentifier', () {
9777 final __test = new StaticWarningCodeTest();
9778 runJUnitTest(__test, __test.test_redirectToNonClass_undefinedIdentifier) ;
8991 }); 9779 });
8992 _ut.test('test_returnWithoutValue', () { 9780 _ut.test('test_returnWithoutValue', () {
8993 final __test = new StaticWarningCodeTest(); 9781 final __test = new StaticWarningCodeTest();
8994 runJUnitTest(__test, __test.test_returnWithoutValue); 9782 runJUnitTest(__test, __test.test_returnWithoutValue);
8995 }); 9783 });
8996 _ut.test('test_staticAccessToInstanceMember_method_invocation', () { 9784 _ut.test('test_staticAccessToInstanceMember_method_invocation', () {
8997 final __test = new StaticWarningCodeTest(); 9785 final __test = new StaticWarningCodeTest();
8998 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method_inv ocation); 9786 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method_inv ocation);
8999 }); 9787 });
9000 _ut.test('test_staticAccessToInstanceMember_method_reference', () { 9788 _ut.test('test_staticAccessToInstanceMember_method_reference', () {
(...skipping 25 matching lines...) Expand all
9026 runJUnitTest(__test, __test.test_undefinedClassBoolean_variableDeclarati on); 9814 runJUnitTest(__test, __test.test_undefinedClassBoolean_variableDeclarati on);
9027 }); 9815 });
9028 _ut.test('test_undefinedClass_instanceCreation', () { 9816 _ut.test('test_undefinedClass_instanceCreation', () {
9029 final __test = new StaticWarningCodeTest(); 9817 final __test = new StaticWarningCodeTest();
9030 runJUnitTest(__test, __test.test_undefinedClass_instanceCreation); 9818 runJUnitTest(__test, __test.test_undefinedClass_instanceCreation);
9031 }); 9819 });
9032 _ut.test('test_undefinedClass_variableDeclaration', () { 9820 _ut.test('test_undefinedClass_variableDeclaration', () {
9033 final __test = new StaticWarningCodeTest(); 9821 final __test = new StaticWarningCodeTest();
9034 runJUnitTest(__test, __test.test_undefinedClass_variableDeclaration); 9822 runJUnitTest(__test, __test.test_undefinedClass_variableDeclaration);
9035 }); 9823 });
9824 _ut.test('test_undefinedGetter_fromLibrary', () {
9825 final __test = new StaticWarningCodeTest();
9826 runJUnitTest(__test, __test.test_undefinedGetter_fromLibrary);
9827 });
9036 _ut.test('test_undefinedIdentifier_initializer', () { 9828 _ut.test('test_undefinedIdentifier_initializer', () {
9037 final __test = new StaticWarningCodeTest(); 9829 final __test = new StaticWarningCodeTest();
9038 runJUnitTest(__test, __test.test_undefinedIdentifier_initializer); 9830 runJUnitTest(__test, __test.test_undefinedIdentifier_initializer);
9039 }); 9831 });
9040 _ut.test('test_undefinedIdentifier_metadata', () { 9832 _ut.test('test_undefinedIdentifier_metadata', () {
9041 final __test = new StaticWarningCodeTest(); 9833 final __test = new StaticWarningCodeTest();
9042 runJUnitTest(__test, __test.test_undefinedIdentifier_metadata); 9834 runJUnitTest(__test, __test.test_undefinedIdentifier_metadata);
9043 }); 9835 });
9044 _ut.test('test_undefinedIdentifier_methodInvocation', () { 9836 _ut.test('test_undefinedIdentifier_methodInvocation', () {
9045 final __test = new StaticWarningCodeTest(); 9837 final __test = new StaticWarningCodeTest();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
9148 * The type representing the built-in type 'StackTrace'. 9940 * The type representing the built-in type 'StackTrace'.
9149 */ 9941 */
9150 InterfaceType _stackTraceType; 9942 InterfaceType _stackTraceType;
9151 9943
9152 /** 9944 /**
9153 * The type representing the built-in type 'String'. 9945 * The type representing the built-in type 'String'.
9154 */ 9946 */
9155 InterfaceType _stringType; 9947 InterfaceType _stringType;
9156 9948
9157 /** 9949 /**
9950 * The type representing the built-in type 'Symbol'.
9951 */
9952 InterfaceType _symbolType;
9953
9954 /**
9158 * The type representing the built-in type 'Type'. 9955 * The type representing the built-in type 'Type'.
9159 */ 9956 */
9160 InterfaceType _typeType; 9957 InterfaceType _typeType;
9161 InterfaceType get boolType { 9958 InterfaceType get boolType {
9162 if (_boolType == null) { 9959 if (_boolType == null) {
9163 _boolType = ElementFactory.classElement2("bool", []).type; 9960 _boolType = ElementFactory.classElement2("bool", []).type;
9164 } 9961 }
9165 return _boolType; 9962 return _boolType;
9166 } 9963 }
9167 Type2 get bottomType { 9964 Type2 get bottomType {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
9263 } 10060 }
9264 InterfaceType get stringType { 10061 InterfaceType get stringType {
9265 if (_stringType == null) { 10062 if (_stringType == null) {
9266 _stringType = ElementFactory.classElement2("String", []).type; 10063 _stringType = ElementFactory.classElement2("String", []).type;
9267 ClassElementImpl stringElement = _stringType.element as ClassElementImpl; 10064 ClassElementImpl stringElement = _stringType.element as ClassElementImpl;
9268 stringElement.accessors = <PropertyAccessorElement> [ElementFactory.getter Element("isEmpty", false, boolType), ElementFactory.getterElement("length", fals e, intType), ElementFactory.getterElement("codeUnits", false, listType.substitut e5(<Type2> [intType]))]; 10065 stringElement.accessors = <PropertyAccessorElement> [ElementFactory.getter Element("isEmpty", false, boolType), ElementFactory.getterElement("length", fals e, intType), ElementFactory.getterElement("codeUnits", false, listType.substitut e5(<Type2> [intType]))];
9269 stringElement.methods = <MethodElement> [ElementFactory.methodElement("toL owerCase", _stringType, []), ElementFactory.methodElement("toUpperCase", _string Type, [])]; 10066 stringElement.methods = <MethodElement> [ElementFactory.methodElement("toL owerCase", _stringType, []), ElementFactory.methodElement("toUpperCase", _string Type, [])];
9270 } 10067 }
9271 return _stringType; 10068 return _stringType;
9272 } 10069 }
10070 InterfaceType get symbolType {
10071 if (_symbolType == null) {
10072 _symbolType = ElementFactory.classElement2("Symbol", []).type;
10073 }
10074 return _symbolType;
10075 }
9273 InterfaceType get typeType { 10076 InterfaceType get typeType {
9274 if (_typeType == null) { 10077 if (_typeType == null) {
9275 _typeType = ElementFactory.classElement2("Type", []).type; 10078 _typeType = ElementFactory.classElement2("Type", []).type;
9276 } 10079 }
9277 return _typeType; 10080 return _typeType;
9278 } 10081 }
9279 10082
9280 /** 10083 /**
9281 * Initialize the numeric types. They are created as a group so that we can (a ) create the right 10084 * Initialize the numeric types. They are created as a group so that we can (a ) create the right
9282 * hierarchy and (b) add members to them. 10085 * hierarchy and (b) add members to them.
(...skipping 16 matching lines...) Expand all
9299 for (int i = 0; i < fieldCount; i++) { 10102 for (int i = 0; i < fieldCount; i++) {
9300 accessors[i] = fields[i].getter; 10103 accessors[i] = fields[i].getter;
9301 } 10104 }
9302 doubleElement.accessors = accessors; 10105 doubleElement.accessors = accessors;
9303 doubleElement.methods = <MethodElement> [ElementFactory.methodElement("remai nder", _doubleType, [_numType]), ElementFactory.methodElement("+", _doubleType, [_numType]), ElementFactory.methodElement("-", _doubleType, [_numType]), Element Factory.methodElement("*", _doubleType, [_numType]), ElementFactory.methodElemen t("%", _doubleType, [_numType]), ElementFactory.methodElement("/", _doubleType, [_numType]), ElementFactory.methodElement("~/", _doubleType, [_numType]), Elemen tFactory.methodElement("-", _doubleType, []), ElementFactory.methodElement("abs" , _doubleType, []), ElementFactory.methodElement("round", _doubleType, []), Elem entFactory.methodElement("floor", _doubleType, []), ElementFactory.methodElement ("ceil", _doubleType, []), ElementFactory.methodElement("truncate", _doubleType, []), ElementFactory.methodElement("toString", _stringType, [])]; 10106 doubleElement.methods = <MethodElement> [ElementFactory.methodElement("remai nder", _doubleType, [_numType]), ElementFactory.methodElement("+", _doubleType, [_numType]), ElementFactory.methodElement("-", _doubleType, [_numType]), Element Factory.methodElement("*", _doubleType, [_numType]), ElementFactory.methodElemen t("%", _doubleType, [_numType]), ElementFactory.methodElement("/", _doubleType, [_numType]), ElementFactory.methodElement("~/", _doubleType, [_numType]), Elemen tFactory.methodElement("-", _doubleType, []), ElementFactory.methodElement("abs" , _doubleType, []), ElementFactory.methodElement("round", _doubleType, []), Elem entFactory.methodElement("floor", _doubleType, []), ElementFactory.methodElement ("ceil", _doubleType, []), ElementFactory.methodElement("truncate", _doubleType, []), ElementFactory.methodElement("toString", _stringType, [])];
9304 } 10107 }
9305 10108
9306 /** 10109 /**
9307 * Given a class element representing a class with type parameters, propagate those type 10110 * Given a class element representing a class with type parameters, propagate those type
9308 * parameters to all of the accessors, methods and constructors defined for th e class. 10111 * parameters to all of the accessors, methods and constructors defined for th e class.
10112 *
9309 * @param classElement the element representing the class with type parameters 10113 * @param classElement the element representing the class with type parameters
9310 */ 10114 */
9311 void propagateTypeArguments(ClassElementImpl classElement) { 10115 void propagateTypeArguments(ClassElementImpl classElement) {
9312 List<Type2> typeArguments = TypeVariableTypeImpl.getTypes(classElement.typeV ariables); 10116 List<Type2> typeArguments = TypeVariableTypeImpl.getTypes(classElement.typeV ariables);
9313 for (PropertyAccessorElement accessor in classElement.accessors) { 10117 for (PropertyAccessorElement accessor in classElement.accessors) {
9314 FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl; 10118 FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl;
9315 functionType.typeArguments = typeArguments; 10119 functionType.typeArguments = typeArguments;
9316 } 10120 }
9317 for (MethodElement method in classElement.methods) { 10121 for (MethodElement method in classElement.methods) {
9318 FunctionTypeImpl functionType = method.type as FunctionTypeImpl; 10122 FunctionTypeImpl functionType = method.type as FunctionTypeImpl;
9319 functionType.typeArguments = typeArguments; 10123 functionType.typeArguments = typeArguments;
9320 } 10124 }
9321 for (ConstructorElement constructor in classElement.constructors) { 10125 for (ConstructorElement constructor in classElement.constructors) {
9322 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl; 10126 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl;
9323 functionType.typeArguments = typeArguments; 10127 functionType.typeArguments = typeArguments;
9324 } 10128 }
9325 } 10129 }
9326 } 10130 }
9327 /** 10131 /**
9328 * The class `AnalysisContextFactory` defines utility methods used to create ana lysis contexts 10132 * The class `AnalysisContextFactory` defines utility methods used to create ana lysis contexts
9329 * for testing purposes. 10133 * for testing purposes.
9330 */ 10134 */
9331 class AnalysisContextFactory { 10135 class AnalysisContextFactory {
9332 10136
9333 /** 10137 /**
9334 * Create an analysis context that has a fake core library already resolved. 10138 * Create an analysis context that has a fake core library already resolved.
10139 *
9335 * @return the analysis context that was created 10140 * @return the analysis context that was created
9336 */ 10141 */
9337 static AnalysisContextImpl contextWithCore() { 10142 static AnalysisContextImpl contextWithCore() {
9338 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl; 10143 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl;
9339 SourceFactory sourceFactory = sdkContext.sourceFactory; 10144 SourceFactory sourceFactory = sdkContext.sourceFactory;
9340 TestTypeProvider provider = new TestTypeProvider(); 10145 TestTypeProvider provider = new TestTypeProvider();
9341 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art"); 10146 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art");
9342 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 10147 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
9343 sdkContext.setContents(coreSource, ""); 10148 sdkContext.setContents(coreSource, "");
9344 coreUnit.source = coreSource; 10149 coreUnit.source = coreSource;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
9528 } 10333 }
9529 _jtd_constructor_361_impl() { 10334 _jtd_constructor_361_impl() {
9530 _jtd_constructor_362_impl(null); 10335 _jtd_constructor_362_impl(null);
9531 } 10336 }
9532 10337
9533 /** 10338 /**
9534 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST 10339 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST
9535 * structures that are expected to have been resolved have an element associat ed with them. Nodes 10340 * structures that are expected to have been resolved have an element associat ed with them. Nodes
9536 * in the set of known exceptions are not expected to have been resolved, even if they normally 10341 * in the set of known exceptions are not expected to have been resolved, even if they normally
9537 * would have been expected to have been resolved. 10342 * would have been expected to have been resolved.
10343 *
9538 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should 10344 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should
9539 * therefore not cause the test to fail 10345 * therefore not cause the test to fail
9540 */ 10346 **/
9541 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) { 10347 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) {
9542 _jtd_constructor_362_impl(knownExceptions2); 10348 _jtd_constructor_362_impl(knownExceptions2);
9543 } 10349 }
9544 _jtd_constructor_362_impl(Set<ASTNode> knownExceptions2) { 10350 _jtd_constructor_362_impl(Set<ASTNode> knownExceptions2) {
9545 this._knownExceptions = knownExceptions2; 10351 this._knownExceptions = knownExceptions2;
9546 } 10352 }
9547 10353
9548 /** 10354 /**
9549 * Assert that all of the visited identifiers were resolved. 10355 * Assert that all of the visited identifiers were resolved.
9550 */ 10356 */
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
10276 } 11082 }
10277 void test_visitThrowExpression_withValue() { 11083 void test_visitThrowExpression_withValue() {
10278 Expression node = ASTFactory.throwExpression2(resolvedInteger(0)); 11084 Expression node = ASTFactory.throwExpression2(resolvedInteger(0));
10279 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); 11085 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node));
10280 _listener.assertNoErrors(); 11086 _listener.assertNoErrors();
10281 } 11087 }
10282 11088
10283 /** 11089 /**
10284 * Return the type associated with the given expression after the static type analyzer has 11090 * Return the type associated with the given expression after the static type analyzer has
10285 * computed a type for it. 11091 * computed a type for it.
11092 *
10286 * @param node the expression with which the type is associated 11093 * @param node the expression with which the type is associated
10287 * @return the type associated with the expression 11094 * @return the type associated with the expression
10288 */ 11095 */
10289 Type2 analyze(Expression node) => analyze2(node, null); 11096 Type2 analyze(Expression node) => analyze2(node, null);
10290 11097
10291 /** 11098 /**
10292 * Return the type associated with the given expression after the static type analyzer has 11099 * Return the type associated with the given expression after the static type analyzer has
10293 * computed a type for it. 11100 * computed a type for it.
11101 *
10294 * @param node the expression with which the type is associated 11102 * @param node the expression with which the type is associated
10295 * @param thisType the type of 'this' 11103 * @param thisType the type of 'this'
10296 * @return the type associated with the expression 11104 * @return the type associated with the expression
10297 */ 11105 */
10298 Type2 analyze2(Expression node, InterfaceType thisType) { 11106 Type2 analyze2(Expression node, InterfaceType thisType) {
10299 try { 11107 try {
10300 _analyzer.thisType_J2DAccessor = thisType; 11108 _analyzer.thisType_J2DAccessor = thisType;
10301 } catch (exception) { 11109 } catch (exception) {
10302 throw new IllegalArgumentException("Could not set type of 'this'", excepti on); 11110 throw new IllegalArgumentException("Could not set type of 'this'", excepti on);
10303 } 11111 }
10304 node.accept(_analyzer); 11112 node.accept(_analyzer);
10305 return node.staticType; 11113 return node.staticType;
10306 } 11114 }
10307 11115
10308 /** 11116 /**
10309 * Return the type associated with the given parameter after the static type a nalyzer has computed 11117 * Return the type associated with the given parameter after the static type a nalyzer has computed
10310 * a type for it. 11118 * a type for it.
11119 *
10311 * @param node the parameter with which the type is associated 11120 * @param node the parameter with which the type is associated
10312 * @return the type associated with the parameter 11121 * @return the type associated with the parameter
10313 */ 11122 */
10314 Type2 analyze3(FormalParameter node) { 11123 Type2 analyze3(FormalParameter node) {
10315 node.accept(_analyzer); 11124 node.accept(_analyzer);
10316 return ((node.identifier.element as ParameterElement)).type; 11125 return ((node.identifier.element as ParameterElement)).type;
10317 } 11126 }
10318 11127
10319 /** 11128 /**
10320 * Assert that the actual type is a function type with the expected characteri stics. 11129 * Assert that the actual type is a function type with the expected characteri stics.
11130 *
10321 * @param expectedReturnType the expected return type of the function 11131 * @param expectedReturnType the expected return type of the function
10322 * @param expectedNormalTypes the expected types of the normal parameters 11132 * @param expectedNormalTypes the expected types of the normal parameters
10323 * @param expectedOptionalTypes the expected types of the optional parameters 11133 * @param expectedOptionalTypes the expected types of the optional parameters
10324 * @param expectedNamedTypes the expected types of the named parameters 11134 * @param expectedNamedTypes the expected types of the named parameters
10325 * @param actualType the type being tested 11135 * @param actualType the type being tested
10326 */ 11136 */
10327 void assertFunctionType(Type2 expectedReturnType, List<Type2> expectedNormalTy pes, List<Type2> expectedOptionalTypes, Map<String, Type2> expectedNamedTypes, T ype2 actualType) { 11137 void assertFunctionType(Type2 expectedReturnType, List<Type2> expectedNormalTy pes, List<Type2> expectedOptionalTypes, Map<String, Type2> expectedNamedTypes, T ype2 actualType) {
10328 EngineTestCase.assertInstanceOf(FunctionType, actualType); 11138 EngineTestCase.assertInstanceOf(FunctionType, actualType);
10329 FunctionType functionType = actualType as FunctionType; 11139 FunctionType functionType = actualType as FunctionType;
10330 List<Type2> normalTypes = functionType.normalParameterTypes; 11140 List<Type2> normalTypes = functionType.normalParameterTypes;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
10371 } 11181 }
10372 void assertType2(Type2 expectedType, Type2 actualType) { 11182 void assertType2(Type2 expectedType, Type2 actualType) {
10373 if (expectedType is InterfaceTypeImpl) { 11183 if (expectedType is InterfaceTypeImpl) {
10374 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); 11184 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType);
10375 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy peImpl)); 11185 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy peImpl));
10376 } 11186 }
10377 } 11187 }
10378 11188
10379 /** 11189 /**
10380 * Create the analyzer used by the tests. 11190 * Create the analyzer used by the tests.
11191 *
10381 * @return the analyzer to be used by the tests 11192 * @return the analyzer to be used by the tests
10382 */ 11193 */
10383 StaticTypeAnalyzer createAnalyzer() { 11194 StaticTypeAnalyzer createAnalyzer() {
10384 AnalysisContextImpl context = new AnalysisContextImpl(); 11195 AnalysisContextImpl context = new AnalysisContextImpl();
10385 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Di rectoryBasedDartSdk.defaultSdk)]); 11196 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Di rectoryBasedDartSdk.defaultSdk)]);
10386 context.sourceFactory = sourceFactory; 11197 context.sourceFactory = sourceFactory;
10387 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache , FileUtilities2.createFile("/lib.dart")); 11198 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache , FileUtilities2.createFile("/lib.dart"));
10388 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("lib.dart"); 11199 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("lib.dart");
10389 definingCompilationUnit.source = source; 11200 definingCompilationUnit.source = source;
10390 LibraryElementImpl definingLibrary = new LibraryElementImpl(context, null); 11201 LibraryElementImpl definingLibrary = new LibraryElementImpl(context, null);
10391 definingLibrary.definingCompilationUnit = definingCompilationUnit; 11202 definingLibrary.definingCompilationUnit = definingCompilationUnit;
10392 Library library = new Library(context, _listener, source); 11203 Library library = new Library(context, _listener, source);
10393 library.libraryElement = definingLibrary; 11204 library.libraryElement = definingLibrary;
10394 _visitor = new ResolverVisitor.con1(library, source, _typeProvider); 11205 _visitor = new ResolverVisitor.con1(library, source, _typeProvider);
10395 _visitor.overrideManager.enterScope(); 11206 _visitor.overrideManager.enterScope();
10396 try { 11207 try {
10397 return _visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer; 11208 return _visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer;
10398 } catch (exception) { 11209 } catch (exception) {
10399 throw new IllegalArgumentException("Could not create analyzer", exception) ; 11210 throw new IllegalArgumentException("Could not create analyzer", exception) ;
10400 } 11211 }
10401 } 11212 }
10402 11213
10403 /** 11214 /**
10404 * Return an integer literal that has been resolved to the correct type. 11215 * Return an integer literal that has been resolved to the correct type.
11216 *
10405 * @param value the value of the literal 11217 * @param value the value of the literal
10406 * @return an integer literal that has been resolved to the correct type 11218 * @return an integer literal that has been resolved to the correct type
10407 */ 11219 */
10408 DoubleLiteral resolvedDouble(double value) { 11220 DoubleLiteral resolvedDouble(double value) {
10409 DoubleLiteral literal = ASTFactory.doubleLiteral(value); 11221 DoubleLiteral literal = ASTFactory.doubleLiteral(value);
10410 literal.staticType = _typeProvider.doubleType; 11222 literal.staticType = _typeProvider.doubleType;
10411 return literal; 11223 return literal;
10412 } 11224 }
10413 11225
10414 /** 11226 /**
10415 * Create a function expression that has an element associated with it, where the element has an 11227 * Create a function expression that has an element associated with it, where the element has an
10416 * incomplete type associated with it (just like the one[ElementBuilder#visitF unctionExpression] would have built if we had 11228 * incomplete type associated with it (just like the one
11229 * [ElementBuilder#visitFunctionExpression] would have built if we had
10417 * run it). 11230 * run it).
11231 *
10418 * @param parameters the parameters to the function 11232 * @param parameters the parameters to the function
10419 * @param body the body of the function 11233 * @param body the body of the function
10420 * @return a resolved function expression 11234 * @return a resolved function expression
10421 */ 11235 */
10422 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters2, FunctionBody body) { 11236 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters2, FunctionBody body) {
10423 for (FormalParameter parameter in parameters2.parameters) { 11237 for (FormalParameter parameter in parameters2.parameters) {
10424 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er); 11238 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er);
10425 element.parameterKind = parameter.kind; 11239 element.parameterKind = parameter.kind;
10426 element.type = _typeProvider.dynamicType; 11240 element.type = _typeProvider.dynamicType;
10427 parameter.identifier.element = element; 11241 parameter.identifier.element = element;
10428 } 11242 }
10429 FunctionExpression node = ASTFactory.functionExpression2(parameters2, body); 11243 FunctionExpression node = ASTFactory.functionExpression2(parameters2, body);
10430 FunctionElementImpl element = new FunctionElementImpl.con1(null); 11244 FunctionElementImpl element = new FunctionElementImpl.con1(null);
10431 element.type = new FunctionTypeImpl.con1(element); 11245 element.type = new FunctionTypeImpl.con1(element);
10432 node.element = element; 11246 node.element = element;
10433 return node; 11247 return node;
10434 } 11248 }
10435 11249
10436 /** 11250 /**
10437 * Return an integer literal that has been resolved to the correct type. 11251 * Return an integer literal that has been resolved to the correct type.
11252 *
10438 * @param value the value of the literal 11253 * @param value the value of the literal
10439 * @return an integer literal that has been resolved to the correct type 11254 * @return an integer literal that has been resolved to the correct type
10440 */ 11255 */
10441 IntegerLiteral resolvedInteger(int value) { 11256 IntegerLiteral resolvedInteger(int value) {
10442 IntegerLiteral literal = ASTFactory.integer(value); 11257 IntegerLiteral literal = ASTFactory.integer(value);
10443 literal.staticType = _typeProvider.intType; 11258 literal.staticType = _typeProvider.intType;
10444 return literal; 11259 return literal;
10445 } 11260 }
10446 11261
10447 /** 11262 /**
10448 * Return a string literal that has been resolved to the correct type. 11263 * Return a string literal that has been resolved to the correct type.
11264 *
10449 * @param value the value of the literal 11265 * @param value the value of the literal
10450 * @return a string literal that has been resolved to the correct type 11266 * @return a string literal that has been resolved to the correct type
10451 */ 11267 */
10452 SimpleStringLiteral resolvedString(String value) { 11268 SimpleStringLiteral resolvedString(String value) {
10453 SimpleStringLiteral string = ASTFactory.string2(value); 11269 SimpleStringLiteral string = ASTFactory.string2(value);
10454 string.staticType = _typeProvider.stringType; 11270 string.staticType = _typeProvider.stringType;
10455 return string; 11271 return string;
10456 } 11272 }
10457 11273
10458 /** 11274 /**
10459 * Return a simple identifier that has been resolved to a variable element wit h the given type. 11275 * Return a simple identifier that has been resolved to a variable element wit h the given type.
11276 *
10460 * @param type the type of the variable being represented 11277 * @param type the type of the variable being represented
10461 * @param variableName the name of the variable 11278 * @param variableName the name of the variable
10462 * @return a simple identifier that has been resolved to a variable element wi th the given type 11279 * @return a simple identifier that has been resolved to a variable element wi th the given type
10463 */ 11280 */
10464 SimpleIdentifier resolvedVariable(InterfaceType type2, String variableName) { 11281 SimpleIdentifier resolvedVariable(InterfaceType type2, String variableName) {
10465 SimpleIdentifier identifier = ASTFactory.identifier3(variableName); 11282 SimpleIdentifier identifier = ASTFactory.identifier3(variableName);
10466 VariableElementImpl element = ElementFactory.localVariableElement(identifier ); 11283 VariableElementImpl element = ElementFactory.localVariableElement(identifier );
10467 element.type = type2; 11284 element.type = type2;
10468 identifier.element = element; 11285 identifier.element = element;
10469 identifier.staticType = type2; 11286 identifier.staticType = type2;
10470 return identifier; 11287 return identifier;
10471 } 11288 }
10472 11289
10473 /** 11290 /**
10474 * Sets the element for the node and remembers it as the static resolution. 11291 * Sets the element for the node and remembers it as the static resolution.
10475 */ 11292 */
10476 void setStaticElement(BinaryExpression node, MethodElement element2) { 11293 void setStaticElement(BinaryExpression node, MethodElement element2) {
10477 node.staticElement = element2; 11294 node.staticElement = element2;
10478 node.element = element2; 11295 node.element = element2;
10479 } 11296 }
10480 11297
10481 /** 11298 /**
10482 * Set the type of the given parameter to the given type. 11299 * Set the type of the given parameter to the given type.
11300 *
10483 * @param parameter the parameter whose type is to be set 11301 * @param parameter the parameter whose type is to be set
10484 * @param type the new type of the given parameter 11302 * @param type the new type of the given parameter
10485 */ 11303 */
10486 void setType(FormalParameter parameter, Type2 type2) { 11304 void setType(FormalParameter parameter, Type2 type2) {
10487 SimpleIdentifier identifier = parameter.identifier; 11305 SimpleIdentifier identifier = parameter.identifier;
10488 Element element = identifier.element; 11306 Element element = identifier.element;
10489 if (element is! ParameterElement) { 11307 if (element is! ParameterElement) {
10490 element = new ParameterElementImpl(identifier); 11308 element = new ParameterElementImpl(identifier);
10491 identifier.element = element; 11309 identifier.element = element;
10492 } 11310 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
10758 final __test = new StaticTypeAnalyzerTest(); 11576 final __test = new StaticTypeAnalyzerTest();
10759 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue); 11577 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue);
10760 }); 11578 });
10761 }); 11579 });
10762 } 11580 }
10763 } 11581 }
10764 class EnclosedScopeTest extends ResolverTestCase { 11582 class EnclosedScopeTest extends ResolverTestCase {
10765 void test_define_duplicate() { 11583 void test_define_duplicate() {
10766 LibraryElement definingLibrary2 = createTestLibrary(); 11584 LibraryElement definingLibrary2 = createTestLibrary();
10767 GatheringErrorListener errorListener2 = new GatheringErrorListener(); 11585 GatheringErrorListener errorListener2 = new GatheringErrorListener();
10768 Scope rootScope = new Scope_16(definingLibrary2, errorListener2); 11586 Scope rootScope = new Scope_17(definingLibrary2, errorListener2);
10769 EnclosedScope scope = new EnclosedScope(rootScope); 11587 EnclosedScope scope = new EnclosedScope(rootScope);
10770 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 11588 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
10771 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 11589 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
10772 scope.define(element1); 11590 scope.define(element1);
10773 scope.define(element2); 11591 scope.define(element2);
10774 errorListener2.assertErrors3([ErrorSeverity.ERROR]); 11592 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
10775 } 11593 }
10776 void test_define_normal() { 11594 void test_define_normal() {
10777 LibraryElement definingLibrary3 = createTestLibrary(); 11595 LibraryElement definingLibrary3 = createTestLibrary();
10778 GatheringErrorListener errorListener3 = new GatheringErrorListener(); 11596 GatheringErrorListener errorListener3 = new GatheringErrorListener();
10779 Scope rootScope = new Scope_17(definingLibrary3, errorListener3); 11597 Scope rootScope = new Scope_18(definingLibrary3, errorListener3);
10780 EnclosedScope outerScope = new EnclosedScope(rootScope); 11598 EnclosedScope outerScope = new EnclosedScope(rootScope);
10781 EnclosedScope innerScope = new EnclosedScope(outerScope); 11599 EnclosedScope innerScope = new EnclosedScope(outerScope);
10782 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 11600 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
10783 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2")); 11601 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
10784 outerScope.define(element1); 11602 outerScope.define(element1);
10785 innerScope.define(element2); 11603 innerScope.define(element2);
10786 errorListener3.assertNoErrors(); 11604 errorListener3.assertNoErrors();
10787 } 11605 }
10788 static dartSuite() { 11606 static dartSuite() {
10789 _ut.group('EnclosedScopeTest', () { 11607 _ut.group('EnclosedScopeTest', () {
10790 _ut.test('test_define_duplicate', () { 11608 _ut.test('test_define_duplicate', () {
10791 final __test = new EnclosedScopeTest(); 11609 final __test = new EnclosedScopeTest();
10792 runJUnitTest(__test, __test.test_define_duplicate); 11610 runJUnitTest(__test, __test.test_define_duplicate);
10793 }); 11611 });
10794 _ut.test('test_define_normal', () { 11612 _ut.test('test_define_normal', () {
10795 final __test = new EnclosedScopeTest(); 11613 final __test = new EnclosedScopeTest();
10796 runJUnitTest(__test, __test.test_define_normal); 11614 runJUnitTest(__test, __test.test_define_normal);
10797 }); 11615 });
10798 }); 11616 });
10799 } 11617 }
10800 } 11618 }
10801 class Scope_16 extends Scope { 11619 class Scope_17 extends Scope {
10802 LibraryElement definingLibrary2; 11620 LibraryElement definingLibrary2;
10803 GatheringErrorListener errorListener2; 11621 GatheringErrorListener errorListener2;
10804 Scope_16(this.definingLibrary2, this.errorListener2) : super(); 11622 Scope_17(this.definingLibrary2, this.errorListener2) : super();
10805 LibraryElement get definingLibrary => definingLibrary2; 11623 LibraryElement get definingLibrary => definingLibrary2;
10806 AnalysisErrorListener get errorListener => errorListener2; 11624 AnalysisErrorListener get errorListener => errorListener2;
10807 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 11625 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
10808 } 11626 }
10809 class Scope_17 extends Scope { 11627 class Scope_18 extends Scope {
10810 LibraryElement definingLibrary3; 11628 LibraryElement definingLibrary3;
10811 GatheringErrorListener errorListener3; 11629 GatheringErrorListener errorListener3;
10812 Scope_17(this.definingLibrary3, this.errorListener3) : super(); 11630 Scope_18(this.definingLibrary3, this.errorListener3) : super();
10813 LibraryElement get definingLibrary => definingLibrary3; 11631 LibraryElement get definingLibrary => definingLibrary3;
10814 AnalysisErrorListener get errorListener => errorListener3; 11632 AnalysisErrorListener get errorListener => errorListener3;
10815 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 11633 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
10816 } 11634 }
10817 class LibraryElementBuilderTest extends EngineTestCase { 11635 class LibraryElementBuilderTest extends EngineTestCase {
10818 11636
10819 /** 11637 /**
10820 * The source factory used to create [Source sources]. 11638 * The source factory used to create [Source].
10821 */ 11639 */
10822 SourceFactory _sourceFactory; 11640 SourceFactory _sourceFactory;
10823 void setUp() { 11641 void setUp() {
10824 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); 11642 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
10825 } 11643 }
10826 void test_accessorsAcrossFiles() { 11644 void test_accessorsAcrossFiles() {
10827 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "part 'first.dart';", "part 'second.dart';"])); 11645 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "part 'first.dart';", "part 'second.dart';"]));
10828 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "int g et V => 0;"])); 11646 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "int g et V => 0;"]));
10829 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "void set V(int v) {}"])); 11647 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "void set V(int v) {}"]));
10830 LibraryElement element = buildLibrary(librarySource, []); 11648 LibraryElement element = buildLibrary(librarySource, []);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
10894 } 11712 }
10895 void test_singleFile() { 11713 void test_singleFile() {
10896 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "class A {}"])); 11714 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "class A {}"]));
10897 LibraryElement element = buildLibrary(librarySource, []); 11715 LibraryElement element = buildLibrary(librarySource, []);
10898 JUnitTestCase.assertNotNull(element); 11716 JUnitTestCase.assertNotNull(element);
10899 assertTypes(element.definingCompilationUnit, ["A"]); 11717 assertTypes(element.definingCompilationUnit, ["A"]);
10900 } 11718 }
10901 11719
10902 /** 11720 /**
10903 * Add a source file to the content provider. The file path should be absolute . 11721 * Add a source file to the content provider. The file path should be absolute .
11722 *
10904 * @param filePath the path of the file being added 11723 * @param filePath the path of the file being added
10905 * @param contents the contents to be returned by the content provider for the specified file 11724 * @param contents the contents to be returned by the content provider for the specified file
10906 * @return the source object representing the added file 11725 * @return the source object representing the added file
10907 */ 11726 */
10908 Source addSource(String filePath, String contents) { 11727 Source addSource(String filePath, String contents) {
10909 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath)); 11728 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath));
10910 _sourceFactory.setContents(source, contents); 11729 _sourceFactory.setContents(source, contents);
10911 return source; 11730 return source;
10912 } 11731 }
10913 11732
10914 /** 11733 /**
10915 * Ensure that there are elements representing all of the types in the given a rray of type names. 11734 * Ensure that there are elements representing all of the types in the given a rray of type names.
11735 *
10916 * @param unit the compilation unit containing the types 11736 * @param unit the compilation unit containing the types
10917 * @param typeNames the names of the types that should be found 11737 * @param typeNames the names of the types that should be found
10918 */ 11738 */
10919 void assertTypes(CompilationUnitElement unit, List<String> typeNames) { 11739 void assertTypes(CompilationUnitElement unit, List<String> typeNames) {
10920 JUnitTestCase.assertNotNull(unit); 11740 JUnitTestCase.assertNotNull(unit);
10921 List<ClassElement> types = unit.types; 11741 List<ClassElement> types = unit.types;
10922 EngineTestCase.assertLength(typeNames.length, types); 11742 EngineTestCase.assertLength(typeNames.length, types);
10923 for (ClassElement type in types) { 11743 for (ClassElement type in types) {
10924 JUnitTestCase.assertNotNull(type); 11744 JUnitTestCase.assertNotNull(type);
10925 String actualTypeName = type.displayName; 11745 String actualTypeName = type.displayName;
10926 bool wasExpected = false; 11746 bool wasExpected = false;
10927 for (String expectedTypeName in typeNames) { 11747 for (String expectedTypeName in typeNames) {
10928 if (expectedTypeName == actualTypeName) { 11748 if (expectedTypeName == actualTypeName) {
10929 wasExpected = true; 11749 wasExpected = true;
10930 } 11750 }
10931 } 11751 }
10932 if (!wasExpected) { 11752 if (!wasExpected) {
10933 JUnitTestCase.fail("Found unexpected type ${actualTypeName}"); 11753 JUnitTestCase.fail("Found unexpected type ${actualTypeName}");
10934 } 11754 }
10935 } 11755 }
10936 } 11756 }
10937 11757
10938 /** 11758 /**
10939 * Build the element model for the library whose defining compilation unit has the given source. 11759 * Build the element model for the library whose defining compilation unit has the given source.
11760 *
10940 * @param librarySource the source of the defining compilation unit for the li brary 11761 * @param librarySource the source of the defining compilation unit for the li brary
10941 * @param expectedErrorCodes the errors that are expected to be found while bu ilding the element 11762 * @param expectedErrorCodes the errors that are expected to be found while bu ilding the element
10942 * model 11763 * model
10943 * @return the element model that was built for the library 11764 * @return the element model that was built for the library
10944 * @throws Exception if the element model could not be built 11765 * @throws Exception if the element model could not be built
10945 */ 11766 */
10946 LibraryElement buildLibrary(Source librarySource, List<ErrorCode> expectedErro rCodes) { 11767 LibraryElement buildLibrary(Source librarySource, List<ErrorCode> expectedErro rCodes) {
10947 AnalysisContextImpl context = new AnalysisContextImpl(); 11768 AnalysisContextImpl context = new AnalysisContextImpl();
10948 context.sourceFactory = new SourceFactory.con2([new DartUriResolver(Director yBasedDartSdk.defaultSdk), new FileUriResolver()]); 11769 context.sourceFactory = new SourceFactory.con2([new DartUriResolver(Director yBasedDartSdk.defaultSdk), new FileUriResolver()]);
10949 LibraryResolver resolver = new LibraryResolver(context); 11770 LibraryResolver resolver = new LibraryResolver(context);
10950 LibraryElementBuilder builder = new LibraryElementBuilder(resolver); 11771 LibraryElementBuilder builder = new LibraryElementBuilder(resolver);
10951 Library library = resolver.createLibrary(librarySource) as Library; 11772 Library library = resolver.createLibrary(librarySource) as Library;
10952 LibraryElement element = builder.buildLibrary(library); 11773 LibraryElement element = builder.buildLibrary(library);
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
11400 * to be a class, the first member of which is expected to be a method with a block body, and the 12221 * to be a class, the first member of which is expected to be a method with a block body, and the
11401 * first statement in the body is expected to be an expression statement whose expression is a 12222 * first statement in the body is expected to be an expression statement whose expression is a
11402 * method invocation. It is the arguments to that method invocation that are t ested. The method 12223 * method invocation. It is the arguments to that method invocation that are t ested. The method
11403 * invocation can contain errors. 12224 * invocation can contain errors.
11404 * 12225 *
11405 * The arguments were resolved correctly if the number of expressions in the l ist matches the 12226 * The arguments were resolved correctly if the number of expressions in the l ist matches the
11406 * length of the array of indices and if, for each index in the array of indic es, the parameter to 12227 * length of the array of indices and if, for each index in the array of indic es, the parameter to
11407 * which the argument expression was resolved is the parameter in the invoked method's list of 12228 * which the argument expression was resolved is the parameter in the invoked method's list of
11408 * parameters at that index. Arguments that should not be resolved to a parame ter because of an 12229 * parameters at that index. Arguments that should not be resolved to a parame ter because of an
11409 * error can be denoted by including a negative index in the array of indices. 12230 * error can be denoted by including a negative index in the array of indices.
12231 *
11410 * @param source the source to be resolved 12232 * @param source the source to be resolved
11411 * @param indices the array of indices used to associate arguments with parame ters 12233 * @param indices the array of indices used to associate arguments with parame ters
11412 * @throws Exception if the source could not be resolved or if the structure o f the source is not 12234 * @throws Exception if the source could not be resolved or if the structure o f the source is not
11413 * valid 12235 * valid
11414 */ 12236 */
11415 void validateArgumentResolution(Source source, List<int> indices) { 12237 void validateArgumentResolution(Source source, List<int> indices) {
11416 LibraryElement library = resolve(source); 12238 LibraryElement library = resolve(source);
11417 JUnitTestCase.assertNotNull(library); 12239 JUnitTestCase.assertNotNull(library);
11418 ClassElement classElement = library.definingCompilationUnit.types[0]; 12240 ClassElement classElement = library.definingCompilationUnit.types[0];
11419 List<ParameterElement> parameters = classElement.methods[1].parameters; 12241 List<ParameterElement> parameters = classElement.methods[1].parameters;
11420 CompilationUnit unit = resolveCompilationUnit(source, library); 12242 CompilationUnit unit = resolveCompilationUnit(source, library);
11421 JUnitTestCase.assertNotNull(unit); 12243 JUnitTestCase.assertNotNull(unit);
11422 ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration ; 12244 ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration ;
11423 MethodDeclaration methodDeclaration = (classDeclaration.members[0] as Method Declaration); 12245 MethodDeclaration methodDeclaration = (classDeclaration.members[0] as Method Declaration);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
11634 // ScopeTest.dartSuite(); 12456 // ScopeTest.dartSuite();
11635 // CompileTimeErrorCodeTest.dartSuite(); 12457 // CompileTimeErrorCodeTest.dartSuite();
11636 // ErrorResolverTest.dartSuite(); 12458 // ErrorResolverTest.dartSuite();
11637 // NonErrorResolverTest.dartSuite(); 12459 // NonErrorResolverTest.dartSuite();
11638 // SimpleResolverTest.dartSuite(); 12460 // SimpleResolverTest.dartSuite();
11639 // StaticTypeWarningCodeTest.dartSuite(); 12461 // StaticTypeWarningCodeTest.dartSuite();
11640 // StaticWarningCodeTest.dartSuite(); 12462 // StaticWarningCodeTest.dartSuite();
11641 // StrictModeTest.dartSuite(); 12463 // StrictModeTest.dartSuite();
11642 // TypePropagationTest.dartSuite(); 12464 // TypePropagationTest.dartSuite();
11643 } 12465 }
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