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

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

Issue 16337007: Version 0.5.13.1 . (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: 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 3
4 library engine.resolver_test; 4 library engine.resolver_test;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'package:analyzer_experimental/src/generated/java_core.dart'; 7 import 'package:analyzer_experimental/src/generated/java_core.dart';
8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 8 import 'package:analyzer_experimental/src/generated/java_engine.dart';
9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 9 import 'package:analyzer_experimental/src/generated/java_junit.dart';
10 import 'package:analyzer_experimental/src/generated/source_io.dart'; 10 import 'package:analyzer_experimental/src/generated/source_io.dart';
11 import 'package:analyzer_experimental/src/generated/error.dart'; 11 import 'package:analyzer_experimental/src/generated/error.dart';
12 import 'package:analyzer_experimental/src/generated/scanner.dart'; 12 import 'package:analyzer_experimental/src/generated/scanner.dart';
13 import 'package:analyzer_experimental/src/generated/ast.dart' hide Annotation; 13 import 'package:analyzer_experimental/src/generated/ast.dart' hide Annotation;
14 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode; 14 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode;
15 import 'package:analyzer_experimental/src/generated/element.dart'; 15 import 'package:analyzer_experimental/src/generated/element.dart';
16 import 'package:analyzer_experimental/src/generated/resolver.dart'; 16 import 'package:analyzer_experimental/src/generated/resolver.dart';
17 import 'package:analyzer_experimental/src/generated/engine.dart'; 17 import 'package:analyzer_experimental/src/generated/engine.dart';
18 import 'package:analyzer_experimental/src/generated/java_engine_io.dart'; 18 import 'package:analyzer_experimental/src/generated/java_engine_io.dart';
19 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk; 19 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk;
20 import 'package:analyzer_experimental/src/generated/sdk_io.dart' show DirectoryB asedDartSdk; 20 import 'package:analyzer_experimental/src/generated/sdk_io.dart' show DirectoryB asedDartSdk;
21 import 'package:unittest/unittest.dart' as _ut; 21 import 'package:unittest/unittest.dart' as _ut;
22 import 'test_support.dart'; 22 import 'test_support.dart';
23 import 'ast_test.dart' show ASTFactory; 23 import 'ast_test.dart' show ASTFactory;
24 import 'element_test.dart' show ElementFactory; 24 import 'element_test.dart' show ElementFactory;
25 25
26 class TypePropagationTest extends ResolverTestCase { 26 class TypePropagationTest extends ResolverTestCase {
27 void test_as() { 27 void test_as() {
28 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;", " }", "}"])); 28 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;", " }", "}"]));
29 LibraryElement library = resolve(source, []); 29 LibraryElement library = resolve(source);
30 assertNoErrors(); 30 assertNoErrors();
31 verify([source]); 31 verify([source]);
32 CompilationUnit unit = resolveCompilationUnit(source, library); 32 CompilationUnit unit = resolveCompilationUnit(source, library);
33 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 33 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
34 InterfaceType typeA = classA.element.type; 34 InterfaceType typeA = classA.element.type;
35 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 35 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
36 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 36 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
37 IfStatement ifStatement = body2.block.statements[0] as IfStatement; 37 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
38 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 38 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
39 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 39 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
40 JUnitTestCase.assertSame(typeA, variableName.staticType); 40 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
41 } 41 }
42 void test_assert() { 42 void test_assert() {
43 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " assert (p is A);", " return p;", "}"])); 43 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " assert (p is A);", " return p;", "}"]));
44 LibraryElement library = resolve(source, []); 44 LibraryElement library = resolve(source);
45 assertNoErrors(); 45 assertNoErrors();
46 verify([source]); 46 verify([source]);
47 CompilationUnit unit = resolveCompilationUnit(source, library); 47 CompilationUnit unit = resolveCompilationUnit(source, library);
48 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 48 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
49 InterfaceType typeA = classA.element.type; 49 InterfaceType typeA = classA.element.type;
50 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 50 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
51 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 51 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
52 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; 52 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
53 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 53 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
54 JUnitTestCase.assertSame(typeA, variableName.staticType); 54 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
55 } 55 }
56 void test_assignment() { 56 void test_assignment() {
57 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;", " v = 0;", " return v;", "}"])); 57 Source source = addSource(EngineTestCase.createSource(["f() {", " var v;", " v = 0;", " return v;", "}"]));
58 LibraryElement library = resolve(source, []); 58 LibraryElement library = resolve(source);
59 assertNoErrors(); 59 assertNoErrors();
60 verify([source]); 60 verify([source]);
61 CompilationUnit unit = resolveCompilationUnit(source, library); 61 CompilationUnit unit = resolveCompilationUnit(source, library);
62 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 62 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
63 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 63 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
64 ReturnStatement statement = body2.block.statements[2] as ReturnStatement; 64 ReturnStatement statement = body2.block.statements[2] as ReturnStatement;
65 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 65 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
66 JUnitTestCase.assertSame(typeProvider.intType, variableName.staticType); 66 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType);
67 } 67 }
68 void test_assignment_afterInitializer() { 68 void test_assignment_afterInitializer() {
69 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0 ;", " v = 1.0;", " return v;", "}"])); 69 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0 ;", " v = 1.0;", " return v;", "}"]));
70 LibraryElement library = resolve(source, []); 70 LibraryElement library = resolve(source);
71 assertNoErrors(); 71 assertNoErrors();
72 verify([source]); 72 verify([source]);
73 CompilationUnit unit = resolveCompilationUnit(source, library); 73 CompilationUnit unit = resolveCompilationUnit(source, library);
74 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 74 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
75 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 75 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
76 ReturnStatement statement = body2.block.statements[2] as ReturnStatement; 76 ReturnStatement statement = body2.block.statements[2] as ReturnStatement;
77 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 77 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
78 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.staticType); 78 JUnitTestCase.assertSame(typeProvider.doubleType, variableName.propagatedTyp e);
79 } 79 }
80 void test_forEach() { 80 void test_forEach() {
81 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(Li st<A> p) {", " for (var e in p) {", " return e;", " }", "}"])); 81 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(Li st<A> p) {", " for (var e in p) {", " return e;", " }", "}"]));
82 LibraryElement library = resolve(source, []); 82 LibraryElement library = resolve(source);
83 assertNoErrors(); 83 assertNoErrors();
84 verify([source]); 84 verify([source]);
85 CompilationUnit unit = resolveCompilationUnit(source, library); 85 CompilationUnit unit = resolveCompilationUnit(source, library);
86 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 86 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
87 InterfaceType typeA = classA.element.type; 87 InterfaceType typeA = classA.element.type;
88 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 88 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
89 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 89 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
90 ForEachStatement forStatement = body2.block.statements[0] as ForEachStatemen t; 90 ForEachStatement forStatement = body2.block.statements[0] as ForEachStatemen t;
91 ReturnStatement statement = ((forStatement.body as Block)).statements[0] as ReturnStatement; 91 ReturnStatement statement = ((forStatement.body as Block)).statements[0] as ReturnStatement;
92 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 92 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
93 JUnitTestCase.assertSame(typeA, variableName.staticType); 93 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
94 } 94 }
95 void test_initializer() { 95 void test_initializer() {
96 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0 ;", " return v;", "}"])); 96 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0 ;", " return v;", "}"]));
97 LibraryElement library = resolve(source, []); 97 LibraryElement library = resolve(source);
98 assertNoErrors(); 98 assertNoErrors();
99 verify([source]); 99 verify([source]);
100 CompilationUnit unit = resolveCompilationUnit(source, library); 100 CompilationUnit unit = resolveCompilationUnit(source, library);
101 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 101 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
102 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 102 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
103 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; 103 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
104 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 104 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
105 JUnitTestCase.assertSame(typeProvider.intType, variableName.staticType); 105 JUnitTestCase.assertSame(typeProvider.intType, variableName.propagatedType);
106 } 106 }
107 void test_initializer_dereference() { 107 void test_initializer_dereference() {
108 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = ' String';", " v.", "}"])); 108 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = ' String';", " v.", "}"]));
109 LibraryElement library = resolve(source, []); 109 LibraryElement library = resolve(source);
110 CompilationUnit unit = resolveCompilationUnit(source, library); 110 CompilationUnit unit = resolveCompilationUnit(source, library);
111 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; 111 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
112 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 112 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
113 ExpressionStatement statement = body2.block.statements[1] as ExpressionState ment; 113 ExpressionStatement statement = body2.block.statements[1] as ExpressionState ment;
114 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier; 114 PrefixedIdentifier invocation = statement.expression as PrefixedIdentifier;
115 SimpleIdentifier variableName = invocation.prefix; 115 SimpleIdentifier variableName = invocation.prefix;
116 JUnitTestCase.assertSame(typeProvider.stringType, variableName.staticType); 116 JUnitTestCase.assertSame(typeProvider.stringType, variableName.propagatedTyp e);
117 } 117 }
118 void test_is_conditional() { 118 void test_is_conditional() {
119 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " return (p is A) ? p : null;", "}"])); 119 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " return (p is A) ? p : null;", "}"]));
120 LibraryElement library = resolve(source, []); 120 LibraryElement library = resolve(source);
121 assertNoErrors(); 121 assertNoErrors();
122 verify([source]); 122 verify([source]);
123 CompilationUnit unit = resolveCompilationUnit(source, library); 123 CompilationUnit unit = resolveCompilationUnit(source, library);
124 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 124 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
125 InterfaceType typeA = classA.element.type; 125 InterfaceType typeA = classA.element.type;
126 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 126 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
127 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 127 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
128 ReturnStatement statement = body2.block.statements[0] as ReturnStatement; 128 ReturnStatement statement = body2.block.statements[0] as ReturnStatement;
129 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion; 129 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion;
130 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi er; 130 SimpleIdentifier variableName = conditional.thenExpression as SimpleIdentifi er;
131 JUnitTestCase.assertSame(typeA, variableName.staticType); 131 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
132 } 132 }
133 void test_is_if() { 133 void test_is_if() {
134 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is A) {", " return p;", " } else {", " return null;", " }", "}"])); 134 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is A) {", " return p;", " } else {", " return null;", " }", "}"]));
135 LibraryElement library = resolve(source, []); 135 LibraryElement library = resolve(source);
136 assertNoErrors(); 136 assertNoErrors();
137 verify([source]); 137 verify([source]);
138 CompilationUnit unit = resolveCompilationUnit(source, library); 138 CompilationUnit unit = resolveCompilationUnit(source, library);
139 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 139 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
140 InterfaceType typeA = classA.element.type; 140 InterfaceType typeA = classA.element.type;
141 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 141 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
142 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 142 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
143 IfStatement ifStatement = body2.block.statements[0] as IfStatement; 143 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
144 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 144 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
145 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 145 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
146 JUnitTestCase.assertSame(typeA, variableName.staticType); 146 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
147 } 147 }
148 void test_is_if_lessSpecific() { 148 void test_is_if_lessSpecific() {
149 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(A p) {", " if (p is Object) {", " return p;", " } else {", " return null;" , " }", "}"])); 149 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(A p) {", " if (p is Object) {", " return p;", " } else {", " return null;" , " }", "}"]));
150 LibraryElement library = resolve(source, []); 150 LibraryElement library = resolve(source);
151 assertNoErrors(); 151 assertNoErrors();
152 verify([source]); 152 verify([source]);
153 CompilationUnit unit = resolveCompilationUnit(source, library); 153 CompilationUnit unit = resolveCompilationUnit(source, library);
154 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
155 InterfaceType typeA = classA.element.type;
156 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 154 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
157 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 155 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
158 IfStatement ifStatement = body2.block.statements[0] as IfStatement; 156 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
159 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 157 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
160 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 158 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
161 JUnitTestCase.assertSame(typeA, variableName.staticType); 159 JUnitTestCase.assertSame(null, variableName.propagatedType);
162 } 160 }
163 void test_is_if_logicalAnd() { 161 void test_is_if_logicalAnd() {
164 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is A && p != null) {", " return p;", " } else {", " ret urn null;", " }", "}"])); 162 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is A && p != null) {", " return p;", " } else {", " ret urn null;", " }", "}"]));
165 LibraryElement library = resolve(source, []); 163 LibraryElement library = resolve(source);
166 assertNoErrors(); 164 assertNoErrors();
167 verify([source]); 165 verify([source]);
168 CompilationUnit unit = resolveCompilationUnit(source, library); 166 CompilationUnit unit = resolveCompilationUnit(source, library);
169 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 167 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
170 InterfaceType typeA = classA.element.type; 168 InterfaceType typeA = classA.element.type;
171 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 169 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
172 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 170 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
173 IfStatement ifStatement = body2.block.statements[0] as IfStatement; 171 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
174 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 172 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
175 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 173 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
176 JUnitTestCase.assertSame(typeA, variableName.staticType); 174 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
177 } 175 }
178 void test_is_postConditional() { 176 void test_is_postConditional() {
179 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " A a = (p is A) ? p : throw null;", " return p;", "}"])); 177 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " A a = (p is A) ? p : throw null;", " return p;", "}"]));
180 LibraryElement library = resolve(source, []); 178 LibraryElement library = resolve(source);
181 assertNoErrors(); 179 assertNoErrors();
182 verify([source]); 180 verify([source]);
183 CompilationUnit unit = resolveCompilationUnit(source, library); 181 CompilationUnit unit = resolveCompilationUnit(source, library);
184 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 182 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
185 InterfaceType typeA = classA.element.type; 183 InterfaceType typeA = classA.element.type;
186 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 184 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
187 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 185 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
188 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; 186 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
189 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 187 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
190 JUnitTestCase.assertSame(typeA, variableName.staticType); 188 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
191 } 189 }
192 void test_is_postIf() { 190 void test_is_postIf() {
193 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is A) {", " A a = p;", " } else {", " return null;", " }", " return p;", "}"])); 191 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is A) {", " A a = p;", " } else {", " return null;", " }", " return p;", "}"]));
194 LibraryElement library = resolve(source, []); 192 LibraryElement library = resolve(source);
195 assertNoErrors(); 193 assertNoErrors();
196 verify([source]); 194 verify([source]);
197 CompilationUnit unit = resolveCompilationUnit(source, library); 195 CompilationUnit unit = resolveCompilationUnit(source, library);
198 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 196 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
199 InterfaceType typeA = classA.element.type; 197 InterfaceType typeA = classA.element.type;
200 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 198 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
201 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 199 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
202 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; 200 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
203 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 201 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
204 JUnitTestCase.assertSame(typeA, variableName.staticType); 202 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
205 } 203 }
206 void test_is_subclass() { 204 void test_is_subclass() {
207 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B m() => this;", "}", "A f(A p) {", " if (p is B) {", " r eturn p.m();", " }", "}"])); 205 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B m() => this;", "}", "A f(A p) {", " if (p is B) {", " r eturn p.m();", " }", "}"]));
208 LibraryElement library = resolve(source, []); 206 LibraryElement library = resolve(source);
209 assertNoErrors(); 207 assertNoErrors();
210 verify([source]); 208 verify([source]);
211 CompilationUnit unit = resolveCompilationUnit(source, library); 209 CompilationUnit unit = resolveCompilationUnit(source, library);
212 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration; 210 FunctionDeclaration function = unit.declarations[2] as FunctionDeclaration;
213 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 211 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
214 IfStatement ifStatement = body2.block.statements[0] as IfStatement; 212 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
215 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement; 213 ReturnStatement statement = ((ifStatement.thenStatement as Block)).statement s[0] as ReturnStatement;
216 MethodInvocation invocation = statement.expression as MethodInvocation; 214 MethodInvocation invocation = statement.expression as MethodInvocation;
217 JUnitTestCase.assertNotNull(invocation.methodName.element); 215 JUnitTestCase.assertNotNull(invocation.methodName.element);
218 } 216 }
219 void test_is_while() { 217 void test_is_while() {
220 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " while (p is A) {", " return p;", " }", "}"])); 218 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " while (p is A) {", " return p;", " }", "}"]));
221 LibraryElement library = resolve(source, []); 219 LibraryElement library = resolve(source);
222 assertNoErrors(); 220 assertNoErrors();
223 verify([source]); 221 verify([source]);
224 CompilationUnit unit = resolveCompilationUnit(source, library); 222 CompilationUnit unit = resolveCompilationUnit(source, library);
225 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 223 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
226 InterfaceType typeA = classA.element.type; 224 InterfaceType typeA = classA.element.type;
227 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 225 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
228 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 226 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
229 WhileStatement whileStatement = body2.block.statements[0] as WhileStatement; 227 WhileStatement whileStatement = body2.block.statements[0] as WhileStatement;
230 ReturnStatement statement = ((whileStatement.body as Block)).statements[0] a s ReturnStatement; 228 ReturnStatement statement = ((whileStatement.body as Block)).statements[0] a s ReturnStatement;
231 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 229 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
232 JUnitTestCase.assertSame(typeA, variableName.staticType); 230 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
233 } 231 }
234 void test_isNot_conditional() { 232 void test_isNot_conditional() {
235 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " return (p is! A) ? null : p;", "}"])); 233 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " return (p is! A) ? null : p;", "}"]));
236 LibraryElement library = resolve(source, []); 234 LibraryElement library = resolve(source);
237 assertNoErrors(); 235 assertNoErrors();
238 verify([source]); 236 verify([source]);
239 CompilationUnit unit = resolveCompilationUnit(source, library); 237 CompilationUnit unit = resolveCompilationUnit(source, library);
240 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 238 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
241 InterfaceType typeA = classA.element.type; 239 InterfaceType typeA = classA.element.type;
242 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 240 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
243 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 241 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
244 ReturnStatement statement = body2.block.statements[0] as ReturnStatement; 242 ReturnStatement statement = body2.block.statements[0] as ReturnStatement;
245 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion; 243 ConditionalExpression conditional = statement.expression as ConditionalExpre ssion;
246 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi er; 244 SimpleIdentifier variableName = conditional.elseExpression as SimpleIdentifi er;
247 JUnitTestCase.assertSame(typeA, variableName.staticType); 245 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
248 } 246 }
249 void test_isNot_if() { 247 void test_isNot_if() {
250 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is! A) {", " return null;", " } else {", " return p;", " }", "}"])); 248 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is! A) {", " return null;", " } else {", " return p;", " }", "}"]));
251 LibraryElement library = resolve(source, []); 249 LibraryElement library = resolve(source);
252 assertNoErrors(); 250 assertNoErrors();
253 verify([source]); 251 verify([source]);
254 CompilationUnit unit = resolveCompilationUnit(source, library); 252 CompilationUnit unit = resolveCompilationUnit(source, library);
255 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 253 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
256 InterfaceType typeA = classA.element.type; 254 InterfaceType typeA = classA.element.type;
257 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 255 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
258 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 256 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
259 IfStatement ifStatement = body2.block.statements[0] as IfStatement; 257 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
260 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement; 258 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement;
261 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 259 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
262 JUnitTestCase.assertSame(typeA, variableName.staticType); 260 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
263 } 261 }
264 void test_isNot_if_logicalOr() { 262 void test_isNot_if_logicalOr() {
265 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is! A || null == p) {", " return null;", " } else {", " return p;", " }", "}"])); 263 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is! A || null == p) {", " return null;", " } else {", " return p;", " }", "}"]));
266 LibraryElement library = resolve(source, []); 264 LibraryElement library = resolve(source);
267 assertNoErrors(); 265 assertNoErrors();
268 verify([source]); 266 verify([source]);
269 CompilationUnit unit = resolveCompilationUnit(source, library); 267 CompilationUnit unit = resolveCompilationUnit(source, library);
270 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 268 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
271 InterfaceType typeA = classA.element.type; 269 InterfaceType typeA = classA.element.type;
272 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 270 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
273 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 271 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
274 IfStatement ifStatement = body2.block.statements[0] as IfStatement; 272 IfStatement ifStatement = body2.block.statements[0] as IfStatement;
275 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement; 273 ReturnStatement statement = ((ifStatement.elseStatement as Block)).statement s[0] as ReturnStatement;
276 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 274 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
277 JUnitTestCase.assertSame(typeA, variableName.staticType); 275 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
278 } 276 }
279 void test_isNot_postConditional() { 277 void test_isNot_postConditional() {
280 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " A a = (p is! A) ? throw null : p;", " return p;", "}"])); 278 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " A a = (p is! A) ? throw null : p;", " return p;", "}"]));
281 LibraryElement library = resolve(source, []); 279 LibraryElement library = resolve(source);
282 assertNoErrors(); 280 assertNoErrors();
283 verify([source]); 281 verify([source]);
284 CompilationUnit unit = resolveCompilationUnit(source, library); 282 CompilationUnit unit = resolveCompilationUnit(source, library);
285 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 283 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
286 InterfaceType typeA = classA.element.type; 284 InterfaceType typeA = classA.element.type;
287 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 285 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
288 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 286 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
289 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; 287 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
290 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 288 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
291 JUnitTestCase.assertSame(typeA, variableName.staticType); 289 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
292 } 290 }
293 void test_isNot_postIf() { 291 void test_isNot_postIf() {
294 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is! A) {", " return null;", " }", " return p;", "}"])); 292 Source source = addSource(EngineTestCase.createSource(["class A {}", "A f(va r p) {", " if (p is! A) {", " return null;", " }", " return p;", "}"]));
295 LibraryElement library = resolve(source, []); 293 LibraryElement library = resolve(source);
296 assertNoErrors(); 294 assertNoErrors();
297 verify([source]); 295 verify([source]);
298 CompilationUnit unit = resolveCompilationUnit(source, library); 296 CompilationUnit unit = resolveCompilationUnit(source, library);
299 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 297 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
300 InterfaceType typeA = classA.element.type; 298 InterfaceType typeA = classA.element.type;
301 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 299 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
302 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody; 300 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
303 ReturnStatement statement = body2.block.statements[1] as ReturnStatement; 301 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
304 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 302 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
305 JUnitTestCase.assertSame(typeA, variableName.staticType); 303 JUnitTestCase.assertSame(typeA, variableName.propagatedType);
304 }
305 void test_listLiteral_different() {
306 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [ 0, '1', 2];", " return v[2];", "}"]));
307 LibraryElement library = resolve(source);
308 assertNoErrors();
309 verify([source]);
310 CompilationUnit unit = resolveCompilationUnit(source, library);
311 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
312 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
313 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
314 IndexExpression indexExpression = statement.expression as IndexExpression;
315 JUnitTestCase.assertNull(indexExpression.propagatedType);
316 }
317 void test_listLiteral_same() {
318 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = [ 0, 1, 2];", " return v[2];", "}"]));
319 LibraryElement library = resolve(source);
320 assertNoErrors();
321 verify([source]);
322 CompilationUnit unit = resolveCompilationUnit(source, library);
323 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
324 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
325 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
326 IndexExpression indexExpression = statement.expression as IndexExpression;
327 JUnitTestCase.assertSame(typeProvider.intType, indexExpression.propagatedTyp e);
328 }
329 void test_mapLiteral_different() {
330 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = { '0' : 0, 1 : '1', '2' : 2};", " return v;", "}"]));
331 LibraryElement library = resolve(source);
332 assertNoErrors();
333 verify([source]);
334 CompilationUnit unit = resolveCompilationUnit(source, library);
335 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
336 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
337 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
338 SimpleIdentifier identifier = statement.expression as SimpleIdentifier;
339 InterfaceType propagatedType2 = identifier.propagatedType as InterfaceType;
340 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType2.eleme nt);
341 List<Type2> typeArguments2 = propagatedType2.typeArguments;
342 EngineTestCase.assertLength(2, typeArguments2);
343 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments2[0]);
344 JUnitTestCase.assertSame(typeProvider.dynamicType, typeArguments2[1]);
345 }
346 void test_mapLiteral_same() {
347 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = { 'a' : 0, 'b' : 1, 'c' : 2};", " return v;", "}"]));
348 LibraryElement library = resolve(source);
349 assertNoErrors();
350 verify([source]);
351 CompilationUnit unit = resolveCompilationUnit(source, library);
352 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration;
353 BlockFunctionBody body2 = function.functionExpression.body as BlockFunctionB ody;
354 ReturnStatement statement = body2.block.statements[1] as ReturnStatement;
355 SimpleIdentifier identifier = statement.expression as SimpleIdentifier;
356 InterfaceType propagatedType2 = identifier.propagatedType as InterfaceType;
357 JUnitTestCase.assertSame(typeProvider.mapType.element, propagatedType2.eleme nt);
358 List<Type2> typeArguments2 = propagatedType2.typeArguments;
359 EngineTestCase.assertLength(2, typeArguments2);
360 JUnitTestCase.assertSame(typeProvider.stringType, typeArguments2[0]);
361 JUnitTestCase.assertSame(typeProvider.intType, typeArguments2[1]);
306 } 362 }
307 void test_query() { 363 void test_query() {
308 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];", "}"])); 364 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];", "}"]));
309 LibraryElement library = resolve(source, []); 365 LibraryElement library = resolve(source);
310 assertNoErrors(); 366 assertNoErrors();
311 verify([source]); 367 verify([source]);
312 CompilationUnit unit = resolveCompilationUnit(source, library); 368 CompilationUnit unit = resolveCompilationUnit(source, library);
313 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration; 369 FunctionDeclaration main = unit.declarations[0] as FunctionDeclaration;
314 BlockFunctionBody body2 = main.functionExpression.body as BlockFunctionBody; 370 BlockFunctionBody body2 = main.functionExpression.body as BlockFunctionBody;
315 ReturnStatement statement = body2.block.statements[11] as ReturnStatement; 371 ReturnStatement statement = body2.block.statements[11] as ReturnStatement;
316 NodeList<Expression> elements2 = ((statement.expression as ListLiteral)).ele ments; 372 NodeList<Expression> elements2 = ((statement.expression as ListLiteral)).ele ments;
317 JUnitTestCase.assertEquals("AnchorElement", elements2[0].staticType.name); 373 JUnitTestCase.assertEquals("AnchorElement", elements2[0].propagatedType.name );
318 JUnitTestCase.assertEquals("AnchorElement", elements2[1].staticType.name); 374 JUnitTestCase.assertEquals("AnchorElement", elements2[1].propagatedType.name );
319 JUnitTestCase.assertEquals("BodyElement", elements2[2].staticType.name); 375 JUnitTestCase.assertEquals("BodyElement", elements2[2].propagatedType.name);
320 JUnitTestCase.assertEquals("ButtonElement", elements2[3].staticType.name); 376 JUnitTestCase.assertEquals("ButtonElement", elements2[3].propagatedType.name );
321 JUnitTestCase.assertEquals("DivElement", elements2[4].staticType.name); 377 JUnitTestCase.assertEquals("DivElement", elements2[4].propagatedType.name);
322 JUnitTestCase.assertEquals("InputElement", elements2[5].staticType.name); 378 JUnitTestCase.assertEquals("InputElement", elements2[5].propagatedType.name) ;
323 JUnitTestCase.assertEquals("SelectElement", elements2[6].staticType.name); 379 JUnitTestCase.assertEquals("SelectElement", elements2[6].propagatedType.name );
324 JUnitTestCase.assertEquals("DivElement", elements2[7].staticType.name); 380 JUnitTestCase.assertEquals("DivElement", elements2[7].propagatedType.name);
325 JUnitTestCase.assertEquals("Element", elements2[8].staticType.name); 381 JUnitTestCase.assertEquals("Element", elements2[8].propagatedType.name);
326 JUnitTestCase.assertEquals("Element", elements2[9].staticType.name); 382 JUnitTestCase.assertEquals("Element", elements2[9].propagatedType.name);
327 JUnitTestCase.assertEquals("Element", elements2[10].staticType.name); 383 JUnitTestCase.assertEquals("Element", elements2[10].propagatedType.name);
328 } 384 }
329 static dartSuite() { 385 static dartSuite() {
330 _ut.group('TypePropagationTest', () { 386 _ut.group('TypePropagationTest', () {
331 _ut.test('test_as', () { 387 _ut.test('test_as', () {
332 final __test = new TypePropagationTest(); 388 final __test = new TypePropagationTest();
333 runJUnitTest(__test, __test.test_as); 389 runJUnitTest(__test, __test.test_as);
334 }); 390 });
335 _ut.test('test_assert', () { 391 _ut.test('test_assert', () {
336 final __test = new TypePropagationTest(); 392 final __test = new TypePropagationTest();
337 runJUnitTest(__test, __test.test_assert); 393 runJUnitTest(__test, __test.test_assert);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 runJUnitTest(__test, __test.test_is_postIf); 457 runJUnitTest(__test, __test.test_is_postIf);
402 }); 458 });
403 _ut.test('test_is_subclass', () { 459 _ut.test('test_is_subclass', () {
404 final __test = new TypePropagationTest(); 460 final __test = new TypePropagationTest();
405 runJUnitTest(__test, __test.test_is_subclass); 461 runJUnitTest(__test, __test.test_is_subclass);
406 }); 462 });
407 _ut.test('test_is_while', () { 463 _ut.test('test_is_while', () {
408 final __test = new TypePropagationTest(); 464 final __test = new TypePropagationTest();
409 runJUnitTest(__test, __test.test_is_while); 465 runJUnitTest(__test, __test.test_is_while);
410 }); 466 });
467 _ut.test('test_listLiteral_different', () {
468 final __test = new TypePropagationTest();
469 runJUnitTest(__test, __test.test_listLiteral_different);
470 });
471 _ut.test('test_listLiteral_same', () {
472 final __test = new TypePropagationTest();
473 runJUnitTest(__test, __test.test_listLiteral_same);
474 });
475 _ut.test('test_mapLiteral_different', () {
476 final __test = new TypePropagationTest();
477 runJUnitTest(__test, __test.test_mapLiteral_different);
478 });
479 _ut.test('test_mapLiteral_same', () {
480 final __test = new TypePropagationTest();
481 runJUnitTest(__test, __test.test_mapLiteral_same);
482 });
411 _ut.test('test_query', () { 483 _ut.test('test_query', () {
412 final __test = new TypePropagationTest(); 484 final __test = new TypePropagationTest();
413 runJUnitTest(__test, __test.test_query); 485 runJUnitTest(__test, __test.test_query);
414 }); 486 });
415 }); 487 });
416 } 488 }
417 } 489 }
418 class NonErrorResolverTest extends ResolverTestCase { 490 class NonErrorResolverTest extends ResolverTestCase {
491 void test_ambiguousExport() {
492 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"]));
493 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s M {}"]));
494 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
495 resolve(source);
496 assertNoErrors();
497 verify([source]);
498 }
499 void test_ambiguousExport_combinators_hide() {
500 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart' hide B;"]));
501 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class A {}", "class B {}"]));
502 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class B {}", "class C {}"]));
503 resolve(source);
504 assertNoErrors();
505 verify([source]);
506 }
507 void test_ambiguousExport_combinators_show() {
508 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart' show C;"]));
509 addSource2("/lib1.dart", EngineTestCase.createSource(["library L1;", "class A {}", "class B {}"]));
510 addSource2("/lib2.dart", EngineTestCase.createSource(["library L2;", "class B {}", "class C {}"]));
511 resolve(source);
512 assertNoErrors();
513 verify([source]);
514 }
419 void test_argumentDefinitionTestNonParameter_formalParameter() { 515 void test_argumentDefinitionTestNonParameter_formalParameter() {
420 Source source = addSource(EngineTestCase.createSource(["f(var v) {", " retu rn ?v;", "}"])); 516 Source source = addSource(EngineTestCase.createSource(["f(var v) {", " retu rn ?v;", "}"]));
421 resolve(source, []); 517 resolve(source);
422 assertNoErrors(); 518 assertNoErrors();
423 verify([source]); 519 verify([source]);
424 } 520 }
425 void test_argumentDefinitionTestNonParameter_namedParameter() { 521 void test_argumentDefinitionTestNonParameter_namedParameter() {
426 Source source = addSource(EngineTestCase.createSource(["f({var v : 0}) {", " return ?v;", "}"])); 522 Source source = addSource(EngineTestCase.createSource(["f({var v : 0}) {", " return ?v;", "}"]));
427 resolve(source, []); 523 resolve(source);
428 assertNoErrors(); 524 assertNoErrors();
429 verify([source]); 525 verify([source]);
430 } 526 }
431 void test_argumentDefinitionTestNonParameter_optionalParameter() { 527 void test_argumentDefinitionTestNonParameter_optionalParameter() {
432 Source source = addSource(EngineTestCase.createSource(["f([var v]) {", " re turn ?v;", "}"])); 528 Source source = addSource(EngineTestCase.createSource(["f([var v]) {", " re turn ?v;", "}"]));
433 resolve(source, []); 529 resolve(source);
530 assertNoErrors();
531 verify([source]);
532 }
533 void test_argumentTypeNotAssignable_invocation_functionParameter_generic() {
534 Source source = addSource(EngineTestCase.createSource(["class A<K> {", " m( f(K k), K v) {", " f(v);", " }", "}"]));
535 resolve(source);
536 assertNoErrors();
537 verify([source]);
538 }
539 void test_argumentTypeNotAssignable_invocation_typedef_generic() {
540 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);", "f(A<int> a) {", " a(1);", "}"]));
541 resolve(source);
542 assertNoErrors();
543 verify([source]);
544 }
545 void test_argumentTypeNotAssignable_Object_Function() {
546 Source source = addSource(EngineTestCase.createSource(["main() {", " proces s(() {});", "}", "process(Object x) {}"]));
547 resolve(source);
548 assertNoErrors();
549 verify([source]);
550 }
551 void test_argumentTypeNotAssignable_typedef_local() {
552 Source source = addSource(EngineTestCase.createSource(["typedef A(int p1, St ring p2);", "A getA() => null;", "f() {", " A a = getA();", " a(1, '2');", "}" ]));
553 resolve(source);
554 assertNoErrors();
555 verify([source]);
556 }
557 void test_argumentTypeNotAssignable_typedef_parameter() {
558 Source source = addSource(EngineTestCase.createSource(["typedef A(int p1, St ring p2);", "f(A a) {", " a(1, '2');", "}"]));
559 resolve(source);
560 assertNoErrors();
561 verify([source]);
562 }
563 void test_assignmentToFinal_prefixNegate() {
564 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " -x;", "}"]));
565 resolve(source);
566 assertNoErrors();
567 verify([source]);
568 }
569 void test_assignmentToFinals_importWithPrefix() {
570 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'lib1.dart' as foo;", "main() {", " foo.x = true;", "}"]));
571 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "bool x = false;"]));
572 resolve(source);
434 assertNoErrors(); 573 assertNoErrors();
435 verify([source]); 574 verify([source]);
436 } 575 }
437 void test_breakWithoutLabelInSwitch() { 576 void test_breakWithoutLabelInSwitch() {
438 Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " case 0:", " break;", " }", " }", "}"])); 577 Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " case 0:", " break;", " }", " }", "}"]));
439 resolve(source, []); 578 resolve(source);
440 assertNoErrors(); 579 assertNoErrors();
441 verify([source]); 580 verify([source]);
442 } 581 }
443 void test_builtInIdentifierAsType_dynamic() { 582 void test_builtInIdentifierAsType_dynamic() {
444 Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x ;", "}"])); 583 Source source = addSource(EngineTestCase.createSource(["f() {", " dynamic x ;", "}"]));
445 resolve(source, []); 584 resolve(source);
585 assertNoErrors();
586 verify([source]);
587 }
588 void test_caseBlockNotTerminated() {
589 Source source = addSource(EngineTestCase.createSource(["f(int p) {", " for (int i = 0; i < 10; i++) {", " switch (p) {", " case 0:", " break ;", " case 1:", " continue;", " case 2:", " return;", " case 3:", " throw new Object();", " case 4:", " case 5:", " return;", " case 6:", " default:", " return;", " }" , " }", "}"]));
590 resolve(source);
591 assertNoErrors();
592 verify([source]);
593 }
594 void test_caseBlockNotTerminated_lastCase() {
595 Source source = addSource(EngineTestCase.createSource(["f(int p) {", " swit ch (p) {", " case 0:", " p = p + 1;", " }", "}"]));
596 resolve(source);
446 assertNoErrors(); 597 assertNoErrors();
447 verify([source]); 598 verify([source]);
448 } 599 }
449 void test_caseExpressionTypeImplementsEquals_int() { 600 void test_caseExpressionTypeImplementsEquals_int() {
450 Source source = addSource(EngineTestCase.createSource(["f(int i) {", " swit ch(i) {", " case(1) : return 1;", " default: return 0;", " }", "}"])); 601 Source source = addSource(EngineTestCase.createSource(["f(int i) {", " swit ch(i) {", " case(1) : return 1;", " default: return 0;", " }", "}"]));
451 resolve(source, []); 602 resolve(source);
452 assertNoErrors(); 603 assertNoErrors();
453 verify([source]); 604 verify([source]);
454 } 605 }
455 void test_caseExpressionTypeImplementsEquals_Object() { 606 void test_caseExpressionTypeImplementsEquals_Object() {
456 Source source = addSource(EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", "}", "", "f(IntWrapper intWrapper) {", " switch(intWrapper) {", " case(const IntWrapper(1)) : retu rn 1;", " default: return 0;", " }", "}"])); 607 Source source = addSource(EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", "}", "", "f(IntWrapper intWrapper) {", " switch(intWrapper) {", " case(const IntWrapper(1)) : retu rn 1;", " default: return 0;", " }", "}"]));
457 resolve(source, []); 608 resolve(source);
458 assertNoErrors(); 609 assertNoErrors();
459 verify([source]); 610 verify([source]);
460 } 611 }
461 void test_caseExpressionTypeImplementsEquals_String() { 612 void test_caseExpressionTypeImplementsEquals_String() {
462 Source source = addSource(EngineTestCase.createSource(["f(String s) {", " s witch(s) {", " case('1') : return 1;", " default: return 0;", " }", "}"]) ); 613 Source source = addSource(EngineTestCase.createSource(["f(String s) {", " s witch(s) {", " case('1') : return 1;", " default: return 0;", " }", "}"]) );
463 resolve(source, []); 614 resolve(source);
464 assertNoErrors(); 615 assertNoErrors();
465 verify([source]); 616 verify([source]);
466 } 617 }
467 void test_concreteClassWithAbstractMember() { 618 void test_concreteClassWithAbstractMember() {
468 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", "}"])); 619 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", "}"]));
469 resolve(source, []); 620 resolve(source);
621 assertNoErrors();
622 verify([source]);
623 }
624 void test_conflictingInstanceGetterAndSuperclassMember_instance() {
625 Source source = addSource(EngineTestCase.createSource(["class A {", " get v => 0;", "}", "class B extends A {", " get v => 1;", "}"]));
626 resolve(source);
627 assertNoErrors();
628 verify([source]);
629 }
630 void test_conflictingStaticGetterAndInstanceSetter_thisClass() {
631 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c get x => 0;", " static set x(int p) {}", "}"]));
632 resolve(source);
633 assertNoErrors();
634 verify([source]);
635 }
636 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() {
637 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c x() {}", " static set x(int p) {}", "}"]));
638 resolve(source);
470 assertNoErrors(); 639 assertNoErrors();
471 verify([source]); 640 verify([source]);
472 } 641 }
473 void test_constConstructorWithNonFinalField_constInstanceVar() { 642 void test_constConstructorWithNonFinalField_constInstanceVar() {
474 Source source = addSource(EngineTestCase.createSource(["class A {", " const int x = 0;", " const A() {}", "}"])); 643 Source source = addSource(EngineTestCase.createSource(["class A {", " const int x = 0;", " const A();", "}"]));
475 resolve(source, []); 644 resolve(source);
476 assertNoErrors(); 645 assertNoErrors();
477 verify([source]); 646 verify([source]);
478 } 647 }
479 void test_constConstructorWithNonFinalField_finalInstanceVar() { 648 void test_constConstructorWithNonFinalField_finalInstanceVar() {
480 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " const A() {}", "}"])); 649 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " const A();", "}"]));
481 resolve(source, []); 650 resolve(source);
651 assertNoErrors();
652 verify([source]);
653 }
654 void test_constConstructorWithNonFinalField_mixin() {
655 Source source = addSource(EngineTestCase.createSource(["class A {", " a() { }", "}", "class B extends Object with A {", " const B();", "}"]));
656 resolve(source);
482 assertNoErrors(); 657 assertNoErrors();
483 verify([source]); 658 verify([source]);
484 } 659 }
485 void test_constConstructorWithNonFinalField_static() { 660 void test_constConstructorWithNonFinalField_static() {
486 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " const A() {}", "}"])); 661 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " const A();", "}"]));
487 resolve(source, []); 662 resolve(source);
488 assertNoErrors(); 663 assertNoErrors();
489 verify([source]); 664 verify([source]);
490 } 665 }
491 void test_constConstructorWithNonFinalField_syntheticField() { 666 void test_constConstructorWithNonFinalField_syntheticField() {
492 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"])); 667 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"]));
493 resolve(source, []); 668 resolve(source);
669 assertNoErrors();
670 verify([source]);
671 }
672 void test_constEvalTypeBoolNumString_equal() {
673 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;", "}"]));
674 resolve(source);
675 assertNoErrors();
676 verify([source]);
677 }
678 void test_constEvalTypeBoolNumString_notEqual() {
679 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;", "}"]));
680 resolve(source);
681 assertNoErrors();
682 verify([source]);
683 }
684 void test_constWithNonConstantArgument_literals() {
685 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(a, b, c, d);", "}", "f() { return const A(true, 0, 1.0, '2'); }"]));
686 resolve(source);
687 assertNoErrors();
688 verify([source]);
689 }
690 void test_constWithTypeParameters_direct() {
691 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " co nst V = const A<int>();", " const A();", "}"]));
692 resolve(source);
693 assertNoErrors();
694 verify([source]);
695 }
696 void test_constWithUndefinedConstructor() {
697 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.name();", "}", "f() {", " return const A.name();", "}"]));
698 resolve(source);
699 assertNoErrors();
700 verify([source]);
701 }
702 void test_constWithUndefinedConstructorDefault() {
703 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "f() {", " return const A();", "}"]));
704 resolve(source);
494 assertNoErrors(); 705 assertNoErrors();
495 verify([source]); 706 verify([source]);
496 } 707 }
497 void test_defaultValueInFunctionTypeAlias() { 708 void test_defaultValueInFunctionTypeAlias() {
498 Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"])); 709 Source source = addSource(EngineTestCase.createSource(["typedef F([x]);"]));
499 resolve(source, []); 710 resolve(source);
500 assertErrors([]); 711 assertErrors([]);
501 verify([source]); 712 verify([source]);
502 } 713 }
503 void test_duplicateDefinition_emptyName() { 714 void test_duplicateDefinition_emptyName() {
504 Source source = addSource(EngineTestCase.createSource(["Map _globalMap = {", " 'a' : () {},", " 'b' : () {}", "}"])); 715 Source source = addSource(EngineTestCase.createSource(["Map _globalMap = {", " 'a' : () {},", " 'b' : () {}", "};"]));
505 resolve(source, []); 716 resolve(source);
506 assertNoErrors(); 717 assertNoErrors();
507 verify([source]); 718 verify([source]);
508 } 719 }
509 void test_duplicateDefinition_getter() { 720 void test_duplicateDefinition_getter() {
510 Source source = addSource(EngineTestCase.createSource(["bool get a => true;" ])); 721 Source source = addSource(EngineTestCase.createSource(["bool get a => true;" ]));
511 resolve(source, []); 722 resolve(source);
512 assertNoErrors(); 723 assertNoErrors();
513 verify([source]); 724 verify([source]);
514 } 725 }
515 void test_exportOfNonLibrary_libraryDeclared() { 726 void test_exportOfNonLibrary_libraryDeclared() {
516 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"])); 727 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
517 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); 728 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
518 resolve(source, []); 729 resolve(source);
519 assertNoErrors(); 730 assertNoErrors();
520 verify([source]); 731 verify([source]);
521 } 732 }
522 void test_exportOfNonLibrary_libraryNotDeclared() { 733 void test_exportOfNonLibrary_libraryNotDeclared() {
523 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"])); 734 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
524 addSource2("/lib1.dart", EngineTestCase.createSource([""])); 735 addSource2("/lib1.dart", EngineTestCase.createSource([""]));
525 resolve(source, []); 736 resolve(source);
737 assertNoErrors();
738 verify([source]);
739 }
740 void test_extraPositionalArguments_function() {
741 Source source = addSource(EngineTestCase.createSource(["f(p1, p2) {}", "main () {", " f(1, 2);", "}"]));
742 resolve(source);
743 assertNoErrors();
744 verify([source]);
745 }
746 void test_extraPositionalArguments_Function() {
747 Source source = addSource(EngineTestCase.createSource(["f(Function a) {", " a(1, 2);", "}"]));
748 resolve(source);
749 assertNoErrors();
750 verify([source]);
751 }
752 void test_extraPositionalArguments_typedef_local() {
753 Source source = addSource(EngineTestCase.createSource(["typedef A(p1, p2);", "A getA() => null;", "f() {", " A a = getA();", " a(1, 2);", "}"]));
754 resolve(source);
755 assertNoErrors();
756 verify([source]);
757 }
758 void test_extraPositionalArguments_typedef_parameter() {
759 Source source = addSource(EngineTestCase.createSource(["typedef A(p1, p2);", "f(A a) {", " a(1, 2);", "}"]));
760 resolve(source);
526 assertNoErrors(); 761 assertNoErrors();
527 verify([source]); 762 verify([source]);
528 } 763 }
529 void test_fieldInitializedByMultipleInitializers() { 764 void test_fieldInitializedByMultipleInitializers() {
530 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " int y;", " A() : x = 0, y = 0 {}", "}"])); 765 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " int y;", " A() : x = 0, y = 0 {}", "}"]));
531 resolve(source, []); 766 resolve(source);
532 assertNoErrors(); 767 assertNoErrors();
533 verify([source]); 768 verify([source]);
534 } 769 }
535 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() { 770 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() {
536 Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 0;", " A() : x = 1 {}", "}"])); 771 Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 0;", " A() : x = 1 {}", "}"]));
537 resolve(source, []); 772 resolve(source);
538 assertNoErrors(); 773 assertNoErrors();
539 verify([source]); 774 verify([source]);
540 } 775 }
541 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() { 776 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() {
542 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 1 {}", "}"])); 777 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 1 {}", "}"]));
543 resolve(source, []); 778 resolve(source);
544 assertNoErrors(); 779 assertNoErrors();
545 verify([source]); 780 verify([source]);
546 } 781 }
547 void test_fieldInitializerOutsideConstructor() { 782 void test_fieldInitializerOutsideConstructor() {
548 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"])); 783 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"]));
549 resolve(source, []); 784 resolve(source);
550 assertNoErrors(); 785 assertNoErrors();
551 verify([source]); 786 verify([source]);
552 } 787 }
553 void test_fieldInitializerOutsideConstructor_defaultParameters() { 788 void test_fieldInitializerOutsideConstructor_defaultParameters() {
554 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A([this.x]) {}", "}"])); 789 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A([this.x]) {}", "}"]));
555 resolve(source, []); 790 resolve(source);
791 assertNoErrors();
792 verify([source]);
793 }
794 void test_fieldInitializerRedirectingConstructor_super() {
795 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " int x;", " A(this.x) : super();", "}"]));
796 resolve(source);
556 assertNoErrors(); 797 assertNoErrors();
557 verify([source]); 798 verify([source]);
558 } 799 }
559 void test_finalInitializedInDeclarationAndConstructor_initializer() { 800 void test_finalInitializedInDeclarationAndConstructor_initializer() {
560 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 1 {}", "}"])); 801 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 1 {}", "}"]));
561 resolve(source, []); 802 resolve(source);
562 assertNoErrors(); 803 assertNoErrors();
563 verify([source]); 804 verify([source]);
564 } 805 }
565 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { 806 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
566 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) {}", "}"])); 807 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) {}", "}"]));
567 resolve(source, []); 808 resolve(source);
568 assertNoErrors(); 809 assertNoErrors();
569 verify([source]); 810 verify([source]);
570 } 811 }
571 void test_finalNotInitialized_atDeclaration() { 812 void test_finalNotInitialized_atDeclaration() {
572 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"])); 813 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"]));
573 resolve(source, []); 814 resolve(source);
574 assertNoErrors(); 815 assertNoErrors();
575 verify([source]); 816 verify([source]);
576 } 817 }
577 void test_finalNotInitialized_fieldFormal() { 818 void test_finalNotInitialized_fieldFormal() {
578 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"])); 819 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() {}", "}"]));
579 resolve(source, []); 820 resolve(source);
580 assertNoErrors(); 821 assertNoErrors();
581 verify([source]); 822 verify([source]);
582 } 823 }
583 void test_finalNotInitialized_initializer() { 824 void test_finalNotInitialized_initializer() {
584 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 0 {}", "}"])); 825 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 0 {}", "}"]));
585 resolve(source, []); 826 resolve(source);
827 assertNoErrors();
828 verify([source]);
829 }
830 void test_implicitThisReferenceInInitializer_constructorName() {
831 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam ed() {}", "}", "class B {", " var v;", " B() : v = new A.named();", "}"]));
832 resolve(source);
833 assertNoErrors();
834 verify([source]);
835 }
836 void test_implicitThisReferenceInInitializer_prefixedIdentifier() {
837 Source source = addSource(EngineTestCase.createSource(["class A {", " var f ;", "}", "class B {", " var v;", " B(A a) : v = a.f;", "}"]));
838 resolve(source);
839 assertNoErrors();
840 verify([source]);
841 }
842 void test_implicitThisReferenceInInitializer_qualifiedMethodInvocation() {
843 Source source = addSource(EngineTestCase.createSource(["class A {", " f() { }", "}", "class B {", " var v;", " B() : v = new A().f();", "}"]));
844 resolve(source);
845 assertNoErrors();
846 verify([source]);
847 }
848 void test_implicitThisReferenceInInitializer_qualifiedPropertyAccess() {
849 Source source = addSource(EngineTestCase.createSource(["class A {", " var f ;", "}", "class B {", " var v;", " B() : v = new A().f;", "}"]));
850 resolve(source);
851 assertNoErrors();
852 verify([source]);
853 }
854 void test_implicitThisReferenceInInitializer_staticField_superClass() {
855 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c var f;", "}", "class B extends A {", " var v;", " B() : v = f;", "}"]));
856 resolve(source);
857 assertNoErrors();
858 verify([source]);
859 }
860 void test_implicitThisReferenceInInitializer_staticField_thisClass() {
861 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f;", " static var f;", "}"]));
862 resolve(source);
863 assertNoErrors();
864 verify([source]);
865 }
866 void test_implicitThisReferenceInInitializer_staticGetter() {
867 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f;", " static get f => 42;", "}"]));
868 resolve(source);
869 assertNoErrors();
870 verify([source]);
871 }
872 void test_implicitThisReferenceInInitializer_staticMethod() {
873 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f();", " static f() => 42;", "}"]));
874 resolve(source);
875 assertNoErrors();
876 verify([source]);
877 }
878 void test_implicitThisReferenceInInitializer_topLevelField() {
879 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f;", "}", "var f = 42;"]));
880 resolve(source);
881 assertNoErrors();
882 verify([source]);
883 }
884 void test_implicitThisReferenceInInitializer_topLevelFunction() {
885 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f();", "}", "f() => 42;"]));
886 resolve(source);
887 assertNoErrors();
888 verify([source]);
889 }
890 void test_implicitThisReferenceInInitializer_topLevelGetter() {
891 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f;", "}", "get f => 42;"]));
892 resolve(source);
893 assertNoErrors();
894 verify([source]);
895 }
896 void test_implicitThisReferenceInInitializer_typeVariable() {
897 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " va r v;", " A(p) : v = (p is T);", "}"]));
898 resolve(source);
899 assertNoErrors();
900 verify([source]);
901 }
902 void test_importDuplicatedLibraryName() {
903 Source source = addSource(EngineTestCase.createSource(["library test;", "imp ort 'lib.dart';", "import 'lib.dart';"]));
904 addSource2("/lib.dart", "library lib;");
905 resolve(source);
586 assertNoErrors(); 906 assertNoErrors();
587 verify([source]); 907 verify([source]);
588 } 908 }
589 void test_importOfNonLibrary_libraryDeclared() { 909 void test_importOfNonLibrary_libraryDeclared() {
590 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';"])); 910 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';"]));
591 addSource2("/part.dart", EngineTestCase.createSource(["library lib1;"])); 911 addSource2("/part.dart", EngineTestCase.createSource(["library lib1;"]));
592 resolve(source, []); 912 resolve(source);
593 assertNoErrors(); 913 assertNoErrors();
594 verify([source]); 914 verify([source]);
595 } 915 }
596 void test_importOfNonLibrary_libraryNotDeclared() { 916 void test_importOfNonLibrary_libraryNotDeclared() {
597 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';"])); 917 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';"]));
598 addSource2("/part.dart", EngineTestCase.createSource([""])); 918 addSource2("/part.dart", EngineTestCase.createSource([""]));
599 resolve(source, []); 919 resolve(source);
600 assertNoErrors(); 920 assertNoErrors();
601 verify([source]); 921 verify([source]);
602 } 922 }
603 void test_inconsistentCaseExpressionTypes() { 923 void test_inconsistentCaseExpressionTypes() {
604 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " swit ch (p) {", " case 1:", " break;", " case 2:", " break;", " }", "}"])); 924 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " swit ch (p) {", " case 1:", " break;", " case 2:", " break;", " }", "}"]));
605 resolve(source, []); 925 resolve(source);
606 assertNoErrors(); 926 assertNoErrors();
607 verify([source]); 927 verify([source]);
608 } 928 }
609 void test_initializingFormalForNonExistantField() { 929 void test_initializingFormalForNonExistantField() {
610 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"])); 930 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"]));
611 resolve(source, []); 931 resolve(source);
612 assertNoErrors(); 932 assertNoErrors();
613 verify([source]); 933 verify([source]);
614 } 934 }
615 void test_invalidAssignment() { 935 void test_invalidAssignment() {
616 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;", " var y;", " x = y;", "}"])); 936 Source source = addSource(EngineTestCase.createSource(["f() {", " var x;", " var y;", " x = y;", "}"]));
617 resolve(source, []); 937 resolve(source);
938 assertNoErrors();
939 verify([source]);
940 }
941 void test_invalidAssignment_compoundAssignment() {
942 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;", "}"]));
943 resolve(source);
618 assertNoErrors(); 944 assertNoErrors();
619 verify([source]); 945 verify([source]);
620 } 946 }
621 void test_invalidAssignment_toDynamic() { 947 void test_invalidAssignment_toDynamic() {
622 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g = () => 0;", "}"])); 948 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g = () => 0;", "}"]));
623 resolve(source, []); 949 resolve(source);
950 assertNoErrors();
951 verify([source]);
952 }
953 void test_invalidFactoryNameNotAClass() {
954 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}"]));
955 resolve(source);
956 assertNoErrors();
957 verify([source]);
958 }
959 void test_invalidOverrideNamed_unorderedNamedParameter() {
960 Source source = addSource(EngineTestCase.createSource(["class A {", " m({a, b}) {}", "}", "class B extends A {", " m({b, a}) {}", "}"]));
961 resolve(source);
962 assertNoErrors();
963 verify([source]);
964 }
965 void test_invalidOverrideReturnType_returnType_interface() {
966 Source source = addSource2("/test.dart", EngineTestCase.createSource(["abstr act class A {", " num m();", "}", "class B implements A {", " int m() { return 1; }", "}"]));
967 resolve(source);
968 assertNoErrors();
969 verify([source]);
970 }
971 void test_invalidOverrideReturnType_returnType_interface2() {
972 Source source = addSource2("/test.dart", EngineTestCase.createSource(["abstr act class A {", " num m();", "}", "abstract class B implements A {", "}", "clas s C implements B {", " int m() { return 1; }", "}"]));
973 resolve(source);
974 assertNoErrors();
975 verify([source]);
976 }
977 void test_invalidOverrideReturnType_returnType_mixin() {
978 Source source = addSource2("/test.dart", EngineTestCase.createSource(["class A {", " num m() { return 0; }", "}", "class B extends Object with A {", " int m() { return 1; }", "}"]));
979 resolve(source);
980 assertNoErrors();
981 verify([source]);
982 }
983 void test_invalidOverrideReturnType_returnType_parameterizedTypes() {
984 Source source = addSource(EngineTestCase.createSource(["abstract class A<E> {", " List<E> m();", "}", "class B extends A<dynamic> {", " List<dynamic> m() { return new List<dynamic>(); }", "}"]));
985 resolve(source);
986 assertNoErrors();
987 verify([source]);
988 }
989 void test_invalidOverrideReturnType_returnType_sameType() {
990 Source source = addSource2("/test.dart", EngineTestCase.createSource(["class A {", " int m() { return 0; }", "}", "class B extends A {", " int m() { retur n 1; }", "}"]));
991 resolve(source);
992 assertNoErrors();
993 verify([source]);
994 }
995 void test_invalidOverrideReturnType_returnType_superclass() {
996 Source source = addSource2("/test.dart", EngineTestCase.createSource(["class A {", " num m() { return 0; }", "}", "class B extends A {", " int m() { retur n 1; }", "}"]));
997 resolve(source);
998 assertNoErrors();
999 verify([source]);
1000 }
1001 void test_invalidOverrideReturnType_returnType_superclass2() {
1002 Source source = addSource2("/test.dart", EngineTestCase.createSource(["class A {", " num m() { return 0; }", "}", "class B extends A {", "}", "class C exte nds B {", " int m() { return 1; }", "}"]));
1003 resolve(source);
1004 assertNoErrors();
1005 verify([source]);
1006 }
1007 void test_invalidOverrideReturnType_returnType_void() {
1008 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {}", "}", "class B extends A {", " int m() {}", "}"]));
1009 resolve(source);
1010 assertNoErrors();
1011 verify([source]);
1012 }
1013 void test_invalidReferenceToThis_constructor() {
1014 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { ", " var v = this;", " }", "}"]));
1015 resolve(source);
1016 assertNoErrors();
1017 verify([source]);
1018 }
1019 void test_invalidReferenceToThis_instanceMethod() {
1020 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { ", " var v = this;", " }", "}"]));
1021 resolve(source);
624 assertNoErrors(); 1022 assertNoErrors();
625 verify([source]); 1023 verify([source]);
626 } 1024 }
627 void test_invalidTypeArgumentInConstList() { 1025 void test_invalidTypeArgumentInConstList() {
628 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m( ) {", " return <E>[]", " }", "}"])); 1026 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m( ) {", " return <E>[];", " }", "}"]));
629 resolve(source, []); 1027 resolve(source);
630 assertNoErrors(); 1028 assertNoErrors();
631 verify([source]); 1029 verify([source]);
632 } 1030 }
633 void test_invalidTypeArgumentInConstMap() { 1031 void test_invalidTypeArgumentInConstMap() {
634 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m( ) {", " return <String, E>{}", " }", "}"])); 1032 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m( ) {", " return <String, E>{};", " }", "}"]));
635 resolve(source, []); 1033 resolve(source);
636 assertNoErrors(); 1034 assertNoErrors();
637 verify([source]); 1035 verify([source]);
638 } 1036 }
639 void test_invocationOfNonFunction_dynamic() { 1037 void test_invocationOfNonFunction_dynamic() {
640 Source source = addSource(EngineTestCase.createSource(["class A {", " var f ;", "}", "class B extends A {", " g() {", " f();", " }", "}"])); 1038 Source source = addSource(EngineTestCase.createSource(["class A {", " var f ;", "}", "class B extends A {", " g() {", " f();", " }", "}"]));
641 resolve(source, []); 1039 resolve(source);
642 assertNoErrors(); 1040 assertNoErrors();
643 verify([source]); 1041 verify([source]);
644 } 1042 }
645 void test_invocationOfNonFunction_getter() { 1043 void test_invocationOfNonFunction_getter() {
646 Source source = addSource(EngineTestCase.createSource(["class A {", " var g ;", "}", "f() {", " A a;", " a.g();", "}"])); 1044 Source source = addSource(EngineTestCase.createSource(["class A {", " var g ;", "}", "f() {", " A a;", " a.g();", "}"]));
647 resolve(source, []); 1045 resolve(source);
648 assertNoErrors(); 1046 assertNoErrors();
649 verify([source]); 1047 verify([source]);
650 } 1048 }
651 void test_invocationOfNonFunction_localVariable() { 1049 void test_invocationOfNonFunction_localVariable() {
652 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g();", "}"])); 1050 Source source = addSource(EngineTestCase.createSource(["f() {", " var g;", " g();", "}"]));
653 resolve(source, []); 1051 resolve(source);
1052 assertNoErrors();
1053 verify([source]);
1054 }
1055 void test_memberWithClassName_setter() {
1056 Source source = addSource(EngineTestCase.createSource(["class A {", " set A (v) {}", "}"]));
1057 resolve(source);
1058 assertNoErrors();
1059 verify([source]);
1060 }
1061 void test_misMatchedGetterAndSetterTypes_instance_sameTypes() {
1062 Source source = addSource(EngineTestCase.createSource(["class C {", " int g et x => 0;", " set x(int v) {}", "}"]));
1063 resolve(source);
1064 assertNoErrors();
1065 verify([source]);
1066 }
1067 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter() {
1068 Source source = addSource(EngineTestCase.createSource(["class C {", " get x => 0;", " set x(String v) {}", "}"]));
1069 resolve(source);
1070 assertNoErrors();
1071 verify([source]);
1072 }
1073 void test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter() {
1074 Source source = addSource(EngineTestCase.createSource(["class C {", " int g et x => 0;", " set x(v) {}", "}"]));
1075 resolve(source);
1076 assertNoErrors();
1077 verify([source]);
1078 }
1079 void test_misMatchedGetterAndSetterTypes_topLevel_sameTypes() {
1080 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s et x(int v) {}"]));
1081 resolve(source);
1082 assertNoErrors();
1083 verify([source]);
1084 }
1085 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter() {
1086 Source source = addSource(EngineTestCase.createSource(["get x => 0;", "set x (String v) {}"]));
1087 resolve(source);
1088 assertNoErrors();
1089 verify([source]);
1090 }
1091 void test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter() {
1092 Source source = addSource(EngineTestCase.createSource(["int get x => 0;", "s et x(v) {}"]));
1093 resolve(source);
1094 assertNoErrors();
1095 verify([source]);
1096 }
1097 void test_mixinDeclaresConstructor() {
1098 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "class B extends Object with A {}"]));
1099 resolve(source);
1100 assertNoErrors();
1101 verify([source]);
1102 }
1103 void test_mixinDeclaresConstructor_factory() {
1104 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}", "class B extends Object with A {}"]));
1105 resolve(source);
1106 assertNoErrors();
1107 verify([source]);
1108 }
1109 void test_mixinInheritsFromNotObject_classDeclaration_mixTypedef() {
1110 Source source = addSource(EngineTestCase.createSource(["class A {}", "typede f B = Object with A;", "class C extends Object with B {}"]));
1111 resolve(source);
1112 assertNoErrors();
1113 verify([source]);
1114 }
1115 void test_mixinInheritsFromNotObject_typedef_mixTypedef() {
1116 Source source = addSource(EngineTestCase.createSource(["class A {}", "typede f B = Object with A;", "typedef C = Object with B;"]));
1117 resolve(source);
1118 assertNoErrors();
1119 verify([source]);
1120 }
1121 void test_multipleSuperInitializers_no() {
1122 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B() {}", "}"]));
1123 resolve(source);
1124 assertNoErrors();
1125 verify([source]);
1126 }
1127 void test_multipleSuperInitializers_single() {
1128 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B() : super() {}", "}"]));
1129 resolve(source);
654 assertNoErrors(); 1130 assertNoErrors();
655 verify([source]); 1131 verify([source]);
656 } 1132 }
657 void test_newWithAbstractClass_factory() { 1133 void test_newWithAbstractClass_factory() {
658 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " factory A() { return new B(); }", "}", "class B implements A {", " B() {}", "}", "A f() {", " return new A();", "}"])); 1134 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " factory A() { return new B(); }", "}", "class B implements A {", " B() {}", "}", "A f() {", " return new A();", "}"]));
659 resolve(source, []); 1135 resolve(source);
1136 assertNoErrors();
1137 verify([source]);
1138 }
1139 void test_newWithUndefinedConstructor() {
1140 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam e() {}", "}", "f() {", " new A.name();", "}"]));
1141 resolve(source);
1142 assertNoErrors();
1143 verify([source]);
1144 }
1145 void test_newWithUndefinedConstructorDefault() {
1146 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A();", "}"]));
1147 resolve(source);
660 assertNoErrors(); 1148 assertNoErrors();
661 verify([source]); 1149 verify([source]);
662 } 1150 }
663 void test_nonBoolExpression_assert_bool() { 1151 void test_nonBoolExpression_assert_bool() {
664 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr ue);", "}"])); 1152 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr ue);", "}"]));
665 resolve(source, []); 1153 resolve(source);
666 assertNoErrors(); 1154 assertNoErrors();
667 verify([source]); 1155 verify([source]);
668 } 1156 }
669 void test_nonBoolExpression_assert_functionType() { 1157 void test_nonBoolExpression_assert_functionType() {
670 Source source = addSource(EngineTestCase.createSource(["bool makeAssertion() => true;", "f() {", " assert(makeAssertion);", "}"])); 1158 Source source = addSource(EngineTestCase.createSource(["bool makeAssertion() => true;", "f() {", " assert(makeAssertion);", "}"]));
671 resolve(source, []); 1159 resolve(source);
1160 assertNoErrors();
1161 verify([source]);
1162 }
1163 void test_nonConstCaseExpression() {
1164 Source source = addSource(EngineTestCase.createSource(["f(Type t) {", " swi tch (t) {", " case bool:", " case int:", " return true;", " defaul t:", " return false;", " }", "}"]));
1165 resolve(source);
1166 assertNoErrors();
1167 verify([source]);
1168 }
1169 void test_nonConstMapAsExpressionStatement_const() {
1170 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a ' : 0, 'b' : 1};", "}"]));
1171 resolve(source);
1172 assertNoErrors();
1173 verify([source]);
1174 }
1175 void test_nonConstMapAsExpressionStatement_notExpressionStatement() {
1176 Source source = addSource(EngineTestCase.createSource(["f() {", " var m = { 'a' : 0, 'b' : 1};", "}"]));
1177 resolve(source);
1178 assertNoErrors();
1179 verify([source]);
1180 }
1181 void test_nonConstMapAsExpressionStatement_typeArguments() {
1182 Source source = addSource(EngineTestCase.createSource(["f() {", " <String, int> {'a' : 0, 'b' : 1};", "}"]));
1183 resolve(source);
1184 assertNoErrors();
1185 verify([source]);
1186 }
1187 void test_nonConstValueInInitializer_binary_bool() {
1188 Source source = addSource(EngineTestCase.createSource(["class A {", " final v;", " const A.a1(bool p) : v = p && true;", " const A.a2(bool p) : v = true && p;", " const A.b1(bool p) : v = p || true;", " const A.b2(bool p) : v = tru e || p;", "}"]));
1189 resolve(source);
1190 assertNoErrors();
1191 verify([source]);
1192 }
1193 void test_nonConstValueInInitializer_binary_dynamic() {
1194 Source source = addSource(EngineTestCase.createSource(["class A {", " final v;", " const A.a1(p) : v = p + 5;", " const A.a2(p) : v = 5 + p;", " const A .b1(p) : v = p - 5;", " const A.b2(p) : v = 5 - p;", " const A.c1(p) : v = p * 5;", " const A.c2(p) : v = 5 * p;", " const A.d1(p) : v = p / 5;", " const A .d2(p) : v = 5 / p;", " const A.e1(p) : v = p ~/ 5;", " const A.e2(p) : v = 5 ~/ p;", " const A.f1(p) : v = p > 5;", " const A.f2(p) : v = 5 > p;", " const A.g1(p) : v = p < 5;", " const A.g2(p) : v = 5 < p;", " const A.h1(p) : v = p >= 5;", " const A.h2(p) : v = 5 >= p;", " const A.i1(p) : v = p <= 5;", " co nst A.i2(p) : v = 5 <= p;", " const A.j1(p) : v = p % 5;", " const A.j2(p) : v = 5 % p;", "}"]));
1195 resolve(source);
1196 assertNoErrors();
1197 }
1198 void test_nonConstValueInInitializer_binary_int() {
1199 Source source = addSource(EngineTestCase.createSource(["class A {", " final v;", " const A.a1(int p) : v = p ^ 5;", " const A.a2(int p) : v = 5 ^ p;", " const A.b1(int p) : v = p & 5;", " const A.b2(int p) : v = 5 & p;", " const A .c1(int p) : v = p | 5;", " const A.c2(int p) : v = 5 | p;", " const A.d1(int p) : v = p >> 5;", " const A.d2(int p) : v = 5 >> p;", " const A.e1(int p) : v = p << 5;", " const A.e2(int p) : v = 5 << p;", "}"]));
1200 resolve(source);
1201 assertNoErrors();
1202 verify([source]);
1203 }
1204 void test_nonConstValueInInitializer_binary_num() {
1205 Source source = addSource(EngineTestCase.createSource(["class A {", " final v;", " const A.a1(num p) : v = p + 5;", " const A.a2(num p) : v = 5 + p;", " const A.b1(num p) : v = p - 5;", " const A.b2(num p) : v = 5 - p;", " const A .c1(num p) : v = p * 5;", " const A.c2(num p) : v = 5 * p;", " const A.d1(num p) : v = p / 5;", " const A.d2(num p) : v = 5 / p;", " const A.e1(num p) : v = p ~/ 5;", " const A.e2(num p) : v = 5 ~/ p;", " const A.f1(num p) : v = p > 5 ;", " const A.f2(num p) : v = 5 > p;", " const A.g1(num p) : v = p < 5;", " c onst A.g2(num p) : v = 5 < p;", " const A.h1(num p) : v = p >= 5;", " const A. h2(num p) : v = 5 >= p;", " const A.i1(num p) : v = p <= 5;", " const A.i2(num p) : v = 5 <= p;", " const A.j1(num p) : v = p % 5;", " const A.j2(num p) : v = 5 % p;", "}"]));
1206 resolve(source);
1207 assertNoErrors();
1208 verify([source]);
1209 }
1210 void test_nonConstValueInInitializer_field() {
1211 Source source = addSource(EngineTestCase.createSource(["class A {", " final int a;", " const A() : a = 5;", "}"]));
1212 resolve(source);
1213 assertNoErrors();
1214 verify([source]);
1215 }
1216 void test_nonConstValueInInitializer_redirecting() {
1217 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.named(p);", " const A() : this.named(42);", "}"]));
1218 resolve(source);
1219 assertNoErrors();
1220 verify([source]);
1221 }
1222 void test_nonConstValueInInitializer_super() {
1223 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(p);", "}", "class B extends A {", " const B() : super(42);", "}"]));
1224 resolve(source);
1225 assertNoErrors();
1226 verify([source]);
1227 }
1228 void test_nonConstValueInInitializer_unary() {
1229 Source source = addSource(EngineTestCase.createSource(["class A {", " final v;", " const A.a(bool p) : v = !p;", " const A.b(int p) : v = ~p;", " const A.c(num p) : v = -p;", "}"]));
1230 resolve(source);
1231 assertNoErrors();
1232 verify([source]);
1233 }
1234 void test_nonGenerativeConstructor() {
1235 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam ed() {}", " factory A() {}", "}", "class B extends A {", " B() : super.named() ;", "}"]));
1236 resolve(source);
1237 assertNoErrors();
1238 verify([source]);
1239 }
1240 void test_nonTypeInCatchClause_isClass() {
1241 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", " } on String catch (e) {", " }", "}"]));
1242 resolve(source);
1243 assertNoErrors();
1244 verify([source]);
1245 }
1246 void test_nonTypeInCatchClause_isFunctionTypeAlias() {
1247 Source source = addSource(EngineTestCase.createSource(["typedef F();", "f() {", " try {", " } on F catch (e) {", " }", "}"]));
1248 resolve(source);
1249 assertNoErrors();
1250 verify([source]);
1251 }
1252 void test_nonTypeInCatchClause_isTypeVariable() {
1253 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " f( ) {", " try {", " } on T catch (e) {", " }", " }", "}"]));
1254 resolve(source);
1255 assertNoErrors();
1256 verify([source]);
1257 }
1258 void test_nonTypeInCatchClause_noType() {
1259 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", " } catch (e) {", " }", "}"]));
1260 resolve(source);
1261 assertNoErrors();
1262 verify([source]);
1263 }
1264 void test_nonVoidReturnForOperator_no() {
1265 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor []=(a, b) {}", "}"]));
1266 resolve(source);
1267 assertNoErrors();
1268 verify([source]);
1269 }
1270 void test_nonVoidReturnForOperator_void() {
1271 Source source = addSource(EngineTestCase.createSource(["class A {", " void operator []=(a, b) {}", "}"]));
1272 resolve(source);
1273 assertNoErrors();
1274 verify([source]);
1275 }
1276 void test_nonVoidReturnForSetter_function_no() {
1277 Source source = addSource("set x(v) {}");
1278 resolve(source);
1279 assertNoErrors();
1280 verify([source]);
1281 }
1282 void test_nonVoidReturnForSetter_function_void() {
1283 Source source = addSource("void set x(v) {}");
1284 resolve(source);
1285 assertNoErrors();
1286 verify([source]);
1287 }
1288 void test_nonVoidReturnForSetter_method_no() {
1289 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (v) {}", "}"]));
1290 resolve(source);
1291 assertNoErrors();
1292 verify([source]);
1293 }
1294 void test_nonVoidReturnForSetter_method_void() {
1295 Source source = addSource(EngineTestCase.createSource(["class A {", " void set x(v) {}", "}"]));
1296 resolve(source);
672 assertNoErrors(); 1297 assertNoErrors();
673 verify([source]); 1298 verify([source]);
674 } 1299 }
675 void test_optionalParameterInOperator_required() { 1300 void test_optionalParameterInOperator_required() {
676 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +(p) {}", "}"])); 1301 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +(p) {}", "}"]));
677 resolve(source, []); 1302 resolve(source);
1303 assertNoErrors();
1304 verify([source]);
1305 }
1306 void test_prefixCollidesWithTopLevelMembers() {
1307 addSource2("/lib.dart", "library lib;");
1308 Source source = addSource(EngineTestCase.createSource(["import '/lib.dart' a s p;", "typedef P();", "p2() {}", "var p3;", "class p4 {}"]));
1309 resolve(source);
1310 assertNoErrors();
1311 verify([source]);
1312 }
1313 void test_recursiveConstructorRedirect() {
1314 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a() : this.b();", " A.b() : this.c();", " A.c() {}", "}"]));
1315 resolve(source);
1316 assertNoErrors();
1317 verify([source]);
1318 }
1319 void test_recursiveFactoryRedirect() {
1320 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() = B;", "}", "class B implements A {", " factory B() = C;", "}", "class C implements B {", " factory C() {}", "}"]));
1321 resolve(source);
1322 assertNoErrors();
1323 verify([source]);
1324 }
1325 void test_redirectToInvalidFunctionType() {
1326 Source source = addSource(EngineTestCase.createSource(["class A implements B {", " A(int p) {}", "}", "class B {", " B(int p) = A;", "}"]));
1327 resolve(source);
1328 assertNoErrors();
1329 verify([source]);
1330 }
1331 void test_redirectToNonConstConstructor() {
1332 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.a();", " const factory A.b() = A.a;", "}"]));
1333 resolve(source);
1334 assertNoErrors();
1335 verify([source]);
1336 }
1337 void test_referenceToDeclaredVariableInInitializer_constructorName() {
1338 Source source = addSource(EngineTestCase.createSource(["class A {", " A.x() {}", "}", "f() {", " var x = new A.x();", "}"]));
1339 resolve(source);
1340 assertNoErrors();
1341 verify([source]);
1342 }
1343 void test_referenceToDeclaredVariableInInitializer_methodName() {
1344 Source source = addSource(EngineTestCase.createSource(["class A {", " x() { }", "}", "f(A a) {", " var x = a.x();", "}"]));
1345 resolve(source);
1346 assertNoErrors();
1347 verify([source]);
1348 }
1349 void test_referenceToDeclaredVariableInInitializer_propertyName() {
1350 Source source = addSource(EngineTestCase.createSource(["class A {", " var x ;", "}", "f(A a) {", " var x = a.x;", "}"]));
1351 resolve(source);
678 assertNoErrors(); 1352 assertNoErrors();
679 verify([source]); 1353 verify([source]);
680 } 1354 }
681 void test_rethrowOutsideCatch() { 1355 void test_rethrowOutsideCatch() {
682 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " try {} catch (e) {rethrow;}", " }", "}"])); 1356 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " try {} catch (e) {rethrow;}", " }", "}"]));
683 resolve(source, []); 1357 resolve(source);
684 assertNoErrors(); 1358 assertNoErrors();
685 verify([source]); 1359 verify([source]);
686 } 1360 }
687 void test_returnInGenerativeConstructor() { 1361 void test_returnInGenerativeConstructor() {
688 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { return; }", "}"])); 1362 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { return; }", "}"]));
689 resolve(source, []); 1363 resolve(source);
690 assertNoErrors(); 1364 assertNoErrors();
691 verify([source]); 1365 verify([source]);
692 } 1366 }
693 void test_returnOfInvalidType_dynamic() { 1367 void test_returnOfInvalidType_dynamic() {
694 Source source = addSource(EngineTestCase.createSource(["class TypeError {}", "class A {", " static void testLogicalOp() {", " testOr(a, b, onTypeError) {", " try {", " return a || b;", " } on TypeError catch (t) {", " return onTypeError;", " }", " }", " }", "}"])); 1368 Source source = addSource(EngineTestCase.createSource(["class TypeError {}", "class A {", " static void testLogicalOp() {", " testOr(a, b, onTypeError) {", " try {", " return a || b;", " } on TypeError catch (t) {", " return onTypeError;", " }", " }", " }", "}"]));
695 resolve(source, []); 1369 resolve(source);
696 assertNoErrors(); 1370 assertNoErrors();
697 verify([source]); 1371 verify([source]);
698 } 1372 }
699 void test_returnOfInvalidType_subtype() { 1373 void test_returnOfInvalidType_subtype() {
700 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "A f(B b) { return b; }"])); 1374 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "A f(B b) { return b; }"]));
701 resolve(source, []); 1375 resolve(source);
702 assertNoErrors(); 1376 assertNoErrors();
703 verify([source]); 1377 verify([source]);
704 } 1378 }
705 void test_returnOfInvalidType_supertype() { 1379 void test_returnOfInvalidType_supertype() {
706 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "B f(A a) { return a; }"])); 1380 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "B f(A a) { return a; }"]));
707 resolve(source, []); 1381 resolve(source);
1382 assertNoErrors();
1383 verify([source]);
1384 }
1385 void test_returnOfInvalidType_void() {
1386 Source source = addSource(EngineTestCase.createSource(["void f1() {}", "void f2() { return; }", "void f3() { return null; }", "void f4() { return g1(); }", "void f5() { return g2(); }", "g1() {}", "void g2() {}", ""]));
1387 resolve(source);
708 assertNoErrors(); 1388 assertNoErrors();
709 verify([source]); 1389 verify([source]);
710 } 1390 }
711 void test_returnWithoutValue_noReturnType() { 1391 void test_returnWithoutValue_noReturnType() {
712 Source source = addSource(EngineTestCase.createSource(["f() { return; }"])); 1392 Source source = addSource(EngineTestCase.createSource(["f() { return; }"]));
713 resolve(source, []); 1393 resolve(source);
714 assertNoErrors(); 1394 assertNoErrors();
715 verify([source]); 1395 verify([source]);
716 } 1396 }
717 void test_returnWithoutValue_void() { 1397 void test_returnWithoutValue_void() {
718 Source source = addSource(EngineTestCase.createSource(["void f() { return; } "])); 1398 Source source = addSource(EngineTestCase.createSource(["void f() { return; } "]));
719 resolve(source, []); 1399 resolve(source);
1400 assertNoErrors();
1401 verify([source]);
1402 }
1403 void test_staticAccessToInstanceMember_method() {
1404 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c m() {}", "}", "main() {", " A.m;", " A.m();", "}"]));
1405 resolve(source);
1406 assertNoErrors();
1407 verify([source]);
1408 }
1409 void test_staticAccessToInstanceMember_propertyAccess_field() {
1410 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c var f;", "}", "main() {", " A.f;", " A.f = 1;", "}"]));
1411 resolve(source);
1412 assertNoErrors();
1413 verify([source]);
1414 }
1415 void test_staticAccessToInstanceMember_propertyAccess_propertyAccessor() {
1416 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c get f => 42;", " static set f(x) {}", "}", "main() {", " A.f;", " A.f = 1;" , "}"]));
1417 resolve(source);
1418 assertNoErrors();
1419 verify([source]);
1420 }
1421 void test_superInInvalidContext() {
1422 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "class B extends A {", " B() {", " var v = super.m();", " }", " n () {", " var v = super.m();", " }", "}"]));
1423 resolve(source);
720 assertNoErrors(); 1424 assertNoErrors();
721 verify([source]); 1425 verify([source]);
722 } 1426 }
723 void test_typeArgumentNotMatchingBounds_const() { 1427 void test_typeArgumentNotMatchingBounds_const() {
724 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {", " const G() {}", "}", "f() { return const G<B>(); }"])); 1428 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {", " const G();", "}", "f() { return co nst G<B>(); }"]));
725 resolve(source, []); 1429 resolve(source);
726 assertNoErrors(); 1430 assertNoErrors();
727 verify([source]); 1431 verify([source]);
728 } 1432 }
729 void test_typeArgumentNotMatchingBounds_new() { 1433 void test_typeArgumentNotMatchingBounds_new() {
730 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {}", "f() { return new G<B>(); }"])); 1434 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {}", "f() { return new G<B>(); }"]));
731 resolve(source, []); 1435 resolve(source);
732 assertNoErrors(); 1436 assertNoErrors();
733 verify([source]); 1437 verify([source]);
1438 }
1439 void test_undefinedConstructorInInitializer_explicit_named() {
1440 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam ed() {}", "}", "class B extends A {", " B() : super.named();", "}"]));
1441 resolve(source);
1442 assertNoErrors();
1443 verify([source]);
1444 }
1445 void test_undefinedConstructorInInitializer_explicit_unnamed() {
1446 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " B() : super();", "}"]));
1447 resolve(source);
1448 assertNoErrors();
1449 verify([source]);
1450 }
1451 void test_undefinedConstructorInInitializer_implicit() {
1452 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " B();", "}"]));
1453 resolve(source);
1454 assertNoErrors();
1455 verify([source]);
1456 }
1457 void test_undefinedConstructorInInitializer_implicit_typedef() {
1458 Source source = addSource(EngineTestCase.createSource(["class M {}", "typede f A = Object with M;", "class B extends A {", " B();", "}"]));
1459 resolve(source);
1460 assertNoErrors();
1461 verify([source]);
1462 }
1463 void test_undefinedGetter_noSuchMethod_getter() {
1464 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", "}", "f() {", " (new A()).g;", "}"]));
1465 resolve(source);
1466 assertNoErrors();
1467 }
1468 void test_undefinedGetter_noSuchMethod_getter2() {
1469 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", "}", "class B {", " A a = new A();", " m() {", " a .g;", " }", "}"]));
1470 resolve(source);
1471 assertNoErrors();
734 } 1472 }
735 void test_undefinedGetter_typeSubstitution() { 1473 void test_undefinedGetter_typeSubstitution() {
736 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " E element;", "}", "class B extends A<List> {", " m() {", " element.last;", " }", "}"])); 1474 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " E element;", "}", "class B extends A<List> {", " m() {", " element.last;", " }", "}"]));
737 resolve(source, []); 1475 resolve(source);
738 assertNoErrors(); 1476 assertNoErrors();
739 verify([source]); 1477 verify([source]);
740 } 1478 }
741 void test_undefinedIdentifier_hide() { 1479 void test_undefinedIdentifier_hide() {
742 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' hide a;"])); 1480 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' hide a;"]));
743 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); 1481 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
744 resolve(source, []); 1482 resolve(source);
745 assertNoErrors(); 1483 assertNoErrors();
746 verify([source]); 1484 verify([source]);
1485 }
1486 void test_undefinedIdentifier_noSuchMethod() {
1487 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", " f() {", " var v = a;", " }", "}"]));
1488 resolve(source);
1489 assertNoErrors();
747 } 1490 }
748 void test_undefinedIdentifier_show() { 1491 void test_undefinedIdentifier_show() {
749 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' show a;"])); 1492 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart' show a;"]));
750 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"])); 1493 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;"]));
751 resolve(source, []); 1494 resolve(source);
752 assertNoErrors(); 1495 assertNoErrors();
753 verify([source]); 1496 verify([source]);
754 } 1497 }
755 void test_undefinedMethod_noSuchMethod() { 1498 void test_undefinedMethod_noSuchMethod() {
756 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod() {}", "}", "f() {", " (new A()).someMethod();", "}"])); 1499 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", "}", "f() {", " (new A()).m();", "}"]));
757 resolve(source, []); 1500 resolve(source);
758 assertNoErrors(); 1501 assertNoErrors();
1502 }
1503 void test_undefinedOperator_index() {
1504 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor [](a) {}", " operator []=(a, b) {}", "}", "f(A a) {", " a[0];", " a[0] = 1;", "}"]));
1505 resolve(source);
1506 assertNoErrors();
1507 verify([source]);
759 } 1508 }
760 void test_undefinedOperator_tilde() { 1509 void test_undefinedOperator_tilde() {
761 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons t B = ~((1 << A) - 1);"])); 1510 Source source = addSource(EngineTestCase.createSource(["const A = 3;", "cons t B = ~((1 << A) - 1);"]));
762 resolve(source, []); 1511 resolve(source);
763 assertNoErrors(); 1512 assertNoErrors();
764 verify([source]); 1513 verify([source]);
1514 }
1515 void test_undefinedSetter_noSuchMethod() {
1516 Source source = addSource(EngineTestCase.createSource(["class A {", " noSuc hMethod(invocation) {}", "}", "f() {", " (new A()).s = 1;", "}"]));
1517 resolve(source);
1518 assertNoErrors();
1519 }
1520 void test_wrongNumberOfParametersForOperator_index() {
1521 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor []=(a, b) {}", "}"]));
1522 resolve(source);
1523 assertNoErrors();
1524 verify([source]);
1525 }
1526 void test_wrongNumberOfParametersForOperator_minus() {
1527 check_wrongNumberOfParametersForOperator("-", "");
1528 check_wrongNumberOfParametersForOperator("-", "a");
1529 }
1530 void test_wrongNumberOfParametersForOperator1() {
1531 check_wrongNumberOfParametersForOperator1("<");
1532 check_wrongNumberOfParametersForOperator1(">");
1533 check_wrongNumberOfParametersForOperator1("<=");
1534 check_wrongNumberOfParametersForOperator1(">=");
1535 check_wrongNumberOfParametersForOperator1("+");
1536 check_wrongNumberOfParametersForOperator1("/");
1537 check_wrongNumberOfParametersForOperator1("~/");
1538 check_wrongNumberOfParametersForOperator1("*");
1539 check_wrongNumberOfParametersForOperator1("%");
1540 check_wrongNumberOfParametersForOperator1("|");
1541 check_wrongNumberOfParametersForOperator1("^");
1542 check_wrongNumberOfParametersForOperator1("&");
1543 check_wrongNumberOfParametersForOperator1("<<");
1544 check_wrongNumberOfParametersForOperator1(">>");
1545 check_wrongNumberOfParametersForOperator1("[]");
765 } 1546 }
766 void test_wrongNumberOfParametersForSetter() { 1547 void test_wrongNumberOfParametersForSetter() {
767 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (a) {}", "}"])); 1548 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (a) {}", "}"]));
768 resolve(source, []); 1549 resolve(source);
769 assertNoErrors(); 1550 assertNoErrors();
770 verify([source]); 1551 verify([source]);
1552 }
1553 void check_wrongNumberOfParametersForOperator(String name, String parameters) {
1554 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor ${name}(${parameters}) {}", "}"]));
1555 resolve(source);
1556 assertNoErrors();
1557 verify([source]);
1558 reset();
1559 }
1560 void check_wrongNumberOfParametersForOperator1(String name) {
1561 check_wrongNumberOfParametersForOperator(name, "a");
771 } 1562 }
772 static dartSuite() { 1563 static dartSuite() {
773 _ut.group('NonErrorResolverTest', () { 1564 _ut.group('NonErrorResolverTest', () {
1565 _ut.test('test_ambiguousExport', () {
1566 final __test = new NonErrorResolverTest();
1567 runJUnitTest(__test, __test.test_ambiguousExport);
1568 });
1569 _ut.test('test_ambiguousExport_combinators_hide', () {
1570 final __test = new NonErrorResolverTest();
1571 runJUnitTest(__test, __test.test_ambiguousExport_combinators_hide);
1572 });
1573 _ut.test('test_ambiguousExport_combinators_show', () {
1574 final __test = new NonErrorResolverTest();
1575 runJUnitTest(__test, __test.test_ambiguousExport_combinators_show);
1576 });
774 _ut.test('test_argumentDefinitionTestNonParameter_formalParameter', () { 1577 _ut.test('test_argumentDefinitionTestNonParameter_formalParameter', () {
775 final __test = new NonErrorResolverTest(); 1578 final __test = new NonErrorResolverTest();
776 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_form alParameter); 1579 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_form alParameter);
777 }); 1580 });
778 _ut.test('test_argumentDefinitionTestNonParameter_namedParameter', () { 1581 _ut.test('test_argumentDefinitionTestNonParameter_namedParameter', () {
779 final __test = new NonErrorResolverTest(); 1582 final __test = new NonErrorResolverTest();
780 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_name dParameter); 1583 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_name dParameter);
781 }); 1584 });
782 _ut.test('test_argumentDefinitionTestNonParameter_optionalParameter', () { 1585 _ut.test('test_argumentDefinitionTestNonParameter_optionalParameter', () {
783 final __test = new NonErrorResolverTest(); 1586 final __test = new NonErrorResolverTest();
784 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_opti onalParameter); 1587 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_opti onalParameter);
785 }); 1588 });
1589 _ut.test('test_argumentTypeNotAssignable_Object_Function', () {
1590 final __test = new NonErrorResolverTest();
1591 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_Object_Functi on);
1592 });
1593 _ut.test('test_argumentTypeNotAssignable_invocation_functionParameter_gene ric', () {
1594 final __test = new NonErrorResolverTest();
1595 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_fu nctionParameter_generic);
1596 });
1597 _ut.test('test_argumentTypeNotAssignable_invocation_typedef_generic', () {
1598 final __test = new NonErrorResolverTest();
1599 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ty pedef_generic);
1600 });
1601 _ut.test('test_argumentTypeNotAssignable_typedef_local', () {
1602 final __test = new NonErrorResolverTest();
1603 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_typedef_local );
1604 });
1605 _ut.test('test_argumentTypeNotAssignable_typedef_parameter', () {
1606 final __test = new NonErrorResolverTest();
1607 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_typedef_param eter);
1608 });
1609 _ut.test('test_assignmentToFinal_prefixNegate', () {
1610 final __test = new NonErrorResolverTest();
1611 runJUnitTest(__test, __test.test_assignmentToFinal_prefixNegate);
1612 });
1613 _ut.test('test_assignmentToFinals_importWithPrefix', () {
1614 final __test = new NonErrorResolverTest();
1615 runJUnitTest(__test, __test.test_assignmentToFinals_importWithPrefix);
1616 });
786 _ut.test('test_breakWithoutLabelInSwitch', () { 1617 _ut.test('test_breakWithoutLabelInSwitch', () {
787 final __test = new NonErrorResolverTest(); 1618 final __test = new NonErrorResolverTest();
788 runJUnitTest(__test, __test.test_breakWithoutLabelInSwitch); 1619 runJUnitTest(__test, __test.test_breakWithoutLabelInSwitch);
789 }); 1620 });
790 _ut.test('test_builtInIdentifierAsType_dynamic', () { 1621 _ut.test('test_builtInIdentifierAsType_dynamic', () {
791 final __test = new NonErrorResolverTest(); 1622 final __test = new NonErrorResolverTest();
792 runJUnitTest(__test, __test.test_builtInIdentifierAsType_dynamic); 1623 runJUnitTest(__test, __test.test_builtInIdentifierAsType_dynamic);
793 }); 1624 });
1625 _ut.test('test_caseBlockNotTerminated', () {
1626 final __test = new NonErrorResolverTest();
1627 runJUnitTest(__test, __test.test_caseBlockNotTerminated);
1628 });
1629 _ut.test('test_caseBlockNotTerminated_lastCase', () {
1630 final __test = new NonErrorResolverTest();
1631 runJUnitTest(__test, __test.test_caseBlockNotTerminated_lastCase);
1632 });
794 _ut.test('test_caseExpressionTypeImplementsEquals_Object', () { 1633 _ut.test('test_caseExpressionTypeImplementsEquals_Object', () {
795 final __test = new NonErrorResolverTest(); 1634 final __test = new NonErrorResolverTest();
796 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Obje ct); 1635 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Obje ct);
797 }); 1636 });
798 _ut.test('test_caseExpressionTypeImplementsEquals_String', () { 1637 _ut.test('test_caseExpressionTypeImplementsEquals_String', () {
799 final __test = new NonErrorResolverTest(); 1638 final __test = new NonErrorResolverTest();
800 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Stri ng); 1639 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Stri ng);
801 }); 1640 });
802 _ut.test('test_caseExpressionTypeImplementsEquals_int', () { 1641 _ut.test('test_caseExpressionTypeImplementsEquals_int', () {
803 final __test = new NonErrorResolverTest(); 1642 final __test = new NonErrorResolverTest();
804 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_int) ; 1643 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_int) ;
805 }); 1644 });
806 _ut.test('test_concreteClassWithAbstractMember', () { 1645 _ut.test('test_concreteClassWithAbstractMember', () {
807 final __test = new NonErrorResolverTest(); 1646 final __test = new NonErrorResolverTest();
808 runJUnitTest(__test, __test.test_concreteClassWithAbstractMember); 1647 runJUnitTest(__test, __test.test_concreteClassWithAbstractMember);
809 }); 1648 });
1649 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_instance', () {
1650 final __test = new NonErrorResolverTest();
1651 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_instance);
1652 });
1653 _ut.test('test_conflictingStaticGetterAndInstanceSetter_thisClass', () {
1654 final __test = new NonErrorResolverTest();
1655 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette r_thisClass);
1656 });
1657 _ut.test('test_conflictingStaticSetterAndInstanceMember_thisClass_method', () {
1658 final __test = new NonErrorResolverTest();
1659 runJUnitTest(__test, __test.test_conflictingStaticSetterAndInstanceMembe r_thisClass_method);
1660 });
810 _ut.test('test_constConstructorWithNonFinalField_constInstanceVar', () { 1661 _ut.test('test_constConstructorWithNonFinalField_constInstanceVar', () {
811 final __test = new NonErrorResolverTest(); 1662 final __test = new NonErrorResolverTest();
812 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_const InstanceVar); 1663 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_const InstanceVar);
813 }); 1664 });
814 _ut.test('test_constConstructorWithNonFinalField_finalInstanceVar', () { 1665 _ut.test('test_constConstructorWithNonFinalField_finalInstanceVar', () {
815 final __test = new NonErrorResolverTest(); 1666 final __test = new NonErrorResolverTest();
816 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_final InstanceVar); 1667 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_final InstanceVar);
817 }); 1668 });
1669 _ut.test('test_constConstructorWithNonFinalField_mixin', () {
1670 final __test = new NonErrorResolverTest();
1671 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_mixin );
1672 });
818 _ut.test('test_constConstructorWithNonFinalField_static', () { 1673 _ut.test('test_constConstructorWithNonFinalField_static', () {
819 final __test = new NonErrorResolverTest(); 1674 final __test = new NonErrorResolverTest();
820 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_stati c); 1675 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_stati c);
821 }); 1676 });
822 _ut.test('test_constConstructorWithNonFinalField_syntheticField', () { 1677 _ut.test('test_constConstructorWithNonFinalField_syntheticField', () {
823 final __test = new NonErrorResolverTest(); 1678 final __test = new NonErrorResolverTest();
824 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField); 1679 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField);
825 }); 1680 });
1681 _ut.test('test_constEvalTypeBoolNumString_equal', () {
1682 final __test = new NonErrorResolverTest();
1683 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal);
1684 });
1685 _ut.test('test_constEvalTypeBoolNumString_notEqual', () {
1686 final __test = new NonErrorResolverTest();
1687 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual);
1688 });
1689 _ut.test('test_constWithNonConstantArgument_literals', () {
1690 final __test = new NonErrorResolverTest();
1691 runJUnitTest(__test, __test.test_constWithNonConstantArgument_literals);
1692 });
1693 _ut.test('test_constWithTypeParameters_direct', () {
1694 final __test = new NonErrorResolverTest();
1695 runJUnitTest(__test, __test.test_constWithTypeParameters_direct);
1696 });
1697 _ut.test('test_constWithUndefinedConstructor', () {
1698 final __test = new NonErrorResolverTest();
1699 runJUnitTest(__test, __test.test_constWithUndefinedConstructor);
1700 });
1701 _ut.test('test_constWithUndefinedConstructorDefault', () {
1702 final __test = new NonErrorResolverTest();
1703 runJUnitTest(__test, __test.test_constWithUndefinedConstructorDefault);
1704 });
826 _ut.test('test_defaultValueInFunctionTypeAlias', () { 1705 _ut.test('test_defaultValueInFunctionTypeAlias', () {
827 final __test = new NonErrorResolverTest(); 1706 final __test = new NonErrorResolverTest();
828 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias); 1707 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
829 }); 1708 });
830 _ut.test('test_duplicateDefinition_emptyName', () { 1709 _ut.test('test_duplicateDefinition_emptyName', () {
831 final __test = new NonErrorResolverTest(); 1710 final __test = new NonErrorResolverTest();
832 runJUnitTest(__test, __test.test_duplicateDefinition_emptyName); 1711 runJUnitTest(__test, __test.test_duplicateDefinition_emptyName);
833 }); 1712 });
834 _ut.test('test_duplicateDefinition_getter', () { 1713 _ut.test('test_duplicateDefinition_getter', () {
835 final __test = new NonErrorResolverTest(); 1714 final __test = new NonErrorResolverTest();
836 runJUnitTest(__test, __test.test_duplicateDefinition_getter); 1715 runJUnitTest(__test, __test.test_duplicateDefinition_getter);
837 }); 1716 });
838 _ut.test('test_exportOfNonLibrary_libraryDeclared', () { 1717 _ut.test('test_exportOfNonLibrary_libraryDeclared', () {
839 final __test = new NonErrorResolverTest(); 1718 final __test = new NonErrorResolverTest();
840 runJUnitTest(__test, __test.test_exportOfNonLibrary_libraryDeclared); 1719 runJUnitTest(__test, __test.test_exportOfNonLibrary_libraryDeclared);
841 }); 1720 });
842 _ut.test('test_exportOfNonLibrary_libraryNotDeclared', () { 1721 _ut.test('test_exportOfNonLibrary_libraryNotDeclared', () {
843 final __test = new NonErrorResolverTest(); 1722 final __test = new NonErrorResolverTest();
844 runJUnitTest(__test, __test.test_exportOfNonLibrary_libraryNotDeclared); 1723 runJUnitTest(__test, __test.test_exportOfNonLibrary_libraryNotDeclared);
845 }); 1724 });
1725 _ut.test('test_extraPositionalArguments_Function', () {
1726 final __test = new NonErrorResolverTest();
1727 runJUnitTest(__test, __test.test_extraPositionalArguments_Function);
1728 });
1729 _ut.test('test_extraPositionalArguments_function', () {
1730 final __test = new NonErrorResolverTest();
1731 runJUnitTest(__test, __test.test_extraPositionalArguments_function);
1732 });
1733 _ut.test('test_extraPositionalArguments_typedef_local', () {
1734 final __test = new NonErrorResolverTest();
1735 runJUnitTest(__test, __test.test_extraPositionalArguments_typedef_local) ;
1736 });
1737 _ut.test('test_extraPositionalArguments_typedef_parameter', () {
1738 final __test = new NonErrorResolverTest();
1739 runJUnitTest(__test, __test.test_extraPositionalArguments_typedef_parame ter);
1740 });
846 _ut.test('test_fieldInitializedByMultipleInitializers', () { 1741 _ut.test('test_fieldInitializedByMultipleInitializers', () {
847 final __test = new NonErrorResolverTest(); 1742 final __test = new NonErrorResolverTest();
848 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers) ; 1743 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers) ;
849 }); 1744 });
850 _ut.test('test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal', () { 1745 _ut.test('test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal', () {
851 final __test = new NonErrorResolverTest(); 1746 final __test = new NonErrorResolverTest();
852 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_fieldNotFinal); 1747 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_fieldNotFinal);
853 }); 1748 });
854 _ut.test('test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSe t', () { 1749 _ut.test('test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSe t', () {
855 final __test = new NonErrorResolverTest(); 1750 final __test = new NonErrorResolverTest();
856 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_finalFieldNotSet); 1751 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_finalFieldNotSet);
857 }); 1752 });
858 _ut.test('test_fieldInitializerOutsideConstructor', () { 1753 _ut.test('test_fieldInitializerOutsideConstructor', () {
859 final __test = new NonErrorResolverTest(); 1754 final __test = new NonErrorResolverTest();
860 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor); 1755 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor);
861 }); 1756 });
862 _ut.test('test_fieldInitializerOutsideConstructor_defaultParameters', () { 1757 _ut.test('test_fieldInitializerOutsideConstructor_defaultParameters', () {
863 final __test = new NonErrorResolverTest(); 1758 final __test = new NonErrorResolverTest();
864 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor_defa ultParameters); 1759 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor_defa ultParameters);
865 }); 1760 });
1761 _ut.test('test_fieldInitializerRedirectingConstructor_super', () {
1762 final __test = new NonErrorResolverTest();
1763 runJUnitTest(__test, __test.test_fieldInitializerRedirectingConstructor_ super);
1764 });
866 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializer', ( ) { 1765 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializer', ( ) {
867 final __test = new NonErrorResolverTest(); 1766 final __test = new NonErrorResolverTest();
868 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializer); 1767 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializer);
869 }); 1768 });
870 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializingFor mal', () { 1769 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializingFor mal', () {
871 final __test = new NonErrorResolverTest(); 1770 final __test = new NonErrorResolverTest();
872 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializingFormal); 1771 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializingFormal);
873 }); 1772 });
874 _ut.test('test_finalNotInitialized_atDeclaration', () { 1773 _ut.test('test_finalNotInitialized_atDeclaration', () {
875 final __test = new NonErrorResolverTest(); 1774 final __test = new NonErrorResolverTest();
876 runJUnitTest(__test, __test.test_finalNotInitialized_atDeclaration); 1775 runJUnitTest(__test, __test.test_finalNotInitialized_atDeclaration);
877 }); 1776 });
878 _ut.test('test_finalNotInitialized_fieldFormal', () { 1777 _ut.test('test_finalNotInitialized_fieldFormal', () {
879 final __test = new NonErrorResolverTest(); 1778 final __test = new NonErrorResolverTest();
880 runJUnitTest(__test, __test.test_finalNotInitialized_fieldFormal); 1779 runJUnitTest(__test, __test.test_finalNotInitialized_fieldFormal);
881 }); 1780 });
882 _ut.test('test_finalNotInitialized_initializer', () { 1781 _ut.test('test_finalNotInitialized_initializer', () {
883 final __test = new NonErrorResolverTest(); 1782 final __test = new NonErrorResolverTest();
884 runJUnitTest(__test, __test.test_finalNotInitialized_initializer); 1783 runJUnitTest(__test, __test.test_finalNotInitialized_initializer);
885 }); 1784 });
1785 _ut.test('test_implicitThisReferenceInInitializer_constructorName', () {
1786 final __test = new NonErrorResolverTest();
1787 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_cons tructorName);
1788 });
1789 _ut.test('test_implicitThisReferenceInInitializer_prefixedIdentifier', () {
1790 final __test = new NonErrorResolverTest();
1791 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_pref ixedIdentifier);
1792 });
1793 _ut.test('test_implicitThisReferenceInInitializer_qualifiedMethodInvocatio n', () {
1794 final __test = new NonErrorResolverTest();
1795 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_qual ifiedMethodInvocation);
1796 });
1797 _ut.test('test_implicitThisReferenceInInitializer_qualifiedPropertyAccess' , () {
1798 final __test = new NonErrorResolverTest();
1799 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_qual ifiedPropertyAccess);
1800 });
1801 _ut.test('test_implicitThisReferenceInInitializer_staticField_superClass', () {
1802 final __test = new NonErrorResolverTest();
1803 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_stat icField_superClass);
1804 });
1805 _ut.test('test_implicitThisReferenceInInitializer_staticField_thisClass', () {
1806 final __test = new NonErrorResolverTest();
1807 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_stat icField_thisClass);
1808 });
1809 _ut.test('test_implicitThisReferenceInInitializer_staticGetter', () {
1810 final __test = new NonErrorResolverTest();
1811 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_stat icGetter);
1812 });
1813 _ut.test('test_implicitThisReferenceInInitializer_staticMethod', () {
1814 final __test = new NonErrorResolverTest();
1815 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_stat icMethod);
1816 });
1817 _ut.test('test_implicitThisReferenceInInitializer_topLevelField', () {
1818 final __test = new NonErrorResolverTest();
1819 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL evelField);
1820 });
1821 _ut.test('test_implicitThisReferenceInInitializer_topLevelFunction', () {
1822 final __test = new NonErrorResolverTest();
1823 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL evelFunction);
1824 });
1825 _ut.test('test_implicitThisReferenceInInitializer_topLevelGetter', () {
1826 final __test = new NonErrorResolverTest();
1827 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_topL evelGetter);
1828 });
1829 _ut.test('test_implicitThisReferenceInInitializer_typeVariable', () {
1830 final __test = new NonErrorResolverTest();
1831 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_type Variable);
1832 });
1833 _ut.test('test_importDuplicatedLibraryName', () {
1834 final __test = new NonErrorResolverTest();
1835 runJUnitTest(__test, __test.test_importDuplicatedLibraryName);
1836 });
886 _ut.test('test_importOfNonLibrary_libraryDeclared', () { 1837 _ut.test('test_importOfNonLibrary_libraryDeclared', () {
887 final __test = new NonErrorResolverTest(); 1838 final __test = new NonErrorResolverTest();
888 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryDeclared); 1839 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryDeclared);
889 }); 1840 });
890 _ut.test('test_importOfNonLibrary_libraryNotDeclared', () { 1841 _ut.test('test_importOfNonLibrary_libraryNotDeclared', () {
891 final __test = new NonErrorResolverTest(); 1842 final __test = new NonErrorResolverTest();
892 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared); 1843 runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared);
893 }); 1844 });
894 _ut.test('test_inconsistentCaseExpressionTypes', () { 1845 _ut.test('test_inconsistentCaseExpressionTypes', () {
895 final __test = new NonErrorResolverTest(); 1846 final __test = new NonErrorResolverTest();
896 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes); 1847 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes);
897 }); 1848 });
898 _ut.test('test_initializingFormalForNonExistantField', () { 1849 _ut.test('test_initializingFormalForNonExistantField', () {
899 final __test = new NonErrorResolverTest(); 1850 final __test = new NonErrorResolverTest();
900 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField); 1851 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField);
901 }); 1852 });
902 _ut.test('test_invalidAssignment', () { 1853 _ut.test('test_invalidAssignment', () {
903 final __test = new NonErrorResolverTest(); 1854 final __test = new NonErrorResolverTest();
904 runJUnitTest(__test, __test.test_invalidAssignment); 1855 runJUnitTest(__test, __test.test_invalidAssignment);
905 }); 1856 });
1857 _ut.test('test_invalidAssignment_compoundAssignment', () {
1858 final __test = new NonErrorResolverTest();
1859 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment);
1860 });
906 _ut.test('test_invalidAssignment_toDynamic', () { 1861 _ut.test('test_invalidAssignment_toDynamic', () {
907 final __test = new NonErrorResolverTest(); 1862 final __test = new NonErrorResolverTest();
908 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic); 1863 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic);
909 }); 1864 });
1865 _ut.test('test_invalidFactoryNameNotAClass', () {
1866 final __test = new NonErrorResolverTest();
1867 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass);
1868 });
1869 _ut.test('test_invalidOverrideNamed_unorderedNamedParameter', () {
1870 final __test = new NonErrorResolverTest();
1871 runJUnitTest(__test, __test.test_invalidOverrideNamed_unorderedNamedPara meter);
1872 });
1873 _ut.test('test_invalidOverrideReturnType_returnType_interface', () {
1874 final __test = new NonErrorResolverTest();
1875 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in terface);
1876 });
1877 _ut.test('test_invalidOverrideReturnType_returnType_interface2', () {
1878 final __test = new NonErrorResolverTest();
1879 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in terface2);
1880 });
1881 _ut.test('test_invalidOverrideReturnType_returnType_mixin', () {
1882 final __test = new NonErrorResolverTest();
1883 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_mi xin);
1884 });
1885 _ut.test('test_invalidOverrideReturnType_returnType_parameterizedTypes', ( ) {
1886 final __test = new NonErrorResolverTest();
1887 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_pa rameterizedTypes);
1888 });
1889 _ut.test('test_invalidOverrideReturnType_returnType_sameType', () {
1890 final __test = new NonErrorResolverTest();
1891 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_sa meType);
1892 });
1893 _ut.test('test_invalidOverrideReturnType_returnType_superclass', () {
1894 final __test = new NonErrorResolverTest();
1895 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_su perclass);
1896 });
1897 _ut.test('test_invalidOverrideReturnType_returnType_superclass2', () {
1898 final __test = new NonErrorResolverTest();
1899 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_su perclass2);
1900 });
1901 _ut.test('test_invalidOverrideReturnType_returnType_void', () {
1902 final __test = new NonErrorResolverTest();
1903 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_vo id);
1904 });
1905 _ut.test('test_invalidReferenceToThis_constructor', () {
1906 final __test = new NonErrorResolverTest();
1907 runJUnitTest(__test, __test.test_invalidReferenceToThis_constructor);
1908 });
1909 _ut.test('test_invalidReferenceToThis_instanceMethod', () {
1910 final __test = new NonErrorResolverTest();
1911 runJUnitTest(__test, __test.test_invalidReferenceToThis_instanceMethod);
1912 });
910 _ut.test('test_invalidTypeArgumentInConstList', () { 1913 _ut.test('test_invalidTypeArgumentInConstList', () {
911 final __test = new NonErrorResolverTest(); 1914 final __test = new NonErrorResolverTest();
912 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList); 1915 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList);
913 }); 1916 });
914 _ut.test('test_invalidTypeArgumentInConstMap', () { 1917 _ut.test('test_invalidTypeArgumentInConstMap', () {
915 final __test = new NonErrorResolverTest(); 1918 final __test = new NonErrorResolverTest();
916 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstMap); 1919 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstMap);
917 }); 1920 });
918 _ut.test('test_invocationOfNonFunction_dynamic', () { 1921 _ut.test('test_invocationOfNonFunction_dynamic', () {
919 final __test = new NonErrorResolverTest(); 1922 final __test = new NonErrorResolverTest();
920 runJUnitTest(__test, __test.test_invocationOfNonFunction_dynamic); 1923 runJUnitTest(__test, __test.test_invocationOfNonFunction_dynamic);
921 }); 1924 });
922 _ut.test('test_invocationOfNonFunction_getter', () { 1925 _ut.test('test_invocationOfNonFunction_getter', () {
923 final __test = new NonErrorResolverTest(); 1926 final __test = new NonErrorResolverTest();
924 runJUnitTest(__test, __test.test_invocationOfNonFunction_getter); 1927 runJUnitTest(__test, __test.test_invocationOfNonFunction_getter);
925 }); 1928 });
926 _ut.test('test_invocationOfNonFunction_localVariable', () { 1929 _ut.test('test_invocationOfNonFunction_localVariable', () {
927 final __test = new NonErrorResolverTest(); 1930 final __test = new NonErrorResolverTest();
928 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable); 1931 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable);
929 }); 1932 });
1933 _ut.test('test_memberWithClassName_setter', () {
1934 final __test = new NonErrorResolverTest();
1935 runJUnitTest(__test, __test.test_memberWithClassName_setter);
1936 });
1937 _ut.test('test_misMatchedGetterAndSetterTypes_instance_sameTypes', () {
1938 final __test = new NonErrorResolverTest();
1939 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance _sameTypes);
1940 });
1941 _ut.test('test_misMatchedGetterAndSetterTypes_instance_unspecifiedGetter', () {
1942 final __test = new NonErrorResolverTest();
1943 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance _unspecifiedGetter);
1944 });
1945 _ut.test('test_misMatchedGetterAndSetterTypes_instance_unspecifiedSetter', () {
1946 final __test = new NonErrorResolverTest();
1947 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance _unspecifiedSetter);
1948 });
1949 _ut.test('test_misMatchedGetterAndSetterTypes_topLevel_sameTypes', () {
1950 final __test = new NonErrorResolverTest();
1951 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel _sameTypes);
1952 });
1953 _ut.test('test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedGetter', () {
1954 final __test = new NonErrorResolverTest();
1955 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel _unspecifiedGetter);
1956 });
1957 _ut.test('test_misMatchedGetterAndSetterTypes_topLevel_unspecifiedSetter', () {
1958 final __test = new NonErrorResolverTest();
1959 runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_topLevel _unspecifiedSetter);
1960 });
1961 _ut.test('test_mixinDeclaresConstructor', () {
1962 final __test = new NonErrorResolverTest();
1963 runJUnitTest(__test, __test.test_mixinDeclaresConstructor);
1964 });
1965 _ut.test('test_mixinDeclaresConstructor_factory', () {
1966 final __test = new NonErrorResolverTest();
1967 runJUnitTest(__test, __test.test_mixinDeclaresConstructor_factory);
1968 });
1969 _ut.test('test_mixinInheritsFromNotObject_classDeclaration_mixTypedef', () {
1970 final __test = new NonErrorResolverTest();
1971 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_classDeclara tion_mixTypedef);
1972 });
1973 _ut.test('test_mixinInheritsFromNotObject_typedef_mixTypedef', () {
1974 final __test = new NonErrorResolverTest();
1975 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_typedef_mixT ypedef);
1976 });
1977 _ut.test('test_multipleSuperInitializers_no', () {
1978 final __test = new NonErrorResolverTest();
1979 runJUnitTest(__test, __test.test_multipleSuperInitializers_no);
1980 });
1981 _ut.test('test_multipleSuperInitializers_single', () {
1982 final __test = new NonErrorResolverTest();
1983 runJUnitTest(__test, __test.test_multipleSuperInitializers_single);
1984 });
930 _ut.test('test_newWithAbstractClass_factory', () { 1985 _ut.test('test_newWithAbstractClass_factory', () {
931 final __test = new NonErrorResolverTest(); 1986 final __test = new NonErrorResolverTest();
932 runJUnitTest(__test, __test.test_newWithAbstractClass_factory); 1987 runJUnitTest(__test, __test.test_newWithAbstractClass_factory);
933 }); 1988 });
1989 _ut.test('test_newWithUndefinedConstructor', () {
1990 final __test = new NonErrorResolverTest();
1991 runJUnitTest(__test, __test.test_newWithUndefinedConstructor);
1992 });
1993 _ut.test('test_newWithUndefinedConstructorDefault', () {
1994 final __test = new NonErrorResolverTest();
1995 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault);
1996 });
934 _ut.test('test_nonBoolExpression_assert_bool', () { 1997 _ut.test('test_nonBoolExpression_assert_bool', () {
935 final __test = new NonErrorResolverTest(); 1998 final __test = new NonErrorResolverTest();
936 runJUnitTest(__test, __test.test_nonBoolExpression_assert_bool); 1999 runJUnitTest(__test, __test.test_nonBoolExpression_assert_bool);
937 }); 2000 });
938 _ut.test('test_nonBoolExpression_assert_functionType', () { 2001 _ut.test('test_nonBoolExpression_assert_functionType', () {
939 final __test = new NonErrorResolverTest(); 2002 final __test = new NonErrorResolverTest();
940 runJUnitTest(__test, __test.test_nonBoolExpression_assert_functionType); 2003 runJUnitTest(__test, __test.test_nonBoolExpression_assert_functionType);
941 }); 2004 });
2005 _ut.test('test_nonConstCaseExpression', () {
2006 final __test = new NonErrorResolverTest();
2007 runJUnitTest(__test, __test.test_nonConstCaseExpression);
2008 });
2009 _ut.test('test_nonConstMapAsExpressionStatement_const', () {
2010 final __test = new NonErrorResolverTest();
2011 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_const) ;
2012 });
2013 _ut.test('test_nonConstMapAsExpressionStatement_notExpressionStatement', ( ) {
2014 final __test = new NonErrorResolverTest();
2015 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_notExp ressionStatement);
2016 });
2017 _ut.test('test_nonConstMapAsExpressionStatement_typeArguments', () {
2018 final __test = new NonErrorResolverTest();
2019 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_typeAr guments);
2020 });
2021 _ut.test('test_nonConstValueInInitializer_binary_bool', () {
2022 final __test = new NonErrorResolverTest();
2023 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_bool) ;
2024 });
2025 _ut.test('test_nonConstValueInInitializer_binary_dynamic', () {
2026 final __test = new NonErrorResolverTest();
2027 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_dynam ic);
2028 });
2029 _ut.test('test_nonConstValueInInitializer_binary_int', () {
2030 final __test = new NonErrorResolverTest();
2031 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_int);
2032 });
2033 _ut.test('test_nonConstValueInInitializer_binary_num', () {
2034 final __test = new NonErrorResolverTest();
2035 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_num);
2036 });
2037 _ut.test('test_nonConstValueInInitializer_field', () {
2038 final __test = new NonErrorResolverTest();
2039 runJUnitTest(__test, __test.test_nonConstValueInInitializer_field);
2040 });
2041 _ut.test('test_nonConstValueInInitializer_redirecting', () {
2042 final __test = new NonErrorResolverTest();
2043 runJUnitTest(__test, __test.test_nonConstValueInInitializer_redirecting) ;
2044 });
2045 _ut.test('test_nonConstValueInInitializer_super', () {
2046 final __test = new NonErrorResolverTest();
2047 runJUnitTest(__test, __test.test_nonConstValueInInitializer_super);
2048 });
2049 _ut.test('test_nonConstValueInInitializer_unary', () {
2050 final __test = new NonErrorResolverTest();
2051 runJUnitTest(__test, __test.test_nonConstValueInInitializer_unary);
2052 });
2053 _ut.test('test_nonGenerativeConstructor', () {
2054 final __test = new NonErrorResolverTest();
2055 runJUnitTest(__test, __test.test_nonGenerativeConstructor);
2056 });
2057 _ut.test('test_nonTypeInCatchClause_isClass', () {
2058 final __test = new NonErrorResolverTest();
2059 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isClass);
2060 });
2061 _ut.test('test_nonTypeInCatchClause_isFunctionTypeAlias', () {
2062 final __test = new NonErrorResolverTest();
2063 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isFunctionTypeAlia s);
2064 });
2065 _ut.test('test_nonTypeInCatchClause_isTypeVariable', () {
2066 final __test = new NonErrorResolverTest();
2067 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isTypeVariable);
2068 });
2069 _ut.test('test_nonTypeInCatchClause_noType', () {
2070 final __test = new NonErrorResolverTest();
2071 runJUnitTest(__test, __test.test_nonTypeInCatchClause_noType);
2072 });
2073 _ut.test('test_nonVoidReturnForOperator_no', () {
2074 final __test = new NonErrorResolverTest();
2075 runJUnitTest(__test, __test.test_nonVoidReturnForOperator_no);
2076 });
2077 _ut.test('test_nonVoidReturnForOperator_void', () {
2078 final __test = new NonErrorResolverTest();
2079 runJUnitTest(__test, __test.test_nonVoidReturnForOperator_void);
2080 });
2081 _ut.test('test_nonVoidReturnForSetter_function_no', () {
2082 final __test = new NonErrorResolverTest();
2083 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_function_no);
2084 });
2085 _ut.test('test_nonVoidReturnForSetter_function_void', () {
2086 final __test = new NonErrorResolverTest();
2087 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_function_void);
2088 });
2089 _ut.test('test_nonVoidReturnForSetter_method_no', () {
2090 final __test = new NonErrorResolverTest();
2091 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_method_no);
2092 });
2093 _ut.test('test_nonVoidReturnForSetter_method_void', () {
2094 final __test = new NonErrorResolverTest();
2095 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_method_void);
2096 });
942 _ut.test('test_optionalParameterInOperator_required', () { 2097 _ut.test('test_optionalParameterInOperator_required', () {
943 final __test = new NonErrorResolverTest(); 2098 final __test = new NonErrorResolverTest();
944 runJUnitTest(__test, __test.test_optionalParameterInOperator_required); 2099 runJUnitTest(__test, __test.test_optionalParameterInOperator_required);
945 }); 2100 });
2101 _ut.test('test_prefixCollidesWithTopLevelMembers', () {
2102 final __test = new NonErrorResolverTest();
2103 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers);
2104 });
2105 _ut.test('test_recursiveConstructorRedirect', () {
2106 final __test = new NonErrorResolverTest();
2107 runJUnitTest(__test, __test.test_recursiveConstructorRedirect);
2108 });
2109 _ut.test('test_recursiveFactoryRedirect', () {
2110 final __test = new NonErrorResolverTest();
2111 runJUnitTest(__test, __test.test_recursiveFactoryRedirect);
2112 });
2113 _ut.test('test_redirectToInvalidFunctionType', () {
2114 final __test = new NonErrorResolverTest();
2115 runJUnitTest(__test, __test.test_redirectToInvalidFunctionType);
2116 });
2117 _ut.test('test_redirectToNonConstConstructor', () {
2118 final __test = new NonErrorResolverTest();
2119 runJUnitTest(__test, __test.test_redirectToNonConstConstructor);
2120 });
2121 _ut.test('test_referenceToDeclaredVariableInInitializer_constructorName', () {
2122 final __test = new NonErrorResolverTest();
2123 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_constructorName);
2124 });
2125 _ut.test('test_referenceToDeclaredVariableInInitializer_methodName', () {
2126 final __test = new NonErrorResolverTest();
2127 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_methodName);
2128 });
2129 _ut.test('test_referenceToDeclaredVariableInInitializer_propertyName', () {
2130 final __test = new NonErrorResolverTest();
2131 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_propertyName);
2132 });
946 _ut.test('test_rethrowOutsideCatch', () { 2133 _ut.test('test_rethrowOutsideCatch', () {
947 final __test = new NonErrorResolverTest(); 2134 final __test = new NonErrorResolverTest();
948 runJUnitTest(__test, __test.test_rethrowOutsideCatch); 2135 runJUnitTest(__test, __test.test_rethrowOutsideCatch);
949 }); 2136 });
950 _ut.test('test_returnInGenerativeConstructor', () { 2137 _ut.test('test_returnInGenerativeConstructor', () {
951 final __test = new NonErrorResolverTest(); 2138 final __test = new NonErrorResolverTest();
952 runJUnitTest(__test, __test.test_returnInGenerativeConstructor); 2139 runJUnitTest(__test, __test.test_returnInGenerativeConstructor);
953 }); 2140 });
954 _ut.test('test_returnOfInvalidType_dynamic', () { 2141 _ut.test('test_returnOfInvalidType_dynamic', () {
955 final __test = new NonErrorResolverTest(); 2142 final __test = new NonErrorResolverTest();
956 runJUnitTest(__test, __test.test_returnOfInvalidType_dynamic); 2143 runJUnitTest(__test, __test.test_returnOfInvalidType_dynamic);
957 }); 2144 });
958 _ut.test('test_returnOfInvalidType_subtype', () { 2145 _ut.test('test_returnOfInvalidType_subtype', () {
959 final __test = new NonErrorResolverTest(); 2146 final __test = new NonErrorResolverTest();
960 runJUnitTest(__test, __test.test_returnOfInvalidType_subtype); 2147 runJUnitTest(__test, __test.test_returnOfInvalidType_subtype);
961 }); 2148 });
962 _ut.test('test_returnOfInvalidType_supertype', () { 2149 _ut.test('test_returnOfInvalidType_supertype', () {
963 final __test = new NonErrorResolverTest(); 2150 final __test = new NonErrorResolverTest();
964 runJUnitTest(__test, __test.test_returnOfInvalidType_supertype); 2151 runJUnitTest(__test, __test.test_returnOfInvalidType_supertype);
965 }); 2152 });
2153 _ut.test('test_returnOfInvalidType_void', () {
2154 final __test = new NonErrorResolverTest();
2155 runJUnitTest(__test, __test.test_returnOfInvalidType_void);
2156 });
966 _ut.test('test_returnWithoutValue_noReturnType', () { 2157 _ut.test('test_returnWithoutValue_noReturnType', () {
967 final __test = new NonErrorResolverTest(); 2158 final __test = new NonErrorResolverTest();
968 runJUnitTest(__test, __test.test_returnWithoutValue_noReturnType); 2159 runJUnitTest(__test, __test.test_returnWithoutValue_noReturnType);
969 }); 2160 });
970 _ut.test('test_returnWithoutValue_void', () { 2161 _ut.test('test_returnWithoutValue_void', () {
971 final __test = new NonErrorResolverTest(); 2162 final __test = new NonErrorResolverTest();
972 runJUnitTest(__test, __test.test_returnWithoutValue_void); 2163 runJUnitTest(__test, __test.test_returnWithoutValue_void);
973 }); 2164 });
2165 _ut.test('test_staticAccessToInstanceMember_method', () {
2166 final __test = new NonErrorResolverTest();
2167 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method);
2168 });
2169 _ut.test('test_staticAccessToInstanceMember_propertyAccess_field', () {
2170 final __test = new NonErrorResolverTest();
2171 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_field);
2172 });
2173 _ut.test('test_staticAccessToInstanceMember_propertyAccess_propertyAccesso r', () {
2174 final __test = new NonErrorResolverTest();
2175 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_propertyAccessor);
2176 });
2177 _ut.test('test_superInInvalidContext', () {
2178 final __test = new NonErrorResolverTest();
2179 runJUnitTest(__test, __test.test_superInInvalidContext);
2180 });
974 _ut.test('test_typeArgumentNotMatchingBounds_const', () { 2181 _ut.test('test_typeArgumentNotMatchingBounds_const', () {
975 final __test = new NonErrorResolverTest(); 2182 final __test = new NonErrorResolverTest();
976 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const); 2183 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
977 }); 2184 });
978 _ut.test('test_typeArgumentNotMatchingBounds_new', () { 2185 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
979 final __test = new NonErrorResolverTest(); 2186 final __test = new NonErrorResolverTest();
980 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new); 2187 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
981 }); 2188 });
2189 _ut.test('test_undefinedConstructorInInitializer_explicit_named', () {
2190 final __test = new NonErrorResolverTest();
2191 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_named);
2192 });
2193 _ut.test('test_undefinedConstructorInInitializer_explicit_unnamed', () {
2194 final __test = new NonErrorResolverTest();
2195 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_unnamed);
2196 });
2197 _ut.test('test_undefinedConstructorInInitializer_implicit', () {
2198 final __test = new NonErrorResolverTest();
2199 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit);
2200 });
2201 _ut.test('test_undefinedConstructorInInitializer_implicit_typedef', () {
2202 final __test = new NonErrorResolverTest();
2203 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit_typedef);
2204 });
2205 _ut.test('test_undefinedGetter_noSuchMethod_getter', () {
2206 final __test = new NonErrorResolverTest();
2207 runJUnitTest(__test, __test.test_undefinedGetter_noSuchMethod_getter);
2208 });
2209 _ut.test('test_undefinedGetter_noSuchMethod_getter2', () {
2210 final __test = new NonErrorResolverTest();
2211 runJUnitTest(__test, __test.test_undefinedGetter_noSuchMethod_getter2);
2212 });
982 _ut.test('test_undefinedGetter_typeSubstitution', () { 2213 _ut.test('test_undefinedGetter_typeSubstitution', () {
983 final __test = new NonErrorResolverTest(); 2214 final __test = new NonErrorResolverTest();
984 runJUnitTest(__test, __test.test_undefinedGetter_typeSubstitution); 2215 runJUnitTest(__test, __test.test_undefinedGetter_typeSubstitution);
985 }); 2216 });
986 _ut.test('test_undefinedIdentifier_hide', () { 2217 _ut.test('test_undefinedIdentifier_hide', () {
987 final __test = new NonErrorResolverTest(); 2218 final __test = new NonErrorResolverTest();
988 runJUnitTest(__test, __test.test_undefinedIdentifier_hide); 2219 runJUnitTest(__test, __test.test_undefinedIdentifier_hide);
989 }); 2220 });
2221 _ut.test('test_undefinedIdentifier_noSuchMethod', () {
2222 final __test = new NonErrorResolverTest();
2223 runJUnitTest(__test, __test.test_undefinedIdentifier_noSuchMethod);
2224 });
990 _ut.test('test_undefinedIdentifier_show', () { 2225 _ut.test('test_undefinedIdentifier_show', () {
991 final __test = new NonErrorResolverTest(); 2226 final __test = new NonErrorResolverTest();
992 runJUnitTest(__test, __test.test_undefinedIdentifier_show); 2227 runJUnitTest(__test, __test.test_undefinedIdentifier_show);
993 }); 2228 });
994 _ut.test('test_undefinedMethod_noSuchMethod', () { 2229 _ut.test('test_undefinedMethod_noSuchMethod', () {
995 final __test = new NonErrorResolverTest(); 2230 final __test = new NonErrorResolverTest();
996 runJUnitTest(__test, __test.test_undefinedMethod_noSuchMethod); 2231 runJUnitTest(__test, __test.test_undefinedMethod_noSuchMethod);
997 }); 2232 });
2233 _ut.test('test_undefinedOperator_index', () {
2234 final __test = new NonErrorResolverTest();
2235 runJUnitTest(__test, __test.test_undefinedOperator_index);
2236 });
998 _ut.test('test_undefinedOperator_tilde', () { 2237 _ut.test('test_undefinedOperator_tilde', () {
999 final __test = new NonErrorResolverTest(); 2238 final __test = new NonErrorResolverTest();
1000 runJUnitTest(__test, __test.test_undefinedOperator_tilde); 2239 runJUnitTest(__test, __test.test_undefinedOperator_tilde);
1001 }); 2240 });
2241 _ut.test('test_undefinedSetter_noSuchMethod', () {
2242 final __test = new NonErrorResolverTest();
2243 runJUnitTest(__test, __test.test_undefinedSetter_noSuchMethod);
2244 });
2245 _ut.test('test_wrongNumberOfParametersForOperator1', () {
2246 final __test = new NonErrorResolverTest();
2247 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator1);
2248 });
2249 _ut.test('test_wrongNumberOfParametersForOperator_index', () {
2250 final __test = new NonErrorResolverTest();
2251 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_inde x);
2252 });
2253 _ut.test('test_wrongNumberOfParametersForOperator_minus', () {
2254 final __test = new NonErrorResolverTest();
2255 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_minu s);
2256 });
1002 _ut.test('test_wrongNumberOfParametersForSetter', () { 2257 _ut.test('test_wrongNumberOfParametersForSetter', () {
1003 final __test = new NonErrorResolverTest(); 2258 final __test = new NonErrorResolverTest();
1004 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter); 2259 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter);
1005 }); 2260 });
1006 }); 2261 });
1007 } 2262 }
1008 } 2263 }
1009 class LibraryTest extends EngineTestCase { 2264 class LibraryTest extends EngineTestCase {
2265
1010 /** 2266 /**
1011 * The error listener to which all errors will be reported. 2267 * The error listener to which all errors will be reported.
1012 */ 2268 */
1013 GatheringErrorListener _errorListener; 2269 GatheringErrorListener _errorListener;
2270
1014 /** 2271 /**
1015 * The source factory used to create libraries. 2272 * The source factory used to create libraries.
1016 */ 2273 */
1017 SourceFactory _sourceFactory; 2274 SourceFactory _sourceFactory;
2275
1018 /** 2276 /**
1019 * The analysis context to pass in to all libraries created by the tests. 2277 * The analysis context to pass in to all libraries created by the tests.
1020 */ 2278 */
1021 AnalysisContextImpl _analysisContext; 2279 AnalysisContextImpl _analysisContext;
2280
1022 /** 2281 /**
1023 * The library used by the tests. 2282 * The library used by the tests.
1024 */ 2283 */
1025 Library _library5; 2284 Library _library5;
1026 void setUp() { 2285 void setUp() {
1027 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); 2286 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
1028 _analysisContext = new AnalysisContextImpl(); 2287 _analysisContext = new AnalysisContextImpl();
1029 _analysisContext.sourceFactory = _sourceFactory; 2288 _analysisContext.sourceFactory = _sourceFactory;
1030 _errorListener = new GatheringErrorListener(); 2289 _errorListener = new GatheringErrorListener();
1031 _library5 = library("/lib.dart"); 2290 _library5 = library("/lib.dart");
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 _ut.test('test_setLibraryElement', () { 2407 _ut.test('test_setLibraryElement', () {
1149 final __test = new LibraryTest(); 2408 final __test = new LibraryTest();
1150 runJUnitTest(__test, __test.test_setLibraryElement); 2409 runJUnitTest(__test, __test.test_setLibraryElement);
1151 }); 2410 });
1152 }); 2411 });
1153 } 2412 }
1154 } 2413 }
1155 class StaticTypeWarningCodeTest extends ResolverTestCase { 2414 class StaticTypeWarningCodeTest extends ResolverTestCase {
1156 void fail_inaccessibleSetter() { 2415 void fail_inaccessibleSetter() {
1157 Source source = addSource(EngineTestCase.createSource([])); 2416 Source source = addSource(EngineTestCase.createSource([]));
1158 resolve(source, []); 2417 resolve(source);
1159 assertErrors([StaticTypeWarningCode.INACCESSIBLE_SETTER]); 2418 assertErrors([StaticTypeWarningCode.INACCESSIBLE_SETTER]);
1160 verify([source]); 2419 verify([source]);
1161 } 2420 }
1162 void fail_inconsistentMethodInheritance() {
1163 Source source = addSource(EngineTestCase.createSource([]));
1164 resolve(source, []);
1165 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
1166 verify([source]);
1167 }
1168 void fail_nonTypeAsTypeArgument() { 2421 void fail_nonTypeAsTypeArgument() {
1169 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"])); 2422 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"]));
1170 resolve(source, []); 2423 resolve(source);
1171 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); 2424 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
1172 verify([source]); 2425 verify([source]);
1173 } 2426 }
1174 void fail_redirectWithInvalidTypeParameters() { 2427 void fail_redirectWithInvalidTypeParameters() {
1175 Source source = addSource(EngineTestCase.createSource([])); 2428 Source source = addSource(EngineTestCase.createSource([]));
1176 resolve(source, []); 2429 resolve(source);
1177 assertErrors([StaticTypeWarningCode.REDIRECT_WITH_INVALID_TYPE_PARAMETERS]); 2430 assertErrors([StaticTypeWarningCode.REDIRECT_WITH_INVALID_TYPE_PARAMETERS]);
1178 verify([source]); 2431 verify([source]);
1179 } 2432 }
1180 void fail_typeArgumentViolatesBounds() { 2433 void fail_typeArgumentViolatesBounds() {
1181 Source source = addSource(EngineTestCase.createSource([])); 2434 Source source = addSource(EngineTestCase.createSource([]));
1182 resolve(source, []); 2435 resolve(source);
1183 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_VIOLATES_BOUNDS]); 2436 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_VIOLATES_BOUNDS]);
1184 verify([source]); 2437 verify([source]);
1185 } 2438 }
2439 void test_inconsistentMethodInheritanceGetterAndMethod() {
2440 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " int x();", "}", "abstract class B {", " int get x;", "}", "class C implemen ts A, B {", "}"]));
2441 resolve(source);
2442 assertErrors([StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_M ETHOD]);
2443 verify([source]);
2444 }
2445 void test_invalidAssignment_compoundAssignment() {
2446 Source source = addSource(EngineTestCase.createSource(["class byte {", " in t _value;", " byte(this._value);", " int operator +(int val) {}", "}", "", "vo id main() {", " byte b = new byte(52);", " b += 3;", "}"]));
2447 resolve(source);
2448 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
2449 verify([source]);
2450 }
1186 void test_invalidAssignment_instanceVariable() { 2451 void test_invalidAssignment_instanceVariable() {
1187 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", "}", "f() {", " A a;", " a.x = '0';", "}"])); 2452 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", "}", "f() {", " A a;", " a.x = '0';", "}"]));
1188 resolve(source, []); 2453 resolve(source);
1189 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); 2454 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
1190 verify([source]); 2455 verify([source]);
1191 } 2456 }
1192 void test_invalidAssignment_localVariable() { 2457 void test_invalidAssignment_localVariable() {
1193 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;", " x = '0';", "}"])); 2458 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;", " x = '0';", "}"]));
1194 resolve(source, []); 2459 resolve(source);
1195 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); 2460 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
1196 verify([source]); 2461 verify([source]);
1197 } 2462 }
1198 void test_invalidAssignment_staticVariable() { 2463 void test_invalidAssignment_staticVariable() {
1199 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", "}", "f() {", " A.x = '0';", "}"])); 2464 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", "}", "f() {", " A.x = '0';", "}"]));
1200 resolve(source, []); 2465 resolve(source);
2466 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
2467 verify([source]);
2468 }
2469 void test_invalidAssignment_topLevelVariableDeclaration() {
2470 Source source = addSource(EngineTestCase.createSource(["int x = 'string';"]) );
2471 resolve(source);
2472 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
2473 verify([source]);
2474 }
2475 void test_invalidAssignment_variableDeclaration() {
2476 Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 'string';", "}"]));
2477 resolve(source);
1201 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); 2478 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
1202 verify([source]); 2479 verify([source]);
1203 } 2480 }
1204 void test_invocationOfNonFunction_class() { 2481 void test_invocationOfNonFunction_class() {
1205 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " A();", " }", "}"])); 2482 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " A();", " }", "}"]));
1206 resolve(source, []); 2483 resolve(source);
1207 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); 2484 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
1208 } 2485 }
1209 void test_invocationOfNonFunction_localVariable() { 2486 void test_invocationOfNonFunction_localVariable() {
1210 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;", " return x();", "}"])); 2487 Source source = addSource(EngineTestCase.createSource(["f() {", " int x;", " return x();", "}"]));
1211 resolve(source, []); 2488 resolve(source);
1212 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); 2489 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
1213 verify([source]); 2490 verify([source]);
1214 } 2491 }
1215 void test_invocationOfNonFunction_ordinaryInvocation() { 2492 void test_invocationOfNonFunction_ordinaryInvocation() {
1216 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", "}", "class B {", " m() {", " A.x();", " }", "}"])); 2493 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", "}", "class B {", " m() {", " A.x();", " }", "}"]));
1217 resolve(source, []); 2494 resolve(source);
1218 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); 2495 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
1219 } 2496 }
1220 void test_invocationOfNonFunction_staticInvocation() { 2497 void test_invocationOfNonFunction_staticInvocation() {
1221 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int get g => 0;", " f() {", " A.g();", " }", "}"])); 2498 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int get g => 0;", " f() {", " A.g();", " }", "}"]));
1222 resolve(source, []); 2499 resolve(source);
1223 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]); 2500 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
1224 } 2501 }
1225 void test_nonBoolCondition_conditional() { 2502 void test_nonBoolCondition_conditional() {
1226 Source source = addSource(EngineTestCase.createSource(["f() { return 3 ? 2 : 1; }"])); 2503 Source source = addSource(EngineTestCase.createSource(["f() { return 3 ? 2 : 1; }"]));
1227 resolve(source, []); 2504 resolve(source);
1228 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); 2505 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
1229 verify([source]); 2506 verify([source]);
1230 } 2507 }
1231 void test_nonBoolCondition_do() { 2508 void test_nonBoolCondition_do() {
1232 Source source = addSource(EngineTestCase.createSource(["f() {", " do {} whi le (3);", "}"])); 2509 Source source = addSource(EngineTestCase.createSource(["f() {", " do {} whi le (3);", "}"]));
1233 resolve(source, []); 2510 resolve(source);
1234 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); 2511 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
1235 verify([source]); 2512 verify([source]);
1236 } 2513 }
1237 void test_nonBoolCondition_if() { 2514 void test_nonBoolCondition_if() {
1238 Source source = addSource(EngineTestCase.createSource(["f() {", " if (3) re turn 2; else return 1;", "}"])); 2515 Source source = addSource(EngineTestCase.createSource(["f() {", " if (3) re turn 2; else return 1;", "}"]));
1239 resolve(source, []); 2516 resolve(source);
1240 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); 2517 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
1241 verify([source]); 2518 verify([source]);
1242 } 2519 }
1243 void test_nonBoolCondition_while() { 2520 void test_nonBoolCondition_while() {
1244 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3) {}", "}"])); 2521 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3) {}", "}"]));
1245 resolve(source, []); 2522 resolve(source);
1246 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); 2523 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
1247 verify([source]); 2524 verify([source]);
1248 } 2525 }
1249 void test_nonBoolExpression() { 2526 void test_nonBoolExpression() {
1250 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"])); 2527 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"]));
1251 resolve(source, []); 2528 resolve(source);
1252 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]); 2529 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
1253 verify([source]); 2530 verify([source]);
1254 } 2531 }
1255 void test_returnOfInvalidType_function() { 2532 void test_returnOfInvalidType_function() {
1256 Source source = addSource(EngineTestCase.createSource(["int f() { return '0' ; }"])); 2533 Source source = addSource(EngineTestCase.createSource(["int f() { return '0' ; }"]));
1257 resolve(source, []); 2534 resolve(source);
1258 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 2535 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
1259 verify([source]); 2536 verify([source]);
1260 } 2537 }
1261 void test_returnOfInvalidType_localFunction() { 2538 void test_returnOfInvalidType_localFunction() {
1262 Source source = addSource(EngineTestCase.createSource(["class A {", " Strin g m() {", " int f() { return '0'; }", " }", "}"])); 2539 Source source = addSource(EngineTestCase.createSource(["class A {", " Strin g m() {", " int f() { return '0'; }", " }", "}"]));
1263 resolve(source, []); 2540 resolve(source);
1264 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 2541 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
1265 verify([source]); 2542 verify([source]);
1266 } 2543 }
1267 void test_returnOfInvalidType_method() { 2544 void test_returnOfInvalidType_method() {
1268 Source source = addSource(EngineTestCase.createSource(["class A {", " int f () { return '0'; }", "}"])); 2545 Source source = addSource(EngineTestCase.createSource(["class A {", " int f () { return '0'; }", "}"]));
1269 resolve(source, []); 2546 resolve(source);
2547 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2548 verify([source]);
2549 }
2550 void test_returnOfInvalidType_void() {
2551 Source source = addSource(EngineTestCase.createSource(["void f() { return 42 ; }"]));
2552 resolve(source);
1270 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 2553 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
1271 verify([source]); 2554 verify([source]);
1272 } 2555 }
1273 void test_typeArgumentNotMatchingBounds_const() { 2556 void test_typeArgumentNotMatchingBounds_const() {
1274 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {", " const G() {}", "}", "f() { return const G<B> (); }"])); 2557 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {", " const G();", "}", "f() { return const G<B>() ; }"]));
1275 resolve(source, []); 2558 resolve(source);
1276 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); 2559 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
1277 verify([source]); 2560 verify([source]);
1278 } 2561 }
1279 void test_typeArgumentNotMatchingBounds_new() { 2562 void test_typeArgumentNotMatchingBounds_new() {
1280 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "f() { return new G<B>(); }"])); 2563 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "class G<E extends A> {}", "f() { return new G<B>(); }"]));
1281 resolve(source, []); 2564 resolve(source);
1282 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]); 2565 assertErrors([StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS]);
1283 verify([source]); 2566 verify([source]);
1284 } 2567 }
1285 void test_undefinedFunction() { 2568 void test_undefinedFunction() {
1286 Source source = addSource(EngineTestCase.createSource(["void f() {", " g(); ", "}"])); 2569 Source source = addSource(EngineTestCase.createSource(["void f() {", " g(); ", "}"]));
1287 resolve(source, []); 2570 resolve(source);
1288 assertErrors([StaticTypeWarningCode.UNDEFINED_FUNCTION]); 2571 assertErrors([StaticTypeWarningCode.UNDEFINED_FUNCTION]);
1289 } 2572 }
1290 void test_undefinedGetter() { 2573 void test_undefinedGetter() {
1291 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e) { return e.m; }"])); 2574 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e) { return e.m; }"]));
1292 resolve(source, []); 2575 resolve(source);
1293 assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]); 2576 assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]);
1294 } 2577 }
1295 void test_undefinedGetter_static() { 2578 void test_undefinedGetter_static() {
1296 Source source = addSource(EngineTestCase.createSource(["class A {}", "var a = A.B;"])); 2579 Source source = addSource(EngineTestCase.createSource(["class A {}", "var a = A.B;"]));
1297 resolve(source, []); 2580 resolve(source);
1298 assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]); 2581 assertErrors([StaticTypeWarningCode.UNDEFINED_GETTER]);
1299 } 2582 }
1300 void test_undefinedMethod() { 2583 void test_undefinedMethod() {
1301 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " n();", " }", "}"])); 2584 Source source = addSource(EngineTestCase.createSource(["class A {", " void m() {", " n();", " }", "}"]));
1302 resolve(source, []); 2585 resolve(source);
1303 assertErrors([StaticTypeWarningCode.UNDEFINED_METHOD]); 2586 assertErrors([StaticTypeWarningCode.UNDEFINED_METHOD]);
1304 } 2587 }
2588 void test_undefinedOperator_indexBoth() {
2589 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a[0]++;", "}"]));
2590 resolve(source);
2591 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
2592 }
2593 void test_undefinedOperator_indexGetter() {
2594 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a[0];", "}"]));
2595 resolve(source);
2596 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
2597 }
2598 void test_undefinedOperator_indexSetter() {
2599 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a[0] = 1;", "}"]));
2600 resolve(source);
2601 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
2602 }
2603 void test_undefinedOperator_plus() {
2604 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(A a) {", " a + 1;", "}"]));
2605 resolve(source);
2606 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
2607 }
1305 void test_undefinedSetter() { 2608 void test_undefinedSetter() {
1306 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e1 ) { e1.m = 0; }"])); 2609 Source source = addSource(EngineTestCase.createSource(["class T {}", "f(T e1 ) { e1.m = 0; }"]));
1307 resolve(source, []); 2610 resolve(source);
1308 assertErrors([StaticTypeWarningCode.UNDEFINED_SETTER]); 2611 assertErrors([StaticTypeWarningCode.UNDEFINED_SETTER]);
1309 } 2612 }
1310 void test_undefinedSetter_static() { 2613 void test_undefinedSetter_static() {
1311 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { A.B = 0;}"])); 2614 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { A.B = 0;}"]));
1312 resolve(source, []); 2615 resolve(source);
1313 assertErrors([StaticTypeWarningCode.UNDEFINED_SETTER]); 2616 assertErrors([StaticTypeWarningCode.UNDEFINED_SETTER]);
1314 } 2617 }
1315 void test_undefinedSuperMethod() { 2618 void test_undefinedSuperMethod() {
1316 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " m() { return super.m(); }", "}"])); 2619 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " m() { return super.m(); }", "}"]));
1317 resolve(source, []); 2620 resolve(source);
1318 assertErrors([StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]); 2621 assertErrors([StaticTypeWarningCode.UNDEFINED_SUPER_METHOD]);
1319 } 2622 }
1320 void test_wrongNumberOfTypeArguments_tooFew() { 2623 void test_wrongNumberOfTypeArguments_tooFew() {
1321 Source source = addSource(EngineTestCase.createSource(["class A<E, F> {}", " A<A> a = null;"])); 2624 Source source = addSource(EngineTestCase.createSource(["class A<E, F> {}", " A<A> a = null;"]));
1322 resolve(source, []); 2625 resolve(source);
1323 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 2626 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
1324 verify([source]); 2627 verify([source]);
1325 } 2628 }
1326 void test_wrongNumberOfTypeArguments_tooMany() { 2629 void test_wrongNumberOfTypeArguments_tooMany() {
1327 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A , A> a = null;"])); 2630 Source source = addSource(EngineTestCase.createSource(["class A<E> {}", "A<A , A> a = null;"]));
1328 resolve(source, []); 2631 resolve(source);
1329 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 2632 assertErrors([StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
1330 verify([source]); 2633 verify([source]);
1331 } 2634 }
1332 static dartSuite() { 2635 static dartSuite() {
1333 _ut.group('StaticTypeWarningCodeTest', () { 2636 _ut.group('StaticTypeWarningCodeTest', () {
2637 _ut.test('test_inconsistentMethodInheritanceGetterAndMethod', () {
2638 final __test = new StaticTypeWarningCodeTest();
2639 runJUnitTest(__test, __test.test_inconsistentMethodInheritanceGetterAndM ethod);
2640 });
2641 _ut.test('test_invalidAssignment_compoundAssignment', () {
2642 final __test = new StaticTypeWarningCodeTest();
2643 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment);
2644 });
1334 _ut.test('test_invalidAssignment_instanceVariable', () { 2645 _ut.test('test_invalidAssignment_instanceVariable', () {
1335 final __test = new StaticTypeWarningCodeTest(); 2646 final __test = new StaticTypeWarningCodeTest();
1336 runJUnitTest(__test, __test.test_invalidAssignment_instanceVariable); 2647 runJUnitTest(__test, __test.test_invalidAssignment_instanceVariable);
1337 }); 2648 });
1338 _ut.test('test_invalidAssignment_localVariable', () { 2649 _ut.test('test_invalidAssignment_localVariable', () {
1339 final __test = new StaticTypeWarningCodeTest(); 2650 final __test = new StaticTypeWarningCodeTest();
1340 runJUnitTest(__test, __test.test_invalidAssignment_localVariable); 2651 runJUnitTest(__test, __test.test_invalidAssignment_localVariable);
1341 }); 2652 });
1342 _ut.test('test_invalidAssignment_staticVariable', () { 2653 _ut.test('test_invalidAssignment_staticVariable', () {
1343 final __test = new StaticTypeWarningCodeTest(); 2654 final __test = new StaticTypeWarningCodeTest();
1344 runJUnitTest(__test, __test.test_invalidAssignment_staticVariable); 2655 runJUnitTest(__test, __test.test_invalidAssignment_staticVariable);
1345 }); 2656 });
2657 _ut.test('test_invalidAssignment_topLevelVariableDeclaration', () {
2658 final __test = new StaticTypeWarningCodeTest();
2659 runJUnitTest(__test, __test.test_invalidAssignment_topLevelVariableDecla ration);
2660 });
2661 _ut.test('test_invalidAssignment_variableDeclaration', () {
2662 final __test = new StaticTypeWarningCodeTest();
2663 runJUnitTest(__test, __test.test_invalidAssignment_variableDeclaration);
2664 });
1346 _ut.test('test_invocationOfNonFunction_class', () { 2665 _ut.test('test_invocationOfNonFunction_class', () {
1347 final __test = new StaticTypeWarningCodeTest(); 2666 final __test = new StaticTypeWarningCodeTest();
1348 runJUnitTest(__test, __test.test_invocationOfNonFunction_class); 2667 runJUnitTest(__test, __test.test_invocationOfNonFunction_class);
1349 }); 2668 });
1350 _ut.test('test_invocationOfNonFunction_localVariable', () { 2669 _ut.test('test_invocationOfNonFunction_localVariable', () {
1351 final __test = new StaticTypeWarningCodeTest(); 2670 final __test = new StaticTypeWarningCodeTest();
1352 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable); 2671 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable);
1353 }); 2672 });
1354 _ut.test('test_invocationOfNonFunction_ordinaryInvocation', () { 2673 _ut.test('test_invocationOfNonFunction_ordinaryInvocation', () {
1355 final __test = new StaticTypeWarningCodeTest(); 2674 final __test = new StaticTypeWarningCodeTest();
(...skipping 28 matching lines...) Expand all
1384 runJUnitTest(__test, __test.test_returnOfInvalidType_function); 2703 runJUnitTest(__test, __test.test_returnOfInvalidType_function);
1385 }); 2704 });
1386 _ut.test('test_returnOfInvalidType_localFunction', () { 2705 _ut.test('test_returnOfInvalidType_localFunction', () {
1387 final __test = new StaticTypeWarningCodeTest(); 2706 final __test = new StaticTypeWarningCodeTest();
1388 runJUnitTest(__test, __test.test_returnOfInvalidType_localFunction); 2707 runJUnitTest(__test, __test.test_returnOfInvalidType_localFunction);
1389 }); 2708 });
1390 _ut.test('test_returnOfInvalidType_method', () { 2709 _ut.test('test_returnOfInvalidType_method', () {
1391 final __test = new StaticTypeWarningCodeTest(); 2710 final __test = new StaticTypeWarningCodeTest();
1392 runJUnitTest(__test, __test.test_returnOfInvalidType_method); 2711 runJUnitTest(__test, __test.test_returnOfInvalidType_method);
1393 }); 2712 });
2713 _ut.test('test_returnOfInvalidType_void', () {
2714 final __test = new StaticTypeWarningCodeTest();
2715 runJUnitTest(__test, __test.test_returnOfInvalidType_void);
2716 });
1394 _ut.test('test_typeArgumentNotMatchingBounds_const', () { 2717 _ut.test('test_typeArgumentNotMatchingBounds_const', () {
1395 final __test = new StaticTypeWarningCodeTest(); 2718 final __test = new StaticTypeWarningCodeTest();
1396 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const); 2719 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
1397 }); 2720 });
1398 _ut.test('test_typeArgumentNotMatchingBounds_new', () { 2721 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
1399 final __test = new StaticTypeWarningCodeTest(); 2722 final __test = new StaticTypeWarningCodeTest();
1400 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new); 2723 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
1401 }); 2724 });
1402 _ut.test('test_undefinedFunction', () { 2725 _ut.test('test_undefinedFunction', () {
1403 final __test = new StaticTypeWarningCodeTest(); 2726 final __test = new StaticTypeWarningCodeTest();
1404 runJUnitTest(__test, __test.test_undefinedFunction); 2727 runJUnitTest(__test, __test.test_undefinedFunction);
1405 }); 2728 });
1406 _ut.test('test_undefinedGetter', () { 2729 _ut.test('test_undefinedGetter', () {
1407 final __test = new StaticTypeWarningCodeTest(); 2730 final __test = new StaticTypeWarningCodeTest();
1408 runJUnitTest(__test, __test.test_undefinedGetter); 2731 runJUnitTest(__test, __test.test_undefinedGetter);
1409 }); 2732 });
1410 _ut.test('test_undefinedGetter_static', () { 2733 _ut.test('test_undefinedGetter_static', () {
1411 final __test = new StaticTypeWarningCodeTest(); 2734 final __test = new StaticTypeWarningCodeTest();
1412 runJUnitTest(__test, __test.test_undefinedGetter_static); 2735 runJUnitTest(__test, __test.test_undefinedGetter_static);
1413 }); 2736 });
1414 _ut.test('test_undefinedMethod', () { 2737 _ut.test('test_undefinedMethod', () {
1415 final __test = new StaticTypeWarningCodeTest(); 2738 final __test = new StaticTypeWarningCodeTest();
1416 runJUnitTest(__test, __test.test_undefinedMethod); 2739 runJUnitTest(__test, __test.test_undefinedMethod);
1417 }); 2740 });
2741 _ut.test('test_undefinedOperator_indexBoth', () {
2742 final __test = new StaticTypeWarningCodeTest();
2743 runJUnitTest(__test, __test.test_undefinedOperator_indexBoth);
2744 });
2745 _ut.test('test_undefinedOperator_indexGetter', () {
2746 final __test = new StaticTypeWarningCodeTest();
2747 runJUnitTest(__test, __test.test_undefinedOperator_indexGetter);
2748 });
2749 _ut.test('test_undefinedOperator_indexSetter', () {
2750 final __test = new StaticTypeWarningCodeTest();
2751 runJUnitTest(__test, __test.test_undefinedOperator_indexSetter);
2752 });
2753 _ut.test('test_undefinedOperator_plus', () {
2754 final __test = new StaticTypeWarningCodeTest();
2755 runJUnitTest(__test, __test.test_undefinedOperator_plus);
2756 });
1418 _ut.test('test_undefinedSetter', () { 2757 _ut.test('test_undefinedSetter', () {
1419 final __test = new StaticTypeWarningCodeTest(); 2758 final __test = new StaticTypeWarningCodeTest();
1420 runJUnitTest(__test, __test.test_undefinedSetter); 2759 runJUnitTest(__test, __test.test_undefinedSetter);
1421 }); 2760 });
1422 _ut.test('test_undefinedSetter_static', () { 2761 _ut.test('test_undefinedSetter_static', () {
1423 final __test = new StaticTypeWarningCodeTest(); 2762 final __test = new StaticTypeWarningCodeTest();
1424 runJUnitTest(__test, __test.test_undefinedSetter_static); 2763 runJUnitTest(__test, __test.test_undefinedSetter_static);
1425 }); 2764 });
1426 _ut.test('test_undefinedSuperMethod', () { 2765 _ut.test('test_undefinedSuperMethod', () {
1427 final __test = new StaticTypeWarningCodeTest(); 2766 final __test = new StaticTypeWarningCodeTest();
1428 runJUnitTest(__test, __test.test_undefinedSuperMethod); 2767 runJUnitTest(__test, __test.test_undefinedSuperMethod);
1429 }); 2768 });
1430 _ut.test('test_wrongNumberOfTypeArguments_tooFew', () { 2769 _ut.test('test_wrongNumberOfTypeArguments_tooFew', () {
1431 final __test = new StaticTypeWarningCodeTest(); 2770 final __test = new StaticTypeWarningCodeTest();
1432 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooFew); 2771 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooFew);
1433 }); 2772 });
1434 _ut.test('test_wrongNumberOfTypeArguments_tooMany', () { 2773 _ut.test('test_wrongNumberOfTypeArguments_tooMany', () {
1435 final __test = new StaticTypeWarningCodeTest(); 2774 final __test = new StaticTypeWarningCodeTest();
1436 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooMany); 2775 runJUnitTest(__test, __test.test_wrongNumberOfTypeArguments_tooMany);
1437 }); 2776 });
1438 }); 2777 });
1439 } 2778 }
1440 } 2779 }
1441 class TypeResolverVisitorTest extends EngineTestCase { 2780 class TypeResolverVisitorTest extends EngineTestCase {
2781
1442 /** 2782 /**
1443 * The error listener to which errors will be reported. 2783 * The error listener to which errors will be reported.
1444 */ 2784 */
1445 GatheringErrorListener _listener; 2785 GatheringErrorListener _listener;
2786
1446 /** 2787 /**
1447 * The object representing the information about the library in which the type s are being 2788 * The object representing the information about the library in which the type s are being
1448 * resolved. 2789 * resolved.
1449 */ 2790 */
1450 Library _library; 2791 Library _library;
2792
1451 /** 2793 /**
1452 * The type provider used to access the types. 2794 * The type provider used to access the types.
1453 */ 2795 */
1454 TestTypeProvider _typeProvider; 2796 TestTypeProvider _typeProvider;
2797
1455 /** 2798 /**
1456 * The visitor used to resolve types needed to form the type hierarchy. 2799 * The visitor used to resolve types needed to form the type hierarchy.
1457 */ 2800 */
1458 TypeResolverVisitor _visitor; 2801 TypeResolverVisitor _visitor;
1459 void fail_visitConstructorDeclaration() { 2802 void fail_visitConstructorDeclaration() {
1460 JUnitTestCase.fail("Not yet tested"); 2803 JUnitTestCase.fail("Not yet tested");
1461 _listener.assertNoErrors(); 2804 _listener.assertNoErrors();
1462 } 2805 }
1463 void fail_visitFieldFormalParameter_noType() { 2806 void fail_visitFieldFormalParameter_noType() {
1464 FormalParameter node = ASTFactory.fieldFormalParameter(Keyword.VAR, null, "p "); 2807 FormalParameter node = ASTFactory.fieldFormalParameter(Keyword.VAR, null, "p ");
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]); 2975 JUnitTestCase.assertSame(DynamicTypeImpl.instance, resultArguments[0]);
1633 _listener.assertNoErrors(); 2976 _listener.assertNoErrors();
1634 } 2977 }
1635 void test_visitTypeName_void() { 2978 void test_visitTypeName_void() {
1636 ClassElement classA = ElementFactory.classElement2("A", []); 2979 ClassElement classA = ElementFactory.classElement2("A", []);
1637 TypeName typeName = ASTFactory.typeName4("void", []); 2980 TypeName typeName = ASTFactory.typeName4("void", []);
1638 resolveNode(typeName, [classA]); 2981 resolveNode(typeName, [classA]);
1639 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type); 2982 JUnitTestCase.assertSame(VoidTypeImpl.instance, typeName.type);
1640 _listener.assertNoErrors(); 2983 _listener.assertNoErrors();
1641 } 2984 }
2985
1642 /** 2986 /**
1643 * Analyze the given catch clause and assert that the types of the parameters have been set to the 2987 * Analyze the given catch clause and assert that the types of the parameters have been set to the
1644 * given types. The types can be null if the catch clause does not have the co rresponding 2988 * given types. The types can be null if the catch clause does not have the co rresponding
1645 * parameter. 2989 * parameter.
1646 * @param node the catch clause to be analyzed 2990 * @param node the catch clause to be analyzed
1647 * @param exceptionType the expected type of the exception parameter 2991 * @param exceptionType the expected type of the exception parameter
1648 * @param stackTraceType the expected type of the stack trace parameter 2992 * @param stackTraceType the expected type of the stack trace parameter
1649 * @param definedElements the elements that are to be defined in the scope in which the element is 2993 * @param definedElements the elements that are to be defined in the scope in which the element is
1650 * being resolved 2994 * being resolved
1651 */ 2995 */
1652 void resolve(CatchClause node, InterfaceType exceptionType, InterfaceType stac kTraceType, List<Element> definedElements) { 2996 void resolve(CatchClause node, InterfaceType exceptionType, InterfaceType stac kTraceType, List<Element> definedElements) {
1653 resolveNode(node, definedElements); 2997 resolveNode(node, definedElements);
1654 SimpleIdentifier exceptionParameter2 = node.exceptionParameter; 2998 SimpleIdentifier exceptionParameter2 = node.exceptionParameter;
1655 if (exceptionParameter2 != null) { 2999 if (exceptionParameter2 != null) {
1656 JUnitTestCase.assertSame(exceptionType, exceptionParameter2.staticType); 3000 JUnitTestCase.assertSame(exceptionType, exceptionParameter2.staticType);
1657 } 3001 }
1658 SimpleIdentifier stackTraceParameter2 = node.stackTraceParameter; 3002 SimpleIdentifier stackTraceParameter2 = node.stackTraceParameter;
1659 if (stackTraceParameter2 != null) { 3003 if (stackTraceParameter2 != null) {
1660 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter2.staticType); 3004 JUnitTestCase.assertSame(stackTraceType, stackTraceParameter2.staticType);
1661 } 3005 }
1662 } 3006 }
3007
1663 /** 3008 /**
1664 * Return the type associated with the given parameter after the static type a nalyzer has computed 3009 * Return the type associated with the given parameter after the static type a nalyzer has computed
1665 * a type for it. 3010 * a type for it.
1666 * @param node the parameter with which the type is associated 3011 * @param node the parameter with which the type is associated
1667 * @param definedElements the elements that are to be defined in the scope in which the element is 3012 * @param definedElements the elements that are to be defined in the scope in which the element is
1668 * being resolved 3013 * being resolved
1669 * @return the type associated with the parameter 3014 * @return the type associated with the parameter
1670 */ 3015 */
1671 Type2 resolve6(FormalParameter node, List<Element> definedElements) { 3016 Type2 resolve6(FormalParameter node, List<Element> definedElements) {
1672 resolveNode(node, definedElements); 3017 resolveNode(node, definedElements);
1673 return ((node.identifier.element as ParameterElement)).type; 3018 return ((node.identifier.element as ParameterElement)).type;
1674 } 3019 }
3020
1675 /** 3021 /**
1676 * Return the element associated with the given identifier after the resolver has resolved the 3022 * Return the element associated with the given identifier after the resolver has resolved the
1677 * identifier. 3023 * identifier.
1678 * @param node the expression to be resolved 3024 * @param node the expression to be resolved
1679 * @param definedElements the elements that are to be defined in the scope in which the element is 3025 * @param definedElements the elements that are to be defined in the scope in which the element is
1680 * being resolved 3026 * being resolved
1681 * @return the element to which the expression was resolved 3027 * @return the element to which the expression was resolved
1682 */ 3028 */
1683 void resolveNode(ASTNode node, List<Element> definedElements) { 3029 void resolveNode(ASTNode node, List<Element> definedElements) {
1684 for (Element element in definedElements) { 3030 for (Element element in definedElements) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 runJUnitTest(__test, __test.test_visitTypeName_parameters_noArguments); 3079 runJUnitTest(__test, __test.test_visitTypeName_parameters_noArguments);
1734 }); 3080 });
1735 _ut.test('test_visitTypeName_void', () { 3081 _ut.test('test_visitTypeName_void', () {
1736 final __test = new TypeResolverVisitorTest(); 3082 final __test = new TypeResolverVisitorTest();
1737 runJUnitTest(__test, __test.test_visitTypeName_void); 3083 runJUnitTest(__test, __test.test_visitTypeName_void);
1738 }); 3084 });
1739 }); 3085 });
1740 } 3086 }
1741 } 3087 }
1742 class ResolverTestCase extends EngineTestCase { 3088 class ResolverTestCase extends EngineTestCase {
3089
1743 /** 3090 /**
1744 * The source factory used to create {@link Source sources}. 3091 * The source factory used to create {@link Source sources}.
1745 */ 3092 */
1746 SourceFactory _sourceFactory; 3093 SourceFactory _sourceFactory;
1747 /** 3094
1748 * The error listener used during resolution.
1749 */
1750 GatheringErrorListener _errorListener;
1751 /** 3095 /**
1752 * The analysis context used to parse the compilation units being resolved. 3096 * The analysis context used to parse the compilation units being resolved.
1753 */ 3097 */
1754 AnalysisContextImpl _analysisContext; 3098 AnalysisContextImpl _analysisContext;
1755 /** 3099 void setUp() {
1756 * Assert that the number of errors that have been gathered matches the number of errors that are 3100 reset();
1757 * given and that they have the expected error codes. The order in which the e rrors were gathered
1758 * is ignored.
1759 * @param expectedErrorCodes the error codes of the errors that should have be en gathered
1760 * @throws AssertionFailedError if a different number of errors have been gath ered than were
1761 * expected
1762 */
1763 void assertErrors(List<ErrorCode> expectedErrorCodes) {
1764 _errorListener.assertErrors2(expectedErrorCodes);
1765 } 3101 }
1766 void setUp() { 3102
1767 _errorListener = new GatheringErrorListener();
1768 _analysisContext = AnalysisContextFactory.contextWithCore();
1769 _sourceFactory = _analysisContext.sourceFactory;
1770 }
1771 /** 3103 /**
1772 * Add a source file to the content provider. 3104 * Add a source file to the content provider.
1773 * @param contents the contents to be returned by the content provider for the specified file 3105 * @param contents the contents to be returned by the content provider for the specified file
1774 * @return the source object representing the added file 3106 * @return the source object representing the added file
1775 */ 3107 */
1776 Source addSource(String contents) => addSource2("/test.dart", contents); 3108 Source addSource(String contents) => addSource2("/test.dart", contents);
3109
1777 /** 3110 /**
1778 * Add a source file to the content provider. The file path should be absolute . 3111 * Add a source file to the content provider. The file path should be absolute .
1779 * @param filePath the path of the file being added 3112 * @param filePath the path of the file being added
1780 * @param contents the contents to be returned by the content provider for the specified file 3113 * @param contents the contents to be returned by the content provider for the specified file
1781 * @return the source object representing the added file 3114 * @return the source object representing the added file
1782 */ 3115 */
1783 Source addSource2(String filePath, String contents) { 3116 Source addSource2(String filePath, String contents) {
1784 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath)); 3117 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath));
1785 _sourceFactory.setContents(source, contents); 3118 _sourceFactory.setContents(source, contents);
1786 ChangeSet changeSet = new ChangeSet(); 3119 ChangeSet changeSet = new ChangeSet();
1787 changeSet.added(source); 3120 changeSet.added(source);
1788 _analysisContext.applyChanges(changeSet); 3121 _analysisContext.applyChanges(changeSet);
1789 return source; 3122 return source;
1790 } 3123 }
3124
3125 /**
3126 * Assert that the number of errors that have been gathered matches the number of errors that are
3127 * given and that they have the expected error codes. The order in which the e rrors were gathered
3128 * is ignored.
3129 * @param expectedErrorCodes the error codes of the errors that should have be en gathered
3130 * @throws AssertionFailedError if a different number of errors have been gath ered than were
3131 * expected
3132 */
3133 void assertErrors(List<ErrorCode> expectedErrorCodes) {
3134 GatheringErrorListener errorListener = new GatheringErrorListener();
3135 for (ChangeNotice notice in _analysisContext.performAnalysisTask()) {
3136 for (AnalysisError error in notice.errors) {
3137 errorListener.onError(error);
3138 }
3139 }
3140 errorListener.assertErrors2(expectedErrorCodes);
3141 }
3142
1791 /** 3143 /**
1792 * Assert that no errors have been gathered. 3144 * Assert that no errors have been gathered.
1793 * @throws AssertionFailedError if any errors have been gathered 3145 * @throws AssertionFailedError if any errors have been gathered
1794 */ 3146 */
1795 void assertNoErrors() { 3147 void assertNoErrors() {
1796 _errorListener.assertNoErrors(); 3148 GatheringErrorListener errorListener = new GatheringErrorListener();
3149 for (ChangeNotice notice in _analysisContext.performAnalysisTask()) {
3150 for (AnalysisError error in notice.errors) {
3151 errorListener.onError(error);
3152 }
3153 }
3154 errorListener.assertNoErrors();
1797 } 3155 }
3156
1798 /** 3157 /**
1799 * Create a library element that represents a library named {@code "test"} con taining a single 3158 * Create a library element that represents a library named {@code "test"} con taining a single
1800 * empty compilation unit. 3159 * empty compilation unit.
1801 * @return the library element that was created 3160 * @return the library element that was created
1802 */ 3161 */
1803 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []); 3162 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []);
3163
1804 /** 3164 /**
1805 * Create a library element that represents a library with the given name cont aining a single 3165 * Create a library element that represents a library with the given name cont aining a single
1806 * empty compilation unit. 3166 * empty compilation unit.
1807 * @param libraryName the name of the library to be created 3167 * @param libraryName the name of the library to be created
1808 * @return the library element that was created 3168 * @return the library element that was created
1809 */ 3169 */
1810 LibraryElementImpl createTestLibrary2(AnalysisContext context, String libraryN ame, List<String> typeNames) { 3170 LibraryElementImpl createTestLibrary2(AnalysisContext context, String libraryN ame, List<String> typeNames) {
1811 int count = typeNames.length; 3171 int count = typeNames.length;
1812 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat ionUnitElementImpl>(count); 3172 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat ionUnitElementImpl>(count);
1813 for (int i = 0; i < count; i++) { 3173 for (int i = 0; i < count; i++) {
1814 String typeName = typeNames[i]; 3174 String typeName = typeNames[i];
1815 ClassElementImpl type = new ClassElementImpl(ASTFactory.identifier3(typeNa me)); 3175 ClassElementImpl type = new ClassElementImpl(ASTFactory.identifier3(typeNa me));
1816 String fileName = "${typeName}.dart"; 3176 String fileName = "${typeName}.dart";
1817 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImp l(fileName); 3177 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImp l(fileName);
1818 compilationUnit.source = createSource2(fileName); 3178 compilationUnit.source = createSource2(fileName);
1819 compilationUnit.types = <ClassElement> [type]; 3179 compilationUnit.types = <ClassElement> [type];
1820 sourcedCompilationUnits[i] = compilationUnit; 3180 sourcedCompilationUnits[i] = compilationUnit;
1821 } 3181 }
1822 String fileName = "${libraryName}.dart"; 3182 String fileName = "${libraryName}.dart";
1823 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName); 3183 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName);
1824 compilationUnit.source = createSource2(fileName); 3184 compilationUnit.source = createSource2(fileName);
1825 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName])); 3185 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName]));
1826 library.definingCompilationUnit = compilationUnit; 3186 library.definingCompilationUnit = compilationUnit;
1827 library.parts = sourcedCompilationUnits; 3187 library.parts = sourcedCompilationUnits;
1828 return library; 3188 return library;
1829 } 3189 }
1830 AnalysisContext get analysisContext => _analysisContext; 3190 AnalysisContext get analysisContext => _analysisContext;
1831 GatheringErrorListener get errorListener => _errorListener;
1832 SourceFactory get sourceFactory => _sourceFactory; 3191 SourceFactory get sourceFactory => _sourceFactory;
3192
1833 /** 3193 /**
1834 * Return a type provider that can be used to test the results of resolution. 3194 * Return a type provider that can be used to test the results of resolution.
1835 * @return a type provider 3195 * @return a type provider
1836 */ 3196 */
1837 TypeProvider get typeProvider { 3197 TypeProvider get typeProvider {
1838 Source coreSource = _analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ; 3198 Source coreSource = _analysisContext.sourceFactory.forUri(DartSdk.DART_CORE) ;
1839 LibraryElement coreElement = _analysisContext.getLibraryElement(coreSource); 3199 LibraryElement coreElement = _analysisContext.getLibraryElement(coreSource);
1840 return new TypeProviderImpl(coreElement); 3200 return new TypeProviderImpl(coreElement);
1841 } 3201 }
3202
3203 /**
3204 * In the rare cases we want to group several tests into single "test_" method , so need a way to
3205 * reset test instance to reuse it.
3206 */
3207 void reset() {
3208 _analysisContext = AnalysisContextFactory.contextWithCore();
3209 _sourceFactory = _analysisContext.sourceFactory;
3210 }
3211
1842 /** 3212 /**
1843 * Given a library and all of its parts, resolve the contents of the library a nd the contents of 3213 * Given a library and all of its parts, resolve the contents of the library a nd the contents of
1844 * the parts. This assumes that the sources for the library and its parts have already been added 3214 * the parts. This assumes that the sources for the library and its parts have already been added
1845 * to the content provider using the method {@link #addSource(String,String)}. 3215 * to the content provider using the method {@link #addSource(String,String)}.
1846 * @param librarySource the source for the compilation unit that defines the l ibrary 3216 * @param librarySource the source for the compilation unit that defines the l ibrary
1847 * @param unitSources the sources for the compilation units that are part of t he library
1848 * @return the element representing the resolved library 3217 * @return the element representing the resolved library
1849 * @throws AnalysisException if the analysis could not be performed 3218 * @throws AnalysisException if the analysis could not be performed
1850 */ 3219 */
1851 LibraryElement resolve(Source librarySource, List<Source> unitSources) { 3220 LibraryElement resolve(Source librarySource) => _analysisContext.computeLibrar yElement(librarySource);
1852 LibraryResolver resolver = new LibraryResolver.con2(_analysisContext, _error Listener); 3221
1853 return resolver.resolveLibrary(librarySource, true);
1854 }
1855 /** 3222 /**
1856 * Return the resolved compilation unit corresponding to the given source in t he given library. 3223 * Return the resolved compilation unit corresponding to the given source in t he given library.
1857 * @param source the source of the compilation unit to be returned 3224 * @param source the source of the compilation unit to be returned
1858 * @param library the library in which the compilation unit is to be resolved 3225 * @param library the library in which the compilation unit is to be resolved
1859 * @return the resolved compilation unit 3226 * @return the resolved compilation unit
1860 * @throws Exception if the compilation unit could not be resolved 3227 * @throws Exception if the compilation unit could not be resolved
1861 */ 3228 */
1862 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) => _analysisContext.resolveCompilationUnit(source, library); 3229 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) => _analysisContext.resolveCompilationUnit(source, library);
3230
1863 /** 3231 /**
1864 * Verify that all of the identifiers in the compilation units associated with the given sources 3232 * Verify that all of the identifiers in the compilation units associated with the given sources
1865 * have been resolved. 3233 * have been resolved.
1866 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element 3234 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element
1867 * to which they were resolved 3235 * to which they were resolved
1868 * @param sources the sources identifying the compilation units to be verified 3236 * @param sources the sources identifying the compilation units to be verified
1869 * @throws Exception if the contents of the compilation unit cannot be accesse d 3237 * @throws Exception if the contents of the compilation unit cannot be accesse d
1870 */ 3238 */
1871 void verify(List<Source> sources) { 3239 void verify(List<Source> sources) {
1872 ResolutionVerifier verifier = new ResolutionVerifier(); 3240 ResolutionVerifier verifier = new ResolutionVerifier();
1873 for (Source source in sources) { 3241 for (Source source in sources) {
1874 _analysisContext.parseCompilationUnit(source).accept(verifier); 3242 _analysisContext.parseCompilationUnit(source).accept(verifier);
1875 } 3243 }
1876 verifier.assertResolved(); 3244 verifier.assertResolved();
1877 } 3245 }
3246
1878 /** 3247 /**
1879 * Create a source object representing a file with the given name and give it an empty content. 3248 * Create a source object representing a file with the given name and give it an empty content.
1880 * @param fileName the name of the file for which a source is to be created 3249 * @param fileName the name of the file for which a source is to be created
1881 * @return the source that was created 3250 * @return the source that was created
1882 */ 3251 */
1883 FileBasedSource createSource2(String fileName) { 3252 FileBasedSource createSource2(String fileName) {
1884 FileBasedSource source = new FileBasedSource.con1(_sourceFactory.contentCach e, FileUtilities2.createFile(fileName)); 3253 FileBasedSource source = new FileBasedSource.con1(_sourceFactory.contentCach e, FileUtilities2.createFile(fileName));
1885 _sourceFactory.setContents(source, ""); 3254 _sourceFactory.setContents(source, "");
1886 return source; 3255 return source;
1887 } 3256 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 } 3312 }
1944 static dartSuite() { 3313 static dartSuite() {
1945 _ut.group('TypeProviderImplTest', () { 3314 _ut.group('TypeProviderImplTest', () {
1946 _ut.test('test_creation', () { 3315 _ut.test('test_creation', () {
1947 final __test = new TypeProviderImplTest(); 3316 final __test = new TypeProviderImplTest();
1948 runJUnitTest(__test, __test.test_creation); 3317 runJUnitTest(__test, __test.test_creation);
1949 }); 3318 });
1950 }); 3319 });
1951 } 3320 }
1952 } 3321 }
3322 class InheritanceManagerTest extends EngineTestCase {
3323
3324 /**
3325 * The type provider used to access the types.
3326 */
3327 TestTypeProvider _typeProvider;
3328
3329 /**
3330 * The library containing the code being resolved.
3331 */
3332 LibraryElementImpl _definingLibrary;
3333
3334 /**
3335 * The inheritance manager being tested.
3336 */
3337 InheritanceManager _inheritanceManager;
3338 void setUp() {
3339 _typeProvider = new TestTypeProvider();
3340 _inheritanceManager = createInheritanceManager();
3341 }
3342 void test_lookupInheritance_interface_getter() {
3343 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3344 String getterName = "g";
3345 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
3346 classA.accessors = <PropertyAccessorElement> [getterG];
3347 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3348 classB.interfaces = <InterfaceType> [classA.type];
3349 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas sB, getterName));
3350 assertNoErrors(classA);
3351 assertNoErrors(classB);
3352 }
3353 void test_lookupInheritance_interface_method() {
3354 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3355 String methodName = "m";
3356 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3357 classA.methods = <MethodElement> [methodM];
3358 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3359 classB.interfaces = <InterfaceType> [classA.type];
3360 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas sB, methodName));
3361 assertNoErrors(classA);
3362 assertNoErrors(classB);
3363 }
3364 void test_lookupInheritance_interface_setter() {
3365 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3366 String setterName = "s";
3367 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, _typeProvider.intType);
3368 classA.accessors = <PropertyAccessorElement> [setterS];
3369 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3370 classB.interfaces = <InterfaceType> [classA.type];
3371 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas sB, "${setterName}="));
3372 assertNoErrors(classA);
3373 assertNoErrors(classB);
3374 }
3375 void test_lookupInheritance_interface_staticMember() {
3376 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3377 String methodName = "m";
3378 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3379 ((methodM as MethodElementImpl)).static = true;
3380 classA.methods = <MethodElement> [methodM];
3381 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3382 classB.interfaces = <InterfaceType> [classA.type];
3383 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho dName));
3384 assertNoErrors(classA);
3385 assertNoErrors(classB);
3386 }
3387 void test_lookupInheritance_interfaces_infiniteLoop() {
3388 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3389 classA.interfaces = <InterfaceType> [classA.type];
3390 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name "));
3391 assertNoErrors(classA);
3392 }
3393 void test_lookupInheritance_interfaces_infiniteLoop2() {
3394 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3395 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3396 classA.interfaces = <InterfaceType> [classB.type];
3397 classB.interfaces = <InterfaceType> [classA.type];
3398 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name "));
3399 assertNoErrors(classA);
3400 assertNoErrors(classB);
3401 }
3402 void test_lookupInheritance_interfaces_STWC_inconsistentMethodInheritance() {
3403 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []);
3404 String methodName = "m";
3405 MethodElement methodM1 = ElementFactory.methodElement(methodName, null, [_ty peProvider.intType]);
3406 classI1.methods = <MethodElement> [methodM1];
3407 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []);
3408 MethodElement methodM2 = ElementFactory.methodElement(methodName, null, [_ty peProvider.stringType]);
3409 classI2.methods = <MethodElement> [methodM2];
3410 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3411 classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
3412 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, metho dName));
3413 assertNoErrors(classI1);
3414 assertNoErrors(classI2);
3415 assertErrors(classA, [StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE] );
3416 }
3417 void test_lookupInheritance_interfaces_SWC_inconsistentMethodInheritance() {
3418 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []);
3419 String methodName = "m";
3420 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3421 classI1.methods = <MethodElement> [methodM];
3422 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []);
3423 PropertyAccessorElement getter = ElementFactory.getterElement(methodName, fa lse, _typeProvider.intType);
3424 classI2.accessors = <PropertyAccessorElement> [getter];
3425 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3426 classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
3427 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, metho dName));
3428 assertNoErrors(classI1);
3429 assertNoErrors(classI2);
3430 assertErrors(classA, [StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETT ER_AND_METHOD]);
3431 }
3432 void test_lookupInheritance_interfaces_union1() {
3433 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []);
3434 String methodName1 = "m1";
3435 MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProv ider.intType, []);
3436 classI1.methods = <MethodElement> [methodM1];
3437 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []);
3438 String methodName2 = "m2";
3439 MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProv ider.intType, []);
3440 classI2.methods = <MethodElement> [methodM2];
3441 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3442 classA.interfaces = <InterfaceType> [classI1.type, classI2.type];
3443 JUnitTestCase.assertSame(methodM1, _inheritanceManager.lookupInheritance(cla ssA, methodName1));
3444 JUnitTestCase.assertSame(methodM2, _inheritanceManager.lookupInheritance(cla ssA, methodName2));
3445 assertNoErrors(classI1);
3446 assertNoErrors(classI2);
3447 assertNoErrors(classA);
3448 }
3449 void test_lookupInheritance_interfaces_union2() {
3450 ClassElementImpl classI1 = ElementFactory.classElement2("I1", []);
3451 String methodName1 = "m1";
3452 MethodElement methodM1 = ElementFactory.methodElement(methodName1, _typeProv ider.intType, []);
3453 classI1.methods = <MethodElement> [methodM1];
3454 ClassElementImpl classI2 = ElementFactory.classElement2("I2", []);
3455 String methodName2 = "m2";
3456 MethodElement methodM2 = ElementFactory.methodElement(methodName2, _typeProv ider.intType, []);
3457 classI2.methods = <MethodElement> [methodM2];
3458 classI2.interfaces = <InterfaceType> [classI1.type];
3459 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3460 classA.interfaces = <InterfaceType> [classI2.type];
3461 JUnitTestCase.assertSame(methodM1, _inheritanceManager.lookupInheritance(cla ssA, methodName1));
3462 JUnitTestCase.assertSame(methodM2, _inheritanceManager.lookupInheritance(cla ssA, methodName2));
3463 assertNoErrors(classI1);
3464 assertNoErrors(classI2);
3465 assertNoErrors(classA);
3466 }
3467 void test_lookupInheritance_mixin_getter() {
3468 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3469 String getterName = "g";
3470 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
3471 classA.accessors = <PropertyAccessorElement> [getterG];
3472 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3473 classB.mixins = <InterfaceType> [classA.type];
3474 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas sB, getterName));
3475 assertNoErrors(classA);
3476 assertNoErrors(classB);
3477 }
3478 void test_lookupInheritance_mixin_method() {
3479 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3480 String methodName = "m";
3481 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3482 classA.methods = <MethodElement> [methodM];
3483 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3484 classB.mixins = <InterfaceType> [classA.type];
3485 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas sB, methodName));
3486 assertNoErrors(classA);
3487 assertNoErrors(classB);
3488 }
3489 void test_lookupInheritance_mixin_setter() {
3490 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3491 String setterName = "s";
3492 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, _typeProvider.intType);
3493 classA.accessors = <PropertyAccessorElement> [setterS];
3494 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3495 classB.mixins = <InterfaceType> [classA.type];
3496 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas sB, "${setterName}="));
3497 assertNoErrors(classA);
3498 assertNoErrors(classB);
3499 }
3500 void test_lookupInheritance_mixin_staticMember() {
3501 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3502 String methodName = "m";
3503 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3504 ((methodM as MethodElementImpl)).static = true;
3505 classA.methods = <MethodElement> [methodM];
3506 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3507 classB.mixins = <InterfaceType> [classA.type];
3508 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho dName));
3509 assertNoErrors(classA);
3510 assertNoErrors(classB);
3511 }
3512 void test_lookupInheritance_noMember() {
3513 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3514 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "a")) ;
3515 assertNoErrors(classA);
3516 }
3517 void test_lookupInheritance_superclass_getter() {
3518 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3519 String getterName = "g";
3520 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
3521 classA.accessors = <PropertyAccessorElement> [getterG];
3522 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
3523 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupInheritance(clas sB, getterName));
3524 assertNoErrors(classA);
3525 assertNoErrors(classB);
3526 }
3527 void test_lookupInheritance_superclass_infiniteLoop() {
3528 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3529 classA.supertype = classA.type;
3530 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name "));
3531 assertNoErrors(classA);
3532 }
3533 void test_lookupInheritance_superclass_infiniteLoop2() {
3534 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3535 ClassElementImpl classB = ElementFactory.classElement2("B", []);
3536 classA.supertype = classB.type;
3537 classB.supertype = classA.type;
3538 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classA, "name "));
3539 assertNoErrors(classA);
3540 assertNoErrors(classB);
3541 }
3542 void test_lookupInheritance_superclass_method() {
3543 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3544 String methodName = "m";
3545 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3546 classA.methods = <MethodElement> [methodM];
3547 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
3548 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupInheritance(clas sB, methodName));
3549 assertNoErrors(classA);
3550 assertNoErrors(classB);
3551 }
3552 void test_lookupInheritance_superclass_setter() {
3553 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3554 String setterName = "s";
3555 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, _typeProvider.intType);
3556 classA.accessors = <PropertyAccessorElement> [setterS];
3557 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
3558 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupInheritance(clas sB, "${setterName}="));
3559 assertNoErrors(classA);
3560 assertNoErrors(classB);
3561 }
3562 void test_lookupInheritance_superclass_staticMember() {
3563 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3564 String methodName = "m";
3565 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3566 ((methodM as MethodElementImpl)).static = true;
3567 classA.methods = <MethodElement> [methodM];
3568 ClassElementImpl classB = ElementFactory.classElement("B", classA.type, []);
3569 JUnitTestCase.assertNull(_inheritanceManager.lookupInheritance(classB, metho dName));
3570 assertNoErrors(classA);
3571 assertNoErrors(classB);
3572 }
3573 void test_lookupMember_getter() {
3574 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3575 String getterName = "g";
3576 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, f alse, _typeProvider.intType);
3577 classA.accessors = <PropertyAccessorElement> [getterG];
3578 JUnitTestCase.assertSame(getterG, _inheritanceManager.lookupMember(classA, g etterName));
3579 assertNoErrors(classA);
3580 }
3581 void test_lookupMember_getter_static() {
3582 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3583 String getterName = "g";
3584 PropertyAccessorElement getterG = ElementFactory.getterElement(getterName, t rue, _typeProvider.intType);
3585 classA.accessors = <PropertyAccessorElement> [getterG];
3586 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, getterName ));
3587 assertNoErrors(classA);
3588 }
3589 void test_lookupMember_method() {
3590 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3591 String methodName = "m";
3592 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3593 classA.methods = <MethodElement> [methodM];
3594 JUnitTestCase.assertSame(methodM, _inheritanceManager.lookupMember(classA, m ethodName));
3595 assertNoErrors(classA);
3596 }
3597 void test_lookupMember_method_static() {
3598 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3599 String methodName = "m";
3600 MethodElement methodM = ElementFactory.methodElement(methodName, _typeProvid er.intType, []);
3601 ((methodM as MethodElementImpl)).static = true;
3602 classA.methods = <MethodElement> [methodM];
3603 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, methodName ));
3604 assertNoErrors(classA);
3605 }
3606 void test_lookupMember_noMember() {
3607 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3608 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, "a"));
3609 assertNoErrors(classA);
3610 }
3611 void test_lookupMember_setter() {
3612 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3613 String setterName = "s";
3614 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, f alse, _typeProvider.intType);
3615 classA.accessors = <PropertyAccessorElement> [setterS];
3616 JUnitTestCase.assertSame(setterS, _inheritanceManager.lookupMember(classA, " ${setterName}="));
3617 assertNoErrors(classA);
3618 }
3619 void test_lookupMember_setter_static() {
3620 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3621 String setterName = "s";
3622 PropertyAccessorElement setterS = ElementFactory.setterElement(setterName, t rue, _typeProvider.intType);
3623 classA.accessors = <PropertyAccessorElement> [setterS];
3624 JUnitTestCase.assertNull(_inheritanceManager.lookupMember(classA, setterName ));
3625 assertNoErrors(classA);
3626 }
3627 void assertErrors(ClassElement classElt, List<ErrorCode> expectedErrorCodes) {
3628 GatheringErrorListener errorListener = new GatheringErrorListener();
3629 Set<AnalysisError> actualErrors = _inheritanceManager.getErrors(classElt);
3630 if (actualErrors != null) {
3631 for (AnalysisError error in actualErrors) {
3632 errorListener.onError(error);
3633 }
3634 }
3635 errorListener.assertErrors2(expectedErrorCodes);
3636 }
3637 void assertNoErrors(ClassElement classElt) {
3638 assertErrors(classElt, []);
3639 }
3640
3641 /**
3642 * Create the inheritance manager used by the tests.
3643 * @return the inheritance manager that was created
3644 */
3645 InheritanceManager createInheritanceManager() {
3646 AnalysisContextImpl context = AnalysisContextFactory.contextWithCore();
3647 FileBasedSource source = new FileBasedSource.con1(new ContentCache(), FileUt ilities2.createFile("/test.dart"));
3648 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart");
3649 definingCompilationUnit.source = source;
3650 _definingLibrary = ElementFactory.library(context, "test");
3651 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
3652 return new InheritanceManager(_definingLibrary);
3653 }
3654 static dartSuite() {
3655 _ut.group('InheritanceManagerTest', () {
3656 _ut.test('test_lookupInheritance_interface_getter', () {
3657 final __test = new InheritanceManagerTest();
3658 runJUnitTest(__test, __test.test_lookupInheritance_interface_getter);
3659 });
3660 _ut.test('test_lookupInheritance_interface_method', () {
3661 final __test = new InheritanceManagerTest();
3662 runJUnitTest(__test, __test.test_lookupInheritance_interface_method);
3663 });
3664 _ut.test('test_lookupInheritance_interface_setter', () {
3665 final __test = new InheritanceManagerTest();
3666 runJUnitTest(__test, __test.test_lookupInheritance_interface_setter);
3667 });
3668 _ut.test('test_lookupInheritance_interface_staticMember', () {
3669 final __test = new InheritanceManagerTest();
3670 runJUnitTest(__test, __test.test_lookupInheritance_interface_staticMembe r);
3671 });
3672 _ut.test('test_lookupInheritance_interfaces_STWC_inconsistentMethodInherit ance', () {
3673 final __test = new InheritanceManagerTest();
3674 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_STWC_incon sistentMethodInheritance);
3675 });
3676 _ut.test('test_lookupInheritance_interfaces_SWC_inconsistentMethodInherita nce', () {
3677 final __test = new InheritanceManagerTest();
3678 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_SWC_incons istentMethodInheritance);
3679 });
3680 _ut.test('test_lookupInheritance_interfaces_infiniteLoop', () {
3681 final __test = new InheritanceManagerTest();
3682 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_infiniteLo op);
3683 });
3684 _ut.test('test_lookupInheritance_interfaces_infiniteLoop2', () {
3685 final __test = new InheritanceManagerTest();
3686 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_infiniteLo op2);
3687 });
3688 _ut.test('test_lookupInheritance_interfaces_union1', () {
3689 final __test = new InheritanceManagerTest();
3690 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_union1);
3691 });
3692 _ut.test('test_lookupInheritance_interfaces_union2', () {
3693 final __test = new InheritanceManagerTest();
3694 runJUnitTest(__test, __test.test_lookupInheritance_interfaces_union2);
3695 });
3696 _ut.test('test_lookupInheritance_mixin_getter', () {
3697 final __test = new InheritanceManagerTest();
3698 runJUnitTest(__test, __test.test_lookupInheritance_mixin_getter);
3699 });
3700 _ut.test('test_lookupInheritance_mixin_method', () {
3701 final __test = new InheritanceManagerTest();
3702 runJUnitTest(__test, __test.test_lookupInheritance_mixin_method);
3703 });
3704 _ut.test('test_lookupInheritance_mixin_setter', () {
3705 final __test = new InheritanceManagerTest();
3706 runJUnitTest(__test, __test.test_lookupInheritance_mixin_setter);
3707 });
3708 _ut.test('test_lookupInheritance_mixin_staticMember', () {
3709 final __test = new InheritanceManagerTest();
3710 runJUnitTest(__test, __test.test_lookupInheritance_mixin_staticMember);
3711 });
3712 _ut.test('test_lookupInheritance_noMember', () {
3713 final __test = new InheritanceManagerTest();
3714 runJUnitTest(__test, __test.test_lookupInheritance_noMember);
3715 });
3716 _ut.test('test_lookupInheritance_superclass_getter', () {
3717 final __test = new InheritanceManagerTest();
3718 runJUnitTest(__test, __test.test_lookupInheritance_superclass_getter);
3719 });
3720 _ut.test('test_lookupInheritance_superclass_infiniteLoop', () {
3721 final __test = new InheritanceManagerTest();
3722 runJUnitTest(__test, __test.test_lookupInheritance_superclass_infiniteLo op);
3723 });
3724 _ut.test('test_lookupInheritance_superclass_infiniteLoop2', () {
3725 final __test = new InheritanceManagerTest();
3726 runJUnitTest(__test, __test.test_lookupInheritance_superclass_infiniteLo op2);
3727 });
3728 _ut.test('test_lookupInheritance_superclass_method', () {
3729 final __test = new InheritanceManagerTest();
3730 runJUnitTest(__test, __test.test_lookupInheritance_superclass_method);
3731 });
3732 _ut.test('test_lookupInheritance_superclass_setter', () {
3733 final __test = new InheritanceManagerTest();
3734 runJUnitTest(__test, __test.test_lookupInheritance_superclass_setter);
3735 });
3736 _ut.test('test_lookupInheritance_superclass_staticMember', () {
3737 final __test = new InheritanceManagerTest();
3738 runJUnitTest(__test, __test.test_lookupInheritance_superclass_staticMemb er);
3739 });
3740 _ut.test('test_lookupMember_getter', () {
3741 final __test = new InheritanceManagerTest();
3742 runJUnitTest(__test, __test.test_lookupMember_getter);
3743 });
3744 _ut.test('test_lookupMember_getter_static', () {
3745 final __test = new InheritanceManagerTest();
3746 runJUnitTest(__test, __test.test_lookupMember_getter_static);
3747 });
3748 _ut.test('test_lookupMember_method', () {
3749 final __test = new InheritanceManagerTest();
3750 runJUnitTest(__test, __test.test_lookupMember_method);
3751 });
3752 _ut.test('test_lookupMember_method_static', () {
3753 final __test = new InheritanceManagerTest();
3754 runJUnitTest(__test, __test.test_lookupMember_method_static);
3755 });
3756 _ut.test('test_lookupMember_noMember', () {
3757 final __test = new InheritanceManagerTest();
3758 runJUnitTest(__test, __test.test_lookupMember_noMember);
3759 });
3760 _ut.test('test_lookupMember_setter', () {
3761 final __test = new InheritanceManagerTest();
3762 runJUnitTest(__test, __test.test_lookupMember_setter);
3763 });
3764 _ut.test('test_lookupMember_setter_static', () {
3765 final __test = new InheritanceManagerTest();
3766 runJUnitTest(__test, __test.test_lookupMember_setter_static);
3767 });
3768 });
3769 }
3770 }
1953 class CompileTimeErrorCodeTest extends ResolverTestCase { 3771 class CompileTimeErrorCodeTest extends ResolverTestCase {
1954 void fail_ambiguousExport() {
1955 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"]));
1956 addSource2("/lib1.dart", EngineTestCase.createSource(["class N {}"]));
1957 addSource2("/lib2.dart", EngineTestCase.createSource(["class N {}"]));
1958 resolve(source, []);
1959 assertErrors([CompileTimeErrorCode.AMBIGUOUS_EXPORT]);
1960 verify([source]);
1961 }
1962 void fail_ambiguousImport_function() {
1963 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "import 'lib2.dart';", "g() { return f(); }"]));
1964 addSource2("/lib1.dart", EngineTestCase.createSource(["f() {}"]));
1965 addSource2("/lib2.dart", EngineTestCase.createSource(["f() {}"]));
1966 resolve(source, []);
1967 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
1968 verify([source]);
1969 }
1970 void fail_ambiguousImport_typeAnnotation() {
1971 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "import 'lib2.dart';", "class A extends N {}"]));
1972 addSource2("/lib1.dart", EngineTestCase.createSource(["class N {}"]));
1973 addSource2("/lib2.dart", EngineTestCase.createSource(["class N {}"]));
1974 resolve(source, []);
1975 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
1976 verify([source]);
1977 }
1978 void fail_compileTimeConstantRaisesException() { 3772 void fail_compileTimeConstantRaisesException() {
1979 Source source = addSource(EngineTestCase.createSource([])); 3773 Source source = addSource(EngineTestCase.createSource([]));
1980 resolve(source, []); 3774 resolve(source);
1981 assertErrors([CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]); 3775 assertErrors([CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION]);
1982 verify([source]); 3776 verify([source]);
1983 } 3777 }
1984 void fail_constWithNonConstantArgument() { 3778 void fail_constEvalThrowsException() {
1985 Source source = addSource(EngineTestCase.createSource(["class T {", " T(a) {};", "}", "f(p) { return const T(p); }"])); 3779 Source source = addSource(EngineTestCase.createSource(["class C {", " const C();", "}", "f() { return const C(); }"]));
1986 resolve(source, []); 3780 resolve(source);
1987 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]); 3781 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION]);
1988 verify([source]);
1989 }
1990 void fail_constWithNonType() {
1991 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", " return const A();", "}"]));
1992 resolve(source, []);
1993 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
1994 verify([source]);
1995 }
1996 void fail_constWithTypeParameters() {
1997 Source source = addSource(EngineTestCase.createSource([]));
1998 resolve(source, []);
1999 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]);
2000 verify([source]);
2001 }
2002 void fail_constWithUndefinedConstructor() {
2003 Source source = addSource(EngineTestCase.createSource(["class A {", " A(x) {}", "}", "f() {", " return const A(0);", "}"]));
2004 resolve(source, []);
2005 assertErrors([CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
2006 verify([source]); 3782 verify([source]);
2007 } 3783 }
2008 void fail_duplicateDefinition() { 3784 void fail_duplicateDefinition() {
2009 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0 ;", " m(a) {}", "}"])); 3785 Source source = addSource(EngineTestCase.createSource(["f() {", " int m = 0 ;", " m(a) {}", "}"]));
2010 resolve(source, []); 3786 resolve(source);
2011 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]); 3787 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
2012 verify([source]); 3788 verify([source]);
2013 } 3789 }
2014 void fail_duplicateMemberError_classMembers_fields() { 3790 void fail_duplicateMemberError_classMembers_fields() {
2015 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " int a;", " int a;", "}"])); 3791 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " int a;", " int a;", "}"]));
2016 resolve(librarySource, []); 3792 resolve(librarySource);
2017 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]); 3793 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
2018 verify([librarySource]); 3794 verify([librarySource]);
2019 } 3795 }
2020 void fail_duplicateMemberError_classMembers_methods() { 3796 void fail_duplicateMemberError_localFields() {
2021 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {}", " m() {}", "}"])); 3797 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {", " int a;", " int a;", " }", "}"]));
2022 resolve(librarySource, []); 3798 resolve(librarySource);
2023 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]); 3799 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
2024 verify([librarySource]); 3800 verify([librarySource]);
2025 } 3801 }
2026 void fail_duplicateMemberError_localFields() {
2027 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {", " int a;", " int a;", " }", "}"]));
2028 resolve(librarySource, []);
2029 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
2030 verify([librarySource]);
2031 }
2032 void fail_duplicateMemberName() { 3802 void fail_duplicateMemberName() {
2033 Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 0;", " int x() {}", "}"])); 3803 Source source = addSource(EngineTestCase.createSource(["class A {", " int x = 0;", " int x() {}", "}"]));
2034 resolve(source, []); 3804 resolve(source);
2035 assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME]); 3805 assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME]);
2036 verify([source]); 3806 verify([source]);
2037 } 3807 }
2038 void fail_duplicateMemberNameInstanceStatic() { 3808 void fail_duplicateMemberNameInstanceStatic() {
2039 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " static int x;", "}"])); 3809 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " static int x;", "}"]));
2040 resolve(source, []); 3810 resolve(source);
2041 assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME_INSTANCE_STATIC]); 3811 assertErrors([CompileTimeErrorCode.DUPLICATE_MEMBER_NAME_INSTANCE_STATIC]);
2042 verify([source]); 3812 verify([source]);
2043 } 3813 }
2044 void fail_duplicateNamedArgument() {
2045 Source source = addSource(EngineTestCase.createSource(["f({a, a}) {}"]));
2046 resolve(source, []);
2047 assertErrors([CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]);
2048 verify([source]);
2049 }
2050 void fail_extendsOrImplementsDisallowedClass_extends_null() { 3814 void fail_extendsOrImplementsDisallowedClass_extends_null() {
2051 Source source = addSource(EngineTestCase.createSource(["class A extends Null {}"])); 3815 Source source = addSource(EngineTestCase.createSource(["class A extends Null {}"]));
2052 resolve(source, []); 3816 resolve(source);
2053 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 3817 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
2054 verify([source]); 3818 verify([source]);
2055 } 3819 }
2056 void fail_extendsOrImplementsDisallowedClass_implements_null() { 3820 void fail_extendsOrImplementsDisallowedClass_implements_null() {
2057 Source source = addSource(EngineTestCase.createSource(["class A implements N ull {}"])); 3821 Source source = addSource(EngineTestCase.createSource(["class A implements N ull {}"]));
2058 resolve(source, []); 3822 resolve(source);
2059 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 3823 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2060 verify([source]); 3824 verify([source]);
2061 } 3825 }
2062 void fail_finalNotInitialized_inConstructor() { 3826 void fail_finalNotInitialized_inConstructor() {
2063 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() {}", "}"])); 3827 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " A() {}", "}"]));
2064 resolve(source, []); 3828 resolve(source);
2065 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 3829 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2066 verify([source]); 3830 verify([source]);
2067 } 3831 }
2068 void fail_getterAndMethodWithSameName() {
2069 Source source = addSource(EngineTestCase.createSource(["class A {", " get x -> 0;", " x(y) {}", "}"]));
2070 resolve(source, []);
2071 assertErrors([CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]);
2072 verify([source]);
2073 }
2074 void fail_importDuplicatedLibraryName() {
2075 Source source = addSource(EngineTestCase.createSource(["library test;", "imp ort 'lib1.dart';", "import 'lib2.dart';"]));
2076 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib;"]));
2077 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib;"]));
2078 resolve(source, []);
2079 assertErrors([CompileTimeErrorCode.IMPORT_DUPLICATED_LIBRARY_NAME]);
2080 verify([source]);
2081 }
2082 void fail_invalidConstructorName() {
2083 Source source = addSource(EngineTestCase.createSource([]));
2084 resolve(source, []);
2085 assertErrors([CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
2086 verify([source]);
2087 }
2088 void fail_invalidFactoryNameNotAClass() {
2089 Source source = addSource(EngineTestCase.createSource([]));
2090 resolve(source, []);
2091 assertErrors([CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
2092 verify([source]);
2093 }
2094 void fail_invalidOverrideDefaultValue() { 3832 void fail_invalidOverrideDefaultValue() {
2095 Source source = addSource(EngineTestCase.createSource(["class A {", " m([a = 0]) {}", "}", "class B extends A {", " m([a = 1]) {}", "}"])); 3833 Source source = addSource(EngineTestCase.createSource(["class A {", " m([a = 0]) {}", "}", "class B extends A {", " m([a = 1]) {}", "}"]));
2096 resolve(source, []); 3834 resolve(source);
2097 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_DEFAULT_VALUE]); 3835 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_DEFAULT_VALUE]);
2098 verify([source]); 3836 verify([source]);
2099 } 3837 }
2100 void fail_invalidOverrideNamed() {
2101 Source source = addSource(EngineTestCase.createSource(["class A {", " m({a, b}) {}", "}", "class B extends A {", " m({a}) {}", "}"]));
2102 resolve(source, []);
2103 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_NAMED]);
2104 verify([source]);
2105 }
2106 void fail_invalidOverridePositional() {
2107 Source source = addSource(EngineTestCase.createSource(["class A {", " m([a, b]) {}", "}", "class B extends A {", " m([a]) {}", "}"]));
2108 resolve(source, []);
2109 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_POSITIONAL]);
2110 verify([source]);
2111 }
2112 void fail_invalidOverrideRequired() {
2113 Source source = addSource(EngineTestCase.createSource(["class A {", " m(a) {}", "}", "class B extends A {", " m(a, b) {}", "}"]));
2114 resolve(source, []);
2115 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_REQUIRED]);
2116 verify([source]);
2117 }
2118 void fail_invalidReferenceToThis_staticMethod() {
2119 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c m() { return this; }", "}"]));
2120 resolve(source, []);
2121 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
2122 verify([source]);
2123 }
2124 void fail_invalidReferenceToThis_topLevelFunction() {
2125 Source source = addSource(EngineTestCase.createSource(["f() { return this; } "]));
2126 resolve(source, []);
2127 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
2128 verify([source]);
2129 }
2130 void fail_invalidReferenceToThis_variableInitializer() {
2131 Source source = addSource(EngineTestCase.createSource(["int x = this;"]));
2132 resolve(source, []);
2133 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
2134 verify([source]);
2135 }
2136 void fail_memberWithClassName() {
2137 Source source = addSource(EngineTestCase.createSource(["class A {", " int A = 0;", "}"]));
2138 resolve(source, []);
2139 assertErrors([CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
2140 verify([source]);
2141 }
2142 void fail_mixinDeclaresConstructor() { 3838 void fail_mixinDeclaresConstructor() {
2143 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends Object mixin A {}"])); 3839 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends Object mixin A {}"]));
2144 resolve(source, []); 3840 resolve(source);
2145 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); 3841 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
2146 verify([source]); 3842 verify([source]);
2147 } 3843 }
2148 void fail_mixinInheritsFromNotObject() {
2149 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class C extends Object mixin B {}"]));
2150 resolve(source, []);
2151 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
2152 verify([source]);
2153 }
2154 void fail_mixinOfNonClass() { 3844 void fail_mixinOfNonClass() {
2155 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex tends Object mixin A {}"])); 3845 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex tends Object mixin A {}"]));
2156 resolve(source, []); 3846 resolve(source);
2157 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); 3847 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
2158 verify([source]); 3848 verify([source]);
2159 } 3849 }
2160 void fail_mixinOfNonMixin() {
2161 Source source = addSource(EngineTestCase.createSource([]));
2162 resolve(source, []);
2163 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_MIXIN]);
2164 verify([source]);
2165 }
2166 void fail_mixinReferencesSuper() {
2167 Source source = addSource(EngineTestCase.createSource(["class A {", " toStr ing() -> super.toString();", "}", "class B extends Object mixin A {}"]));
2168 resolve(source, []);
2169 assertErrors([CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]);
2170 verify([source]);
2171 }
2172 void fail_mixinWithNonClassSuperclass() {
2173 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends Object mixin A {}"]));
2174 resolve(source, []);
2175 assertErrors([CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]);
2176 verify([source]);
2177 }
2178 void fail_multipleSuperInitializers() {
2179 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B() : super(), super() {}", "}"]));
2180 resolve(source, []);
2181 assertErrors([CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]);
2182 verify([source]);
2183 }
2184 void fail_nonConstantDefaultValue_named() { 3850 void fail_nonConstantDefaultValue_named() {
2185 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"]) ); 3851 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"]) );
2186 resolve(source, []); 3852 resolve(source);
2187 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 3853 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
2188 verify([source]); 3854 verify([source]);
2189 } 3855 }
2190 void fail_nonConstantDefaultValue_positional() { 3856 void fail_nonConstantDefaultValue_positional() {
2191 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"]) ); 3857 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"]) );
2192 resolve(source, []); 3858 resolve(source);
2193 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 3859 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
2194 verify([source]); 3860 verify([source]);
2195 } 3861 }
2196 void fail_nonConstMapAsExpressionStatement() {
2197 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0, 'b' : 1};", "}"]));
2198 resolve(source, []);
2199 assertErrors([CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]);
2200 verify([source]);
2201 }
2202 void fail_nonConstMapKey() {
2203 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst {a : 0};", "}"]));
2204 resolve(source, []);
2205 assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
2206 verify([source]);
2207 }
2208 void fail_nonConstValueInInitializer() {
2209 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c C;", " int a;", " A() : a = C {}", "}"]));
2210 resolve(source, []);
2211 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
2212 verify([source]);
2213 }
2214 void fail_objectCannotExtendAnotherClass() { 3862 void fail_objectCannotExtendAnotherClass() {
2215 Source source = addSource(EngineTestCase.createSource([])); 3863 Source source = addSource(EngineTestCase.createSource([]));
2216 resolve(source, []); 3864 resolve(source);
2217 assertErrors([CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]); 3865 assertErrors([CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]);
2218 verify([source]); 3866 verify([source]);
2219 } 3867 }
2220 void fail_overrideMissingNamedParameters() {
2221 Source source = addSource(EngineTestCase.createSource(["class A {", " m(a, {b}) {}", "}", "class B extends A {", " m(a) {}", "}"]));
2222 resolve(source, []);
2223 assertErrors([CompileTimeErrorCode.OVERRIDE_MISSING_NAMED_PARAMETERS]);
2224 verify([source]);
2225 }
2226 void fail_overrideMissingRequiredParameters() {
2227 Source source = addSource(EngineTestCase.createSource(["class A {", " m(a) {}", "}", "class B extends A {", " m(a, b) {}", "}"]));
2228 resolve(source, []);
2229 assertErrors([CompileTimeErrorCode.OVERRIDE_MISSING_REQUIRED_PARAMETERS]);
2230 verify([source]);
2231 }
2232 void fail_prefixCollidesWithTopLevelMembers() {
2233 Source source = addSource(EngineTestCase.createSource(["import 'dart:uft' as utf;", "var utf = null;"]));
2234 resolve(source, []);
2235 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
2236 verify([source]);
2237 }
2238 void fail_recursiveCompileTimeConstant() { 3868 void fail_recursiveCompileTimeConstant() {
2239 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", " const y = x + 1;"])); 3869 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", " const y = x + 1;"]));
2240 resolve(source, []); 3870 resolve(source);
2241 assertErrors([CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]); 3871 assertErrors([CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
2242 verify([source]); 3872 verify([source]);
2243 } 3873 }
2244 void fail_recursiveFactoryRedirect() {
2245 Source source = addSource(EngineTestCase.createSource([]));
2246 resolve(source, []);
2247 assertErrors([CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]);
2248 verify([source]);
2249 }
2250 void fail_recursiveFunctionTypeAlias_direct() { 3874 void fail_recursiveFunctionTypeAlias_direct() {
2251 Source source = addSource(EngineTestCase.createSource(["typedef F(F f);"])); 3875 Source source = addSource(EngineTestCase.createSource(["typedef F(F f);"]));
2252 resolve(source, []); 3876 resolve(source);
2253 assertErrors([CompileTimeErrorCode.RECURSIVE_FUNCTION_TYPE_ALIAS]); 3877 assertErrors([CompileTimeErrorCode.RECURSIVE_FUNCTION_TYPE_ALIAS]);
2254 verify([source]); 3878 verify([source]);
2255 } 3879 }
2256 void fail_recursiveFunctionTypeAlias_indirect() { 3880 void fail_recursiveFunctionTypeAlias_indirect() {
2257 Source source = addSource(EngineTestCase.createSource(["typedef F(G g);", "t ypedef G(F f);"])); 3881 Source source = addSource(EngineTestCase.createSource(["typedef F(G g);", "t ypedef G(F f);"]));
2258 resolve(source, []); 3882 resolve(source);
2259 assertErrors([CompileTimeErrorCode.RECURSIVE_FUNCTION_TYPE_ALIAS]); 3883 assertErrors([CompileTimeErrorCode.RECURSIVE_FUNCTION_TYPE_ALIAS]);
2260 verify([source]); 3884 verify([source]);
2261 } 3885 }
2262 void fail_recursiveInterfaceInheritance_direct() {
2263 Source source = addSource(EngineTestCase.createSource(["class A implements A {}"]));
2264 resolve(source, []);
2265 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
2266 verify([source]);
2267 }
2268 void fail_recursiveInterfaceInheritance_indirect() {
2269 Source source = addSource(EngineTestCase.createSource(["class A implements B {}", "class B implements A {}"]));
2270 resolve(source, []);
2271 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
2272 verify([source]);
2273 }
2274 void fail_redirectToNonConstConstructor() {
2275 Source source = addSource(EngineTestCase.createSource([]));
2276 resolve(source, []);
2277 assertErrors([CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR]);
2278 verify([source]);
2279 }
2280 void fail_referenceToDeclaredVariableInInitializer_getter() {
2281 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x + 1;", "}"]));
2282 resolve(source, []);
2283 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL IZER]);
2284 verify([source]);
2285 }
2286 void fail_referenceToDeclaredVariableInInitializer_setter() {
2287 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x ++;", "}"]));
2288 resolve(source, []);
2289 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL IZER]);
2290 verify([source]);
2291 }
2292 void fail_reservedWordAsIdentifier() { 3886 void fail_reservedWordAsIdentifier() {
2293 Source source = addSource(EngineTestCase.createSource(["int class = 2;"])); 3887 Source source = addSource(EngineTestCase.createSource(["int class = 2;"]));
2294 resolve(source, []); 3888 resolve(source);
2295 assertErrors([CompileTimeErrorCode.RESERVED_WORD_AS_IDENTIFIER]); 3889 assertErrors([CompileTimeErrorCode.RESERVED_WORD_AS_IDENTIFIER]);
2296 verify([source]); 3890 verify([source]);
2297 } 3891 }
2298 void fail_staticTopLevelFunction_topLevel() { 3892 void fail_staticTopLevelFunction_topLevel() {
2299 Source source = addSource(EngineTestCase.createSource(["static f() {}"])); 3893 Source source = addSource(EngineTestCase.createSource(["static f() {}"]));
2300 resolve(source, []); 3894 resolve(source);
2301 assertErrors([CompileTimeErrorCode.STATIC_TOP_LEVEL_FUNCTION]); 3895 assertErrors([CompileTimeErrorCode.STATIC_TOP_LEVEL_FUNCTION]);
2302 verify([source]); 3896 verify([source]);
2303 } 3897 }
2304 void fail_staticTopLevelVariable() { 3898 void fail_staticTopLevelVariable() {
2305 Source source = addSource(EngineTestCase.createSource(["static int x;"])); 3899 Source source = addSource(EngineTestCase.createSource(["static int x;"]));
2306 resolve(source, []); 3900 resolve(source);
2307 assertErrors([CompileTimeErrorCode.STATIC_TOP_LEVEL_VARIABLE]); 3901 assertErrors([CompileTimeErrorCode.STATIC_TOP_LEVEL_VARIABLE]);
2308 verify([source]); 3902 verify([source]);
2309 } 3903 }
2310 void fail_superInInvalidContext_factoryConstructor() {
2311 Source source = addSource(EngineTestCase.createSource([]));
2312 resolve(source, []);
2313 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
2314 verify([source]);
2315 }
2316 void fail_superInInvalidContext_instanceVariableInitializer() {
2317 Source source = addSource(EngineTestCase.createSource(["class A {", " var a ;", "}", "class B extends A {", " var b = super.a;", "}"]));
2318 resolve(source, []);
2319 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
2320 verify([source]);
2321 }
2322 void fail_superInInvalidContext_staticMethod() {
2323 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c m() {}", "}", "class B extends A {", " static n() { return super.m(); }", "}" ]));
2324 resolve(source, []);
2325 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
2326 verify([source]);
2327 }
2328 void fail_superInInvalidContext_staticVariableInitializer() {
2329 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c a = 0;", "}", "class B extends A {", " static b = super.a;", "}"]));
2330 resolve(source, []);
2331 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
2332 verify([source]);
2333 }
2334 void fail_superInInvalidContext_topLevelFunction() {
2335 Source source = addSource(EngineTestCase.createSource(["f() {", " super.f() ;", "}"]));
2336 resolve(source, []);
2337 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
2338 verify([source]);
2339 }
2340 void fail_superInInvalidContext_variableInitializer() {
2341 Source source = addSource(EngineTestCase.createSource(["var v = super.v;"])) ;
2342 resolve(source, []);
2343 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
2344 verify([source]);
2345 }
2346 void fail_superInitializerInObject() { 3904 void fail_superInitializerInObject() {
2347 Source source = addSource(EngineTestCase.createSource([])); 3905 Source source = addSource(EngineTestCase.createSource([]));
2348 resolve(source, []); 3906 resolve(source);
2349 assertErrors([CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]); 3907 assertErrors([CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]);
2350 verify([source]); 3908 verify([source]);
2351 } 3909 }
2352 void fail_typeArgumentsForNonGenericClass_creation_const() { 3910 void fail_typeArgumentsForNonGenericClass_creation_const() {
2353 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) { ", " return const A<int>();", "}"])); 3911 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) { ", " return const A<int>();", "}"]));
2354 resolve(source, []); 3912 resolve(source);
2355 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]); 3913 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]);
2356 verify([source]); 3914 verify([source]);
2357 } 3915 }
2358 void fail_typeArgumentsForNonGenericClass_creation_new() { 3916 void fail_typeArgumentsForNonGenericClass_creation_new() {
2359 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) { ", " return new A<int>();", "}"])); 3917 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) { ", " return new A<int>();", "}"]));
2360 resolve(source, []); 3918 resolve(source);
2361 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]); 3919 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]);
2362 verify([source]); 3920 verify([source]);
2363 } 3921 }
2364 void fail_typeArgumentsForNonGenericClass_typeCast() { 3922 void fail_typeArgumentsForNonGenericClass_typeCast() {
2365 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) { ", " return p as A<int>;", "}"])); 3923 Source source = addSource(EngineTestCase.createSource(["class A {}", "f(p) { ", " return p as A<int>;", "}"]));
2366 resolve(source, []); 3924 resolve(source);
2367 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]); 3925 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]);
2368 verify([source]); 3926 verify([source]);
2369 } 3927 }
2370 void fail_undefinedConstructorInInitializer() {
2371 Source source = addSource(EngineTestCase.createSource([]));
2372 resolve(source, []);
2373 assertErrors([CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
2374 verify([source]);
2375 }
2376 void fail_uninitializedFinalField() { 3928 void fail_uninitializedFinalField() {
2377 Source source = addSource(EngineTestCase.createSource(["class A {", " final int i;", "}"])); 3929 Source source = addSource(EngineTestCase.createSource(["class A {", " final int i;", "}"]));
2378 resolve(source, []); 3930 resolve(source);
2379 assertErrors([CompileTimeErrorCode.UNINITIALIZED_FINAL_FIELD]); 3931 assertErrors([CompileTimeErrorCode.UNINITIALIZED_FINAL_FIELD]);
2380 verify([source]); 3932 verify([source]);
2381 } 3933 }
2382 void fail_wrongNumberOfParametersForOperator() {
2383 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor []=(i) {}", "}"]));
2384 resolve(source, []);
2385 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]) ;
2386 verify([source]);
2387 }
2388 void fail_wrongNumberOfTypeArguments_creation_const_tooFew() { 3934 void fail_wrongNumberOfTypeArguments_creation_const_tooFew() {
2389 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return const C<A>();", "}"])); 3935 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return const C<A>();", "}"]));
2390 resolve(source, []); 3936 resolve(source);
2391 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 3937 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
2392 verify([source]); 3938 verify([source]);
2393 } 3939 }
2394 void fail_wrongNumberOfTypeArguments_creation_const_tooMany() { 3940 void fail_wrongNumberOfTypeArguments_creation_const_tooMany() {
2395 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return const C<A, A>();", "}"])); 3941 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return const C<A, A>();", "}"]));
2396 resolve(source, []); 3942 resolve(source);
2397 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 3943 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
2398 verify([source]); 3944 verify([source]);
2399 } 3945 }
2400 void fail_wrongNumberOfTypeArguments_creation_new_tooFew() { 3946 void fail_wrongNumberOfTypeArguments_creation_new_tooFew() {
2401 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return new C<A>();", "}"])); 3947 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return new C<A>();", "}"]));
2402 resolve(source, []); 3948 resolve(source);
2403 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 3949 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
2404 verify([source]); 3950 verify([source]);
2405 } 3951 }
2406 void fail_wrongNumberOfTypeArguments_creation_new_tooMany() { 3952 void fail_wrongNumberOfTypeArguments_creation_new_tooMany() {
2407 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return new C<A, A>();", "}"])); 3953 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return new C<A, A>();", "}"]));
2408 resolve(source, []); 3954 resolve(source);
2409 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 3955 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
2410 verify([source]); 3956 verify([source]);
2411 } 3957 }
2412 void fail_wrongNumberOfTypeArguments_typeTest_tooFew() { 3958 void fail_wrongNumberOfTypeArguments_typeTest_tooFew() {
2413 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return p is C<A>;", "}"])); 3959 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<K, V> {}", "f(p) {", " return p is C<A>;", "}"]));
2414 resolve(source, []); 3960 resolve(source);
2415 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 3961 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
2416 verify([source]); 3962 verify([source]);
2417 } 3963 }
2418 void fail_wrongNumberOfTypeArguments_typeTest_tooMany() { 3964 void fail_wrongNumberOfTypeArguments_typeTest_tooMany() {
2419 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return p is C<A, A>;", "}"])); 3965 Source source = addSource(EngineTestCase.createSource(["class A {}", "class C<E> {}", "f(p) {", " return p is C<A, A>;", "}"]));
2420 resolve(source, []); 3966 resolve(source);
2421 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]); 3967 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
2422 verify([source]); 3968 verify([source]);
2423 } 3969 }
3970 void test_ambiguousExport() {
3971 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';", "export 'lib2.dart';"]));
3972 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
3973 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
3974 resolve(source);
3975 assertErrors([CompileTimeErrorCode.AMBIGUOUS_EXPORT]);
3976 verify([source]);
3977 }
3978 void test_ambiguousImport_as() {
3979 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "f(p) {p as N;}"]));
3980 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
3981 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
3982 resolve(source);
3983 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
3984 }
3985 void test_ambiguousImport_extends() {
3986 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "class A extends N {}"]));
3987 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
3988 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
3989 resolve(source);
3990 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT, CompileTimeErrorCode.EX TENDS_NON_CLASS]);
3991 }
3992 void test_ambiguousImport_function() {
3993 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "g() { return f(); }"]));
3994 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "f() {}"]));
3995 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "f() {}"]));
3996 resolve(source);
3997 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT, StaticTypeWarningCode.U NDEFINED_FUNCTION]);
3998 }
3999 void test_ambiguousImport_implements() {
4000 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "class A implements N {}"]));
4001 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
4002 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
4003 resolve(source);
4004 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT, CompileTimeErrorCode.IM PLEMENTS_NON_CLASS]);
4005 }
4006 void test_ambiguousImport_instanceCreation() {
4007 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'lib1.dart';", "import 'lib2.dart';", "f() {new N();}"]));
4008 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
4009 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
4010 resolve(source);
4011 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
4012 }
4013 void test_ambiguousImport_is() {
4014 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "f(p) {p is N;}"]));
4015 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
4016 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
4017 resolve(source);
4018 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
4019 }
4020 void test_ambiguousImport_qualifier() {
4021 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "g() { N.FOO; }"]));
4022 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
4023 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
4024 resolve(source);
4025 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
4026 }
4027 void test_ambiguousImport_typeArgument_instanceCreation() {
4028 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "class A<T> {}", "f() {new A<N>();}"]));
4029 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
4030 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
4031 resolve(source);
4032 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
4033 }
4034 void test_ambiguousImport_varRead() {
4035 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "f() { g(v); }", "g(p) {}"]));
4036 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var v;"]));
4037 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var v;"]));
4038 resolve(source);
4039 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
4040 }
4041 void test_ambiguousImport_varWrite() {
4042 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "f() { v = 0; }"]));
4043 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "var v;"]));
4044 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "var v;"]));
4045 resolve(source);
4046 assertErrors([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
4047 }
2424 void test_argumentDefinitionTestNonParameter() { 4048 void test_argumentDefinitionTestNonParameter() {
2425 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0; ", " return ?v;", "}"])); 4049 Source source = addSource(EngineTestCase.createSource(["f() {", " var v = 0; ", " return ?v;", "}"]));
2426 resolve(source, []); 4050 resolve(source);
2427 assertErrors([CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER]); 4051 assertErrors([CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER]);
2428 verify([source]); 4052 verify([source]);
2429 } 4053 }
2430 void test_builtInIdentifierAsType() { 4054 void test_builtInIdentifierAsType() {
2431 Source source = addSource(EngineTestCase.createSource(["f() {", " typedef x ;", "}"])); 4055 Source source = addSource(EngineTestCase.createSource(["f() {", " typedef x ;", "}"]));
2432 resolve(source, []); 4056 resolve(source);
2433 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, StaticWarnin gCode.UNDEFINED_CLASS]); 4057 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, StaticWarnin gCode.UNDEFINED_CLASS]);
2434 verify([source]); 4058 verify([source]);
2435 } 4059 }
2436 void test_builtInIdentifierAsTypedefName_classTypeAlias() { 4060 void test_builtInIdentifierAsTypedefName_classTypeAlias() {
2437 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "typedef as = A with B;"])); 4061 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {}", "typedef as = A with B;"]));
2438 resolve(source, []); 4062 resolve(source);
2439 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]); 4063 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
2440 verify([source]); 4064 verify([source]);
2441 } 4065 }
2442 void test_builtInIdentifierAsTypedefName_functionTypeAlias() { 4066 void test_builtInIdentifierAsTypedefName_functionTypeAlias() {
2443 Source source = addSource(EngineTestCase.createSource(["typedef bool as();"] )); 4067 Source source = addSource(EngineTestCase.createSource(["typedef bool as();"] ));
2444 resolve(source, []); 4068 resolve(source);
2445 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]); 4069 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME]);
2446 verify([source]); 4070 verify([source]);
2447 } 4071 }
2448 void test_builtInIdentifierAsTypeName() { 4072 void test_builtInIdentifierAsTypeName() {
2449 Source source = addSource(EngineTestCase.createSource(["class as {}"])); 4073 Source source = addSource(EngineTestCase.createSource(["class as {}"]));
2450 resolve(source, []); 4074 resolve(source);
2451 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]); 4075 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME]);
2452 verify([source]); 4076 verify([source]);
2453 } 4077 }
2454 void test_builtInIdentifierAsTypeVariableName() { 4078 void test_builtInIdentifierAsTypeVariableName() {
2455 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"])); 4079 Source source = addSource(EngineTestCase.createSource(["class A<as> {}"]));
2456 resolve(source, []); 4080 resolve(source);
2457 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME ]); 4081 assertErrors([CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME ]);
2458 verify([source]); 4082 verify([source]);
2459 } 4083 }
2460 void test_caseExpressionTypeImplementsEquals() { 4084 void test_caseExpressionTypeImplementsEquals() {
2461 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;", " }", "}"])); 4085 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;", " }", "}"]));
2462 resolve(source, []); 4086 resolve(source);
2463 assertErrors([CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]); 4087 assertErrors([CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS]);
2464 verify([source]); 4088 verify([source]);
2465 } 4089 }
2466 void test_conflictingConstructorNameAndMember_field() { 4090 void test_conflictingConstructorNameAndMember_field() {
2467 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.x() {}", "}"])); 4091 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.x() {}", "}"]));
2468 resolve(source, []); 4092 resolve(source);
2469 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]); 4093 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD]);
2470 verify([source]); 4094 verify([source]);
2471 } 4095 }
2472 void test_conflictingConstructorNameAndMember_method() { 4096 void test_conflictingConstructorNameAndMember_method() {
2473 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.x() {}", " void x() {}", "}"])); 4097 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.x();", " void x() {}", "}"]));
2474 resolve(source, []); 4098 resolve(source);
2475 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]) ; 4099 assertErrors([CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD]) ;
2476 verify([source]); 4100 verify([source]);
2477 } 4101 }
2478 void test_constConstructorWithNonFinalField() { 4102 void test_constConstructorWithNonFinalField_mixin() {
2479 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " const A() {}", "}"])); 4103 Source source = addSource(EngineTestCase.createSource(["class A {", " var a ;", "}", "class B extends Object with A {", " const B();", "}"]));
2480 resolve(source, []); 4104 resolve(source);
2481 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); 4105 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
2482 verify([source]); 4106 verify([source]);
2483 } 4107 }
2484 void test_constEvalThrowsException() { 4108 void test_constConstructorWithNonFinalField_super() {
2485 Source source = addSource(EngineTestCase.createSource(["class C {", " const C() { throw null; }", "}", "f() { return const C(); }"])); 4109 Source source = addSource(EngineTestCase.createSource(["class A {", " var a ;", "}", "class B extends A {", " const B();", "}"]));
2486 resolve(source, []); 4110 resolve(source);
4111 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
4112 verify([source]);
4113 }
4114 void test_constConstructorWithNonFinalField_this() {
4115 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " const A();", "}"]));
4116 resolve(source);
4117 assertErrors([CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
4118 verify([source]);
4119 }
4120 void test_constEvalThrowsException_binaryMinus_null() {
4121 check_constEvalThrowsException_binary_null("null - 5", false);
4122 check_constEvalThrowsException_binary_null("5 - null", true);
4123 }
4124 void test_constEvalThrowsException_binaryPlus_null() {
4125 check_constEvalThrowsException_binary_null("null + 5", false);
4126 check_constEvalThrowsException_binary_null("5 + null", true);
4127 }
4128 void test_constEvalThrowsException_unaryBitNot_null() {
4129 Source source = addSource("const C = ~null;");
4130 resolve(source);
4131 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, StaticTypeWa rningCode.UNDEFINED_OPERATOR]);
4132 }
4133 void test_constEvalThrowsException_unaryNegated_null() {
4134 Source source = addSource("const C = -null;");
4135 resolve(source);
4136 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, StaticTypeWa rningCode.UNDEFINED_OPERATOR]);
4137 }
4138 void test_constEvalThrowsException_unaryNot_null() {
4139 Source source = addSource("const C = !null;");
4140 resolve(source);
2487 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]); 4141 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
2488 verify([source]); 4142 verify([source]);
2489 } 4143 }
4144 void test_constEvalTypeBool_binary() {
4145 check_constEvalTypeBool_withParameter_binary("p && ''");
4146 check_constEvalTypeBool_withParameter_binary("p || ''");
4147 }
4148 void test_constEvalTypeBoolNumString_equal() {
4149 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final a;", " const B(num p) : a = p == const A();" , "}"]));
4150 resolve(source);
4151 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]);
4152 verify([source]);
4153 }
4154 void test_constEvalTypeBoolNumString_notEqual() {
4155 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "class B {", " final a;", " const B(String p) : a = p != const A( );", "}"]));
4156 resolve(source);
4157 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING]);
4158 verify([source]);
4159 }
4160 void test_constEvalTypeInt_binary() {
4161 check_constEvalTypeInt_withParameter_binary("p ^ ''");
4162 check_constEvalTypeInt_withParameter_binary("p & ''");
4163 check_constEvalTypeInt_withParameter_binary("p | ''");
4164 check_constEvalTypeInt_withParameter_binary("p >> ''");
4165 check_constEvalTypeInt_withParameter_binary("p << ''");
4166 }
4167 void test_constEvalTypeNum_binary() {
4168 check_constEvalTypeNum_withParameter_binary("p + ''");
4169 check_constEvalTypeNum_withParameter_binary("p - ''");
4170 check_constEvalTypeNum_withParameter_binary("p * ''");
4171 check_constEvalTypeNum_withParameter_binary("p / ''");
4172 check_constEvalTypeNum_withParameter_binary("p ~/ ''");
4173 check_constEvalTypeNum_withParameter_binary("p > ''");
4174 check_constEvalTypeNum_withParameter_binary("p < ''");
4175 check_constEvalTypeNum_withParameter_binary("p >= ''");
4176 check_constEvalTypeNum_withParameter_binary("p <= ''");
4177 check_constEvalTypeNum_withParameter_binary("p % ''");
4178 }
2490 void test_constFormalParameter_fieldFormalParameter() { 4179 void test_constFormalParameter_fieldFormalParameter() {
2491 Source source = addSource(EngineTestCase.createSource(["class A {", " var x ;", " A(const this.x) {}", "}"])); 4180 Source source = addSource(EngineTestCase.createSource(["class A {", " var x ;", " A(const this.x) {}", "}"]));
2492 resolve(source, []); 4181 resolve(source);
2493 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); 4182 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
2494 verify([source]); 4183 verify([source]);
2495 } 4184 }
2496 void test_constFormalParameter_simpleFormalParameter() { 4185 void test_constFormalParameter_simpleFormalParameter() {
2497 Source source = addSource(EngineTestCase.createSource(["f(const x) {}"])); 4186 Source source = addSource(EngineTestCase.createSource(["f(const x) {}"]));
2498 resolve(source, []); 4187 resolve(source);
2499 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); 4188 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
2500 verify([source]); 4189 verify([source]);
2501 } 4190 }
2502 void test_constInitializedWithNonConstValue() { 4191 void test_constInitializedWithNonConstValue() {
2503 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C = p;", "}"])); 4192 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C = p;", "}"]));
2504 resolve(source, []); 4193 resolve(source);
2505 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]); 4194 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]);
2506 verify([source]); 4195 verify([source]);
2507 } 4196 }
2508 void test_constWithInvalidTypeParameters() { 4197 void test_constWithInvalidTypeParameters() {
2509 Source source = addSource(EngineTestCase.createSource(["class A {", " const A() {}", "}", "f() { return const A<A>(); }"])); 4198 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "f() { return const A<A>(); }"]));
2510 resolve(source, []); 4199 resolve(source);
2511 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); 4200 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
2512 verify([source]); 4201 verify([source]);
2513 } 4202 }
2514 void test_constWithNonConst() { 4203 void test_constWithNonConst() {
2515 Source source = addSource(EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"])); 4204 Source source = addSource(EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"]));
2516 resolve(source, []); 4205 resolve(source);
2517 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]); 4206 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]);
2518 verify([source]); 4207 verify([source]);
2519 } 4208 }
4209 void test_constWithNonConstantArgument() {
4210 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(a);", "}", "f(p) { return const A(p); }"]));
4211 resolve(source);
4212 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT]);
4213 verify([source]);
4214 }
4215 void test_constWithNonType() {
4216 Source source = addSource(EngineTestCase.createSource(["int A;", "f() {", " return const A();", "}"]));
4217 resolve(source);
4218 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_TYPE]);
4219 verify([source]);
4220 }
4221 void test_constWithTypeParameters_direct() {
4222 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " co nst V = const A<T>();", " const A();", "}"]));
4223 resolve(source);
4224 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]);
4225 verify([source]);
4226 }
4227 void test_constWithTypeParameters_indirect() {
4228 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " co nst V = const A<List<T>>();", " const A();", "}"]));
4229 resolve(source);
4230 assertErrors([CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS]);
4231 verify([source]);
4232 }
4233 void test_constWithUndefinedConstructor() {
4234 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "f() {", " return const A.noSuchConstructor();", "}"]));
4235 resolve(source);
4236 assertErrors([CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR]);
4237 }
4238 void test_constWithUndefinedConstructorDefault() {
4239 Source source = addSource(EngineTestCase.createSource(["class A {", " const A.name();", "}", "f() {", " return const A();", "}"]));
4240 resolve(source);
4241 assertErrors([CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT] );
4242 verify([source]);
4243 }
2520 void test_defaultValueInFunctionTypeAlias() { 4244 void test_defaultValueInFunctionTypeAlias() {
2521 Source source = addSource(EngineTestCase.createSource(["typedef F([x = 0]);" ])); 4245 Source source = addSource(EngineTestCase.createSource(["typedef F([x = 0]);" ]));
2522 resolve(source, []); 4246 resolve(source);
2523 assertErrors([CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]); 4247 assertErrors([CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS]);
2524 verify([source]); 4248 verify([source]);
2525 } 4249 }
4250 void test_duplicateConstructorName_named() {
4251 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a() {}", " A.a() {}", "}"]));
4252 resolve(source);
4253 assertErrors([CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, CompileTimeEr rorCode.DUPLICATE_CONSTRUCTOR_NAME]);
4254 verify([source]);
4255 }
4256 void test_duplicateConstructorName_unnamed() {
4257 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", " A() {}", "}"]));
4258 resolve(source);
4259 assertErrors([CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, CompileTim eErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT]);
4260 verify([source]);
4261 }
4262 void test_duplicateDefinition_parameterWithFunctionName_local() {
4263 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) { }", "}"]));
4264 resolve(source);
4265 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]);
4266 verify([source]);
4267 }
4268 void test_duplicateDefinition_parameterWithFunctionName_topLevel() {
4269 Source source = addSource(EngineTestCase.createSource(["main() {", " f(f) { }", "}"]));
4270 resolve(source);
4271 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]);
4272 verify([source]);
4273 }
2526 void test_duplicateMemberError() { 4274 void test_duplicateMemberError() {
2527 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([ "library lib;", "", "part 'a.dart';", "part 'b.dart';"])); 4275 Source librarySource = addSource2("/lib.dart", EngineTestCase.createSource([ "library lib;", "", "part 'a.dart';", "part 'b.dart';"]));
2528 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"])); 4276 Source sourceA = addSource2("/a.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
2529 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"])); 4277 Source sourceB = addSource2("/b.dart", EngineTestCase.createSource(["part of lib;", "", "class A {}"]));
2530 resolve(librarySource, [sourceA, sourceB]); 4278 resolve(librarySource);
2531 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]); 4279 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION]);
2532 verify([librarySource, sourceA, sourceB]); 4280 verify([librarySource, sourceA, sourceB]);
2533 } 4281 }
4282 void test_duplicateMemberError_classMembers_methods() {
4283 Source librarySource = addSource(EngineTestCase.createSource(["class A {", " m() {}", " m() {}", "}"]));
4284 resolve(librarySource);
4285 assertErrors([CompileTimeErrorCode.DUPLICATE_DEFINITION, CompileTimeErrorCod e.DUPLICATE_DEFINITION]);
4286 verify([librarySource]);
4287 }
4288 void test_duplicateNamedArgument() {
4289 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main () {", " f(a: 1, a: 2);", "}"]));
4290 resolve(source);
4291 assertErrors([CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT]);
4292 verify([source]);
4293 }
4294 void test_exportInternalLibrary() {
4295 Source source = addSource(EngineTestCase.createSource(["export 'dart:_interc eptors';"]));
4296 resolve(source);
4297 assertErrors([CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY]);
4298 verify([source]);
4299 }
2534 void test_exportOfNonLibrary() { 4300 void test_exportOfNonLibrary() {
2535 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"])); 4301 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'lib1.dart';"]));
2536 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"])); 4302 addSource2("/lib1.dart", EngineTestCase.createSource(["part of lib;"]));
2537 resolve(source, []); 4303 resolve(source);
2538 assertErrors([CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); 4304 assertErrors([CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]);
2539 verify([source]); 4305 verify([source]);
2540 } 4306 }
2541 void test_extendsNonClass_class() { 4307 void test_extendsNonClass_class() {
2542 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends A {}"])); 4308 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends A {}"]));
2543 resolve(source, []); 4309 resolve(source);
2544 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]); 4310 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]);
2545 verify([source]); 4311 verify([source]);
2546 } 4312 }
2547 void test_extendsOrImplementsDisallowedClass_extends_bool() { 4313 void test_extendsOrImplementsDisallowedClass_extends_bool() {
2548 Source source = addSource(EngineTestCase.createSource(["class A extends bool {}"])); 4314 Source source = addSource(EngineTestCase.createSource(["class A extends bool {}"]));
2549 resolve(source, []); 4315 resolve(source);
2550 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4316 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
2551 verify([source]); 4317 verify([source]);
2552 } 4318 }
2553 void test_extendsOrImplementsDisallowedClass_extends_double() { 4319 void test_extendsOrImplementsDisallowedClass_extends_double() {
2554 Source source = addSource(EngineTestCase.createSource(["class A extends doub le {}"])); 4320 Source source = addSource(EngineTestCase.createSource(["class A extends doub le {}"]));
2555 resolve(source, []); 4321 resolve(source);
2556 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4322 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
2557 verify([source]); 4323 verify([source]);
2558 } 4324 }
2559 void test_extendsOrImplementsDisallowedClass_extends_int() { 4325 void test_extendsOrImplementsDisallowedClass_extends_int() {
2560 Source source = addSource(EngineTestCase.createSource(["class A extends int {}"])); 4326 Source source = addSource(EngineTestCase.createSource(["class A extends int {}"]));
2561 resolve(source, []); 4327 resolve(source);
2562 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4328 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
2563 verify([source]); 4329 verify([source]);
2564 } 4330 }
2565 void test_extendsOrImplementsDisallowedClass_extends_num() { 4331 void test_extendsOrImplementsDisallowedClass_extends_num() {
2566 Source source = addSource(EngineTestCase.createSource(["class A extends num {}"])); 4332 Source source = addSource(EngineTestCase.createSource(["class A extends num {}"]));
2567 resolve(source, []); 4333 resolve(source);
2568 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4334 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
2569 verify([source]); 4335 verify([source]);
2570 } 4336 }
2571 void test_extendsOrImplementsDisallowedClass_extends_String() { 4337 void test_extendsOrImplementsDisallowedClass_extends_String() {
2572 Source source = addSource(EngineTestCase.createSource(["class A extends Stri ng {}"])); 4338 Source source = addSource(EngineTestCase.createSource(["class A extends Stri ng {}"]));
2573 resolve(source, []); 4339 resolve(source);
2574 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4340 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]);
2575 verify([source]); 4341 verify([source]);
2576 } 4342 }
2577 void test_extendsOrImplementsDisallowedClass_implements_bool() { 4343 void test_extendsOrImplementsDisallowedClass_implements_bool() {
2578 Source source = addSource(EngineTestCase.createSource(["class A implements b ool {}"])); 4344 Source source = addSource(EngineTestCase.createSource(["class A implements b ool {}"]));
2579 resolve(source, []); 4345 resolve(source);
2580 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 4346 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2581 verify([source]); 4347 verify([source]);
2582 } 4348 }
2583 void test_extendsOrImplementsDisallowedClass_implements_double() { 4349 void test_extendsOrImplementsDisallowedClass_implements_double() {
2584 Source source = addSource(EngineTestCase.createSource(["class A implements d ouble {}"])); 4350 Source source = addSource(EngineTestCase.createSource(["class A implements d ouble {}"]));
2585 resolve(source, []); 4351 resolve(source);
2586 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 4352 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2587 verify([source]); 4353 verify([source]);
2588 } 4354 }
2589 void test_extendsOrImplementsDisallowedClass_implements_int() { 4355 void test_extendsOrImplementsDisallowedClass_implements_int() {
2590 Source source = addSource(EngineTestCase.createSource(["class A implements i nt {}"])); 4356 Source source = addSource(EngineTestCase.createSource(["class A implements i nt {}"]));
2591 resolve(source, []); 4357 resolve(source);
2592 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 4358 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2593 verify([source]); 4359 verify([source]);
2594 } 4360 }
2595 void test_extendsOrImplementsDisallowedClass_implements_num() { 4361 void test_extendsOrImplementsDisallowedClass_implements_num() {
2596 Source source = addSource(EngineTestCase.createSource(["class A implements n um {}"])); 4362 Source source = addSource(EngineTestCase.createSource(["class A implements n um {}"]));
2597 resolve(source, []); 4363 resolve(source);
2598 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 4364 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2599 verify([source]); 4365 verify([source]);
2600 } 4366 }
2601 void test_extendsOrImplementsDisallowedClass_implements_String() { 4367 void test_extendsOrImplementsDisallowedClass_implements_String() {
2602 Source source = addSource(EngineTestCase.createSource(["class A implements S tring {}"])); 4368 Source source = addSource(EngineTestCase.createSource(["class A implements S tring {}"]));
2603 resolve(source, []); 4369 resolve(source);
2604 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 4370 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
2605 verify([source]); 4371 verify([source]);
2606 } 4372 }
4373 void test_extraPositionalArguments_const() {
4374 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "main() {", " const A(0);", "}"]));
4375 resolve(source);
4376 assertErrors([CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS]);
4377 verify([source]);
4378 }
2607 void test_fieldInitializedByMultipleInitializers() { 4379 void test_fieldInitializedByMultipleInitializers() {
2608 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A() : x = 0, x = 1 {}", "}"])); 4380 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A() : x = 0, x = 1 {}", "}"]));
2609 resolve(source, []); 4381 resolve(source);
2610 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]); 4382 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]);
2611 verify([source]); 4383 verify([source]);
2612 } 4384 }
2613 void test_fieldInitializedByMultipleInitializers_multipleInits() { 4385 void test_fieldInitializedByMultipleInitializers_multipleInits() {
2614 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A() : x = 0, x = 1, x = 2 {}", "}"])); 4386 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A() : x = 0, x = 1, x = 2 {}", "}"]));
2615 resolve(source, []); 4387 resolve(source);
2616 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S, CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); 4388 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S, CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
2617 verify([source]); 4389 verify([source]);
2618 } 4390 }
2619 void test_fieldInitializedByMultipleInitializers_multipleNames() { 4391 void test_fieldInitializedByMultipleInitializers_multipleNames() {
2620 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " int y;", " A() : x = 0, x = 1, y = 0, y = 1 {}", "}"])); 4392 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " int y;", " A() : x = 0, x = 1, y = 0, y = 1 {}", "}"]));
2621 resolve(source, []); 4393 resolve(source);
2622 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S, CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]); 4394 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S, CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS]);
2623 verify([source]); 4395 verify([source]);
2624 } 4396 }
2625 void test_fieldInitializedInInitializerAndDeclaration_const() { 4397 void test_fieldInitializedInInitializerAndDeclaration_const() {
2626 Source source = addSource(EngineTestCase.createSource(["class A {", " const int x = 0;", " A() : x = 1 {}", "}"])); 4398 Source source = addSource(EngineTestCase.createSource(["class A {", " const int x = 0;", " A() : x = 1 {}", "}"]));
2627 resolve(source, []); 4399 resolve(source);
2628 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]); 4400 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]);
2629 verify([source]); 4401 verify([source]);
2630 } 4402 }
2631 void test_fieldInitializedInInitializerAndDeclaration_final() { 4403 void test_fieldInitializedInInitializerAndDeclaration_final() {
2632 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() : x = 1 {}", "}"])); 4404 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x = 0;", " A() : x = 1 {}", "}"]));
2633 resolve(source, []); 4405 resolve(source);
2634 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]); 4406 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]);
2635 verify([source]); 4407 verify([source]);
2636 } 4408 }
2637 void test_fieldInitializedInParameterAndInitializer() { 4409 void test_fieldInitializedInParameterAndInitializer() {
2638 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) : x = 1 {}", "}"])); 4410 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) : x = 1 {}", "}"]));
2639 resolve(source, []); 4411 resolve(source);
2640 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA LIZER]); 4412 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA LIZER]);
2641 verify([source]); 4413 verify([source]);
2642 } 4414 }
4415 void test_fieldInitializerFactoryConstructor() {
4416 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " factory A(this.x) {}", "}"]));
4417 resolve(source);
4418 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR]);
4419 verify([source]);
4420 }
4421 void test_fieldInitializerNotAssignable() {
4422 Source source = addSource(EngineTestCase.createSource(["class A {", " final int x;", " const A() : x = '';", "}"]));
4423 resolve(source);
4424 assertErrors([CompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE]);
4425 verify([source]);
4426 }
2643 void test_fieldInitializerOutsideConstructor() { 4427 void test_fieldInitializerOutsideConstructor() {
2644 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " m(this.x) {}", "}"])); 4428 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " m(this.x) {}", "}"]));
2645 resolve(source, []); 4429 resolve(source);
2646 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); 4430 assertErrors([ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, Compile TimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
2647 verify([source]); 4431 verify([source]);
2648 } 4432 }
2649 void test_fieldInitializerOutsideConstructor_defaultParameter() { 4433 void test_fieldInitializerOutsideConstructor_defaultParameter() {
2650 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " m([this.x]) {}", "}"])); 4434 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " m([this.x]) {}", "}"]));
2651 resolve(source, []); 4435 resolve(source);
2652 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]); 4436 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
2653 verify([source]); 4437 verify([source]);
2654 } 4438 }
4439 void test_fieldInitializerRedirectingConstructor_afterRedirection() {
4440 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.named() {}", " A() : this.named(), x = 42;", "}"]));
4441 resolve(source);
4442 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR ]);
4443 verify([source]);
4444 }
4445 void test_fieldInitializerRedirectingConstructor_beforeRedirection() {
4446 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.named() {}", " A() : x = 42, this.named();", "}"]));
4447 resolve(source);
4448 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR ]);
4449 verify([source]);
4450 }
4451 void test_fieldInitializingFormalRedirectingConstructor() {
4452 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.named() {}", " A(this.x) : this.named();", "}"]));
4453 resolve(source);
4454 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR ]);
4455 verify([source]);
4456 }
4457
2655 /** 4458 /**
2656 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR code, but tests the 4459 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR code, but tests the
2657 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid ed here to show 4460 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid ed here to show
2658 * coverage over all of the permutations of initializers in constructor declar ations. 4461 * coverage over all of the permutations of initializers in constructor declar ations.
2659 * <p> 4462 * <p>
2660 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of 4463 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of
2661 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w e use it instead of 4464 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w e use it instead of
2662 * the broader code 4465 * the broader code
2663 */ 4466 */
2664 void test_finalInitializedInDeclarationAndConstructor_initializers() { 4467 void test_finalInitializedInDeclarationAndConstructor_initializers() {
2665 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A() : x = 0 {}", "}"])); 4468 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A() : x = 0 {}", "}"]));
2666 resolve(source, []); 4469 resolve(source);
2667 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]); 4470 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]);
2668 verify([source]); 4471 verify([source]);
2669 } 4472 }
2670 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { 4473 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
2671 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"])); 4474 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"]));
2672 resolve(source, []); 4475 resolve(source);
2673 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONS TRUCTOR]); 4476 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONS TRUCTOR]);
2674 verify([source]); 4477 verify([source]);
2675 } 4478 }
2676 void test_finalInitializedMultipleTimes_initializers() { 4479 void test_finalInitializedMultipleTimes_initializers() {
2677 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 0, x = 0 {}", "}"])); 4480 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 0, x = 0 {}", "}"]));
2678 resolve(source, []); 4481 resolve(source);
2679 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]); 4482 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]);
2680 verify([source]); 4483 verify([source]);
2681 } 4484 }
4485
2682 /** 4486 /**
2683 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests the 4487 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests the
2684 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided here to show 4488 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided here to show
2685 * coverage over all of the permutations of initializers in constructor declar ations. 4489 * coverage over all of the permutations of initializers in constructor declar ations.
2686 * <p> 4490 * <p>
2687 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of 4491 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of
2688 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code 4492 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code
2689 */ 4493 */
2690 void test_finalInitializedMultipleTimes_initializingFormal_initializer() { 4494 void test_finalInitializedMultipleTimes_initializingFormal_initializer() {
2691 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) : x = 0 {}", "}"])); 4495 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) : x = 0 {}", "}"]));
2692 resolve(source, []); 4496 resolve(source);
2693 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA LIZER]); 4497 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA LIZER]);
2694 verify([source]); 4498 verify([source]);
2695 } 4499 }
2696 void test_finalInitializedMultipleTimes_initializingFormals() { 4500 void test_finalInitializedMultipleTimes_initializingFormals() {
2697 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x, this.x) {}", "}"])); 4501 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x, this.x) {}", "}"]));
2698 resolve(source, []); 4502 resolve(source);
2699 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES]); 4503 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES]);
2700 verify([source]); 4504 verify([source]);
2701 } 4505 }
2702 void test_finalNotInitialized_instanceField_const() { 4506 void test_finalNotInitialized_instanceField_const() {
2703 Source source = addSource(EngineTestCase.createSource(["class A {", " const F;", "}"])); 4507 Source source = addSource(EngineTestCase.createSource(["class A {", " const F;", "}"]));
2704 resolve(source, []); 4508 resolve(source);
2705 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 4509 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2706 verify([source]); 4510 verify([source]);
2707 } 4511 }
2708 void test_finalNotInitialized_instanceField_const_static() { 4512 void test_finalNotInitialized_instanceField_const_static() {
2709 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c const F;", "}"])); 4513 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c const F;", "}"]));
2710 resolve(source, []); 4514 resolve(source);
2711 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 4515 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2712 verify([source]); 4516 verify([source]);
2713 } 4517 }
2714 void test_finalNotInitialized_instanceField_final() { 4518 void test_finalNotInitialized_instanceField_final() {
2715 Source source = addSource(EngineTestCase.createSource(["class A {", " final F;", "}"])); 4519 Source source = addSource(EngineTestCase.createSource(["class A {", " final F;", "}"]));
2716 resolve(source, []); 4520 resolve(source);
2717 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 4521 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2718 verify([source]); 4522 verify([source]);
2719 } 4523 }
2720 void test_finalNotInitialized_instanceField_final_static() { 4524 void test_finalNotInitialized_instanceField_final_static() {
2721 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c final F;", "}"])); 4525 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c final F;", "}"]));
2722 resolve(source, []); 4526 resolve(source);
2723 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 4527 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2724 verify([source]); 4528 verify([source]);
2725 } 4529 }
2726 void test_finalNotInitialized_library_const() { 4530 void test_finalNotInitialized_library_const() {
2727 Source source = addSource(EngineTestCase.createSource(["const F;"])); 4531 Source source = addSource(EngineTestCase.createSource(["const F;"]));
2728 resolve(source, []); 4532 resolve(source);
2729 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 4533 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2730 verify([source]); 4534 verify([source]);
2731 } 4535 }
2732 void test_finalNotInitialized_library_final() { 4536 void test_finalNotInitialized_library_final() {
2733 Source source = addSource(EngineTestCase.createSource(["final F;"])); 4537 Source source = addSource(EngineTestCase.createSource(["final F;"]));
2734 resolve(source, []); 4538 resolve(source);
2735 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 4539 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2736 verify([source]); 4540 verify([source]);
2737 } 4541 }
2738 void test_finalNotInitialized_local_const() { 4542 void test_finalNotInitialized_local_const() {
2739 Source source = addSource(EngineTestCase.createSource(["f() {", " const int x;", "}"])); 4543 Source source = addSource(EngineTestCase.createSource(["f() {", " const int x;", "}"]));
2740 resolve(source, []); 4544 resolve(source);
2741 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 4545 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2742 verify([source]); 4546 verify([source]);
2743 } 4547 }
2744 void test_finalNotInitialized_local_final() { 4548 void test_finalNotInitialized_local_final() {
2745 Source source = addSource(EngineTestCase.createSource(["f() {", " final int x;", "}"])); 4549 Source source = addSource(EngineTestCase.createSource(["f() {", " final int x;", "}"]));
2746 resolve(source, []); 4550 resolve(source);
2747 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]); 4551 assertErrors([CompileTimeErrorCode.FINAL_NOT_INITIALIZED]);
2748 verify([source]); 4552 verify([source]);
2749 } 4553 }
4554 void test_getterAndMethodWithSameName() {
4555 Source source = addSource(EngineTestCase.createSource(["class A {", " x(y) {}", " get x => 0;", "}"]));
4556 resolve(source);
4557 assertErrors([CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME, Compile TimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]);
4558 verify([source]);
4559 }
2750 void test_implementsDynamic() { 4560 void test_implementsDynamic() {
2751 Source source = addSource(EngineTestCase.createSource(["class A implements d ynamic {}"])); 4561 Source source = addSource(EngineTestCase.createSource(["class A implements d ynamic {}"]));
2752 resolve(source, []); 4562 resolve(source);
2753 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]); 4563 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]);
2754 verify([source]); 4564 verify([source]);
2755 } 4565 }
2756 void test_implementsNonClass_class() { 4566 void test_implementsNonClass_class() {
2757 Source source = addSource(EngineTestCase.createSource(["int A;", "class B im plements A {}"])); 4567 Source source = addSource(EngineTestCase.createSource(["int A;", "class B im plements A {}"]));
2758 resolve(source, []); 4568 resolve(source);
2759 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); 4569 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
2760 verify([source]); 4570 verify([source]);
2761 } 4571 }
2762 void test_implementsNonClass_typedef() { 4572 void test_implementsNonClass_typedef() {
2763 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B; ", "typedef C = A implements B;"])); 4573 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B; ", "typedef C = A implements B;"]));
2764 resolve(source, []); 4574 resolve(source);
2765 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); 4575 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
2766 verify([source]); 4576 verify([source]);
2767 } 4577 }
2768 void test_implementsRepeated() { 4578 void test_implementsRepeated() {
2769 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B implements A, A {}"])); 4579 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B implements A, A {}"]));
2770 resolve(source, []); 4580 resolve(source);
2771 assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED]); 4581 assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
2772 verify([source]); 4582 verify([source]);
2773 } 4583 }
2774 void test_implementsRepeated_3times() { 4584 void test_implementsRepeated_3times() {
2775 Source source = addSource(EngineTestCase.createSource(["class A {} class C{} ", "class B implements A, A, A, A {}"])); 4585 Source source = addSource(EngineTestCase.createSource(["class A {} class C{} ", "class B implements A, A, A, A {}"]));
2776 resolve(source, []); 4586 resolve(source);
2777 assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED, CompileTimeErrorCode .IMPLEMENTS_REPEATED, CompileTimeErrorCode.IMPLEMENTS_REPEATED]); 4587 assertErrors([CompileTimeErrorCode.IMPLEMENTS_REPEATED, CompileTimeErrorCode .IMPLEMENTS_REPEATED, CompileTimeErrorCode.IMPLEMENTS_REPEATED]);
2778 verify([source]); 4588 verify([source]);
2779 } 4589 }
2780 void test_implementsSelf() { 4590 void test_implicitThisReferenceInInitializer_field() {
2781 Source source = addSource(EngineTestCase.createSource(["class A implements A {}"])); 4591 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f;", " var f;", "}"]));
2782 resolve(source, []); 4592 resolve(source);
2783 assertErrors([CompileTimeErrorCode.IMPLEMENTS_SELF]); 4593 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
4594 verify([source]);
4595 }
4596 void test_implicitThisReferenceInInitializer_invocation() {
4597 Source source = addSource(EngineTestCase.createSource(["class A {", " var v ;", " A() : v = f();", " f() {}", "}"]));
4598 resolve(source);
4599 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
4600 verify([source]);
4601 }
4602 void test_implicitThisReferenceInInitializer_redirectingConstructorInvocation( ) {
4603 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p) {}", " A.named() : this(f);", " var f;", "}"]));
4604 resolve(source);
4605 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
4606 verify([source]);
4607 }
4608 void test_implicitThisReferenceInInitializer_superConstructorInvocation() {
4609 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p) {}", "}", "class B extends A {", " B() : super(f);", " var f;", "}"]));
4610 resolve(source);
4611 assertErrors([CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER]);
4612 verify([source]);
4613 }
4614 void test_importInternalLibrary() {
4615 Source source = addSource(EngineTestCase.createSource(["import 'dart:_interc eptors';"]));
4616 resolve(source);
4617 assertErrors([CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY]);
4618 verify([source]);
4619 }
4620 void test_importInternalLibrary_collection() {
4621 Source source = addSource(EngineTestCase.createSource(["import 'dart:_collec tion-dev';"]));
4622 resolve(source);
4623 assertErrors([CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY]);
2784 verify([source]); 4624 verify([source]);
2785 } 4625 }
2786 void test_importOfNonLibrary() { 4626 void test_importOfNonLibrary() {
2787 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';"])); 4627 Source source = addSource(EngineTestCase.createSource(["library lib;", "impo rt 'part.dart';"]));
2788 addSource2("/part.dart", EngineTestCase.createSource(["part of lib;"])); 4628 addSource2("/part.dart", EngineTestCase.createSource(["part of lib;"]));
2789 resolve(source, []); 4629 resolve(source);
2790 assertErrors([CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); 4630 assertErrors([CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]);
2791 verify([source]); 4631 verify([source]);
2792 } 4632 }
2793 void test_inconsistentCaseExpressionTypes() { 4633 void test_inconsistentCaseExpressionTypes() {
2794 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " swit ch (p) {", " case 1:", " break;", " case 'a':", " break;", " }" , "}"])); 4634 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " swit ch (p) {", " case 1:", " break;", " case 'a':", " break;", " }" , "}"]));
2795 resolve(source, []); 4635 resolve(source);
2796 assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]); 4636 assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
2797 verify([source]); 4637 verify([source]);
2798 } 4638 }
2799 void test_inconsistentCaseExpressionTypes_repeated() { 4639 void test_inconsistentCaseExpressionTypes_repeated() {
2800 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " swit ch (p) {", " case 1:", " break;", " case 'a':", " break;", " case 'b':", " break;", " }", "}"])); 4640 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " swit ch (p) {", " case 1:", " break;", " case 'a':", " break;", " case 'b':", " break;", " }", "}"]));
2801 resolve(source, []); 4641 resolve(source);
2802 assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, Compi leTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]); 4642 assertErrors([CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, Compi leTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES]);
2803 verify([source]); 4643 verify([source]);
2804 } 4644 }
2805 void test_initializerForNonExistant_initializer() { 4645 void test_initializerForNonExistant_initializer() {
2806 Source source = addSource(EngineTestCase.createSource(["class A {", " A() : x = 0 {}", "}"])); 4646 Source source = addSource(EngineTestCase.createSource(["class A {", " A() : x = 0 {}", "}"]));
2807 resolve(source, []); 4647 resolve(source);
2808 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIELD]); 4648 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FIELD]);
2809 } 4649 }
2810 void test_initializerForStaticField() { 4650 void test_initializerForStaticField() {
2811 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c x;", " A() : x = 0 {}", "}"])); 4651 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " A() : x = 0 {}", "}"]));
2812 resolve(source, []); 4652 resolve(source);
2813 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]); 4653 assertErrors([CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD]);
2814 verify([source]); 4654 verify([source]);
2815 } 4655 }
2816 void test_initializingFormalForNonExistantField() { 4656 void test_initializingFormalForNonExistantField() {
2817 Source source = addSource(EngineTestCase.createSource(["class A {", " A(thi s.x) {}", "}"])); 4657 Source source = addSource(EngineTestCase.createSource(["class A {", " A(thi s.x) {}", "}"]));
2818 resolve(source, []); 4658 resolve(source);
2819 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]); 4659 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
2820 verify([source]); 4660 verify([source]);
2821 } 4661 }
2822 void test_initializingFormalForNonExistantField_notInEnclosingClass() { 4662 void test_initializingFormalForNonExistantField_notInEnclosingClass() {
2823 Source source = addSource(EngineTestCase.createSource(["class A {", "int x;" , "}", "class B extends A {", " B(this.x) {}", "}"])); 4663 Source source = addSource(EngineTestCase.createSource(["class A {", "int x;" , "}", "class B extends A {", " B(this.x) {}", "}"]));
2824 resolve(source, []); 4664 resolve(source);
2825 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]); 4665 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
2826 verify([source]); 4666 verify([source]);
2827 } 4667 }
2828 void test_initializingFormalForNonExistantField_optional() { 4668 void test_initializingFormalForNonExistantField_optional() {
2829 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th is.x]) {}", "}"])); 4669 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th is.x]) {}", "}"]));
2830 resolve(source, []); 4670 resolve(source);
2831 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]); 4671 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
2832 verify([source]); 4672 verify([source]);
2833 } 4673 }
2834 void test_initializingFormalForNonExistantField_static() { 4674 void test_initializingFormalForNonExistantField_static() {
2835 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c x;", " A([this.x]) {}", "}"])); 4675 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " A([this.x]) {}", "}"]));
2836 resolve(source, []); 4676 resolve(source);
2837 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]); 4677 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]);
2838 verify([source]); 4678 verify([source]);
2839 } 4679 }
4680 void test_invalidConstructorName_notEnclosingClassName() {
4681 Source source = addSource(EngineTestCase.createSource(["class A {", " B() : super();", "}"]));
4682 resolve(source);
4683 assertErrors([CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME]);
4684 }
4685 void test_invalidFactoryNameNotAClass_notClassName() {
4686 Source source = addSource(EngineTestCase.createSource(["int B;", "class A {" , " factory B() {}", "}"]));
4687 resolve(source);
4688 assertErrors([CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
4689 verify([source]);
4690 }
4691 void test_invalidFactoryNameNotAClass_notEnclosingClassName() {
4692 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry B() {}", "}"]));
4693 resolve(source);
4694 assertErrors([CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS]);
4695 }
4696 void test_invalidOverrideNamed_fewerNamedParameters() {
4697 Source source = addSource(EngineTestCase.createSource(["class A {", " m({a, b}) {}", "}", "class B extends A {", " m({a}) {}", "}"]));
4698 resolve(source);
4699 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_NAMED]);
4700 verify([source]);
4701 }
4702 void test_invalidOverrideNamed_missingNamedParameter() {
4703 Source source = addSource(EngineTestCase.createSource(["class A {", " m({a, b}) {}", "}", "class B extends A {", " m({a, c}) {}", "}"]));
4704 resolve(source);
4705 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_NAMED]);
4706 verify([source]);
4707 }
4708 void test_invalidOverridePositional() {
4709 Source source = addSource(EngineTestCase.createSource(["class A {", " m([a, b]) {}", "}", "class B extends A {", " m([a]) {}", "}"]));
4710 resolve(source);
4711 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_POSITIONAL]);
4712 verify([source]);
4713 }
4714 void test_invalidOverrideRequired() {
4715 Source source = addSource(EngineTestCase.createSource(["class A {", " m(a) {}", "}", "class B extends A {", " m(a, b) {}", "}"]));
4716 resolve(source);
4717 assertErrors([CompileTimeErrorCode.INVALID_OVERRIDE_REQUIRED]);
4718 verify([source]);
4719 }
4720 void test_invalidReferenceToThis_factoryConstructor() {
4721 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() { return this; }", "}"]));
4722 resolve(source);
4723 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
4724 verify([source]);
4725 }
4726 void test_invalidReferenceToThis_instanceVariableInitializer_inConstructor() {
4727 Source source = addSource(EngineTestCase.createSource(["class A {", " var f ;", " A() : f = this;", "}"]));
4728 resolve(source);
4729 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
4730 verify([source]);
4731 }
4732 void test_invalidReferenceToThis_instanceVariableInitializer_inDeclaration() {
4733 Source source = addSource(EngineTestCase.createSource(["class A {", " var f = this;", "}"]));
4734 resolve(source);
4735 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
4736 verify([source]);
4737 }
4738 void test_invalidReferenceToThis_staticMethod() {
4739 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c m() { return this; }", "}"]));
4740 resolve(source);
4741 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
4742 verify([source]);
4743 }
4744 void test_invalidReferenceToThis_staticVariableInitializer() {
4745 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c A f = this;", "}"]));
4746 resolve(source);
4747 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
4748 verify([source]);
4749 }
4750 void test_invalidReferenceToThis_topLevelFunction() {
4751 Source source = addSource("f() { return this; }");
4752 resolve(source);
4753 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
4754 verify([source]);
4755 }
4756 void test_invalidReferenceToThis_variableInitializer() {
4757 Source source = addSource("int x = this;");
4758 resolve(source);
4759 assertErrors([CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS]);
4760 verify([source]);
4761 }
2840 void test_invalidTypeArgumentForKey() { 4762 void test_invalidTypeArgumentForKey() {
2841 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { ", " return const <int, int>{}", " }", "}"])); 4763 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { ", " return const <int, int>{};", " }", "}"]));
2842 resolve(source, []); 4764 resolve(source);
2843 assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_FOR_KEY]); 4765 assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_FOR_KEY]);
2844 verify([source]); 4766 verify([source]);
2845 } 4767 }
2846 void test_invalidTypeArgumentInConstList() { 4768 void test_invalidTypeArgumentInConstList() {
2847 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m( ) {", " return const <E>[]", " }", "}"])); 4769 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m( ) {", " return const <E>[];", " }", "}"]));
2848 resolve(source, []); 4770 resolve(source);
2849 assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]); 4771 assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST]);
2850 verify([source]); 4772 verify([source]);
2851 } 4773 }
2852 void test_invalidTypeArgumentInConstMap() { 4774 void test_invalidTypeArgumentInConstMap() {
2853 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m( ) {", " return const <String, E>{}", " }", "}"])); 4775 Source source = addSource(EngineTestCase.createSource(["class A<E> {", " m( ) {", " return const <String, E>{};", " }", "}"]));
2854 resolve(source, []); 4776 resolve(source);
2855 assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]); 4777 assertErrors([CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP]);
2856 verify([source]); 4778 verify([source]);
2857 } 4779 }
2858 void test_invalidUri_export() { 4780 void test_invalidUri_export() {
2859 Source source = addSource(EngineTestCase.createSource(["library L;", "export 'unknown.dart';"])); 4781 Source source = addSource(EngineTestCase.createSource(["export 'ht:';"]));
2860 resolve(source, []); 4782 resolve(source);
2861 assertErrors([CompileTimeErrorCode.INVALID_URI]); 4783 assertErrors([CompileTimeErrorCode.INVALID_URI]);
2862 } 4784 }
2863 void test_invalidUri_import() { 4785 void test_invalidUri_import() {
2864 Source source = addSource(EngineTestCase.createSource(["library L;", "import 'unknown.dart';"])); 4786 Source source = addSource(EngineTestCase.createSource(["import 'ht:';"]));
2865 resolve(source, []); 4787 resolve(source);
2866 assertErrors([CompileTimeErrorCode.INVALID_URI]); 4788 assertErrors([CompileTimeErrorCode.INVALID_URI]);
2867 } 4789 }
2868 void test_invalidUri_part() { 4790 void test_invalidUri_part() {
2869 Source source = addSource(EngineTestCase.createSource(["library L;", "part ' unknown.dart';"])); 4791 Source source = addSource(EngineTestCase.createSource(["part 'ht:';"]));
2870 resolve(source, []); 4792 resolve(source);
2871 assertErrors([CompileTimeErrorCode.INVALID_URI]); 4793 assertErrors([CompileTimeErrorCode.INVALID_URI]);
2872 } 4794 }
2873 void test_labelInOuterScope() { 4795 void test_labelInOuterScope() {
2874 Source source = addSource(EngineTestCase.createSource(["class int {}", "", " class A {", " void m(int i) {", " l: while (i > 0) {", " void f() {", " break l;", " };", " }", " }", "}"])); 4796 Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " l: while (i > 0) {", " void f() {", " break l;", " };", " }", " }", "}"]));
2875 resolve(source, []); 4797 resolve(source);
2876 assertErrors([CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, StaticWarningCode.U NDEFINED_OPERATOR]); 4798 assertErrors([CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE]);
2877 } 4799 }
2878 void test_labelUndefined_break() { 4800 void test_labelUndefined_break() {
2879 Source source = addSource(EngineTestCase.createSource(["f() {", " x: while (true) {", " break y;", " }", "}"])); 4801 Source source = addSource(EngineTestCase.createSource(["f() {", " x: while (true) {", " break y;", " }", "}"]));
2880 resolve(source, []); 4802 resolve(source);
2881 assertErrors([CompileTimeErrorCode.LABEL_UNDEFINED]); 4803 assertErrors([CompileTimeErrorCode.LABEL_UNDEFINED]);
2882 } 4804 }
2883 void test_labelUndefined_continue() { 4805 void test_labelUndefined_continue() {
2884 Source source = addSource(EngineTestCase.createSource(["f() {", " x: while (true) {", " continue y;", " }", "}"])); 4806 Source source = addSource(EngineTestCase.createSource(["f() {", " x: while (true) {", " continue y;", " }", "}"]));
2885 resolve(source, []); 4807 resolve(source);
2886 assertErrors([CompileTimeErrorCode.LABEL_UNDEFINED]); 4808 assertErrors([CompileTimeErrorCode.LABEL_UNDEFINED]);
2887 } 4809 }
4810 void test_memberWithClassName_field() {
4811 Source source = addSource(EngineTestCase.createSource(["class A {", " int A = 0;", "}"]));
4812 resolve(source);
4813 assertErrors([CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
4814 verify([source]);
4815 }
4816 void test_memberWithClassName_field2() {
4817 Source source = addSource(EngineTestCase.createSource(["class A {", " int z , A, b = 0;", "}"]));
4818 resolve(source);
4819 assertErrors([CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
4820 verify([source]);
4821 }
4822 void test_memberWithClassName_getter() {
4823 Source source = addSource(EngineTestCase.createSource(["class A {", " get A => 0;", "}"]));
4824 resolve(source);
4825 assertErrors([CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME]);
4826 verify([source]);
4827 }
4828 void test_memberWithClassName_method() {
4829 }
4830 void test_methodAndGetterWithSameName() {
4831 Source source = addSource(EngineTestCase.createSource(["class A {", " get x => 0;", " x(y) {}", "}"]));
4832 resolve(source);
4833 assertErrors([CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME, Compile TimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]);
4834 verify([source]);
4835 }
4836 void test_mixinDeclaresConstructor_classDeclaration() {
4837 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends Object with A {}"]));
4838 resolve(source);
4839 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
4840 verify([source]);
4841 }
4842 void test_mixinDeclaresConstructor_typedef() {
4843 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "typedef B = Object with A;"]));
4844 resolve(source);
4845 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
4846 verify([source]);
4847 }
4848 void test_mixinInheritsFromNotObject_classDeclaration_extends() {
4849 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "class C extends Object with B {}"]));
4850 resolve(source);
4851 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
4852 verify([source]);
4853 }
4854 void test_mixinInheritsFromNotObject_classDeclaration_with() {
4855 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends Object with A {}", "class C extends Object with B {}"]));
4856 resolve(source);
4857 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
4858 verify([source]);
4859 }
4860 void test_mixinInheritsFromNotObject_typedef_extends() {
4861 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {}", "typedef C = Object with B;"]));
4862 resolve(source);
4863 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
4864 verify([source]);
4865 }
4866 void test_mixinInheritsFromNotObject_typedef_with() {
4867 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends Object with A {}", "typedef C = Object with B;"]));
4868 resolve(source);
4869 assertErrors([CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT]);
4870 verify([source]);
4871 }
2888 void test_mixinOfNonClass_class() { 4872 void test_mixinOfNonClass_class() {
2889 Source source = addSource(EngineTestCase.createSource(["int A;", "class B wi th A {}"])); 4873 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends Object with A {}"]));
2890 resolve(source, []); 4874 resolve(source);
2891 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); 4875 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
2892 verify([source]); 4876 verify([source]);
2893 } 4877 }
2894 void test_mixinOfNonClass_typedef() { 4878 void test_mixinOfNonClass_typedef() {
2895 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B; ", "typedef C = A with B;"])); 4879 Source source = addSource(EngineTestCase.createSource(["class A {}", "int B; ", "typedef C = A with B;"]));
2896 resolve(source, []); 4880 resolve(source);
2897 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); 4881 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
2898 verify([source]); 4882 verify([source]);
2899 } 4883 }
4884 void test_mixinReferencesSuper() {
4885 Source source = addSource(EngineTestCase.createSource(["class A {", " toStr ing() => super.toString();", "}", "class B extends Object with A {}"]));
4886 resolve(source);
4887 assertErrors([CompileTimeErrorCode.MIXIN_REFERENCES_SUPER]);
4888 verify([source]);
4889 }
4890 void test_mixinWithNonClassSuperclass_class() {
4891 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {} ", "class C extends A with B {}"]));
4892 resolve(source);
4893 assertErrors([CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]);
4894 verify([source]);
4895 }
4896 void test_mixinWithNonClassSuperclass_typedef() {
4897 Source source = addSource(EngineTestCase.createSource(["int A;", "class B {} ", "typedef C = A with B;"]));
4898 resolve(source);
4899 assertErrors([CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS]);
4900 verify([source]);
4901 }
4902 void test_multipleRedirectingConstructorInvocations() {
4903 Source source = addSource(EngineTestCase.createSource(["class A {", " A() : this.a(), this.b();", " A.a() {}", " A.b() {}", "}"]));
4904 resolve(source);
4905 assertErrors([CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATI ONS]);
4906 verify([source]);
4907 }
4908 void test_multipleSuperInitializers() {
4909 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B() : super(), super() {}", "}"]));
4910 resolve(source);
4911 assertErrors([CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS]);
4912 verify([source]);
4913 }
2900 void test_nativeFunctionBodyInNonSDKCode_function() { 4914 void test_nativeFunctionBodyInNonSDKCode_function() {
2901 Source source = addSource(EngineTestCase.createSource(["int m(a) native 'str ing';"])); 4915 Source source = addSource(EngineTestCase.createSource(["int m(a) native 'str ing';"]));
2902 resolve(source, []); 4916 resolve(source);
2903 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]); 4917 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
2904 verify([source]); 4918 verify([source]);
2905 } 4919 }
2906 void test_nativeFunctionBodyInNonSDKCode_method() { 4920 void test_nativeFunctionBodyInNonSDKCode_method() {
2907 Source source = addSource(EngineTestCase.createSource(["class A{", " static int m(a) native 'string';", "}"])); 4921 Source source = addSource(EngineTestCase.createSource(["class A{", " static int m(a) native 'string';", "}"]));
2908 resolve(source, []); 4922 resolve(source);
2909 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]); 4923 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
2910 verify([source]); 4924 verify([source]);
2911 } 4925 }
2912 void test_newWithInvalidTypeParameters() { 4926 void test_newWithInvalidTypeParameters() {
2913 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"])); 4927 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"]));
2914 resolve(source, []); 4928 resolve(source);
2915 assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); 4929 assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
2916 verify([source]); 4930 verify([source]);
2917 } 4931 }
2918 void test_nonConstCaseExpression() { 4932 void test_nonConstCaseExpression() {
2919 Source source = addSource(EngineTestCase.createSource(["f(int p, int q) {", " switch (p) {", " case 3 + q:", " break;", " }", "}"])); 4933 Source source = addSource(EngineTestCase.createSource(["f(int p, int q) {", " switch (p) {", " case 3 + q:", " break;", " }", "}"]));
2920 resolve(source, []); 4934 resolve(source);
2921 assertErrors([CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]); 4935 assertErrors([CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]);
2922 verify([source]); 4936 verify([source]);
2923 } 4937 }
2924 void test_nonConstListElement() { 4938 void test_nonConstListElement() {
2925 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst [a];", "}"])); 4939 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst [a];", "}"]));
2926 resolve(source, []); 4940 resolve(source);
2927 assertErrors([CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); 4941 assertErrors([CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
2928 verify([source]); 4942 verify([source]);
2929 } 4943 }
4944 void test_nonConstMapAsExpressionStatement_begin() {
4945 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0, 'b' : 1}.length;", "}"]));
4946 resolve(source);
4947 assertErrors([CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]);
4948 verify([source]);
4949 }
4950 void test_nonConstMapAsExpressionStatement_only() {
4951 Source source = addSource(EngineTestCase.createSource(["f() {", " {'a' : 0, 'b' : 1};", "}"]));
4952 resolve(source);
4953 assertErrors([CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT]);
4954 verify([source]);
4955 }
4956 void test_nonConstMapKey() {
4957 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst {a : 0};", "}"]));
4958 resolve(source);
4959 assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
4960 verify([source]);
4961 }
2930 void test_nonConstMapValue() { 4962 void test_nonConstMapValue() {
2931 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst {'a' : a};", "}"])); 4963 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst {'a' : a};", "}"]));
2932 resolve(source, []); 4964 resolve(source);
2933 assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]); 4965 assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
2934 verify([source]); 4966 verify([source]);
2935 } 4967 }
4968 void test_nonConstValueInInitializer_binary_notBool_left() {
4969 Source source = addSource(EngineTestCase.createSource(["class A {", " final bool a;", " const A(String p) : a = p && true;", "}"]));
4970 resolve(source);
4971 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4972 verify([source]);
4973 }
4974 void test_nonConstValueInInitializer_binary_notBool_right() {
4975 Source source = addSource(EngineTestCase.createSource(["class A {", " final bool a;", " const A(String p) : a = true && p;", "}"]));
4976 resolve(source);
4977 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4978 verify([source]);
4979 }
4980 void test_nonConstValueInInitializer_binary_notInt() {
4981 Source source = addSource(EngineTestCase.createSource(["class A {", " final int a;", " const A(String p) : a = 5 & p;", "}"]));
4982 resolve(source);
4983 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, Static WarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
4984 verify([source]);
4985 }
4986 void test_nonConstValueInInitializer_binary_notNum() {
4987 Source source = addSource(EngineTestCase.createSource(["class A {", " final int a;", " const A(String p) : a = 5 + p;", "}"]));
4988 resolve(source);
4989 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, Static WarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
4990 verify([source]);
4991 }
4992 void test_nonConstValueInInitializer_field() {
4993 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int C;", " final int a;", " const A() : a = C;", "}"]));
4994 resolve(source);
4995 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4996 verify([source]);
4997 }
4998 void test_nonConstValueInInitializer_redirecting() {
4999 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c var C;", " const A.named(p);", " const A() : this.named(C);", "}"]));
5000 resolve(source);
5001 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
5002 verify([source]);
5003 }
5004 void test_nonConstValueInInitializer_super() {
5005 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(p);", "}", "class B extends A {", " static var C;", " const B() : super(C); ", "}"]));
5006 resolve(source);
5007 assertErrors([CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
5008 verify([source]);
5009 }
5010 void test_nonGenerativeConstructor_explicit() {
5011 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A.named() {}", "}", "class B extends A {", " B() : super.named();", "}"]));
5012 resolve(source);
5013 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
5014 verify([source]);
5015 }
5016 void test_nonGenerativeConstructor_implicit() {
5017 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}", "class B extends A {", " B();", "}"]));
5018 resolve(source);
5019 assertErrors([CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR]);
5020 verify([source]);
5021 }
5022 void test_notEnoughRequiredArguments_const() {
5023 Source source = addSource(EngineTestCase.createSource(["class A {", " const A(int p);", "}", "main() {", " const A();", "}"]));
5024 resolve(source);
5025 assertErrors([CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
5026 verify([source]);
5027 }
2936 void test_optionalParameterInOperator_named() { 5028 void test_optionalParameterInOperator_named() {
2937 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +({p}) {}", "}"])); 5029 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +({p}) {}", "}"]));
2938 resolve(source, []); 5030 resolve(source);
2939 assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); 5031 assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
2940 verify([source]); 5032 verify([source]);
2941 } 5033 }
2942 void test_optionalParameterInOperator_positional() { 5034 void test_optionalParameterInOperator_positional() {
2943 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +([p]) {}", "}"])); 5035 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +([p]) {}", "}"]));
2944 resolve(source, []); 5036 resolve(source);
2945 assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]); 5037 assertErrors([CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR]);
2946 verify([source]); 5038 verify([source]);
2947 } 5039 }
2948 void test_partOfNonPart() { 5040 void test_partOfNonPart() {
2949 Source source = addSource(EngineTestCase.createSource(["library l1;", "part 'l2.dart';"])); 5041 Source source = addSource(EngineTestCase.createSource(["library l1;", "part 'l2.dart';"]));
2950 addSource2("/l2.dart", EngineTestCase.createSource(["library l2;"])); 5042 addSource2("/l2.dart", EngineTestCase.createSource(["library l2;"]));
2951 resolve(source, []); 5043 resolve(source);
2952 assertErrors([CompileTimeErrorCode.PART_OF_NON_PART]); 5044 assertErrors([CompileTimeErrorCode.PART_OF_NON_PART]);
2953 verify([source]); 5045 verify([source]);
2954 } 5046 }
5047 void test_prefixCollidesWithTopLevelMembers_functionTypeAlias() {
5048 addSource2("/lib.dart", "library lib;");
5049 Source source = addSource(EngineTestCase.createSource(["import '/lib.dart' a s p;", "typedef p();"]));
5050 resolve(source);
5051 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
5052 verify([source]);
5053 }
5054 void test_prefixCollidesWithTopLevelMembers_topLevelFunction() {
5055 addSource2("/lib.dart", "library lib;");
5056 Source source = addSource(EngineTestCase.createSource(["import '/lib.dart' a s p;", "p() {}"]));
5057 resolve(source);
5058 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
5059 verify([source]);
5060 }
5061 void test_prefixCollidesWithTopLevelMembers_topLevelVariable() {
5062 addSource2("/lib.dart", "library lib;");
5063 Source source = addSource(EngineTestCase.createSource(["import '/lib.dart' a s p;", "var p = null;"]));
5064 resolve(source);
5065 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
5066 verify([source]);
5067 }
5068 void test_prefixCollidesWithTopLevelMembers_type() {
5069 addSource2("/lib.dart", "library lib;");
5070 Source source = addSource(EngineTestCase.createSource(["import '/lib.dart' a s p;", "class p {}"]));
5071 resolve(source);
5072 assertErrors([CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER]);
5073 verify([source]);
5074 }
2955 void test_privateOptionalParameter() { 5075 void test_privateOptionalParameter() {
2956 Source source = addSource(EngineTestCase.createSource(["f({_p : 0}) {}"])); 5076 Source source = addSource(EngineTestCase.createSource(["f({_p : 0}) {}"]));
2957 resolve(source, []); 5077 resolve(source);
2958 assertErrors([CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]); 5078 assertErrors([CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER]);
2959 verify([source]); 5079 verify([source]);
2960 } 5080 }
5081 void test_recursiveConstructorRedirect() {
5082 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a() : this.b();", " A.b() : this.a();", "}"]));
5083 resolve(source);
5084 assertErrors([CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT, CompileTi meErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]);
5085 verify([source]);
5086 }
5087 void test_recursiveConstructorRedirect_directSelfReference() {
5088 Source source = addSource(EngineTestCase.createSource(["class A {", " A() : this();", "}"]));
5089 resolve(source);
5090 assertErrors([CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT]);
5091 verify([source]);
5092 }
5093 void test_recursiveFactoryRedirect() {
5094 Source source = addSource(EngineTestCase.createSource(["class A implements B {", " factory A() = C;", "}", "class B implements C {", " factory B() = A;", "}", "class C implements A {", " factory C() = B;", "}"]));
5095 resolve(source);
5096 assertErrors([CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, CompileTimeEr rorCode.RECURSIVE_FACTORY_REDIRECT, CompileTimeErrorCode.RECURSIVE_FACTORY_REDIR ECT, CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileTimeErrorCode. RECURSIVE_INTERFACE_INHERITANCE, CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERI TANCE]);
5097 verify([source]);
5098 }
5099 void test_recursiveFactoryRedirect_directSelfReference() {
5100 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() = A;", "}"]));
5101 resolve(source);
5102 assertErrors([CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT]);
5103 verify([source]);
5104 }
5105 void test_recursiveFactoryRedirect_generic() {
5106 Source source = addSource(EngineTestCase.createSource(["class A<T> implement s B<T> {", " factory A() = C;", "}", "class B<T> implements C<T> {", " factory B() = A;", "}", "class C<T> implements A<T> {", " factory C() = B;", "}"]));
5107 resolve(source);
5108 assertErrors([CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, CompileTimeEr rorCode.RECURSIVE_FACTORY_REDIRECT, CompileTimeErrorCode.RECURSIVE_FACTORY_REDIR ECT, CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileTimeErrorCode. RECURSIVE_INTERFACE_INHERITANCE, CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERI TANCE]);
5109 verify([source]);
5110 }
5111 void test_recursiveFactoryRedirect_named() {
5112 Source source = addSource(EngineTestCase.createSource(["class A implements B {", " factory A.nameA() = C.nameC;", "}", "class B implements C {", " factory B.nameB() = A.nameA;", "}", "class C implements A {", " factory C.nameC() = B. nameB;", "}"]));
5113 resolve(source);
5114 assertErrors([CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, CompileTimeEr rorCode.RECURSIVE_FACTORY_REDIRECT, CompileTimeErrorCode.RECURSIVE_FACTORY_REDIR ECT, CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileTimeErrorCode. RECURSIVE_INTERFACE_INHERITANCE, CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERI TANCE]);
5115 verify([source]);
5116 }
5117
5118 /**
5119 * "A" references "C" which has cycle with "B". But we should not report probl em for "A" - it is
5120 * not the part of a cycle.
5121 */
5122 void test_recursiveFactoryRedirect_outsideCycle() {
5123 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() = C;", "}", "class B implements C {", " factory B() = C;", "}", "class C implements A, B {", " factory C() = B;", "}"]));
5124 resolve(source);
5125 assertErrors([CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, CompileTimeEr rorCode.RECURSIVE_FACTORY_REDIRECT, CompileTimeErrorCode.RECURSIVE_INTERFACE_INH ERITANCE, CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
5126 verify([source]);
5127 }
5128 void test_recursiveInterfaceInheritance_extends() {
5129 Source source = addSource(EngineTestCase.createSource(["class A extends B {} ", "class B extends A {}"]));
5130 resolve(source);
5131 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileT imeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
5132 verify([source]);
5133 }
5134 void test_recursiveInterfaceInheritance_extends_implements() {
5135 Source source = addSource(EngineTestCase.createSource(["class A extends B {} ", "class B implements A {}"]));
5136 resolve(source);
5137 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileT imeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
5138 verify([source]);
5139 }
5140 void test_recursiveInterfaceInheritance_implements() {
5141 Source source = addSource(EngineTestCase.createSource(["class A implements B {}", "class B implements A {}"]));
5142 resolve(source);
5143 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileT imeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
5144 verify([source]);
5145 }
5146 void test_recursiveInterfaceInheritance_tail() {
5147 Source source = addSource(EngineTestCase.createSource(["abstract class A imp lements A {}", "class B implements A {}"]));
5148 resolve(source);
5149 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE _IMPLEMENTS]);
5150 verify([source]);
5151 }
5152 void test_recursiveInterfaceInheritance_tail2() {
5153 Source source = addSource(EngineTestCase.createSource(["abstract class A imp lements B {}", "abstract class B implements A {}", "class C implements A {}"]));
5154 resolve(source);
5155 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileT imeErrorCode.RECURSIVE_INTERFACE_INHERITANCE]);
5156 verify([source]);
5157 }
5158 void test_recursiveInterfaceInheritance_tail3() {
5159 Source source = addSource(EngineTestCase.createSource(["abstract class A imp lements B {}", "abstract class B implements C {}", "abstract class C implements A {}", "class D implements A {}"]));
5160 resolve(source);
5161 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileT imeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, CompileTimeErrorCode.RECURSIVE_INT ERFACE_INHERITANCE]);
5162 verify([source]);
5163 }
5164 void test_recursiveInterfaceInheritanceBaseCaseExtends() {
5165 Source source = addSource(EngineTestCase.createSource(["class A extends A {} "]));
5166 resolve(source);
5167 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE _EXTENDS]);
5168 verify([source]);
5169 }
5170 void test_recursiveInterfaceInheritanceBaseCaseImplements() {
5171 Source source = addSource(EngineTestCase.createSource(["class A implements A {}"]));
5172 resolve(source);
5173 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE _IMPLEMENTS]);
5174 verify([source]);
5175 }
5176 void test_recursiveInterfaceInheritanceBaseCaseImplements_typedef() {
5177 Source source = addSource(EngineTestCase.createSource(["class A {}", "class M {}", "typedef B = A with M implements B;"]));
5178 resolve(source);
5179 assertErrors([CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE _IMPLEMENTS]);
5180 verify([source]);
5181 }
5182 void test_redirectToNonConstConstructor() {
5183 Source source = addSource(EngineTestCase.createSource(["class A {", " A.a() {}", " const factory A.b() = A.a;", "}"]));
5184 resolve(source);
5185 assertErrors([CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR]);
5186 verify([source]);
5187 }
5188 void test_referenceToDeclaredVariableInInitializer_closure() {
5189 Source source = addSource(EngineTestCase.createSource(["f() {", " var x = ( x) {};", "}"]));
5190 resolve(source);
5191 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL IZER]);
5192 verify([source]);
5193 }
5194 void test_referenceToDeclaredVariableInInitializer_getter() {
5195 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x + 1;", "}"]));
5196 resolve(source);
5197 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL IZER]);
5198 verify([source]);
5199 }
5200 void test_referenceToDeclaredVariableInInitializer_setter() {
5201 Source source = addSource(EngineTestCase.createSource(["f() {", " int x = x ++;", "}"]));
5202 resolve(source);
5203 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL IZER]);
5204 verify([source]);
5205 }
5206 void test_referenceToDeclaredVariableInInitializer_unqualifiedInvocation() {
5207 Source source = addSource(EngineTestCase.createSource(["f() {", " var x = x ();", "}"]));
5208 resolve(source);
5209 assertErrors([CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIAL IZER]);
5210 verify([source]);
5211 }
2961 void test_rethrowOutsideCatch() { 5212 void test_rethrowOutsideCatch() {
2962 Source source = addSource(EngineTestCase.createSource(["f() {", " rethrow;" , "}"])); 5213 Source source = addSource(EngineTestCase.createSource(["f() {", " rethrow;" , "}"]));
2963 resolve(source, []); 5214 resolve(source);
2964 assertErrors([CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]); 5215 assertErrors([CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]);
2965 verify([source]); 5216 verify([source]);
2966 } 5217 }
2967 void test_returnInGenerativeConstructor() { 5218 void test_returnInGenerativeConstructor() {
2968 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { return 0; }", "}"])); 5219 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { return 0; }", "}"]));
2969 resolve(source, []); 5220 resolve(source);
2970 assertErrors([CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]); 5221 assertErrors([CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR]);
2971 verify([source]); 5222 verify([source]);
2972 } 5223 }
5224 void test_superInInvalidContext_binaryExpression() {
5225 Source source = addSource(EngineTestCase.createSource(["var v = super + 0;"] ));
5226 resolve(source);
5227 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5228 }
5229 void test_superInInvalidContext_constructorFieldInitializer() {
5230 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "class B extends A {", " var f;", " B() : f = super.m();", "}"]));
5231 resolve(source);
5232 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5233 }
5234 void test_superInInvalidContext_factoryConstructor() {
5235 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "class B extends A {", " factory B() {", " super.m();", " }", "}"] ));
5236 resolve(source);
5237 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5238 }
5239 void test_superInInvalidContext_instanceVariableInitializer() {
5240 Source source = addSource(EngineTestCase.createSource(["class A {", " var a ;", "}", "class B extends A {", " var b = super.a;", "}"]));
5241 resolve(source);
5242 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5243 }
5244 void test_superInInvalidContext_staticMethod() {
5245 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c m() {}", "}", "class B extends A {", " static n() { return super.m(); }", "}" ]));
5246 resolve(source);
5247 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5248 }
5249 void test_superInInvalidContext_staticVariableInitializer() {
5250 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int a = 0;", "}", "class B extends A {", " static int b = super.a;", "}"]));
5251 resolve(source);
5252 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5253 }
5254 void test_superInInvalidContext_topLevelFunction() {
5255 Source source = addSource(EngineTestCase.createSource(["f() {", " super.f() ;", "}"]));
5256 resolve(source);
5257 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5258 }
5259 void test_superInInvalidContext_topLevelVariableInitializer() {
5260 Source source = addSource(EngineTestCase.createSource(["var v = super.y;"])) ;
5261 resolve(source);
5262 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
5263 }
5264 void test_superInRedirectingConstructor_redirectionSuper() {
5265 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {", " B() : this.name(), super();", " B.name() {}", "}"]));
5266 resolve(source);
5267 assertErrors([CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]);
5268 verify([source]);
5269 }
5270 void test_superInRedirectingConstructor_superRedirection() {
5271 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {", " B() : super(), this.name();", " B.name() {}", "}"]));
5272 resolve(source);
5273 assertErrors([CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR]);
5274 verify([source]);
5275 }
5276 void test_undefinedClass_const() {
5277 Source source = addSource(EngineTestCase.createSource(["f() {", " return co nst A();", "}"]));
5278 resolve(source);
5279 assertErrors([CompileTimeErrorCode.UNDEFINED_CLASS]);
5280 verify([source]);
5281 }
5282 void test_undefinedConstructorInInitializer_explicit_named() {
5283 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B extends A {", " B() : super.named();", "}"]));
5284 resolve(source);
5285 assertErrors([CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER]);
5286 }
5287 void test_undefinedConstructorInInitializer_explicit_unnamed() {
5288 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam ed() {}", "}", "class B extends A {", " B() : super();", "}"]));
5289 resolve(source);
5290 assertErrors([CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFA ULT]);
5291 verify([source]);
5292 }
5293 void test_undefinedConstructorInInitializer_implicit() {
5294 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam ed() {}", "}", "class B extends A {", " B();", "}"]));
5295 resolve(source);
5296 assertErrors([CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFA ULT]);
5297 verify([source]);
5298 }
5299 void test_undefinedNamedParameter() {
5300 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "main() {", " const A(p: 0);", "}"]));
5301 resolve(source);
5302 assertErrors([CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER]);
5303 }
5304 void test_uriDoesNotExist_export() {
5305 Source source = addSource(EngineTestCase.createSource(["export 'unknown.dart ';"]));
5306 resolve(source);
5307 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5308 }
5309 void test_uriDoesNotExist_import() {
5310 Source source = addSource(EngineTestCase.createSource(["import 'unknown.dart ';"]));
5311 resolve(source);
5312 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5313 }
5314 void test_uriDoesNotExist_part() {
5315 Source source = addSource(EngineTestCase.createSource(["part 'unknown.dart'; "]));
5316 resolve(source);
5317 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5318 }
2973 void test_uriWithInterpolation_constant() { 5319 void test_uriWithInterpolation_constant() {
2974 Source source = addSource(EngineTestCase.createSource(["import 'stuff_\$plat form.dart';"])); 5320 Source source = addSource(EngineTestCase.createSource(["import 'stuff_\$plat form.dart';"]));
2975 resolve(source, []); 5321 resolve(source);
2976 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION, StaticWarningCode .UNDEFINED_IDENTIFIER]); 5322 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION, StaticWarningCode .UNDEFINED_IDENTIFIER]);
2977 } 5323 }
2978 void test_uriWithInterpolation_nonConstant() { 5324 void test_uriWithInterpolation_nonConstant() {
2979 Source source = addSource(EngineTestCase.createSource(["library lib;", "part '\${'a'}.dart';"])); 5325 Source source = addSource(EngineTestCase.createSource(["library lib;", "part '\${'a'}.dart';"]));
2980 resolve(source, []); 5326 resolve(source);
2981 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION]); 5327 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION]);
2982 } 5328 }
2983 void test_wrongNumberOfParametersForSetter_tooFew() { 5329 void test_wrongNumberOfParametersForOperator_minus() {
5330 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor -(a, b) {}", "}"]));
5331 resolve(source);
5332 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_M INUS]);
5333 verify([source]);
5334 reset();
5335 }
5336 void test_wrongNumberOfParametersForOperator_tilde() {
5337 check_wrongNumberOfParametersForOperator("~", "a");
5338 check_wrongNumberOfParametersForOperator("~", "a, b");
5339 }
5340 void test_wrongNumberOfParametersForOperator1() {
5341 check_wrongNumberOfParametersForOperator1("<");
5342 check_wrongNumberOfParametersForOperator1(">");
5343 check_wrongNumberOfParametersForOperator1("<=");
5344 check_wrongNumberOfParametersForOperator1(">=");
5345 check_wrongNumberOfParametersForOperator1("+");
5346 check_wrongNumberOfParametersForOperator1("/");
5347 check_wrongNumberOfParametersForOperator1("~/");
5348 check_wrongNumberOfParametersForOperator1("*");
5349 check_wrongNumberOfParametersForOperator1("%");
5350 check_wrongNumberOfParametersForOperator1("|");
5351 check_wrongNumberOfParametersForOperator1("^");
5352 check_wrongNumberOfParametersForOperator1("&");
5353 check_wrongNumberOfParametersForOperator1("<<");
5354 check_wrongNumberOfParametersForOperator1(">>");
5355 check_wrongNumberOfParametersForOperator1("[]");
5356 }
5357 void test_wrongNumberOfParametersForSetter_function_tooFew() {
5358 Source source = addSource("set x() {}");
5359 resolve(source);
5360 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5361 verify([source]);
5362 }
5363 void test_wrongNumberOfParametersForSetter_function_tooMany() {
5364 Source source = addSource("set x(a, b) {}");
5365 resolve(source);
5366 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
5367 verify([source]);
5368 }
5369 void test_wrongNumberOfParametersForSetter_method_tooFew() {
2984 Source source = addSource(EngineTestCase.createSource(["class A {", " set x () {}", "}"])); 5370 Source source = addSource(EngineTestCase.createSource(["class A {", " set x () {}", "}"]));
2985 resolve(source, []); 5371 resolve(source);
2986 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5372 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
2987 verify([source]); 5373 verify([source]);
2988 } 5374 }
2989 void test_wrongNumberOfParametersForSetter_tooMany() { 5375 void test_wrongNumberOfParametersForSetter_method_tooMany() {
2990 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (a, b) {}", "}"])); 5376 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (a, b) {}", "}"]));
2991 resolve(source, []); 5377 resolve(source);
2992 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]); 5378 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER]);
2993 verify([source]); 5379 verify([source]);
2994 } 5380 }
5381 void check_constEvalThrowsException_binary_null(String expr, bool resolved) {
5382 Source source = addSource("const C = ${expr};");
5383 resolve(source);
5384 if (resolved) {
5385 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION]);
5386 verify([source]);
5387 } else {
5388 assertErrors([CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, StaticType WarningCode.UNDEFINED_OPERATOR]);
5389 }
5390 reset();
5391 }
5392 void check_constEvalTypeBool_withParameter_binary(String expr) {
5393 Source source = addSource(EngineTestCase.createSource(["class A {", " final a;", " const A(bool p) : a = ${expr};", "}"]));
5394 resolve(source);
5395 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL]);
5396 verify([source]);
5397 reset();
5398 }
5399 void check_constEvalTypeInt_withParameter_binary(String expr) {
5400 Source source = addSource(EngineTestCase.createSource(["class A {", " final a;", " const A(int p) : a = ${expr};", "}"]));
5401 resolve(source);
5402 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_INT, StaticWarningCode.AR GUMENT_TYPE_NOT_ASSIGNABLE]);
5403 verify([source]);
5404 reset();
5405 }
5406 void check_constEvalTypeNum_withParameter_binary(String expr) {
5407 Source source = addSource(EngineTestCase.createSource(["class A {", " final a;", " const A(num p) : a = ${expr};", "}"]));
5408 resolve(source);
5409 assertErrors([CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, StaticWarningCode.AR GUMENT_TYPE_NOT_ASSIGNABLE]);
5410 verify([source]);
5411 reset();
5412 }
5413 void check_wrongNumberOfParametersForOperator(String name, String parameters) {
5414 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor ${name}(${parameters}) {}", "}"]));
5415 resolve(source);
5416 assertErrors([CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]) ;
5417 verify([source]);
5418 reset();
5419 }
5420 void check_wrongNumberOfParametersForOperator1(String name) {
5421 check_wrongNumberOfParametersForOperator(name, "");
5422 check_wrongNumberOfParametersForOperator(name, "a, b");
5423 }
2995 static dartSuite() { 5424 static dartSuite() {
2996 _ut.group('CompileTimeErrorCodeTest', () { 5425 _ut.group('CompileTimeErrorCodeTest', () {
5426 _ut.test('test_ambiguousExport', () {
5427 final __test = new CompileTimeErrorCodeTest();
5428 runJUnitTest(__test, __test.test_ambiguousExport);
5429 });
5430 _ut.test('test_ambiguousImport_as', () {
5431 final __test = new CompileTimeErrorCodeTest();
5432 runJUnitTest(__test, __test.test_ambiguousImport_as);
5433 });
5434 _ut.test('test_ambiguousImport_extends', () {
5435 final __test = new CompileTimeErrorCodeTest();
5436 runJUnitTest(__test, __test.test_ambiguousImport_extends);
5437 });
5438 _ut.test('test_ambiguousImport_function', () {
5439 final __test = new CompileTimeErrorCodeTest();
5440 runJUnitTest(__test, __test.test_ambiguousImport_function);
5441 });
5442 _ut.test('test_ambiguousImport_implements', () {
5443 final __test = new CompileTimeErrorCodeTest();
5444 runJUnitTest(__test, __test.test_ambiguousImport_implements);
5445 });
5446 _ut.test('test_ambiguousImport_instanceCreation', () {
5447 final __test = new CompileTimeErrorCodeTest();
5448 runJUnitTest(__test, __test.test_ambiguousImport_instanceCreation);
5449 });
5450 _ut.test('test_ambiguousImport_is', () {
5451 final __test = new CompileTimeErrorCodeTest();
5452 runJUnitTest(__test, __test.test_ambiguousImport_is);
5453 });
5454 _ut.test('test_ambiguousImport_qualifier', () {
5455 final __test = new CompileTimeErrorCodeTest();
5456 runJUnitTest(__test, __test.test_ambiguousImport_qualifier);
5457 });
5458 _ut.test('test_ambiguousImport_typeArgument_instanceCreation', () {
5459 final __test = new CompileTimeErrorCodeTest();
5460 runJUnitTest(__test, __test.test_ambiguousImport_typeArgument_instanceCr eation);
5461 });
5462 _ut.test('test_ambiguousImport_varRead', () {
5463 final __test = new CompileTimeErrorCodeTest();
5464 runJUnitTest(__test, __test.test_ambiguousImport_varRead);
5465 });
5466 _ut.test('test_ambiguousImport_varWrite', () {
5467 final __test = new CompileTimeErrorCodeTest();
5468 runJUnitTest(__test, __test.test_ambiguousImport_varWrite);
5469 });
2997 _ut.test('test_argumentDefinitionTestNonParameter', () { 5470 _ut.test('test_argumentDefinitionTestNonParameter', () {
2998 final __test = new CompileTimeErrorCodeTest(); 5471 final __test = new CompileTimeErrorCodeTest();
2999 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter); 5472 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter);
3000 }); 5473 });
3001 _ut.test('test_builtInIdentifierAsType', () { 5474 _ut.test('test_builtInIdentifierAsType', () {
3002 final __test = new CompileTimeErrorCodeTest(); 5475 final __test = new CompileTimeErrorCodeTest();
3003 runJUnitTest(__test, __test.test_builtInIdentifierAsType); 5476 runJUnitTest(__test, __test.test_builtInIdentifierAsType);
3004 }); 5477 });
3005 _ut.test('test_builtInIdentifierAsTypeName', () { 5478 _ut.test('test_builtInIdentifierAsTypeName', () {
3006 final __test = new CompileTimeErrorCodeTest(); 5479 final __test = new CompileTimeErrorCodeTest();
(...skipping 16 matching lines...) Expand all
3023 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals); 5496 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals);
3024 }); 5497 });
3025 _ut.test('test_conflictingConstructorNameAndMember_field', () { 5498 _ut.test('test_conflictingConstructorNameAndMember_field', () {
3026 final __test = new CompileTimeErrorCodeTest(); 5499 final __test = new CompileTimeErrorCodeTest();
3027 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_fie ld); 5500 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_fie ld);
3028 }); 5501 });
3029 _ut.test('test_conflictingConstructorNameAndMember_method', () { 5502 _ut.test('test_conflictingConstructorNameAndMember_method', () {
3030 final __test = new CompileTimeErrorCodeTest(); 5503 final __test = new CompileTimeErrorCodeTest();
3031 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_met hod); 5504 runJUnitTest(__test, __test.test_conflictingConstructorNameAndMember_met hod);
3032 }); 5505 });
3033 _ut.test('test_constConstructorWithNonFinalField', () { 5506 _ut.test('test_constConstructorWithNonFinalField_mixin', () {
3034 final __test = new CompileTimeErrorCodeTest(); 5507 final __test = new CompileTimeErrorCodeTest();
3035 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField); 5508 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_mixin );
3036 }); 5509 });
3037 _ut.test('test_constEvalThrowsException', () { 5510 _ut.test('test_constConstructorWithNonFinalField_super', () {
3038 final __test = new CompileTimeErrorCodeTest(); 5511 final __test = new CompileTimeErrorCodeTest();
3039 runJUnitTest(__test, __test.test_constEvalThrowsException); 5512 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_super );
5513 });
5514 _ut.test('test_constConstructorWithNonFinalField_this', () {
5515 final __test = new CompileTimeErrorCodeTest();
5516 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_this) ;
5517 });
5518 _ut.test('test_constEvalThrowsException_binaryMinus_null', () {
5519 final __test = new CompileTimeErrorCodeTest();
5520 runJUnitTest(__test, __test.test_constEvalThrowsException_binaryMinus_nu ll);
5521 });
5522 _ut.test('test_constEvalThrowsException_binaryPlus_null', () {
5523 final __test = new CompileTimeErrorCodeTest();
5524 runJUnitTest(__test, __test.test_constEvalThrowsException_binaryPlus_nul l);
5525 });
5526 _ut.test('test_constEvalThrowsException_unaryBitNot_null', () {
5527 final __test = new CompileTimeErrorCodeTest();
5528 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryBitNot_nu ll);
5529 });
5530 _ut.test('test_constEvalThrowsException_unaryNegated_null', () {
5531 final __test = new CompileTimeErrorCodeTest();
5532 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryNegated_n ull);
5533 });
5534 _ut.test('test_constEvalThrowsException_unaryNot_null', () {
5535 final __test = new CompileTimeErrorCodeTest();
5536 runJUnitTest(__test, __test.test_constEvalThrowsException_unaryNot_null) ;
5537 });
5538 _ut.test('test_constEvalTypeBoolNumString_equal', () {
5539 final __test = new CompileTimeErrorCodeTest();
5540 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_equal);
5541 });
5542 _ut.test('test_constEvalTypeBoolNumString_notEqual', () {
5543 final __test = new CompileTimeErrorCodeTest();
5544 runJUnitTest(__test, __test.test_constEvalTypeBoolNumString_notEqual);
5545 });
5546 _ut.test('test_constEvalTypeBool_binary', () {
5547 final __test = new CompileTimeErrorCodeTest();
5548 runJUnitTest(__test, __test.test_constEvalTypeBool_binary);
5549 });
5550 _ut.test('test_constEvalTypeInt_binary', () {
5551 final __test = new CompileTimeErrorCodeTest();
5552 runJUnitTest(__test, __test.test_constEvalTypeInt_binary);
5553 });
5554 _ut.test('test_constEvalTypeNum_binary', () {
5555 final __test = new CompileTimeErrorCodeTest();
5556 runJUnitTest(__test, __test.test_constEvalTypeNum_binary);
3040 }); 5557 });
3041 _ut.test('test_constFormalParameter_fieldFormalParameter', () { 5558 _ut.test('test_constFormalParameter_fieldFormalParameter', () {
3042 final __test = new CompileTimeErrorCodeTest(); 5559 final __test = new CompileTimeErrorCodeTest();
3043 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er); 5560 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er);
3044 }); 5561 });
3045 _ut.test('test_constFormalParameter_simpleFormalParameter', () { 5562 _ut.test('test_constFormalParameter_simpleFormalParameter', () {
3046 final __test = new CompileTimeErrorCodeTest(); 5563 final __test = new CompileTimeErrorCodeTest();
3047 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter); 5564 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter);
3048 }); 5565 });
3049 _ut.test('test_constInitializedWithNonConstValue', () { 5566 _ut.test('test_constInitializedWithNonConstValue', () {
3050 final __test = new CompileTimeErrorCodeTest(); 5567 final __test = new CompileTimeErrorCodeTest();
3051 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue); 5568 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue);
3052 }); 5569 });
3053 _ut.test('test_constWithInvalidTypeParameters', () { 5570 _ut.test('test_constWithInvalidTypeParameters', () {
3054 final __test = new CompileTimeErrorCodeTest(); 5571 final __test = new CompileTimeErrorCodeTest();
3055 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters); 5572 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters);
3056 }); 5573 });
3057 _ut.test('test_constWithNonConst', () { 5574 _ut.test('test_constWithNonConst', () {
3058 final __test = new CompileTimeErrorCodeTest(); 5575 final __test = new CompileTimeErrorCodeTest();
3059 runJUnitTest(__test, __test.test_constWithNonConst); 5576 runJUnitTest(__test, __test.test_constWithNonConst);
3060 }); 5577 });
5578 _ut.test('test_constWithNonConstantArgument', () {
5579 final __test = new CompileTimeErrorCodeTest();
5580 runJUnitTest(__test, __test.test_constWithNonConstantArgument);
5581 });
5582 _ut.test('test_constWithNonType', () {
5583 final __test = new CompileTimeErrorCodeTest();
5584 runJUnitTest(__test, __test.test_constWithNonType);
5585 });
5586 _ut.test('test_constWithTypeParameters_direct', () {
5587 final __test = new CompileTimeErrorCodeTest();
5588 runJUnitTest(__test, __test.test_constWithTypeParameters_direct);
5589 });
5590 _ut.test('test_constWithTypeParameters_indirect', () {
5591 final __test = new CompileTimeErrorCodeTest();
5592 runJUnitTest(__test, __test.test_constWithTypeParameters_indirect);
5593 });
5594 _ut.test('test_constWithUndefinedConstructor', () {
5595 final __test = new CompileTimeErrorCodeTest();
5596 runJUnitTest(__test, __test.test_constWithUndefinedConstructor);
5597 });
5598 _ut.test('test_constWithUndefinedConstructorDefault', () {
5599 final __test = new CompileTimeErrorCodeTest();
5600 runJUnitTest(__test, __test.test_constWithUndefinedConstructorDefault);
5601 });
3061 _ut.test('test_defaultValueInFunctionTypeAlias', () { 5602 _ut.test('test_defaultValueInFunctionTypeAlias', () {
3062 final __test = new CompileTimeErrorCodeTest(); 5603 final __test = new CompileTimeErrorCodeTest();
3063 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias); 5604 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
3064 }); 5605 });
5606 _ut.test('test_duplicateConstructorName_named', () {
5607 final __test = new CompileTimeErrorCodeTest();
5608 runJUnitTest(__test, __test.test_duplicateConstructorName_named);
5609 });
5610 _ut.test('test_duplicateConstructorName_unnamed', () {
5611 final __test = new CompileTimeErrorCodeTest();
5612 runJUnitTest(__test, __test.test_duplicateConstructorName_unnamed);
5613 });
5614 _ut.test('test_duplicateDefinition_parameterWithFunctionName_local', () {
5615 final __test = new CompileTimeErrorCodeTest();
5616 runJUnitTest(__test, __test.test_duplicateDefinition_parameterWithFuncti onName_local);
5617 });
5618 _ut.test('test_duplicateDefinition_parameterWithFunctionName_topLevel', () {
5619 final __test = new CompileTimeErrorCodeTest();
5620 runJUnitTest(__test, __test.test_duplicateDefinition_parameterWithFuncti onName_topLevel);
5621 });
3065 _ut.test('test_duplicateMemberError', () { 5622 _ut.test('test_duplicateMemberError', () {
3066 final __test = new CompileTimeErrorCodeTest(); 5623 final __test = new CompileTimeErrorCodeTest();
3067 runJUnitTest(__test, __test.test_duplicateMemberError); 5624 runJUnitTest(__test, __test.test_duplicateMemberError);
3068 }); 5625 });
5626 _ut.test('test_duplicateMemberError_classMembers_methods', () {
5627 final __test = new CompileTimeErrorCodeTest();
5628 runJUnitTest(__test, __test.test_duplicateMemberError_classMembers_metho ds);
5629 });
5630 _ut.test('test_duplicateNamedArgument', () {
5631 final __test = new CompileTimeErrorCodeTest();
5632 runJUnitTest(__test, __test.test_duplicateNamedArgument);
5633 });
5634 _ut.test('test_exportInternalLibrary', () {
5635 final __test = new CompileTimeErrorCodeTest();
5636 runJUnitTest(__test, __test.test_exportInternalLibrary);
5637 });
3069 _ut.test('test_exportOfNonLibrary', () { 5638 _ut.test('test_exportOfNonLibrary', () {
3070 final __test = new CompileTimeErrorCodeTest(); 5639 final __test = new CompileTimeErrorCodeTest();
3071 runJUnitTest(__test, __test.test_exportOfNonLibrary); 5640 runJUnitTest(__test, __test.test_exportOfNonLibrary);
3072 }); 5641 });
3073 _ut.test('test_extendsNonClass_class', () { 5642 _ut.test('test_extendsNonClass_class', () {
3074 final __test = new CompileTimeErrorCodeTest(); 5643 final __test = new CompileTimeErrorCodeTest();
3075 runJUnitTest(__test, __test.test_extendsNonClass_class); 5644 runJUnitTest(__test, __test.test_extendsNonClass_class);
3076 }); 5645 });
3077 _ut.test('test_extendsOrImplementsDisallowedClass_extends_String', () { 5646 _ut.test('test_extendsOrImplementsDisallowedClass_extends_String', () {
3078 final __test = new CompileTimeErrorCodeTest(); 5647 final __test = new CompileTimeErrorCodeTest();
(...skipping 28 matching lines...) Expand all
3107 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_double); 5676 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_double);
3108 }); 5677 });
3109 _ut.test('test_extendsOrImplementsDisallowedClass_implements_int', () { 5678 _ut.test('test_extendsOrImplementsDisallowedClass_implements_int', () {
3110 final __test = new CompileTimeErrorCodeTest(); 5679 final __test = new CompileTimeErrorCodeTest();
3111 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_int); 5680 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_int);
3112 }); 5681 });
3113 _ut.test('test_extendsOrImplementsDisallowedClass_implements_num', () { 5682 _ut.test('test_extendsOrImplementsDisallowedClass_implements_num', () {
3114 final __test = new CompileTimeErrorCodeTest(); 5683 final __test = new CompileTimeErrorCodeTest();
3115 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_num); 5684 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_num);
3116 }); 5685 });
5686 _ut.test('test_extraPositionalArguments_const', () {
5687 final __test = new CompileTimeErrorCodeTest();
5688 runJUnitTest(__test, __test.test_extraPositionalArguments_const);
5689 });
3117 _ut.test('test_fieldInitializedByMultipleInitializers', () { 5690 _ut.test('test_fieldInitializedByMultipleInitializers', () {
3118 final __test = new CompileTimeErrorCodeTest(); 5691 final __test = new CompileTimeErrorCodeTest();
3119 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers) ; 5692 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers) ;
3120 }); 5693 });
3121 _ut.test('test_fieldInitializedByMultipleInitializers_multipleInits', () { 5694 _ut.test('test_fieldInitializedByMultipleInitializers_multipleInits', () {
3122 final __test = new CompileTimeErrorCodeTest(); 5695 final __test = new CompileTimeErrorCodeTest();
3123 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers_ multipleInits); 5696 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers_ multipleInits);
3124 }); 5697 });
3125 _ut.test('test_fieldInitializedByMultipleInitializers_multipleNames', () { 5698 _ut.test('test_fieldInitializedByMultipleInitializers_multipleNames', () {
3126 final __test = new CompileTimeErrorCodeTest(); 5699 final __test = new CompileTimeErrorCodeTest();
3127 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers_ multipleNames); 5700 runJUnitTest(__test, __test.test_fieldInitializedByMultipleInitializers_ multipleNames);
3128 }); 5701 });
3129 _ut.test('test_fieldInitializedInInitializerAndDeclaration_const', () { 5702 _ut.test('test_fieldInitializedInInitializerAndDeclaration_const', () {
3130 final __test = new CompileTimeErrorCodeTest(); 5703 final __test = new CompileTimeErrorCodeTest();
3131 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_const); 5704 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_const);
3132 }); 5705 });
3133 _ut.test('test_fieldInitializedInInitializerAndDeclaration_final', () { 5706 _ut.test('test_fieldInitializedInInitializerAndDeclaration_final', () {
3134 final __test = new CompileTimeErrorCodeTest(); 5707 final __test = new CompileTimeErrorCodeTest();
3135 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_final); 5708 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_final);
3136 }); 5709 });
3137 _ut.test('test_fieldInitializedInParameterAndInitializer', () { 5710 _ut.test('test_fieldInitializedInParameterAndInitializer', () {
3138 final __test = new CompileTimeErrorCodeTest(); 5711 final __test = new CompileTimeErrorCodeTest();
3139 runJUnitTest(__test, __test.test_fieldInitializedInParameterAndInitializ er); 5712 runJUnitTest(__test, __test.test_fieldInitializedInParameterAndInitializ er);
3140 }); 5713 });
5714 _ut.test('test_fieldInitializerFactoryConstructor', () {
5715 final __test = new CompileTimeErrorCodeTest();
5716 runJUnitTest(__test, __test.test_fieldInitializerFactoryConstructor);
5717 });
5718 _ut.test('test_fieldInitializerNotAssignable', () {
5719 final __test = new CompileTimeErrorCodeTest();
5720 runJUnitTest(__test, __test.test_fieldInitializerNotAssignable);
5721 });
3141 _ut.test('test_fieldInitializerOutsideConstructor', () { 5722 _ut.test('test_fieldInitializerOutsideConstructor', () {
3142 final __test = new CompileTimeErrorCodeTest(); 5723 final __test = new CompileTimeErrorCodeTest();
3143 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor); 5724 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor);
3144 }); 5725 });
3145 _ut.test('test_fieldInitializerOutsideConstructor_defaultParameter', () { 5726 _ut.test('test_fieldInitializerOutsideConstructor_defaultParameter', () {
3146 final __test = new CompileTimeErrorCodeTest(); 5727 final __test = new CompileTimeErrorCodeTest();
3147 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor_defa ultParameter); 5728 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor_defa ultParameter);
3148 }); 5729 });
5730 _ut.test('test_fieldInitializerRedirectingConstructor_afterRedirection', ( ) {
5731 final __test = new CompileTimeErrorCodeTest();
5732 runJUnitTest(__test, __test.test_fieldInitializerRedirectingConstructor_ afterRedirection);
5733 });
5734 _ut.test('test_fieldInitializerRedirectingConstructor_beforeRedirection', () {
5735 final __test = new CompileTimeErrorCodeTest();
5736 runJUnitTest(__test, __test.test_fieldInitializerRedirectingConstructor_ beforeRedirection);
5737 });
5738 _ut.test('test_fieldInitializingFormalRedirectingConstructor', () {
5739 final __test = new CompileTimeErrorCodeTest();
5740 runJUnitTest(__test, __test.test_fieldInitializingFormalRedirectingConst ructor);
5741 });
3149 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializers', () { 5742 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializers', () {
3150 final __test = new CompileTimeErrorCodeTest(); 5743 final __test = new CompileTimeErrorCodeTest();
3151 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializers); 5744 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializers);
3152 }); 5745 });
3153 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializingFor mal', () { 5746 _ut.test('test_finalInitializedInDeclarationAndConstructor_initializingFor mal', () {
3154 final __test = new CompileTimeErrorCodeTest(); 5747 final __test = new CompileTimeErrorCodeTest();
3155 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializingFormal); 5748 runJUnitTest(__test, __test.test_finalInitializedInDeclarationAndConstru ctor_initializingFormal);
3156 }); 5749 });
3157 _ut.test('test_finalInitializedMultipleTimes_initializers', () { 5750 _ut.test('test_finalInitializedMultipleTimes_initializers', () {
3158 final __test = new CompileTimeErrorCodeTest(); 5751 final __test = new CompileTimeErrorCodeTest();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3191 runJUnitTest(__test, __test.test_finalNotInitialized_library_final); 5784 runJUnitTest(__test, __test.test_finalNotInitialized_library_final);
3192 }); 5785 });
3193 _ut.test('test_finalNotInitialized_local_const', () { 5786 _ut.test('test_finalNotInitialized_local_const', () {
3194 final __test = new CompileTimeErrorCodeTest(); 5787 final __test = new CompileTimeErrorCodeTest();
3195 runJUnitTest(__test, __test.test_finalNotInitialized_local_const); 5788 runJUnitTest(__test, __test.test_finalNotInitialized_local_const);
3196 }); 5789 });
3197 _ut.test('test_finalNotInitialized_local_final', () { 5790 _ut.test('test_finalNotInitialized_local_final', () {
3198 final __test = new CompileTimeErrorCodeTest(); 5791 final __test = new CompileTimeErrorCodeTest();
3199 runJUnitTest(__test, __test.test_finalNotInitialized_local_final); 5792 runJUnitTest(__test, __test.test_finalNotInitialized_local_final);
3200 }); 5793 });
5794 _ut.test('test_getterAndMethodWithSameName', () {
5795 final __test = new CompileTimeErrorCodeTest();
5796 runJUnitTest(__test, __test.test_getterAndMethodWithSameName);
5797 });
3201 _ut.test('test_implementsDynamic', () { 5798 _ut.test('test_implementsDynamic', () {
3202 final __test = new CompileTimeErrorCodeTest(); 5799 final __test = new CompileTimeErrorCodeTest();
3203 runJUnitTest(__test, __test.test_implementsDynamic); 5800 runJUnitTest(__test, __test.test_implementsDynamic);
3204 }); 5801 });
3205 _ut.test('test_implementsNonClass_class', () { 5802 _ut.test('test_implementsNonClass_class', () {
3206 final __test = new CompileTimeErrorCodeTest(); 5803 final __test = new CompileTimeErrorCodeTest();
3207 runJUnitTest(__test, __test.test_implementsNonClass_class); 5804 runJUnitTest(__test, __test.test_implementsNonClass_class);
3208 }); 5805 });
3209 _ut.test('test_implementsNonClass_typedef', () { 5806 _ut.test('test_implementsNonClass_typedef', () {
3210 final __test = new CompileTimeErrorCodeTest(); 5807 final __test = new CompileTimeErrorCodeTest();
3211 runJUnitTest(__test, __test.test_implementsNonClass_typedef); 5808 runJUnitTest(__test, __test.test_implementsNonClass_typedef);
3212 }); 5809 });
3213 _ut.test('test_implementsRepeated', () { 5810 _ut.test('test_implementsRepeated', () {
3214 final __test = new CompileTimeErrorCodeTest(); 5811 final __test = new CompileTimeErrorCodeTest();
3215 runJUnitTest(__test, __test.test_implementsRepeated); 5812 runJUnitTest(__test, __test.test_implementsRepeated);
3216 }); 5813 });
3217 _ut.test('test_implementsRepeated_3times', () { 5814 _ut.test('test_implementsRepeated_3times', () {
3218 final __test = new CompileTimeErrorCodeTest(); 5815 final __test = new CompileTimeErrorCodeTest();
3219 runJUnitTest(__test, __test.test_implementsRepeated_3times); 5816 runJUnitTest(__test, __test.test_implementsRepeated_3times);
3220 }); 5817 });
3221 _ut.test('test_implementsSelf', () { 5818 _ut.test('test_implicitThisReferenceInInitializer_field', () {
3222 final __test = new CompileTimeErrorCodeTest(); 5819 final __test = new CompileTimeErrorCodeTest();
3223 runJUnitTest(__test, __test.test_implementsSelf); 5820 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_fiel d);
5821 });
5822 _ut.test('test_implicitThisReferenceInInitializer_invocation', () {
5823 final __test = new CompileTimeErrorCodeTest();
5824 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_invo cation);
5825 });
5826 _ut.test('test_implicitThisReferenceInInitializer_redirectingConstructorIn vocation', () {
5827 final __test = new CompileTimeErrorCodeTest();
5828 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_redi rectingConstructorInvocation);
5829 });
5830 _ut.test('test_implicitThisReferenceInInitializer_superConstructorInvocati on', () {
5831 final __test = new CompileTimeErrorCodeTest();
5832 runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_supe rConstructorInvocation);
5833 });
5834 _ut.test('test_importInternalLibrary', () {
5835 final __test = new CompileTimeErrorCodeTest();
5836 runJUnitTest(__test, __test.test_importInternalLibrary);
5837 });
5838 _ut.test('test_importInternalLibrary_collection', () {
5839 final __test = new CompileTimeErrorCodeTest();
5840 runJUnitTest(__test, __test.test_importInternalLibrary_collection);
3224 }); 5841 });
3225 _ut.test('test_importOfNonLibrary', () { 5842 _ut.test('test_importOfNonLibrary', () {
3226 final __test = new CompileTimeErrorCodeTest(); 5843 final __test = new CompileTimeErrorCodeTest();
3227 runJUnitTest(__test, __test.test_importOfNonLibrary); 5844 runJUnitTest(__test, __test.test_importOfNonLibrary);
3228 }); 5845 });
3229 _ut.test('test_inconsistentCaseExpressionTypes', () { 5846 _ut.test('test_inconsistentCaseExpressionTypes', () {
3230 final __test = new CompileTimeErrorCodeTest(); 5847 final __test = new CompileTimeErrorCodeTest();
3231 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes); 5848 runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes);
3232 }); 5849 });
3233 _ut.test('test_inconsistentCaseExpressionTypes_repeated', () { 5850 _ut.test('test_inconsistentCaseExpressionTypes_repeated', () {
(...skipping 17 matching lines...) Expand all
3251 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass); 5868 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass);
3252 }); 5869 });
3253 _ut.test('test_initializingFormalForNonExistantField_optional', () { 5870 _ut.test('test_initializingFormalForNonExistantField_optional', () {
3254 final __test = new CompileTimeErrorCodeTest(); 5871 final __test = new CompileTimeErrorCodeTest();
3255 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_o ptional); 5872 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_o ptional);
3256 }); 5873 });
3257 _ut.test('test_initializingFormalForNonExistantField_static', () { 5874 _ut.test('test_initializingFormalForNonExistantField_static', () {
3258 final __test = new CompileTimeErrorCodeTest(); 5875 final __test = new CompileTimeErrorCodeTest();
3259 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_s tatic); 5876 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_s tatic);
3260 }); 5877 });
5878 _ut.test('test_invalidConstructorName_notEnclosingClassName', () {
5879 final __test = new CompileTimeErrorCodeTest();
5880 runJUnitTest(__test, __test.test_invalidConstructorName_notEnclosingClas sName);
5881 });
5882 _ut.test('test_invalidFactoryNameNotAClass_notClassName', () {
5883 final __test = new CompileTimeErrorCodeTest();
5884 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass_notClassNam e);
5885 });
5886 _ut.test('test_invalidFactoryNameNotAClass_notEnclosingClassName', () {
5887 final __test = new CompileTimeErrorCodeTest();
5888 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass_notEnclosin gClassName);
5889 });
5890 _ut.test('test_invalidOverrideNamed_fewerNamedParameters', () {
5891 final __test = new CompileTimeErrorCodeTest();
5892 runJUnitTest(__test, __test.test_invalidOverrideNamed_fewerNamedParamete rs);
5893 });
5894 _ut.test('test_invalidOverrideNamed_missingNamedParameter', () {
5895 final __test = new CompileTimeErrorCodeTest();
5896 runJUnitTest(__test, __test.test_invalidOverrideNamed_missingNamedParame ter);
5897 });
5898 _ut.test('test_invalidOverridePositional', () {
5899 final __test = new CompileTimeErrorCodeTest();
5900 runJUnitTest(__test, __test.test_invalidOverridePositional);
5901 });
5902 _ut.test('test_invalidOverrideRequired', () {
5903 final __test = new CompileTimeErrorCodeTest();
5904 runJUnitTest(__test, __test.test_invalidOverrideRequired);
5905 });
5906 _ut.test('test_invalidReferenceToThis_factoryConstructor', () {
5907 final __test = new CompileTimeErrorCodeTest();
5908 runJUnitTest(__test, __test.test_invalidReferenceToThis_factoryConstruct or);
5909 });
5910 _ut.test('test_invalidReferenceToThis_instanceVariableInitializer_inConstr uctor', () {
5911 final __test = new CompileTimeErrorCodeTest();
5912 runJUnitTest(__test, __test.test_invalidReferenceToThis_instanceVariable Initializer_inConstructor);
5913 });
5914 _ut.test('test_invalidReferenceToThis_instanceVariableInitializer_inDeclar ation', () {
5915 final __test = new CompileTimeErrorCodeTest();
5916 runJUnitTest(__test, __test.test_invalidReferenceToThis_instanceVariable Initializer_inDeclaration);
5917 });
5918 _ut.test('test_invalidReferenceToThis_staticMethod', () {
5919 final __test = new CompileTimeErrorCodeTest();
5920 runJUnitTest(__test, __test.test_invalidReferenceToThis_staticMethod);
5921 });
5922 _ut.test('test_invalidReferenceToThis_staticVariableInitializer', () {
5923 final __test = new CompileTimeErrorCodeTest();
5924 runJUnitTest(__test, __test.test_invalidReferenceToThis_staticVariableIn itializer);
5925 });
5926 _ut.test('test_invalidReferenceToThis_topLevelFunction', () {
5927 final __test = new CompileTimeErrorCodeTest();
5928 runJUnitTest(__test, __test.test_invalidReferenceToThis_topLevelFunction );
5929 });
5930 _ut.test('test_invalidReferenceToThis_variableInitializer', () {
5931 final __test = new CompileTimeErrorCodeTest();
5932 runJUnitTest(__test, __test.test_invalidReferenceToThis_variableInitiali zer);
5933 });
3261 _ut.test('test_invalidTypeArgumentForKey', () { 5934 _ut.test('test_invalidTypeArgumentForKey', () {
3262 final __test = new CompileTimeErrorCodeTest(); 5935 final __test = new CompileTimeErrorCodeTest();
3263 runJUnitTest(__test, __test.test_invalidTypeArgumentForKey); 5936 runJUnitTest(__test, __test.test_invalidTypeArgumentForKey);
3264 }); 5937 });
3265 _ut.test('test_invalidTypeArgumentInConstList', () { 5938 _ut.test('test_invalidTypeArgumentInConstList', () {
3266 final __test = new CompileTimeErrorCodeTest(); 5939 final __test = new CompileTimeErrorCodeTest();
3267 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList); 5940 runJUnitTest(__test, __test.test_invalidTypeArgumentInConstList);
3268 }); 5941 });
3269 _ut.test('test_invalidTypeArgumentInConstMap', () { 5942 _ut.test('test_invalidTypeArgumentInConstMap', () {
3270 final __test = new CompileTimeErrorCodeTest(); 5943 final __test = new CompileTimeErrorCodeTest();
(...skipping 16 matching lines...) Expand all
3287 runJUnitTest(__test, __test.test_labelInOuterScope); 5960 runJUnitTest(__test, __test.test_labelInOuterScope);
3288 }); 5961 });
3289 _ut.test('test_labelUndefined_break', () { 5962 _ut.test('test_labelUndefined_break', () {
3290 final __test = new CompileTimeErrorCodeTest(); 5963 final __test = new CompileTimeErrorCodeTest();
3291 runJUnitTest(__test, __test.test_labelUndefined_break); 5964 runJUnitTest(__test, __test.test_labelUndefined_break);
3292 }); 5965 });
3293 _ut.test('test_labelUndefined_continue', () { 5966 _ut.test('test_labelUndefined_continue', () {
3294 final __test = new CompileTimeErrorCodeTest(); 5967 final __test = new CompileTimeErrorCodeTest();
3295 runJUnitTest(__test, __test.test_labelUndefined_continue); 5968 runJUnitTest(__test, __test.test_labelUndefined_continue);
3296 }); 5969 });
5970 _ut.test('test_memberWithClassName_field', () {
5971 final __test = new CompileTimeErrorCodeTest();
5972 runJUnitTest(__test, __test.test_memberWithClassName_field);
5973 });
5974 _ut.test('test_memberWithClassName_field2', () {
5975 final __test = new CompileTimeErrorCodeTest();
5976 runJUnitTest(__test, __test.test_memberWithClassName_field2);
5977 });
5978 _ut.test('test_memberWithClassName_getter', () {
5979 final __test = new CompileTimeErrorCodeTest();
5980 runJUnitTest(__test, __test.test_memberWithClassName_getter);
5981 });
5982 _ut.test('test_memberWithClassName_method', () {
5983 final __test = new CompileTimeErrorCodeTest();
5984 runJUnitTest(__test, __test.test_memberWithClassName_method);
5985 });
5986 _ut.test('test_methodAndGetterWithSameName', () {
5987 final __test = new CompileTimeErrorCodeTest();
5988 runJUnitTest(__test, __test.test_methodAndGetterWithSameName);
5989 });
5990 _ut.test('test_mixinDeclaresConstructor_classDeclaration', () {
5991 final __test = new CompileTimeErrorCodeTest();
5992 runJUnitTest(__test, __test.test_mixinDeclaresConstructor_classDeclarati on);
5993 });
5994 _ut.test('test_mixinDeclaresConstructor_typedef', () {
5995 final __test = new CompileTimeErrorCodeTest();
5996 runJUnitTest(__test, __test.test_mixinDeclaresConstructor_typedef);
5997 });
5998 _ut.test('test_mixinInheritsFromNotObject_classDeclaration_extends', () {
5999 final __test = new CompileTimeErrorCodeTest();
6000 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_classDeclara tion_extends);
6001 });
6002 _ut.test('test_mixinInheritsFromNotObject_classDeclaration_with', () {
6003 final __test = new CompileTimeErrorCodeTest();
6004 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_classDeclara tion_with);
6005 });
6006 _ut.test('test_mixinInheritsFromNotObject_typedef_extends', () {
6007 final __test = new CompileTimeErrorCodeTest();
6008 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_typedef_exte nds);
6009 });
6010 _ut.test('test_mixinInheritsFromNotObject_typedef_with', () {
6011 final __test = new CompileTimeErrorCodeTest();
6012 runJUnitTest(__test, __test.test_mixinInheritsFromNotObject_typedef_with );
6013 });
3297 _ut.test('test_mixinOfNonClass_class', () { 6014 _ut.test('test_mixinOfNonClass_class', () {
3298 final __test = new CompileTimeErrorCodeTest(); 6015 final __test = new CompileTimeErrorCodeTest();
3299 runJUnitTest(__test, __test.test_mixinOfNonClass_class); 6016 runJUnitTest(__test, __test.test_mixinOfNonClass_class);
3300 }); 6017 });
3301 _ut.test('test_mixinOfNonClass_typedef', () { 6018 _ut.test('test_mixinOfNonClass_typedef', () {
3302 final __test = new CompileTimeErrorCodeTest(); 6019 final __test = new CompileTimeErrorCodeTest();
3303 runJUnitTest(__test, __test.test_mixinOfNonClass_typedef); 6020 runJUnitTest(__test, __test.test_mixinOfNonClass_typedef);
3304 }); 6021 });
6022 _ut.test('test_mixinReferencesSuper', () {
6023 final __test = new CompileTimeErrorCodeTest();
6024 runJUnitTest(__test, __test.test_mixinReferencesSuper);
6025 });
6026 _ut.test('test_mixinWithNonClassSuperclass_class', () {
6027 final __test = new CompileTimeErrorCodeTest();
6028 runJUnitTest(__test, __test.test_mixinWithNonClassSuperclass_class);
6029 });
6030 _ut.test('test_mixinWithNonClassSuperclass_typedef', () {
6031 final __test = new CompileTimeErrorCodeTest();
6032 runJUnitTest(__test, __test.test_mixinWithNonClassSuperclass_typedef);
6033 });
6034 _ut.test('test_multipleRedirectingConstructorInvocations', () {
6035 final __test = new CompileTimeErrorCodeTest();
6036 runJUnitTest(__test, __test.test_multipleRedirectingConstructorInvocatio ns);
6037 });
6038 _ut.test('test_multipleSuperInitializers', () {
6039 final __test = new CompileTimeErrorCodeTest();
6040 runJUnitTest(__test, __test.test_multipleSuperInitializers);
6041 });
3305 _ut.test('test_nativeFunctionBodyInNonSDKCode_function', () { 6042 _ut.test('test_nativeFunctionBodyInNonSDKCode_function', () {
3306 final __test = new CompileTimeErrorCodeTest(); 6043 final __test = new CompileTimeErrorCodeTest();
3307 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_function ); 6044 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_function );
3308 }); 6045 });
3309 _ut.test('test_nativeFunctionBodyInNonSDKCode_method', () { 6046 _ut.test('test_nativeFunctionBodyInNonSDKCode_method', () {
3310 final __test = new CompileTimeErrorCodeTest(); 6047 final __test = new CompileTimeErrorCodeTest();
3311 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_method); 6048 runJUnitTest(__test, __test.test_nativeFunctionBodyInNonSDKCode_method);
3312 }); 6049 });
3313 _ut.test('test_newWithInvalidTypeParameters', () { 6050 _ut.test('test_newWithInvalidTypeParameters', () {
3314 final __test = new CompileTimeErrorCodeTest(); 6051 final __test = new CompileTimeErrorCodeTest();
3315 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters); 6052 runJUnitTest(__test, __test.test_newWithInvalidTypeParameters);
3316 }); 6053 });
3317 _ut.test('test_nonConstCaseExpression', () { 6054 _ut.test('test_nonConstCaseExpression', () {
3318 final __test = new CompileTimeErrorCodeTest(); 6055 final __test = new CompileTimeErrorCodeTest();
3319 runJUnitTest(__test, __test.test_nonConstCaseExpression); 6056 runJUnitTest(__test, __test.test_nonConstCaseExpression);
3320 }); 6057 });
3321 _ut.test('test_nonConstListElement', () { 6058 _ut.test('test_nonConstListElement', () {
3322 final __test = new CompileTimeErrorCodeTest(); 6059 final __test = new CompileTimeErrorCodeTest();
3323 runJUnitTest(__test, __test.test_nonConstListElement); 6060 runJUnitTest(__test, __test.test_nonConstListElement);
3324 }); 6061 });
6062 _ut.test('test_nonConstMapAsExpressionStatement_begin', () {
6063 final __test = new CompileTimeErrorCodeTest();
6064 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_begin) ;
6065 });
6066 _ut.test('test_nonConstMapAsExpressionStatement_only', () {
6067 final __test = new CompileTimeErrorCodeTest();
6068 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_only);
6069 });
6070 _ut.test('test_nonConstMapKey', () {
6071 final __test = new CompileTimeErrorCodeTest();
6072 runJUnitTest(__test, __test.test_nonConstMapKey);
6073 });
3325 _ut.test('test_nonConstMapValue', () { 6074 _ut.test('test_nonConstMapValue', () {
3326 final __test = new CompileTimeErrorCodeTest(); 6075 final __test = new CompileTimeErrorCodeTest();
3327 runJUnitTest(__test, __test.test_nonConstMapValue); 6076 runJUnitTest(__test, __test.test_nonConstMapValue);
3328 }); 6077 });
6078 _ut.test('test_nonConstValueInInitializer_binary_notBool_left', () {
6079 final __test = new CompileTimeErrorCodeTest();
6080 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_notBo ol_left);
6081 });
6082 _ut.test('test_nonConstValueInInitializer_binary_notBool_right', () {
6083 final __test = new CompileTimeErrorCodeTest();
6084 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_notBo ol_right);
6085 });
6086 _ut.test('test_nonConstValueInInitializer_binary_notInt', () {
6087 final __test = new CompileTimeErrorCodeTest();
6088 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_notIn t);
6089 });
6090 _ut.test('test_nonConstValueInInitializer_binary_notNum', () {
6091 final __test = new CompileTimeErrorCodeTest();
6092 runJUnitTest(__test, __test.test_nonConstValueInInitializer_binary_notNu m);
6093 });
6094 _ut.test('test_nonConstValueInInitializer_field', () {
6095 final __test = new CompileTimeErrorCodeTest();
6096 runJUnitTest(__test, __test.test_nonConstValueInInitializer_field);
6097 });
6098 _ut.test('test_nonConstValueInInitializer_redirecting', () {
6099 final __test = new CompileTimeErrorCodeTest();
6100 runJUnitTest(__test, __test.test_nonConstValueInInitializer_redirecting) ;
6101 });
6102 _ut.test('test_nonConstValueInInitializer_super', () {
6103 final __test = new CompileTimeErrorCodeTest();
6104 runJUnitTest(__test, __test.test_nonConstValueInInitializer_super);
6105 });
6106 _ut.test('test_nonGenerativeConstructor_explicit', () {
6107 final __test = new CompileTimeErrorCodeTest();
6108 runJUnitTest(__test, __test.test_nonGenerativeConstructor_explicit);
6109 });
6110 _ut.test('test_nonGenerativeConstructor_implicit', () {
6111 final __test = new CompileTimeErrorCodeTest();
6112 runJUnitTest(__test, __test.test_nonGenerativeConstructor_implicit);
6113 });
6114 _ut.test('test_notEnoughRequiredArguments_const', () {
6115 final __test = new CompileTimeErrorCodeTest();
6116 runJUnitTest(__test, __test.test_notEnoughRequiredArguments_const);
6117 });
3329 _ut.test('test_optionalParameterInOperator_named', () { 6118 _ut.test('test_optionalParameterInOperator_named', () {
3330 final __test = new CompileTimeErrorCodeTest(); 6119 final __test = new CompileTimeErrorCodeTest();
3331 runJUnitTest(__test, __test.test_optionalParameterInOperator_named); 6120 runJUnitTest(__test, __test.test_optionalParameterInOperator_named);
3332 }); 6121 });
3333 _ut.test('test_optionalParameterInOperator_positional', () { 6122 _ut.test('test_optionalParameterInOperator_positional', () {
3334 final __test = new CompileTimeErrorCodeTest(); 6123 final __test = new CompileTimeErrorCodeTest();
3335 runJUnitTest(__test, __test.test_optionalParameterInOperator_positional) ; 6124 runJUnitTest(__test, __test.test_optionalParameterInOperator_positional) ;
3336 }); 6125 });
3337 _ut.test('test_partOfNonPart', () { 6126 _ut.test('test_partOfNonPart', () {
3338 final __test = new CompileTimeErrorCodeTest(); 6127 final __test = new CompileTimeErrorCodeTest();
3339 runJUnitTest(__test, __test.test_partOfNonPart); 6128 runJUnitTest(__test, __test.test_partOfNonPart);
3340 }); 6129 });
6130 _ut.test('test_prefixCollidesWithTopLevelMembers_functionTypeAlias', () {
6131 final __test = new CompileTimeErrorCodeTest();
6132 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers_funct ionTypeAlias);
6133 });
6134 _ut.test('test_prefixCollidesWithTopLevelMembers_topLevelFunction', () {
6135 final __test = new CompileTimeErrorCodeTest();
6136 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers_topLe velFunction);
6137 });
6138 _ut.test('test_prefixCollidesWithTopLevelMembers_topLevelVariable', () {
6139 final __test = new CompileTimeErrorCodeTest();
6140 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers_topLe velVariable);
6141 });
6142 _ut.test('test_prefixCollidesWithTopLevelMembers_type', () {
6143 final __test = new CompileTimeErrorCodeTest();
6144 runJUnitTest(__test, __test.test_prefixCollidesWithTopLevelMembers_type) ;
6145 });
3341 _ut.test('test_privateOptionalParameter', () { 6146 _ut.test('test_privateOptionalParameter', () {
3342 final __test = new CompileTimeErrorCodeTest(); 6147 final __test = new CompileTimeErrorCodeTest();
3343 runJUnitTest(__test, __test.test_privateOptionalParameter); 6148 runJUnitTest(__test, __test.test_privateOptionalParameter);
3344 }); 6149 });
6150 _ut.test('test_recursiveConstructorRedirect', () {
6151 final __test = new CompileTimeErrorCodeTest();
6152 runJUnitTest(__test, __test.test_recursiveConstructorRedirect);
6153 });
6154 _ut.test('test_recursiveConstructorRedirect_directSelfReference', () {
6155 final __test = new CompileTimeErrorCodeTest();
6156 runJUnitTest(__test, __test.test_recursiveConstructorRedirect_directSelf Reference);
6157 });
6158 _ut.test('test_recursiveFactoryRedirect', () {
6159 final __test = new CompileTimeErrorCodeTest();
6160 runJUnitTest(__test, __test.test_recursiveFactoryRedirect);
6161 });
6162 _ut.test('test_recursiveFactoryRedirect_directSelfReference', () {
6163 final __test = new CompileTimeErrorCodeTest();
6164 runJUnitTest(__test, __test.test_recursiveFactoryRedirect_directSelfRefe rence);
6165 });
6166 _ut.test('test_recursiveFactoryRedirect_generic', () {
6167 final __test = new CompileTimeErrorCodeTest();
6168 runJUnitTest(__test, __test.test_recursiveFactoryRedirect_generic);
6169 });
6170 _ut.test('test_recursiveFactoryRedirect_named', () {
6171 final __test = new CompileTimeErrorCodeTest();
6172 runJUnitTest(__test, __test.test_recursiveFactoryRedirect_named);
6173 });
6174 _ut.test('test_recursiveFactoryRedirect_outsideCycle', () {
6175 final __test = new CompileTimeErrorCodeTest();
6176 runJUnitTest(__test, __test.test_recursiveFactoryRedirect_outsideCycle);
6177 });
6178 _ut.test('test_recursiveInterfaceInheritanceBaseCaseExtends', () {
6179 final __test = new CompileTimeErrorCodeTest();
6180 runJUnitTest(__test, __test.test_recursiveInterfaceInheritanceBaseCaseEx tends);
6181 });
6182 _ut.test('test_recursiveInterfaceInheritanceBaseCaseImplements', () {
6183 final __test = new CompileTimeErrorCodeTest();
6184 runJUnitTest(__test, __test.test_recursiveInterfaceInheritanceBaseCaseIm plements);
6185 });
6186 _ut.test('test_recursiveInterfaceInheritanceBaseCaseImplements_typedef', ( ) {
6187 final __test = new CompileTimeErrorCodeTest();
6188 runJUnitTest(__test, __test.test_recursiveInterfaceInheritanceBaseCaseIm plements_typedef);
6189 });
6190 _ut.test('test_recursiveInterfaceInheritance_extends', () {
6191 final __test = new CompileTimeErrorCodeTest();
6192 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_extends);
6193 });
6194 _ut.test('test_recursiveInterfaceInheritance_extends_implements', () {
6195 final __test = new CompileTimeErrorCodeTest();
6196 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_extends_i mplements);
6197 });
6198 _ut.test('test_recursiveInterfaceInheritance_implements', () {
6199 final __test = new CompileTimeErrorCodeTest();
6200 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_implement s);
6201 });
6202 _ut.test('test_recursiveInterfaceInheritance_tail', () {
6203 final __test = new CompileTimeErrorCodeTest();
6204 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_tail);
6205 });
6206 _ut.test('test_recursiveInterfaceInheritance_tail2', () {
6207 final __test = new CompileTimeErrorCodeTest();
6208 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_tail2);
6209 });
6210 _ut.test('test_recursiveInterfaceInheritance_tail3', () {
6211 final __test = new CompileTimeErrorCodeTest();
6212 runJUnitTest(__test, __test.test_recursiveInterfaceInheritance_tail3);
6213 });
6214 _ut.test('test_redirectToNonConstConstructor', () {
6215 final __test = new CompileTimeErrorCodeTest();
6216 runJUnitTest(__test, __test.test_redirectToNonConstConstructor);
6217 });
6218 _ut.test('test_referenceToDeclaredVariableInInitializer_closure', () {
6219 final __test = new CompileTimeErrorCodeTest();
6220 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_closure);
6221 });
6222 _ut.test('test_referenceToDeclaredVariableInInitializer_getter', () {
6223 final __test = new CompileTimeErrorCodeTest();
6224 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_getter);
6225 });
6226 _ut.test('test_referenceToDeclaredVariableInInitializer_setter', () {
6227 final __test = new CompileTimeErrorCodeTest();
6228 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_setter);
6229 });
6230 _ut.test('test_referenceToDeclaredVariableInInitializer_unqualifiedInvocat ion', () {
6231 final __test = new CompileTimeErrorCodeTest();
6232 runJUnitTest(__test, __test.test_referenceToDeclaredVariableInInitialize r_unqualifiedInvocation);
6233 });
3345 _ut.test('test_rethrowOutsideCatch', () { 6234 _ut.test('test_rethrowOutsideCatch', () {
3346 final __test = new CompileTimeErrorCodeTest(); 6235 final __test = new CompileTimeErrorCodeTest();
3347 runJUnitTest(__test, __test.test_rethrowOutsideCatch); 6236 runJUnitTest(__test, __test.test_rethrowOutsideCatch);
3348 }); 6237 });
3349 _ut.test('test_returnInGenerativeConstructor', () { 6238 _ut.test('test_returnInGenerativeConstructor', () {
3350 final __test = new CompileTimeErrorCodeTest(); 6239 final __test = new CompileTimeErrorCodeTest();
3351 runJUnitTest(__test, __test.test_returnInGenerativeConstructor); 6240 runJUnitTest(__test, __test.test_returnInGenerativeConstructor);
3352 }); 6241 });
6242 _ut.test('test_superInInvalidContext_binaryExpression', () {
6243 final __test = new CompileTimeErrorCodeTest();
6244 runJUnitTest(__test, __test.test_superInInvalidContext_binaryExpression) ;
6245 });
6246 _ut.test('test_superInInvalidContext_constructorFieldInitializer', () {
6247 final __test = new CompileTimeErrorCodeTest();
6248 runJUnitTest(__test, __test.test_superInInvalidContext_constructorFieldI nitializer);
6249 });
6250 _ut.test('test_superInInvalidContext_factoryConstructor', () {
6251 final __test = new CompileTimeErrorCodeTest();
6252 runJUnitTest(__test, __test.test_superInInvalidContext_factoryConstructo r);
6253 });
6254 _ut.test('test_superInInvalidContext_instanceVariableInitializer', () {
6255 final __test = new CompileTimeErrorCodeTest();
6256 runJUnitTest(__test, __test.test_superInInvalidContext_instanceVariableI nitializer);
6257 });
6258 _ut.test('test_superInInvalidContext_staticMethod', () {
6259 final __test = new CompileTimeErrorCodeTest();
6260 runJUnitTest(__test, __test.test_superInInvalidContext_staticMethod);
6261 });
6262 _ut.test('test_superInInvalidContext_staticVariableInitializer', () {
6263 final __test = new CompileTimeErrorCodeTest();
6264 runJUnitTest(__test, __test.test_superInInvalidContext_staticVariableIni tializer);
6265 });
6266 _ut.test('test_superInInvalidContext_topLevelFunction', () {
6267 final __test = new CompileTimeErrorCodeTest();
6268 runJUnitTest(__test, __test.test_superInInvalidContext_topLevelFunction) ;
6269 });
6270 _ut.test('test_superInInvalidContext_topLevelVariableInitializer', () {
6271 final __test = new CompileTimeErrorCodeTest();
6272 runJUnitTest(__test, __test.test_superInInvalidContext_topLevelVariableI nitializer);
6273 });
6274 _ut.test('test_superInRedirectingConstructor_redirectionSuper', () {
6275 final __test = new CompileTimeErrorCodeTest();
6276 runJUnitTest(__test, __test.test_superInRedirectingConstructor_redirecti onSuper);
6277 });
6278 _ut.test('test_superInRedirectingConstructor_superRedirection', () {
6279 final __test = new CompileTimeErrorCodeTest();
6280 runJUnitTest(__test, __test.test_superInRedirectingConstructor_superRedi rection);
6281 });
6282 _ut.test('test_undefinedClass_const', () {
6283 final __test = new CompileTimeErrorCodeTest();
6284 runJUnitTest(__test, __test.test_undefinedClass_const);
6285 });
6286 _ut.test('test_undefinedConstructorInInitializer_explicit_named', () {
6287 final __test = new CompileTimeErrorCodeTest();
6288 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_named);
6289 });
6290 _ut.test('test_undefinedConstructorInInitializer_explicit_unnamed', () {
6291 final __test = new CompileTimeErrorCodeTest();
6292 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_unnamed);
6293 });
6294 _ut.test('test_undefinedConstructorInInitializer_implicit', () {
6295 final __test = new CompileTimeErrorCodeTest();
6296 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit);
6297 });
6298 _ut.test('test_undefinedNamedParameter', () {
6299 final __test = new CompileTimeErrorCodeTest();
6300 runJUnitTest(__test, __test.test_undefinedNamedParameter);
6301 });
6302 _ut.test('test_uriDoesNotExist_export', () {
6303 final __test = new CompileTimeErrorCodeTest();
6304 runJUnitTest(__test, __test.test_uriDoesNotExist_export);
6305 });
6306 _ut.test('test_uriDoesNotExist_import', () {
6307 final __test = new CompileTimeErrorCodeTest();
6308 runJUnitTest(__test, __test.test_uriDoesNotExist_import);
6309 });
6310 _ut.test('test_uriDoesNotExist_part', () {
6311 final __test = new CompileTimeErrorCodeTest();
6312 runJUnitTest(__test, __test.test_uriDoesNotExist_part);
6313 });
3353 _ut.test('test_uriWithInterpolation_constant', () { 6314 _ut.test('test_uriWithInterpolation_constant', () {
3354 final __test = new CompileTimeErrorCodeTest(); 6315 final __test = new CompileTimeErrorCodeTest();
3355 runJUnitTest(__test, __test.test_uriWithInterpolation_constant); 6316 runJUnitTest(__test, __test.test_uriWithInterpolation_constant);
3356 }); 6317 });
3357 _ut.test('test_uriWithInterpolation_nonConstant', () { 6318 _ut.test('test_uriWithInterpolation_nonConstant', () {
3358 final __test = new CompileTimeErrorCodeTest(); 6319 final __test = new CompileTimeErrorCodeTest();
3359 runJUnitTest(__test, __test.test_uriWithInterpolation_nonConstant); 6320 runJUnitTest(__test, __test.test_uriWithInterpolation_nonConstant);
3360 }); 6321 });
3361 _ut.test('test_wrongNumberOfParametersForSetter_tooFew', () { 6322 _ut.test('test_wrongNumberOfParametersForOperator1', () {
3362 final __test = new CompileTimeErrorCodeTest(); 6323 final __test = new CompileTimeErrorCodeTest();
3363 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_tooFew ); 6324 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator1);
3364 }); 6325 });
3365 _ut.test('test_wrongNumberOfParametersForSetter_tooMany', () { 6326 _ut.test('test_wrongNumberOfParametersForOperator_minus', () {
3366 final __test = new CompileTimeErrorCodeTest(); 6327 final __test = new CompileTimeErrorCodeTest();
3367 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_tooMan y); 6328 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_minu s);
6329 });
6330 _ut.test('test_wrongNumberOfParametersForOperator_tilde', () {
6331 final __test = new CompileTimeErrorCodeTest();
6332 runJUnitTest(__test, __test.test_wrongNumberOfParametersForOperator_tild e);
6333 });
6334 _ut.test('test_wrongNumberOfParametersForSetter_function_tooFew', () {
6335 final __test = new CompileTimeErrorCodeTest();
6336 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_tooFew);
6337 });
6338 _ut.test('test_wrongNumberOfParametersForSetter_function_tooMany', () {
6339 final __test = new CompileTimeErrorCodeTest();
6340 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_functi on_tooMany);
6341 });
6342 _ut.test('test_wrongNumberOfParametersForSetter_method_tooFew', () {
6343 final __test = new CompileTimeErrorCodeTest();
6344 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooFew);
6345 });
6346 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () {
6347 final __test = new CompileTimeErrorCodeTest();
6348 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooMany);
3368 }); 6349 });
3369 }); 6350 });
3370 } 6351 }
3371 } 6352 }
6353
3372 /** 6354 /**
3373 * Instances of the class {@code StaticTypeVerifier} verify that all of the node s in an AST 6355 * Instances of the class {@code StaticTypeVerifier} verify that all of the node s in an AST
3374 * structure that should have a static type associated with them do have a stati c type. 6356 * structure that should have a static type associated with them do have a stati c type.
3375 */ 6357 */
3376 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> { 6358 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> {
6359
3377 /** 6360 /**
3378 * A list containing all of the AST Expression nodes that were not resolved. 6361 * A list containing all of the AST Expression nodes that were not resolved.
3379 */ 6362 */
3380 List<Expression> _unresolvedExpressions = new List<Expression>(); 6363 List<Expression> _unresolvedExpressions = new List<Expression>();
6364
3381 /** 6365 /**
3382 * A list containing all of the AST TypeName nodes that were not resolved. 6366 * A list containing all of the AST TypeName nodes that were not resolved.
3383 */ 6367 */
3384 List<TypeName> _unresolvedTypes = new List<TypeName>(); 6368 List<TypeName> _unresolvedTypes = new List<TypeName>();
6369
3385 /** 6370 /**
3386 * Counter for the number of Expression nodes visited that are resolved. 6371 * Counter for the number of Expression nodes visited that are resolved.
3387 */ 6372 */
3388 int _resolvedExpressionCount = 0; 6373 int _resolvedExpressionCount = 0;
6374
3389 /** 6375 /**
3390 * Counter for the number of TypeName nodes visited that are resolved. 6376 * Counter for the number of TypeName nodes visited that are resolved.
3391 */ 6377 */
3392 int _resolvedTypeCount = 0; 6378 int _resolvedTypeCount = 0;
3393 /** 6379
3394 * Initialize a newly created verifier to verify that all of the nodes in an A ST structure that
3395 * should have a static type associated with them do have a static type.
3396 */
3397 StaticTypeVerifier() : super() {
3398 }
3399 /** 6380 /**
3400 * Assert that all of the visited nodes have a static type associated with the m. 6381 * Assert that all of the visited nodes have a static type associated with the m.
3401 */ 6382 */
3402 void assertResolved() { 6383 void assertResolved() {
3403 if (!_unresolvedExpressions.isEmpty || !_unresolvedTypes.isEmpty) { 6384 if (!_unresolvedExpressions.isEmpty || !_unresolvedTypes.isEmpty) {
3404 int unresolvedExpressionCount = _unresolvedExpressions.length; 6385 int unresolvedExpressionCount = _unresolvedExpressions.length;
3405 int unresolvedTypeCount = _unresolvedTypes.length; 6386 int unresolvedTypeCount = _unresolvedTypes.length;
3406 PrintStringWriter writer = new PrintStringWriter(); 6387 PrintStringWriter writer = new PrintStringWriter();
3407 writer.print("Failed to associate types with nodes: "); 6388 writer.print("Failed to associate types with nodes: ");
3408 writer.print(unresolvedExpressionCount); 6389 writer.print(unresolvedExpressionCount);
(...skipping 24 matching lines...) Expand all
3433 writer.print(" ("); 6414 writer.print(" (");
3434 writer.print(getFileName(identifier)); 6415 writer.print(getFileName(identifier));
3435 writer.print(" : "); 6416 writer.print(" : ");
3436 writer.print(identifier.offset); 6417 writer.print(identifier.offset);
3437 writer.println(")"); 6418 writer.println(")");
3438 } 6419 }
3439 } 6420 }
3440 JUnitTestCase.fail(writer.toString()); 6421 JUnitTestCase.fail(writer.toString());
3441 } 6422 }
3442 } 6423 }
6424 Object visitBreakStatement(BreakStatement node) => null;
3443 Object visitCommentReference(CommentReference node) => null; 6425 Object visitCommentReference(CommentReference node) => null;
6426 Object visitContinueStatement(ContinueStatement node) => null;
6427 Object visitExportDirective(ExportDirective node) => null;
3444 Object visitExpression(Expression node) { 6428 Object visitExpression(Expression node) {
3445 node.visitChildren(this); 6429 node.visitChildren(this);
3446 if (node.staticType == null) { 6430 if (node.staticType == null) {
3447 _unresolvedExpressions.add(node); 6431 _unresolvedExpressions.add(node);
3448 } else { 6432 } else {
3449 _resolvedExpressionCount++; 6433 _resolvedExpressionCount++;
3450 } 6434 }
3451 return null; 6435 return null;
3452 } 6436 }
6437 Object visitImportDirective(ImportDirective node) => null;
6438 Object visitLabel(Label node) => null;
3453 Object visitLibraryIdentifier(LibraryIdentifier node) => null; 6439 Object visitLibraryIdentifier(LibraryIdentifier node) => null;
3454 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 6440 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
3455 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) { 6441 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) {
3456 return null; 6442 return null;
3457 } 6443 }
3458 return super.visitPrefixedIdentifier(node); 6444 return super.visitPrefixedIdentifier(node);
3459 } 6445 }
3460 Object visitSimpleIdentifier(SimpleIdentifier node) { 6446 Object visitSimpleIdentifier(SimpleIdentifier node) {
3461 ASTNode parent2 = node.parent; 6447 ASTNode parent2 = node.parent;
3462 if (parent2 is MethodInvocation && identical(node, ((parent2 as MethodInvoca tion)).methodName)) { 6448 if (parent2 is MethodInvocation && identical(node, ((parent2 as MethodInvoca tion)).methodName)) {
3463 return null; 6449 return null;
3464 } else if (parent2 is RedirectingConstructorInvocation && identical(node, (( parent2 as RedirectingConstructorInvocation)).constructorName)) { 6450 } else if (parent2 is RedirectingConstructorInvocation && identical(node, (( parent2 as RedirectingConstructorInvocation)).constructorName)) {
3465 return null; 6451 return null;
3466 } else if (parent2 is SuperConstructorInvocation && identical(node, ((parent 2 as SuperConstructorInvocation)).constructorName)) { 6452 } else if (parent2 is SuperConstructorInvocation && identical(node, ((parent 2 as SuperConstructorInvocation)).constructorName)) {
3467 return null; 6453 return null;
3468 } else if (parent2 is ConstructorName && identical(node, ((parent2 as Constr uctorName)).name)) { 6454 } else if (parent2 is ConstructorName && identical(node, ((parent2 as Constr uctorName)).name)) {
3469 return null; 6455 return null;
3470 } else if (parent2 is Label && identical(node, ((parent2 as Label)).label)) { 6456 } else if (parent2 is ConstructorFieldInitializer && identical(node, ((paren t2 as ConstructorFieldInitializer)).fieldName)) {
3471 return null;
3472 } else if (parent2 is ImportDirective && identical(node, ((parent2 as Import Directive)).prefix)) {
3473 return null; 6457 return null;
3474 } else if (node.element is PrefixElement) { 6458 } else if (node.element is PrefixElement) {
3475 return null; 6459 return null;
3476 } 6460 }
3477 return super.visitSimpleIdentifier(node); 6461 return super.visitSimpleIdentifier(node);
3478 } 6462 }
3479 Object visitTypeName(TypeName node) { 6463 Object visitTypeName(TypeName node) {
3480 if (node.type == null) { 6464 if (node.type == null) {
3481 _unresolvedTypes.add(node); 6465 _unresolvedTypes.add(node);
3482 } else { 6466 } else {
(...skipping 12 matching lines...) Expand all
3495 return "<unknown file- CompilationUnit.getElement() returned null>"; 6479 return "<unknown file- CompilationUnit.getElement() returned null>";
3496 } 6480 }
3497 } else { 6481 } else {
3498 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>"; 6482 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
3499 } 6483 }
3500 } 6484 }
3501 return "<unknown file- ASTNode is null>"; 6485 return "<unknown file- ASTNode is null>";
3502 } 6486 }
3503 } 6487 }
3504 class ElementResolverTest extends EngineTestCase { 6488 class ElementResolverTest extends EngineTestCase {
6489
3505 /** 6490 /**
3506 * The error listener to which errors will be reported. 6491 * The error listener to which errors will be reported.
3507 */ 6492 */
3508 GatheringErrorListener _listener; 6493 GatheringErrorListener _listener;
6494
3509 /** 6495 /**
3510 * The type provider used to access the types. 6496 * The type provider used to access the types.
3511 */ 6497 */
3512 TestTypeProvider _typeProvider; 6498 TestTypeProvider _typeProvider;
6499
3513 /** 6500 /**
3514 * The library containing the code being resolved. 6501 * The library containing the code being resolved.
3515 */ 6502 */
3516 LibraryElementImpl _definingLibrary; 6503 LibraryElementImpl _definingLibrary;
6504
3517 /** 6505 /**
3518 * The resolver visitor that maintains the state for the resolver. 6506 * The resolver visitor that maintains the state for the resolver.
3519 */ 6507 */
3520 ResolverVisitor _visitor; 6508 ResolverVisitor _visitor;
6509
3521 /** 6510 /**
3522 * The resolver being used to resolve the test cases. 6511 * The resolver being used to resolve the test cases.
3523 */ 6512 */
3524 ElementResolver _resolver; 6513 ElementResolver _resolver;
3525 void fail_visitExportDirective_combinators() { 6514 void fail_visitExportDirective_combinators() {
3526 JUnitTestCase.fail("Not yet tested"); 6515 JUnitTestCase.fail("Not yet tested");
3527 ExportDirective directive = ASTFactory.exportDirective2(null, [ASTFactory.hi deCombinator2(["A"])]); 6516 ExportDirective directive = ASTFactory.exportDirective2(null, [ASTFactory.hi deCombinator2(["A"])]);
3528 resolveNode(directive, []); 6517 resolveNode(directive, []);
3529 _listener.assertNoErrors(); 6518 _listener.assertNoErrors();
3530 } 6519 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3587 _listener.assertNoErrors(); 6576 _listener.assertNoErrors();
3588 } 6577 }
3589 void test_visitBreakStatement_withoutLabel() { 6578 void test_visitBreakStatement_withoutLabel() {
3590 BreakStatement statement = ASTFactory.breakStatement(); 6579 BreakStatement statement = ASTFactory.breakStatement();
3591 resolveStatement(statement, null); 6580 resolveStatement(statement, null);
3592 _listener.assertNoErrors(); 6581 _listener.assertNoErrors();
3593 } 6582 }
3594 void test_visitConstructorName_named() { 6583 void test_visitConstructorName_named() {
3595 ClassElementImpl classA = ElementFactory.classElement2("A", []); 6584 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3596 String constructorName = "a"; 6585 String constructorName = "a";
3597 ConstructorElement constructor = ElementFactory.constructorElement(construct orName); 6586 ConstructorElement constructor = ElementFactory.constructorElement(classA, c onstructorName);
3598 classA.constructors = <ConstructorElement> [constructor]; 6587 classA.constructors = <ConstructorElement> [constructor];
3599 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName); 6588 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
3600 resolveNode(name, []); 6589 resolveNode(name, []);
3601 JUnitTestCase.assertSame(constructor, name.element); 6590 JUnitTestCase.assertSame(constructor, name.element);
3602 _listener.assertNoErrors(); 6591 _listener.assertNoErrors();
3603 } 6592 }
3604 void test_visitConstructorName_unnamed() { 6593 void test_visitConstructorName_unnamed() {
3605 ClassElementImpl classA = ElementFactory.classElement2("A", []); 6594 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3606 String constructorName = null; 6595 String constructorName = null;
3607 ConstructorElement constructor = ElementFactory.constructorElement(construct orName); 6596 ConstructorElement constructor = ElementFactory.constructorElement(classA, c onstructorName);
3608 classA.constructors = <ConstructorElement> [constructor]; 6597 classA.constructors = <ConstructorElement> [constructor];
3609 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName); 6598 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
3610 resolveNode(name, []); 6599 resolveNode(name, []);
3611 JUnitTestCase.assertSame(constructor, name.element); 6600 JUnitTestCase.assertSame(constructor, name.element);
3612 _listener.assertNoErrors(); 6601 _listener.assertNoErrors();
3613 } 6602 }
3614 void test_visitContinueStatement_withLabel() { 6603 void test_visitContinueStatement_withLabel() {
3615 String label = "loop"; 6604 String label = "loop";
3616 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3( label), false, false); 6605 LabelElementImpl labelElement = new LabelElementImpl(ASTFactory.identifier3( label), false, false);
3617 ContinueStatement statement = ASTFactory.continueStatement2(label); 6606 ContinueStatement statement = ASTFactory.continueStatement2(label);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3673 SimpleIdentifier array = ASTFactory.identifier3("a"); 6662 SimpleIdentifier array = ASTFactory.identifier3("a");
3674 array.staticType = classA.type; 6663 array.staticType = classA.type;
3675 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i")); 6664 IndexExpression expression = ASTFactory.indexExpression(array, ASTFactory.id entifier3("i"));
3676 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer (0)); 6665 ASTFactory.assignmentExpression(expression, TokenType.EQ, ASTFactory.integer (0));
3677 JUnitTestCase.assertSame(setter, resolve5(expression, [])); 6666 JUnitTestCase.assertSame(setter, resolve5(expression, []));
3678 _listener.assertNoErrors(); 6667 _listener.assertNoErrors();
3679 } 6668 }
3680 void test_visitInstanceCreationExpression_named() { 6669 void test_visitInstanceCreationExpression_named() {
3681 ClassElementImpl classA = ElementFactory.classElement2("A", []); 6670 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3682 String constructorName = "a"; 6671 String constructorName = "a";
3683 ConstructorElement constructor = ElementFactory.constructorElement(construct orName); 6672 ConstructorElement constructor = ElementFactory.constructorElement(classA, c onstructorName);
3684 classA.constructors = <ConstructorElement> [constructor]; 6673 classA.constructors = <ConstructorElement> [constructor];
3685 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName); 6674 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
3686 name.element = constructor; 6675 name.element = constructor;
3687 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, []); 6676 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, []);
3688 resolveNode(creation, []); 6677 resolveNode(creation, []);
3689 JUnitTestCase.assertSame(constructor, creation.element); 6678 JUnitTestCase.assertSame(constructor, creation.element);
3690 _listener.assertNoErrors(); 6679 _listener.assertNoErrors();
3691 } 6680 }
3692 void test_visitInstanceCreationExpression_unnamed() { 6681 void test_visitInstanceCreationExpression_unnamed() {
3693 ClassElementImpl classA = ElementFactory.classElement2("A", []); 6682 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3694 String constructorName = null; 6683 String constructorName = null;
3695 ConstructorElement constructor = ElementFactory.constructorElement(construct orName); 6684 ConstructorElement constructor = ElementFactory.constructorElement(classA, c onstructorName);
3696 classA.constructors = <ConstructorElement> [constructor]; 6685 classA.constructors = <ConstructorElement> [constructor];
3697 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName); 6686 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
3698 name.element = constructor; 6687 name.element = constructor;
3699 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, []); 6688 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, []);
3700 resolveNode(creation, []); 6689 resolveNode(creation, []);
3701 JUnitTestCase.assertSame(constructor, creation.element); 6690 JUnitTestCase.assertSame(constructor, creation.element);
3702 _listener.assertNoErrors(); 6691 _listener.assertNoErrors();
3703 } 6692 }
3704 void test_visitInstanceCreationExpression_unnamed_namedParameter() { 6693 void test_visitInstanceCreationExpression_unnamed_namedParameter() {
3705 ClassElementImpl classA = ElementFactory.classElement2("A", []); 6694 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3706 String constructorName = null; 6695 String constructorName = null;
3707 ConstructorElementImpl constructor = ElementFactory.constructorElement(const ructorName); 6696 ConstructorElementImpl constructor = ElementFactory.constructorElement(class A, constructorName);
3708 String parameterName = "a"; 6697 String parameterName = "a";
3709 ParameterElement parameter = ElementFactory.namedParameter(parameterName); 6698 ParameterElement parameter = ElementFactory.namedParameter(parameterName);
3710 constructor.parameters = <ParameterElement> [parameter]; 6699 constructor.parameters = <ParameterElement> [parameter];
3711 classA.constructors = <ConstructorElement> [constructor]; 6700 classA.constructors = <ConstructorElement> [constructor];
3712 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName); 6701 ConstructorName name = ASTFactory.constructorName(ASTFactory.typeName(classA , []), constructorName);
3713 name.element = constructor; 6702 name.element = constructor;
3714 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege r(0))]); 6703 InstanceCreationExpression creation = ASTFactory.instanceCreationExpression( Keyword.NEW, name, [ASTFactory.namedExpression2(parameterName, ASTFactory.intege r(0))]);
3715 resolveNode(creation, []); 6704 resolveNode(creation, []);
3716 JUnitTestCase.assertSame(constructor, creation.element); 6705 JUnitTestCase.assertSame(constructor, creation.element);
3717 JUnitTestCase.assertSame(parameter, ((creation.argumentList.arguments[0] as NamedExpression)).name.label.element); 6706 JUnitTestCase.assertSame(parameter, ((creation.argumentList.arguments[0] as NamedExpression)).name.label.element);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3801 resolveNode(access, []); 6790 resolveNode(access, []);
3802 JUnitTestCase.assertSame(getter, access.propertyName.element); 6791 JUnitTestCase.assertSame(getter, access.propertyName.element);
3803 _listener.assertNoErrors(); 6792 _listener.assertNoErrors();
3804 } 6793 }
3805 void test_visitPropertyAccess_getter_super() { 6794 void test_visitPropertyAccess_getter_super() {
3806 ClassElementImpl classA = ElementFactory.classElement2("A", []); 6795 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3807 String getterName = "b"; 6796 String getterName = "b";
3808 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType); 6797 PropertyAccessorElement getter = ElementFactory.getterElement(getterName, fa lse, _typeProvider.intType);
3809 classA.accessors = <PropertyAccessorElement> [getter]; 6798 classA.accessors = <PropertyAccessorElement> [getter];
3810 SuperExpression target = ASTFactory.superExpression(); 6799 SuperExpression target = ASTFactory.superExpression();
3811 target.staticType = classA.type; 6800 target.staticType = ElementFactory.classElement("B", classA.type, []).type;
3812 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName); 6801 PropertyAccess access = ASTFactory.propertyAccess2(target, getterName);
6802 ASTFactory.methodDeclaration2(null, null, null, null, ASTFactory.identifier3 ("m"), ASTFactory.formalParameterList([]), ASTFactory.expressionFunctionBody(acc ess));
3813 resolveNode(access, []); 6803 resolveNode(access, []);
3814 JUnitTestCase.assertSame(getter, access.propertyName.element); 6804 JUnitTestCase.assertSame(getter, access.propertyName.element);
3815 _listener.assertNoErrors(); 6805 _listener.assertNoErrors();
3816 } 6806 }
3817 void test_visitPropertyAccess_setter_this() { 6807 void test_visitPropertyAccess_setter_this() {
3818 ClassElementImpl classA = ElementFactory.classElement2("A", []); 6808 ClassElementImpl classA = ElementFactory.classElement2("A", []);
3819 String setterName = "b"; 6809 String setterName = "b";
3820 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, _typeProvider.intType); 6810 PropertyAccessorElement setter = ElementFactory.setterElement(setterName, fa lse, _typeProvider.intType);
3821 classA.accessors = <PropertyAccessorElement> [setter]; 6811 classA.accessors = <PropertyAccessorElement> [setter];
3822 ThisExpression target = ASTFactory.thisExpression(); 6812 ThisExpression target = ASTFactory.thisExpression();
(...skipping 28 matching lines...) Expand all
3851 SimpleIdentifier node = ASTFactory.identifier3(fieldName); 6841 SimpleIdentifier node = ASTFactory.identifier3(fieldName);
3852 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); 6842 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0));
3853 resolveInClass(node, classA); 6843 resolveInClass(node, classA);
3854 Element element2 = node.element; 6844 Element element2 = node.element;
3855 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element2); 6845 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element2);
3856 JUnitTestCase.assertTrue(((element2 as PropertyAccessorElement)).isSetter()) ; 6846 JUnitTestCase.assertTrue(((element2 as PropertyAccessorElement)).isSetter()) ;
3857 _listener.assertNoErrors(); 6847 _listener.assertNoErrors();
3858 } 6848 }
3859 void test_visitSuperConstructorInvocation() { 6849 void test_visitSuperConstructorInvocation() {
3860 ClassElementImpl superclass = ElementFactory.classElement2("A", []); 6850 ClassElementImpl superclass = ElementFactory.classElement2("A", []);
3861 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( null); 6851 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( superclass, null);
3862 superclass.constructors = <ConstructorElement> [superConstructor]; 6852 superclass.constructors = <ConstructorElement> [superConstructor];
3863 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []); 6853 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []);
3864 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(nu ll); 6854 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su bclass, null);
3865 subclass.constructors = <ConstructorElement> [subConstructor]; 6855 subclass.constructors = <ConstructorElement> [subConstructor];
3866 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([]); 6856 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([]);
3867 resolveInClass(invocation, subclass); 6857 resolveInClass(invocation, subclass);
3868 JUnitTestCase.assertEquals(superConstructor, invocation.element); 6858 JUnitTestCase.assertEquals(superConstructor, invocation.element);
3869 _listener.assertNoErrors(); 6859 _listener.assertNoErrors();
3870 } 6860 }
3871 void test_visitSuperConstructorInvocation_namedParameter() { 6861 void test_visitSuperConstructorInvocation_namedParameter() {
3872 ClassElementImpl superclass = ElementFactory.classElement2("A", []); 6862 ClassElementImpl superclass = ElementFactory.classElement2("A", []);
3873 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( null); 6863 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( superclass, null);
3874 String parameterName = "p"; 6864 String parameterName = "p";
3875 ParameterElement parameter = ElementFactory.namedParameter(parameterName); 6865 ParameterElement parameter = ElementFactory.namedParameter(parameterName);
3876 superConstructor.parameters = <ParameterElement> [parameter]; 6866 superConstructor.parameters = <ParameterElement> [parameter];
3877 superclass.constructors = <ConstructorElement> [superConstructor]; 6867 superclass.constructors = <ConstructorElement> [superConstructor];
3878 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []); 6868 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []);
3879 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(nu ll); 6869 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(su bclass, null);
3880 subclass.constructors = <ConstructorElement> [subConstructor]; 6870 subclass.constructors = <ConstructorElement> [subConstructor];
3881 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]); 6871 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([ASTFactory.namedExpression2(parameterName, ASTFactory.integer(0))]);
3882 resolveInClass(invocation, subclass); 6872 resolveInClass(invocation, subclass);
3883 JUnitTestCase.assertEquals(superConstructor, invocation.element); 6873 JUnitTestCase.assertEquals(superConstructor, invocation.element);
3884 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a s NamedExpression)).name.label.element); 6874 JUnitTestCase.assertSame(parameter, ((invocation.argumentList.arguments[0] a s NamedExpression)).name.label.element);
3885 _listener.assertNoErrors(); 6875 _listener.assertNoErrors();
3886 } 6876 }
6877
3887 /** 6878 /**
3888 * Create the resolver used by the tests. 6879 * Create the resolver used by the tests.
3889 * @return the resolver that was created 6880 * @return the resolver that was created
3890 */ 6881 */
3891 ElementResolver createResolver() { 6882 ElementResolver createResolver() {
3892 AnalysisContextImpl context = new AnalysisContextImpl(); 6883 AnalysisContextImpl context = new AnalysisContextImpl();
3893 ContentCache contentCache = new ContentCache(); 6884 ContentCache contentCache = new ContentCache();
3894 SourceFactory sourceFactory = new SourceFactory.con1(contentCache, [new Dart UriResolver(DirectoryBasedDartSdk.defaultSdk)]); 6885 SourceFactory sourceFactory = new SourceFactory.con1(contentCache, [new Dart UriResolver(DirectoryBasedDartSdk.defaultSdk)]);
3895 context.sourceFactory = sourceFactory; 6886 context.sourceFactory = sourceFactory;
3896 FileBasedSource source = new FileBasedSource.con1(contentCache, FileUtilitie s2.createFile("/test.dart")); 6887 FileBasedSource source = new FileBasedSource.con1(contentCache, FileUtilitie s2.createFile("/test.dart"));
3897 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart"); 6888 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart");
3898 definingCompilationUnit.source = source; 6889 definingCompilationUnit.source = source;
3899 _definingLibrary = ElementFactory.library(context, "test"); 6890 _definingLibrary = ElementFactory.library(context, "test");
3900 _definingLibrary.definingCompilationUnit = definingCompilationUnit; 6891 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
3901 Library library = new Library(context, _listener, source); 6892 Library library = new Library(context, _listener, source);
3902 library.libraryElement = _definingLibrary; 6893 library.libraryElement = _definingLibrary;
3903 _visitor = new ResolverVisitor.con1(library, source, _typeProvider); 6894 _visitor = new ResolverVisitor.con1(library, source, _typeProvider);
3904 try { 6895 try {
3905 return _visitor.elementResolver_J2DAccessor as ElementResolver; 6896 return _visitor.elementResolver_J2DAccessor as ElementResolver;
3906 } catch (exception) { 6897 } catch (exception) {
3907 throw new IllegalArgumentException("Could not create resolver", exception) ; 6898 throw new IllegalArgumentException("Could not create resolver", exception) ;
3908 } 6899 }
3909 } 6900 }
6901
3910 /** 6902 /**
3911 * Return the element associated with the label of the given statement after t he resolver has 6903 * Return the element associated with the label of the given statement after t he resolver has
3912 * resolved the statement. 6904 * resolved the statement.
3913 * @param statement the statement to be resolved 6905 * @param statement the statement to be resolved
3914 * @param labelElement the label element to be defined in the statement's labe l scope 6906 * @param labelElement the label element to be defined in the statement's labe l scope
3915 * @return the element to which the statement's label was resolved 6907 * @return the element to which the statement's label was resolved
3916 */ 6908 */
3917 Element resolve(BreakStatement statement, LabelElementImpl labelElement) { 6909 Element resolve(BreakStatement statement, LabelElementImpl labelElement) {
3918 resolveStatement(statement, labelElement); 6910 resolveStatement(statement, labelElement);
3919 return statement.label.element; 6911 return statement.label.element;
3920 } 6912 }
6913
3921 /** 6914 /**
3922 * Return the element associated with the label of the given statement after t he resolver has 6915 * Return the element associated with the label of the given statement after t he resolver has
3923 * resolved the statement. 6916 * resolved the statement.
3924 * @param statement the statement to be resolved 6917 * @param statement the statement to be resolved
3925 * @param labelElement the label element to be defined in the statement's labe l scope 6918 * @param labelElement the label element to be defined in the statement's labe l scope
3926 * @return the element to which the statement's label was resolved 6919 * @return the element to which the statement's label was resolved
3927 */ 6920 */
3928 Element resolve3(ContinueStatement statement, LabelElementImpl labelElement) { 6921 Element resolve3(ContinueStatement statement, LabelElementImpl labelElement) {
3929 resolveStatement(statement, labelElement); 6922 resolveStatement(statement, labelElement);
3930 return statement.label.element; 6923 return statement.label.element;
3931 } 6924 }
6925
3932 /** 6926 /**
3933 * Return the element associated with the given identifier after the resolver has resolved the 6927 * Return the element associated with the given identifier after the resolver has resolved the
3934 * identifier. 6928 * identifier.
3935 * @param node the expression to be resolved 6929 * @param node the expression to be resolved
3936 * @param definedElements the elements that are to be defined in the scope in which the element is 6930 * @param definedElements the elements that are to be defined in the scope in which the element is
3937 * being resolved 6931 * being resolved
3938 * @return the element to which the expression was resolved 6932 * @return the element to which the expression was resolved
3939 */ 6933 */
3940 Element resolve4(Identifier node, List<Element> definedElements) { 6934 Element resolve4(Identifier node, List<Element> definedElements) {
3941 resolveNode(node, definedElements); 6935 resolveNode(node, definedElements);
3942 return node.element; 6936 return node.element;
3943 } 6937 }
6938
3944 /** 6939 /**
3945 * Return the element associated with the given expression after the resolver has resolved the 6940 * Return the element associated with the given expression after the resolver has resolved the
3946 * expression. 6941 * expression.
3947 * @param node the expression to be resolved 6942 * @param node the expression to be resolved
3948 * @param definedElements the elements that are to be defined in the scope in which the element is 6943 * @param definedElements the elements that are to be defined in the scope in which the element is
3949 * being resolved 6944 * being resolved
3950 * @return the element to which the expression was resolved 6945 * @return the element to which the expression was resolved
3951 */ 6946 */
3952 Element resolve5(IndexExpression node, List<Element> definedElements) { 6947 Element resolve5(IndexExpression node, List<Element> definedElements) {
3953 resolveNode(node, definedElements); 6948 resolveNode(node, definedElements);
3954 return node.element; 6949 return node.element;
3955 } 6950 }
6951
3956 /** 6952 /**
3957 * Return the element associated with the given identifier after the resolver has resolved the 6953 * Return the element associated with the given identifier after the resolver has resolved the
3958 * identifier. 6954 * identifier.
3959 * @param node the expression to be resolved 6955 * @param node the expression to be resolved
3960 * @param enclosingClass the element representing the class enclosing the iden tifier 6956 * @param enclosingClass the element representing the class enclosing the iden tifier
3961 * @return the element to which the expression was resolved 6957 * @return the element to which the expression was resolved
3962 */ 6958 */
3963 void resolveInClass(ASTNode node, ClassElement enclosingClass) { 6959 void resolveInClass(ASTNode node, ClassElement enclosingClass) {
3964 try { 6960 try {
3965 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope; 6961 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
3966 try { 6962 try {
3967 _visitor.enclosingClass_J2DAccessor = enclosingClass; 6963 _visitor.enclosingClass_J2DAccessor = enclosingClass;
3968 EnclosedScope innerScope = new ClassScope(outerScope, enclosingClass); 6964 EnclosedScope innerScope = new ClassScope(outerScope, enclosingClass);
3969 _visitor.nameScope_J2DAccessor = innerScope; 6965 _visitor.nameScope_J2DAccessor = innerScope;
3970 node.accept(_resolver); 6966 node.accept(_resolver);
3971 } finally { 6967 } finally {
3972 _visitor.enclosingClass_J2DAccessor = null; 6968 _visitor.enclosingClass_J2DAccessor = null;
3973 _visitor.nameScope_J2DAccessor = outerScope; 6969 _visitor.nameScope_J2DAccessor = outerScope;
3974 } 6970 }
3975 } catch (exception) { 6971 } catch (exception) {
3976 throw new IllegalArgumentException("Could not resolve node", exception); 6972 throw new IllegalArgumentException("Could not resolve node", exception);
3977 } 6973 }
3978 } 6974 }
6975
3979 /** 6976 /**
3980 * Return the element associated with the given identifier after the resolver has resolved the 6977 * Return the element associated with the given identifier after the resolver has resolved the
3981 * identifier. 6978 * identifier.
3982 * @param node the expression to be resolved 6979 * @param node the expression to be resolved
3983 * @param definedElements the elements that are to be defined in the scope in which the element is 6980 * @param definedElements the elements that are to be defined in the scope in which the element is
3984 * being resolved 6981 * being resolved
3985 * @return the element to which the expression was resolved 6982 * @return the element to which the expression was resolved
3986 */ 6983 */
3987 void resolveNode(ASTNode node, List<Element> definedElements) { 6984 void resolveNode(ASTNode node, List<Element> definedElements) {
3988 try { 6985 try {
3989 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope; 6986 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
3990 try { 6987 try {
3991 EnclosedScope innerScope = new EnclosedScope(outerScope); 6988 EnclosedScope innerScope = new EnclosedScope(outerScope);
3992 for (Element element in definedElements) { 6989 for (Element element in definedElements) {
3993 innerScope.define(element); 6990 innerScope.define(element);
3994 } 6991 }
3995 _visitor.nameScope_J2DAccessor = innerScope; 6992 _visitor.nameScope_J2DAccessor = innerScope;
3996 node.accept(_resolver); 6993 node.accept(_resolver);
3997 } finally { 6994 } finally {
3998 _visitor.nameScope_J2DAccessor = outerScope; 6995 _visitor.nameScope_J2DAccessor = outerScope;
3999 } 6996 }
4000 } catch (exception) { 6997 } catch (exception) {
4001 throw new IllegalArgumentException("Could not resolve node", exception); 6998 throw new IllegalArgumentException("Could not resolve node", exception);
4002 } 6999 }
4003 } 7000 }
7001
4004 /** 7002 /**
4005 * Return the element associated with the label of the given statement after t he resolver has 7003 * Return the element associated with the label of the given statement after t he resolver has
4006 * resolved the statement. 7004 * resolved the statement.
4007 * @param statement the statement to be resolved 7005 * @param statement the statement to be resolved
4008 * @param labelElement the label element to be defined in the statement's labe l scope 7006 * @param labelElement the label element to be defined in the statement's labe l scope
4009 * @return the element to which the statement's label was resolved 7007 * @return the element to which the statement's label was resolved
4010 */ 7008 */
4011 void resolveStatement(Statement statement, LabelElementImpl labelElement) { 7009 void resolveStatement(Statement statement, LabelElementImpl labelElement) {
4012 try { 7010 try {
4013 LabelScope outerScope = _visitor.labelScope_J2DAccessor as LabelScope; 7011 LabelScope outerScope = _visitor.labelScope_J2DAccessor as LabelScope;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
4244 runJUnitTest(__test, __test.test_getType_noOverride); 7242 runJUnitTest(__test, __test.test_getType_noOverride);
4245 }); 7243 });
4246 _ut.test('test_getType_noScope', () { 7244 _ut.test('test_getType_noScope', () {
4247 final __test = new TypeOverrideManagerTest(); 7245 final __test = new TypeOverrideManagerTest();
4248 runJUnitTest(__test, __test.test_getType_noScope); 7246 runJUnitTest(__test, __test.test_getType_noScope);
4249 }); 7247 });
4250 }); 7248 });
4251 } 7249 }
4252 } 7250 }
4253 class StaticWarningCodeTest extends ResolverTestCase { 7251 class StaticWarningCodeTest extends ResolverTestCase {
4254 void fail_argumentTypeNotAssignable() { 7252 void fail_argumentTypeNotAssignable_invocation_functionParameter_generic() {
4255 Source source = addSource(EngineTestCase.createSource([])); 7253 Source source = addSource(EngineTestCase.createSource(["class A<K, V> {", " m(f(K k), V v) {", " f(v);", " }", "}"]));
4256 resolve(source, []); 7254 resolve(source);
4257 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 7255 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
4258 verify([source]);
4259 }
4260 void fail_assignmentToFinal() {
4261 Source source = addSource(EngineTestCase.createSource(["final x = 0;", "f() { x = 1; }"]));
4262 resolve(source, []);
4263 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
4264 verify([source]);
4265 }
4266 void fail_caseBlockNotTerminated() {
4267 Source source = addSource(EngineTestCase.createSource(["f(int p) {", " swit ch (p) {", " case 0:", " f(p);", " case 1:", " break;", " }", " }"]));
4268 resolve(source, []);
4269 assertErrors([StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
4270 verify([source]); 7256 verify([source]);
4271 } 7257 }
4272 void fail_castToNonType() { 7258 void fail_castToNonType() {
4273 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri ng s) { var x = s as A; }"])); 7259 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri ng s) { var x = s as A; }"]));
4274 resolve(source, []); 7260 resolve(source);
4275 assertErrors([StaticWarningCode.CAST_TO_NON_TYPE]); 7261 assertErrors([StaticWarningCode.CAST_TO_NON_TYPE]);
4276 verify([source]); 7262 verify([source]);
4277 } 7263 }
4278 void fail_commentReferenceConstructorNotVisible() { 7264 void fail_commentReferenceConstructorNotVisible() {
4279 Source source = addSource(EngineTestCase.createSource([])); 7265 Source source = addSource(EngineTestCase.createSource([]));
4280 resolve(source, []); 7266 resolve(source);
4281 assertErrors([StaticWarningCode.COMMENT_REFERENCE_CONSTRUCTOR_NOT_VISIBLE]); 7267 assertErrors([StaticWarningCode.COMMENT_REFERENCE_CONSTRUCTOR_NOT_VISIBLE]);
4282 verify([source]); 7268 verify([source]);
4283 } 7269 }
4284 void fail_commentReferenceIdentifierNotVisible() { 7270 void fail_commentReferenceIdentifierNotVisible() {
4285 Source source = addSource(EngineTestCase.createSource([])); 7271 Source source = addSource(EngineTestCase.createSource([]));
4286 resolve(source, []); 7272 resolve(source);
4287 assertErrors([StaticWarningCode.COMMENT_REFERENCE_IDENTIFIER_NOT_VISIBLE]); 7273 assertErrors([StaticWarningCode.COMMENT_REFERENCE_IDENTIFIER_NOT_VISIBLE]);
4288 verify([source]); 7274 verify([source]);
4289 } 7275 }
4290 void fail_commentReferenceUndeclaredConstructor() { 7276 void fail_commentReferenceUndeclaredConstructor() {
4291 Source source = addSource(EngineTestCase.createSource([])); 7277 Source source = addSource(EngineTestCase.createSource([]));
4292 resolve(source, []); 7278 resolve(source);
4293 assertErrors([StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_CONSTRUCTOR]); 7279 assertErrors([StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_CONSTRUCTOR]);
4294 verify([source]); 7280 verify([source]);
4295 } 7281 }
4296 void fail_commentReferenceUndeclaredIdentifier() { 7282 void fail_commentReferenceUndeclaredIdentifier() {
4297 Source source = addSource(EngineTestCase.createSource([])); 7283 Source source = addSource(EngineTestCase.createSource([]));
4298 resolve(source, []); 7284 resolve(source);
4299 assertErrors([StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_IDENTIFIER]); 7285 assertErrors([StaticWarningCode.COMMENT_REFERENCE_UNDECLARED_IDENTIFIER]);
4300 verify([source]); 7286 verify([source]);
4301 } 7287 }
4302 void fail_commentReferenceUriNotLibrary() { 7288 void fail_commentReferenceUriNotLibrary() {
4303 Source source = addSource(EngineTestCase.createSource([])); 7289 Source source = addSource(EngineTestCase.createSource([]));
4304 resolve(source, []); 7290 resolve(source);
4305 assertErrors([StaticWarningCode.COMMENT_REFERENCE_URI_NOT_LIBRARY]); 7291 assertErrors([StaticWarningCode.COMMENT_REFERENCE_URI_NOT_LIBRARY]);
4306 verify([source]); 7292 verify([source]);
4307 } 7293 }
4308 void fail_conflictingInstanceGetterAndSuperclassMember() {
4309 Source source = addSource(EngineTestCase.createSource([]));
4310 resolve(source, []);
4311 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M EMBER]);
4312 verify([source]);
4313 }
4314 void fail_conflictingInstanceSetterAndSuperclassMember() {
4315 Source source = addSource(EngineTestCase.createSource([]));
4316 resolve(source, []);
4317 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_M EMBER]);
4318 verify([source]);
4319 }
4320 void fail_conflictingStaticGetterAndInstanceSetter() {
4321 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c get x -> 0;", " set x(int p) {}", "}"]));
4322 resolve(source, []);
4323 assertErrors([StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTE R]);
4324 verify([source]);
4325 }
4326 void fail_conflictingStaticSetterAndInstanceGetter() {
4327 Source source = addSource(EngineTestCase.createSource(["class A {", " get x -> 0;", " static set x(int p) {}", "}"]));
4328 resolve(source, []);
4329 assertErrors([StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_GETTE R]);
4330 verify([source]);
4331 }
4332 void fail_incorrectNumberOfArguments_tooFew() { 7294 void fail_incorrectNumberOfArguments_tooFew() {
4333 Source source = addSource(EngineTestCase.createSource(["f(a, b) -> 0;", "g() {", " f(2);", "}"])); 7295 Source source = addSource(EngineTestCase.createSource(["f(a, b) => 0;", "g() {", " f(2);", "}"]));
4334 resolve(source, []); 7296 resolve(source);
4335 assertErrors([StaticWarningCode.INCORRECT_NUMBER_OF_ARGUMENTS]); 7297 assertErrors([StaticWarningCode.INCORRECT_NUMBER_OF_ARGUMENTS]);
4336 verify([source]); 7298 verify([source]);
4337 } 7299 }
4338 void fail_incorrectNumberOfArguments_tooMany() { 7300 void fail_incorrectNumberOfArguments_tooMany() {
4339 Source source = addSource(EngineTestCase.createSource(["f(a, b) -> 0;", "g() {", " f(2, 3, 4);", "}"])); 7301 Source source = addSource(EngineTestCase.createSource(["f(a, b) => 0;", "g() {", " f(2, 3, 4);", "}"]));
4340 resolve(source, []); 7302 resolve(source);
4341 assertErrors([StaticWarningCode.INCORRECT_NUMBER_OF_ARGUMENTS]); 7303 assertErrors([StaticWarningCode.INCORRECT_NUMBER_OF_ARGUMENTS]);
4342 verify([source]); 7304 verify([source]);
4343 } 7305 }
4344 void fail_instanceMethodNameCollidesWithSuperclassStatic() {
4345 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c n", "}", "class C extends A {", " void n() {}", "}"]));
4346 resolve(source, []);
4347 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
4348 verify([source]);
4349 }
4350 void fail_invalidFactoryName() { 7306 void fail_invalidFactoryName() {
4351 Source source = addSource(EngineTestCase.createSource([])); 7307 Source source = addSource(EngineTestCase.createSource([]));
4352 resolve(source, []); 7308 resolve(source);
4353 assertErrors([StaticWarningCode.INVALID_FACTORY_NAME]); 7309 assertErrors([StaticWarningCode.INVALID_FACTORY_NAME]);
4354 verify([source]); 7310 verify([source]);
4355 } 7311 }
4356 void fail_invalidOverrideGetterType() { 7312 void fail_invalidOverrideDifferentDefaultValues() {
4357 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g -> 0", "}", "class B extends A {", " String get g { return 'a'; }", "}"])) ; 7313 Source source = addSource(EngineTestCase.createSource(["class A {", " m([in t p = 0]) {}", "}", "class B extends A {", " m([int p = 1]) {}", "}"]));
4358 resolve(source, []); 7314 resolve(source);
4359 assertErrors([StaticWarningCode.INVALID_OVERRIDE_GETTER_TYPE]); 7315 assertErrors([StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES]);
4360 verify([source]);
4361 }
4362 void fail_invalidOverrideReturnType() {
4363 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () { return 0; }", "}", "class B extends A {", " String m() { return 'a'; }", " }"]));
4364 resolve(source, []);
4365 assertErrors([StaticWarningCode.INVALID_OVERRIDE_RETURN_TYPE]);
4366 verify([source]);
4367 }
4368 void fail_invalidOverrideSetterReturnType() {
4369 Source source = addSource(EngineTestCase.createSource(["class A {", " void set s(int v) {}", "}", "class B extends A {", " void set s(String v) {}", "}"]) );
4370 resolve(source, []);
4371 assertErrors([StaticWarningCode.INVALID_OVERRIDE_SETTER_RETURN_TYPE]);
4372 verify([source]); 7316 verify([source]);
4373 } 7317 }
4374 void fail_invocationOfNonFunction() { 7318 void fail_invocationOfNonFunction() {
4375 Source source = addSource(EngineTestCase.createSource([])); 7319 Source source = addSource(EngineTestCase.createSource([]));
4376 resolve(source, []); 7320 resolve(source);
4377 assertErrors([StaticWarningCode.INVOCATION_OF_NON_FUNCTION]); 7321 assertErrors([StaticWarningCode.INVOCATION_OF_NON_FUNCTION]);
4378 verify([source]); 7322 verify([source]);
4379 } 7323 }
4380 void fail_mismatchedGetterAndSetterTypes() { 7324 void fail_mismatchedAccessorTypes_getterAndSuperSetter() {
4381 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", " set g(String v) {}", "}"])); 7325 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", " set g(int v) {}", "}", "class B extends A {", " set g(S tring v) {}", "}"]));
4382 resolve(source, []); 7326 resolve(source);
4383 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); 7327 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
4384 verify([source]); 7328 verify([source]);
4385 } 7329 }
4386 void fail_newWithNonType() { 7330 void fail_mismatchedAccessorTypes_superGetterAndSetter() {
4387 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f () {", " A a = new A();", "}"])); 7331 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", " set g(int v) {}", "}", "class B extends A {", " String get g { return ''; }", "}"]));
4388 resolve(source, []); 7332 resolve(source);
4389 assertErrors([StaticWarningCode.NEW_WITH_NON_TYPE]); 7333 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
4390 verify([source]);
4391 }
4392 void fail_newWithUndefinedConstructor() {
4393 Source source = addSource(EngineTestCase.createSource(["class A {", " A(int p) {}", "}", "A f() {", " return new A();", "}"]));
4394 resolve(source, []);
4395 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]);
4396 verify([source]);
4397 }
4398 void fail_nonAbstractClassInheritsAbstractMember() {
4399 Source source = addSource(EngineTestCase.createSource(["class I {", " m(p) {}", "}", "class C implements I {", "}"]));
4400 resolve(source, []);
4401 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER] );
4402 verify([source]);
4403 }
4404 void fail_nonAbstractClassInheritsAbstractMethod() {
4405 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m(p);", "}", "class C extends A {", "}"]));
4406 resolve(source, []);
4407 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_METHOD] );
4408 verify([source]); 7334 verify([source]);
4409 } 7335 }
4410 void fail_nonType() { 7336 void fail_nonType() {
4411 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(var p) {", " if (p is A) {", " }", "}"])); 7337 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(var p) {", " if (p is A) {", " }", "}"]));
4412 resolve(source, []); 7338 resolve(source);
4413 assertErrors([StaticWarningCode.NON_TYPE]); 7339 assertErrors([StaticWarningCode.NON_TYPE]);
4414 verify([source]); 7340 verify([source]);
4415 } 7341 }
4416 void fail_nonTypeInCatchClause() {
4417 Source source = addSource(EngineTestCase.createSource(["var T = 0;", "f(var p) {", " try {", " } on T catch e {", " }", "}"]));
4418 resolve(source, []);
4419 assertErrors([StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
4420 verify([source]);
4421 }
4422 void fail_nonVoidReturnForOperator() {
4423 Source source = addSource(EngineTestCase.createSource(["class A {", " int o perator []=() {}", "}"]));
4424 resolve(source, []);
4425 assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]);
4426 verify([source]);
4427 }
4428 void fail_nonVoidReturnForSetter() {
4429 Source source = addSource(EngineTestCase.createSource(["int set x(int v) {", " var s = x;", " x = v;", " return s;", "}"]));
4430 resolve(source, []);
4431 assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
4432 verify([source]);
4433 }
4434 void fail_overrideNotSubtype() {
4435 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () {}", "}", "class B extends A {", " String m() {}", "}"]));
4436 resolve(source, []);
4437 assertErrors([StaticWarningCode.OVERRIDE_NOT_SUBTYPE]);
4438 verify([source]);
4439 }
4440 void fail_overrideWithDifferentDefault() {
4441 Source source = addSource(EngineTestCase.createSource(["class A {", " m([in t p = 0]) {}", "}", "class B extends A {", " m([int p = 1]) {}", "}"]));
4442 resolve(source, []);
4443 assertErrors([StaticWarningCode.OVERRIDE_WITH_DIFFERENT_DEFAULT]);
4444 verify([source]);
4445 }
4446 void fail_redirectToInvalidReturnType() {
4447 Source source = addSource(EngineTestCase.createSource([]));
4448 resolve(source, []);
4449 assertErrors([StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]);
4450 verify([source]);
4451 }
4452 void fail_redirectToMissingConstructor() { 7342 void fail_redirectToMissingConstructor() {
4453 Source source = addSource(EngineTestCase.createSource([])); 7343 Source source = addSource(EngineTestCase.createSource([]));
4454 resolve(source, []); 7344 resolve(source);
4455 assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]); 7345 assertErrors([StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR]);
4456 verify([source]); 7346 verify([source]);
4457 } 7347 }
4458 void fail_redirectToNonClass() { 7348 void fail_redirectToNonClass() {
4459 Source source = addSource(EngineTestCase.createSource([])); 7349 Source source = addSource(EngineTestCase.createSource([]));
4460 resolve(source, []); 7350 resolve(source);
4461 assertErrors([StaticWarningCode.REDIRECT_TO_NON_CLASS]); 7351 assertErrors([StaticWarningCode.REDIRECT_TO_NON_CLASS]);
4462 verify([source]); 7352 verify([source]);
4463 } 7353 }
4464 void fail_switchExpressionNotAssignable() {
4465 Source source = addSource(EngineTestCase.createSource(["f(int p) {", " swit ch (p) {", " case 'a': break;", " }", "}"]));
4466 resolve(source, []);
4467 assertErrors([StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]);
4468 verify([source]);
4469 }
4470 void fail_undefinedGetter() { 7354 void fail_undefinedGetter() {
4471 Source source = addSource(EngineTestCase.createSource([])); 7355 Source source = addSource(EngineTestCase.createSource([]));
4472 resolve(source, []); 7356 resolve(source);
4473 assertErrors([StaticWarningCode.UNDEFINED_GETTER]); 7357 assertErrors([StaticWarningCode.UNDEFINED_GETTER]);
4474 verify([source]); 7358 verify([source]);
4475 } 7359 }
7360 void fail_undefinedIdentifier_commentReference() {
7361 Source source = addSource(EngineTestCase.createSource(["/** [m] xxx [new B.c ] */", "class A {", "}"]));
7362 resolve(source);
7363 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER, StaticWarningCode.UNDE FINED_IDENTIFIER]);
7364 }
4476 void fail_undefinedIdentifier_function() { 7365 void fail_undefinedIdentifier_function() {
4477 Source source = addSource(EngineTestCase.createSource(["int a() -> b;"])); 7366 Source source = addSource(EngineTestCase.createSource(["int a() => b;"]));
4478 resolve(source, []); 7367 resolve(source);
4479 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); 7368 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
4480 verify([source]); 7369 verify([source]);
4481 } 7370 }
4482 void fail_undefinedSetter() { 7371 void fail_undefinedSetter() {
4483 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " C.m = 0;", "}"])); 7372 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " C.m = 0;", "}"]));
4484 resolve(source, []); 7373 resolve(source);
4485 assertErrors([StaticWarningCode.UNDEFINED_SETTER]); 7374 assertErrors([StaticWarningCode.UNDEFINED_SETTER]);
4486 verify([source]); 7375 verify([source]);
4487 } 7376 }
4488 void fail_undefinedStaticMethodOrGetter_getter() { 7377 void fail_undefinedStaticMethodOrGetter_getter() {
4489 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m);", "}"])); 7378 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m);", "}"]));
4490 resolve(source, []); 7379 resolve(source);
4491 assertErrors([StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]); 7380 assertErrors([StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]);
4492 verify([source]); 7381 verify([source]);
4493 } 7382 }
4494 void fail_undefinedStaticMethodOrGetter_method() { 7383 void fail_undefinedStaticMethodOrGetter_method() {
4495 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m());", "}"])); 7384 Source source = addSource(EngineTestCase.createSource(["class C {}", "f(var p) {", " f(C.m());", "}"]));
4496 resolve(source, []); 7385 resolve(source);
4497 assertErrors([StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]); 7386 assertErrors([StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER]);
4498 verify([source]); 7387 verify([source]);
4499 } 7388 }
7389 void test_ambiguousImport_typeAnnotation() {
7390 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "typedef N FT(N p);", "N f(N p) {", " N v;", "}", "cla ss A {", " N m() {}", "}", "class B<T extends N> {}"]));
7391 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
7392 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
7393 resolve(source);
7394 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOU S_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT , StaticWarningCode.AMBIGUOUS_IMPORT, StaticWarningCode.AMBIGUOUS_IMPORT, Static WarningCode.AMBIGUOUS_IMPORT]);
7395 }
7396 void test_ambiguousImport_typeArgument_annotation() {
7397 Source source = addSource(EngineTestCase.createSource(["import 'lib1.dart';" , "import 'lib2.dart';", "class A<T> {}", "A<N> f() {}"]));
7398 addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "clas s N {}"]));
7399 addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "clas s N {}"]));
7400 resolve(source);
7401 assertErrors([StaticWarningCode.AMBIGUOUS_IMPORT]);
7402 }
7403 void test_argumentTypeNotAssignable_binary() {
7404 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor +(int p) {}", "}", "f(A a) {", " a + '0';", "}"]));
7405 resolve(source);
7406 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7407 verify([source]);
7408 }
7409 void test_argumentTypeNotAssignable_index() {
7410 Source source = addSource(EngineTestCase.createSource(["class A {", " opera tor [](int index) {}", "}", "f(A a) {", " a['0'];", "}"]));
7411 resolve(source);
7412 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7413 verify([source]);
7414 }
7415 void test_argumentTypeNotAssignable_invocation_callParameter() {
7416 Source source = addSource(EngineTestCase.createSource(["class A {", " call( int p) {}", "}", "f(A a) {", " a('0');", "}"]));
7417 resolve(source);
7418 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7419 verify([source]);
7420 }
7421 void test_argumentTypeNotAssignable_invocation_callVariable() {
7422 Source source = addSource(EngineTestCase.createSource(["class A {", " call( int p) {}", "}", "main() {", " A a = new A();", " a('0');", "}"]));
7423 resolve(source);
7424 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7425 verify([source]);
7426 }
7427 void test_argumentTypeNotAssignable_invocation_functionParameter() {
7428 Source source = addSource(EngineTestCase.createSource(["a(b(int p)) {", " b ('0');", "}"]));
7429 resolve(source);
7430 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7431 verify([source]);
7432 }
7433 void test_argumentTypeNotAssignable_invocation_generic() {
7434 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " m( T t) {}", "}", "f(A<String> a) {", " a.m(1);", "}"]));
7435 resolve(source);
7436 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7437 verify([source]);
7438 }
7439 void test_argumentTypeNotAssignable_invocation_named() {
7440 Source source = addSource(EngineTestCase.createSource(["f({String p}) {}", " main() {", " f(p: 42);", "}"]));
7441 resolve(source);
7442 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7443 verify([source]);
7444 }
7445 void test_argumentTypeNotAssignable_invocation_optional() {
7446 Source source = addSource(EngineTestCase.createSource(["f([String p]) {}", " main() {", " f(42);", "}"]));
7447 resolve(source);
7448 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7449 verify([source]);
7450 }
7451 void test_argumentTypeNotAssignable_invocation_required() {
7452 Source source = addSource(EngineTestCase.createSource(["f(String p) {}", "ma in() {", " f(42);", "}"]));
7453 resolve(source);
7454 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7455 verify([source]);
7456 }
7457 void test_argumentTypeNotAssignable_invocation_typedef_generic() {
7458 Source source = addSource(EngineTestCase.createSource(["typedef A<T>(T p);", "f(A<int> a) {", " a('1');", "}"]));
7459 resolve(source);
7460 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7461 verify([source]);
7462 }
7463 void test_argumentTypeNotAssignable_invocation_typedef_local() {
7464 Source source = addSource(EngineTestCase.createSource(["typedef A(int p);", "A getA() => null;", "main() {", " A a = getA();", " a('1');", "}"]));
7465 resolve(source);
7466 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7467 verify([source]);
7468 }
7469 void test_argumentTypeNotAssignable_invocation_typedef_parameter() {
7470 Source source = addSource(EngineTestCase.createSource(["typedef A(int p);", "f(A a) {", " a('1');", "}"]));
7471 resolve(source);
7472 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7473 verify([source]);
7474 }
7475 void test_argumentTypeNotAssignable_new_generic() {
7476 Source source = addSource(EngineTestCase.createSource(["class A<T> {", " A( T p) {}", "}", "main() {", " new A<String>(42);", "}"]));
7477 resolve(source);
7478 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7479 verify([source]);
7480 }
7481 void test_argumentTypeNotAssignable_new_optional() {
7482 Source source = addSource(EngineTestCase.createSource(["class A {", " A([St ring p]) {}", "}", "main() {", " new A(42);", "}"]));
7483 resolve(source);
7484 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7485 verify([source]);
7486 }
7487 void test_argumentTypeNotAssignable_new_required() {
7488 Source source = addSource(EngineTestCase.createSource(["class A {", " A(Str ing p) {}", "}", "main() {", " new A(42);", "}"]));
7489 resolve(source);
7490 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7491 verify([source]);
7492 }
7493 void test_assignmentToFinal_instanceVariable() {
7494 Source source = addSource(EngineTestCase.createSource(["class A {", " final v = 0;", "}", "f() {", " A a = new A();", " a.v = 1;", "}"]));
7495 resolve(source);
7496 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
7497 verify([source]);
7498 }
7499 void test_assignmentToFinal_localVariable() {
7500 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " x = 1;", "}"]));
7501 resolve(source);
7502 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
7503 verify([source]);
7504 }
7505 void test_assignmentToFinal_prefixMinusMinus() {
7506 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " --x;", "}"]));
7507 resolve(source);
7508 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
7509 verify([source]);
7510 }
7511 void test_assignmentToFinal_prefixPlusPlus() {
7512 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " ++x;", "}"]));
7513 resolve(source);
7514 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
7515 verify([source]);
7516 }
7517 void test_assignmentToFinal_propertyAccess() {
7518 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et x => 0;", "}", "class B {", " static A a;", "}", "main() {", " B.a.x = 0;", "}"]));
7519 resolve(source);
7520 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
7521 verify([source]);
7522 }
7523 void test_assignmentToFinal_suffixMinusMinus() {
7524 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " x--;", "}"]));
7525 resolve(source);
7526 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
7527 verify([source]);
7528 }
7529 void test_assignmentToFinal_suffixPlusPlus() {
7530 Source source = addSource(EngineTestCase.createSource(["f() {", " final x = 0;", " x++;", "}"]));
7531 resolve(source);
7532 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
7533 verify([source]);
7534 }
7535 void test_assignmentToFinal_topLevelVariable() {
7536 Source source = addSource(EngineTestCase.createSource(["final x = 0;", "f() { x = 1; }"]));
7537 resolve(source);
7538 assertErrors([StaticWarningCode.ASSIGNMENT_TO_FINAL]);
7539 verify([source]);
7540 }
7541 void test_caseBlockNotTerminated() {
7542 Source source = addSource(EngineTestCase.createSource(["f(int p) {", " swit ch (p) {", " case 0:", " f(p);", " case 1:", " break;", " }", " }"]));
7543 resolve(source);
7544 assertErrors([StaticWarningCode.CASE_BLOCK_NOT_TERMINATED]);
7545 verify([source]);
7546 }
4500 void test_concreteClassWithAbstractMember() { 7547 void test_concreteClassWithAbstractMember() {
4501 Source source = addSource(EngineTestCase.createSource(["class A {", " m();" , "}"])); 7548 Source source = addSource(EngineTestCase.createSource(["class A {", " m();" , "}"]));
4502 resolve(source, []); 7549 resolve(source);
4503 assertErrors([StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]); 7550 assertErrors([StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
4504 verify([source]); 7551 verify([source]);
4505 } 7552 }
7553 void test_conflictingInstanceGetterAndSuperclassMember_direct_field() {
7554 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int v;", "}", "class B extends A {", " get v => 0;", "}"]));
7555 resolve(source);
7556 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M EMBER]);
7557 verify([source]);
7558 }
7559 void test_conflictingInstanceGetterAndSuperclassMember_direct_getter() {
7560 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c get v => 0;", "}", "class B extends A {", " get v => 0;", "}"]));
7561 resolve(source);
7562 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M EMBER]);
7563 verify([source]);
7564 }
7565 void test_conflictingInstanceGetterAndSuperclassMember_direct_method() {
7566 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c v() {}", "}", "class B extends A {", " get v => 0;", "}"]));
7567 resolve(source);
7568 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M EMBER]);
7569 verify([source]);
7570 }
7571 void test_conflictingInstanceGetterAndSuperclassMember_direct_setter() {
7572 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c set v(x) {}", "}", "class B extends A {", " get v => 0;", "}"]));
7573 resolve(source);
7574 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M EMBER]);
7575 verify([source]);
7576 }
7577 void test_conflictingInstanceGetterAndSuperclassMember_indirect() {
7578 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int v;", "}", "class B extends A {}", "class C extends B {", " get v => 0;", "}"]));
7579 resolve(source);
7580 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M EMBER]);
7581 verify([source]);
7582 }
7583 void test_conflictingInstanceGetterAndSuperclassMember_mixin() {
7584 Source source = addSource(EngineTestCase.createSource(["class M {", " stati c int v;", "}", "class B extends Object with M {", " get v => 0;", "}"]));
7585 resolve(source);
7586 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_M EMBER]);
7587 verify([source]);
7588 }
7589 void test_conflictingInstanceSetterAndSuperclassMember() {
7590 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int v;", "}", "class B extends A {", " set v(x) {}", "}"]));
7591 resolve(source);
7592 assertErrors([StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_M EMBER]);
7593 verify([source]);
7594 }
7595 void test_conflictingStaticGetterAndInstanceSetter_mixin() {
7596 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (int p) {}", "}", "class B extends Object with A {", " static get x => 0;", "}" ]));
7597 resolve(source);
7598 assertErrors([StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTE R]);
7599 verify([source]);
7600 }
7601 void test_conflictingStaticGetterAndInstanceSetter_superClass() {
7602 Source source = addSource(EngineTestCase.createSource(["class A {", " set x (int p) {}", "}", "class B extends A {", " static get x => 0;", "}"]));
7603 resolve(source);
7604 assertErrors([StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTE R]);
7605 verify([source]);
7606 }
7607 void test_conflictingStaticGetterAndInstanceSetter_thisClass() {
7608 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c get x => 0;", " set x(int p) {}", "}"]));
7609 resolve(source);
7610 assertErrors([StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTE R]);
7611 verify([source]);
7612 }
7613 void test_conflictingStaticSetterAndInstanceMember_thisClass_getter() {
7614 Source source = addSource(EngineTestCase.createSource(["class A {", " get x => 0;", " static set x(int p) {}", "}"]));
7615 resolve(source);
7616 assertErrors([StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBE R]);
7617 verify([source]);
7618 }
7619 void test_conflictingStaticSetterAndInstanceMember_thisClass_method() {
7620 Source source = addSource(EngineTestCase.createSource(["class A {", " x() { }", " static set x(int p) {}", "}"]));
7621 resolve(source);
7622 assertErrors([StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBE R]);
7623 verify([source]);
7624 }
4506 void test_constWithAbstractClass() { 7625 void test_constWithAbstractClass() {
4507 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " const A() {}", "}", "void f() {", " A a = const A();", "}"])); 7626 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " const A();", "}", "void f() {", " A a = const A();", "}"]));
4508 resolve(source, []); 7627 resolve(source);
4509 assertErrors([StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]); 7628 assertErrors([StaticWarningCode.CONST_WITH_ABSTRACT_CLASS]);
4510 verify([source]); 7629 verify([source]);
4511 } 7630 }
4512 void test_equalKeysInMap() { 7631 void test_equalKeysInMap() {
4513 Source source = addSource(EngineTestCase.createSource(["var m = {'a' : 0, 'b ' : 1, 'a' : 2};"])); 7632 Source source = addSource(EngineTestCase.createSource(["var m = {'a' : 0, 'b ' : 1, 'a' : 2};"]));
4514 resolve(source, []); 7633 resolve(source);
4515 assertErrors([StaticWarningCode.EQUAL_KEYS_IN_MAP]); 7634 assertErrors([StaticWarningCode.EQUAL_KEYS_IN_MAP]);
4516 verify([source]); 7635 verify([source]);
4517 } 7636 }
4518 void test_fieldInitializerWithInvalidType() { 7637 void test_exportDuplicatedLibraryName() {
7638 Source source = addSource(EngineTestCase.createSource(["library test;", "exp ort 'lib1.dart';", "export 'lib2.dart';"]));
7639 addSource2("/lib1.dart", "library lib;");
7640 addSource2("/lib2.dart", "library lib;");
7641 resolve(source);
7642 assertErrors([StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAME]);
7643 verify([source]);
7644 }
7645 void test_extraPositionalArguments() {
7646 Source source = addSource(EngineTestCase.createSource(["f() {}", "main() {", " f(0, 1, '2');", "}"]));
7647 resolve(source);
7648 assertErrors([StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS]);
7649 verify([source]);
7650 }
7651 void test_fieldInitializerNotAssignable() {
7652 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A() : x = '';", "}"]));
7653 resolve(source);
7654 assertErrors([StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE]);
7655 verify([source]);
7656 }
7657 void test_fieldInitializingFormalNotAssignable() {
4519 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(String this.x) {}", "}"])); 7658 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(String this.x) {}", "}"]));
4520 resolve(source, []); 7659 resolve(source);
4521 assertErrors([StaticWarningCode.FIELD_INITIALIZER_WITH_INVALID_TYPE]); 7660 assertErrors([StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE]);
7661 verify([source]);
7662 }
7663 void test_importDuplicatedLibraryName() {
7664 Source source = addSource(EngineTestCase.createSource(["library test;", "imp ort 'lib1.dart';", "import 'lib2.dart';"]));
7665 addSource2("/lib1.dart", "library lib;");
7666 addSource2("/lib2.dart", "library lib;");
7667 resolve(source);
7668 assertErrors([StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAME]);
7669 verify([source]);
7670 }
7671 void test_inconsistentMethodInheritance() {
7672 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " x(int i);", "}", "abstract class B {", " x(String s);", "}", "abstract clas s C implements A, B {}"]));
7673 resolve(source);
7674 assertErrors([StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE]);
7675 verify([source]);
7676 }
7677 void test_instanceMethodNameCollidesWithSuperclassStatic_field() {
7678 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c var n;", "}", "class B extends A {", " void n() {}", "}"]));
7679 resolve(source);
7680 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
7681 verify([source]);
7682 }
7683 void test_instanceMethodNameCollidesWithSuperclassStatic_field2() {
7684 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c var n;", "}", "class B extends A {", "}", "class C extends B {", " void n() { }", "}"]));
7685 resolve(source);
7686 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
7687 verify([source]);
7688 }
7689 void test_instanceMethodNameCollidesWithSuperclassStatic_getter() {
7690 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c get n {return 0;}", "}", "class B extends A {", " void n() {}", "}"]));
7691 resolve(source);
7692 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
7693 verify([source]);
7694 }
7695 void test_instanceMethodNameCollidesWithSuperclassStatic_getter2() {
7696 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c get n {return 0;}", "}", "class B extends A {", "}", "class C extends B {", " void n() {}", "}"]));
7697 resolve(source);
7698 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
7699 verify([source]);
7700 }
7701 void test_instanceMethodNameCollidesWithSuperclassStatic_method() {
7702 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c n () {}", "}", "class B extends A {", " void n() {}", "}"]));
7703 resolve(source);
7704 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
7705 verify([source]);
7706 }
7707 void test_instanceMethodNameCollidesWithSuperclassStatic_method2() {
7708 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c n () {}", "}", "class B extends A {", "}", "class C extends B {", " void n() {}", "}"]));
7709 resolve(source);
7710 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
7711 verify([source]);
7712 }
7713 void test_instanceMethodNameCollidesWithSuperclassStatic_setter() {
7714 Source source = addSource(EngineTestCase.createSource(["class A {", " int i = 0;", " static set n(int x) {i = x;}", "}", "class B extends A {", " void n( ) {}", "}"]));
7715 resolve(source);
7716 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
7717 verify([source]);
7718 }
7719 void test_instanceMethodNameCollidesWithSuperclassStatic_setter2() {
7720 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() {}", "}"]));
7721 resolve(source);
7722 assertErrors([StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLAS S_STATIC]);
7723 verify([source]);
7724 }
7725 void test_invalidGetterOverrideReturnType() {
7726 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", "}", "class B extends A {", " String get g { return 'a'; } ", "}"]));
7727 resolve(source);
7728 assertErrors([StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE]);
7729 verify([source]);
7730 }
7731 void test_invalidMethodOverrideNamedParamType() {
7732 Source source = addSource(EngineTestCase.createSource(["class A {", " m({in t a}) {}", "}", "class B implements A {", " m({String a}) {}", "}"]));
7733 resolve(source);
7734 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE]);
7735 verify([source]);
7736 }
7737 void test_invalidMethodOverrideNormalParamType() {
7738 Source source = addSource(EngineTestCase.createSource(["class A {", " m(int a) {}", "}", "class B implements A {", " m(String a) {}", "}"]));
7739 resolve(source);
7740 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE]);
7741 verify([source]);
7742 }
7743 void test_invalidMethodOverrideOptionalParamType() {
7744 Source source = addSource(EngineTestCase.createSource(["class A {", " m([in t a]) {}", "}", "class B implements A {", " m([String a]) {}", "}"]));
7745 resolve(source);
7746 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE] );
7747 verify([source]);
7748 }
7749 void test_invalidMethodOverrideReturnType_interface() {
7750 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () { return 0; }", "}", "class B implements A {", " String m() { return 'a'; }" , "}"]));
7751 resolve(source);
7752 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
7753 verify([source]);
7754 }
7755 void test_invalidMethodOverrideReturnType_interface2() {
7756 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " int m();", "}", "abstract class B implements A {", "}", "class C implements B {", " String m() { return 'a'; }", "}"]));
7757 resolve(source);
7758 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
7759 verify([source]);
7760 }
7761 void test_invalidMethodOverrideReturnType_mixin() {
7762 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () { return 0; }", "}", "class B extends Object with A {", " String m() { retur n 'a'; }", "}"]));
7763 resolve(source);
7764 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
7765 verify([source]);
7766 }
7767 void test_invalidMethodOverrideReturnType_superclass() {
7768 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () { return 0; }", "}", "class B extends A {", " String m() { return 'a'; }", " }"]));
7769 resolve(source);
7770 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
7771 verify([source]);
7772 }
7773 void test_invalidMethodOverrideReturnType_superclass2() {
7774 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () { return 0; }", "}", "class B extends A {", "}", "class C extends B {", " St ring m() { return 'a'; }", "}"]));
7775 resolve(source);
7776 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
7777 verify([source]);
7778 }
7779 void test_invalidMethodOverrideReturnType_void() {
7780 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () {}", "}", "class B extends A {", " void m() {}", "}"]));
7781 resolve(source);
7782 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
7783 verify([source]);
7784 }
7785 void test_invalidSetterOverrideNormalParamType() {
7786 Source source = addSource(EngineTestCase.createSource(["class A {", " void set s(int v) {}", "}", "class B extends A {", " void set s(String v) {}", "}"]) );
7787 resolve(source);
7788 assertErrors([StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
7789 verify([source]);
7790 }
7791 void test_mismatchedAccessorTypes_class() {
7792 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", " set g(String v) {}", "}"]));
7793 resolve(source);
7794 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
7795 verify([source]);
7796 }
7797 void test_mismatchedAccessorTypes_topLevel() {
7798 Source source = addSource(EngineTestCase.createSource(["int get g { return 0 ; }", "set g(String v) {}"]));
7799 resolve(source);
7800 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
4522 verify([source]); 7801 verify([source]);
4523 } 7802 }
4524 void test_newWithAbstractClass() { 7803 void test_newWithAbstractClass() {
4525 Source source = addSource(EngineTestCase.createSource(["abstract class A {}" , "void f() {", " A a = new A();", "}"])); 7804 Source source = addSource(EngineTestCase.createSource(["abstract class A {}" , "void f() {", " A a = new A();", "}"]));
4526 resolve(source, []); 7805 resolve(source);
4527 assertErrors([StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]); 7806 assertErrors([StaticWarningCode.NEW_WITH_ABSTRACT_CLASS]);
4528 verify([source]); 7807 verify([source]);
4529 } 7808 }
7809 void test_newWithNonType() {
7810 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "void f () {", " A a = new A();", "}"]));
7811 resolve(source);
7812 assertErrors([StaticWarningCode.NEW_WITH_NON_TYPE]);
7813 verify([source]);
7814 }
7815 void test_newWithUndefinedConstructor() {
7816 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A.name();", "}"]));
7817 resolve(source);
7818 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]);
7819 }
7820 void test_newWithUndefinedConstructorDefault() {
7821 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam e() {}", "}", "f() {", " new A();", "}"]));
7822 resolve(source);
7823 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]);
7824 verify([source]);
7825 }
7826 void test_nonAbstractClassInheritsAbstractMemberFivePlus() {
7827 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", " q();", "}", "class C extends A {", " }"]));
7828 resolve(source);
7829 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FIVE_PLUS]);
7830 verify([source]);
7831 }
7832 void test_nonAbstractClassInheritsAbstractMemberFour() {
7833 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", "}", "class C extends A {", "}"]));
7834 resolve(source);
7835 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FOUR]);
7836 verify([source]);
7837 }
7838 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterface() {
7839 Source source = addSource(EngineTestCase.createSource(["class I {", " int g et g {return 1;}", "}", "class C implements I {", "}"]));
7840 resolve(source);
7841 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
7842 verify([source]);
7843 }
7844 void test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperclass() {
7845 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " int get g;", "}", "class C extends A {", "}"]));
7846 resolve(source);
7847 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
7848 verify([source]);
7849 }
7850 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterface() {
7851 Source source = addSource(EngineTestCase.createSource(["class I {", " m(p) {}", "}", "class C implements I {", "}"]));
7852 resolve(source);
7853 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
7854 verify([source]);
7855 }
7856 void test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperclass() {
7857 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m(p);", "}", "class C extends A {", "}"]));
7858 resolve(source);
7859 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
7860 verify([source]);
7861 }
7862 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterface() {
7863 Source source = addSource(EngineTestCase.createSource(["class I {", " set s (int i) {}", "}", "class C implements I {", "}"]));
7864 resolve(source);
7865 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
7866 verify([source]);
7867 }
7868 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() {
7869 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " set s(int i);", "}", "class C extends A {", "}"]));
7870 resolve(source);
7871 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
7872 verify([source]);
7873 }
7874 void test_nonAbstractClassInheritsAbstractMemberThree() {
7875 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", "}", "class C extends A {", "}"]));
7876 resolve(source);
7877 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ THREE]);
7878 verify([source]);
7879 }
7880 void test_nonAbstractClassInheritsAbstractMemberTwo() {
7881 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", "}", "class C extends A {", "}"]));
7882 resolve(source);
7883 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ TWO]);
7884 verify([source]);
7885 }
7886 void test_nonTypeInCatchClause_noElement() {
7887 Source source = addSource(EngineTestCase.createSource(["f() {", " try {", " } on T catch (e) {", " }", "}"]));
7888 resolve(source);
7889 assertErrors([StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
7890 verify([source]);
7891 }
7892 void test_nonTypeInCatchClause_notType() {
7893 Source source = addSource(EngineTestCase.createSource(["var T = 0;", "f() {" , " try {", " } on T catch (e) {", " }", "}"]));
7894 resolve(source);
7895 assertErrors([StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
7896 verify([source]);
7897 }
7898 void test_nonVoidReturnForOperator() {
7899 Source source = addSource(EngineTestCase.createSource(["class A {", " int o perator []=(a, b) {}", "}"]));
7900 resolve(source);
7901 assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR]);
7902 verify([source]);
7903 }
7904 void test_nonVoidReturnForSetter_function() {
7905 Source source = addSource(EngineTestCase.createSource(["int set x(int v) {", " return 42;", "}"]));
7906 resolve(source);
7907 assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
7908 verify([source]);
7909 }
7910 void test_nonVoidReturnForSetter_method() {
7911 Source source = addSource(EngineTestCase.createSource(["class A {", " int s et x(int v) {", " return 42;", " }", "}"]));
7912 resolve(source);
7913 assertErrors([StaticWarningCode.NON_VOID_RETURN_FOR_SETTER]);
7914 verify([source]);
7915 }
7916 void test_notEnoughRequiredArguments() {
7917 Source source = addSource(EngineTestCase.createSource(["f(int a, String b) { }", "main() {", " f();", "}"]));
7918 resolve(source);
7919 assertErrors([StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS]);
7920 verify([source]);
7921 }
4530 void test_partOfDifferentLibrary() { 7922 void test_partOfDifferentLibrary() {
4531 Source source = addSource(EngineTestCase.createSource(["library lib;", "part 'part.dart';"])); 7923 Source source = addSource(EngineTestCase.createSource(["library lib;", "part 'part.dart';"]));
4532 addSource2("/part.dart", EngineTestCase.createSource(["part of lub;"])); 7924 addSource2("/part.dart", EngineTestCase.createSource(["part of lub;"]));
4533 resolve(source, []); 7925 resolve(source);
4534 assertErrors([StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]); 7926 assertErrors([StaticWarningCode.PART_OF_DIFFERENT_LIBRARY]);
4535 verify([source]); 7927 verify([source]);
4536 } 7928 }
7929 void test_redirectToInvalidFunctionType() {
7930 Source source = addSource(EngineTestCase.createSource(["class A implements B {", " A(int p) {}", "}", "class B {", " B() = A;", "}"]));
7931 resolve(source);
7932 assertErrors([StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE]);
7933 verify([source]);
7934 }
7935 void test_redirectToInvalidReturnType() {
7936 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B {", " B() = A;", "}"]));
7937 resolve(source);
7938 assertErrors([StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE]);
7939 verify([source]);
7940 }
4537 void test_returnWithoutValue() { 7941 void test_returnWithoutValue() {
4538 Source source = addSource(EngineTestCase.createSource(["int f() { return; }" ])); 7942 Source source = addSource(EngineTestCase.createSource(["int f() { return; }" ]));
4539 resolve(source, []); 7943 resolve(source);
4540 assertErrors([StaticWarningCode.RETURN_WITHOUT_VALUE]); 7944 assertErrors([StaticWarningCode.RETURN_WITHOUT_VALUE]);
4541 verify([source]); 7945 verify([source]);
4542 } 7946 }
7947 void test_staticAccessToInstanceMember_method_invocation() {
7948 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "main() {", " A.m();", "}"]));
7949 resolve(source);
7950 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
7951 verify([source]);
7952 }
7953 void test_staticAccessToInstanceMember_method_reference() {
7954 Source source = addSource(EngineTestCase.createSource(["class A {", " m() { }", "}", "main() {", " A.m;", "}"]));
7955 resolve(source);
7956 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
7957 verify([source]);
7958 }
7959 void test_staticAccessToInstanceMember_propertyAccess_field() {
7960 Source source = addSource(EngineTestCase.createSource(["class A {", " var f ;", "}", "main() {", " A.f;", "}"]));
7961 resolve(source);
7962 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
7963 verify([source]);
7964 }
7965 void test_staticAccessToInstanceMember_propertyAccess_getter() {
7966 Source source = addSource(EngineTestCase.createSource(["class A {", " get f => 42;", "}", "main() {", " A.f;", "}"]));
7967 resolve(source);
7968 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
7969 verify([source]);
7970 }
7971 void test_staticAccessToInstanceMember_propertyAccess_setter() {
7972 Source source = addSource(EngineTestCase.createSource(["class A {", " set f (x) {}", "}", "main() {", " A.f = 42;", "}"]));
7973 resolve(source);
7974 assertErrors([StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER]);
7975 verify([source]);
7976 }
7977 void test_switchExpressionNotAssignable() {
7978 Source source = addSource(EngineTestCase.createSource(["f(int p) {", " swit ch (p) {", " case 'a': break;", " }", "}"]));
7979 resolve(source);
7980 assertErrors([StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE]);
7981 verify([source]);
7982 }
4543 void test_undefinedClass_instanceCreation() { 7983 void test_undefinedClass_instanceCreation() {
4544 Source source = addSource(EngineTestCase.createSource(["f() { new C(); }"])) ; 7984 Source source = addSource(EngineTestCase.createSource(["f() { new C(); }"])) ;
4545 resolve(source, []); 7985 resolve(source);
4546 assertErrors([StaticWarningCode.UNDEFINED_CLASS]); 7986 assertErrors([StaticWarningCode.UNDEFINED_CLASS]);
4547 } 7987 }
4548 void test_undefinedClass_variableDeclaration() { 7988 void test_undefinedClass_variableDeclaration() {
4549 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"])); 7989 Source source = addSource(EngineTestCase.createSource(["f() { C c; }"]));
4550 resolve(source, []); 7990 resolve(source);
4551 assertErrors([StaticWarningCode.UNDEFINED_CLASS]); 7991 assertErrors([StaticWarningCode.UNDEFINED_CLASS]);
4552 } 7992 }
4553 void test_undefinedClassBoolean_variableDeclaration() { 7993 void test_undefinedClassBoolean_variableDeclaration() {
4554 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"] )); 7994 Source source = addSource(EngineTestCase.createSource(["f() { boolean v; }"] ));
4555 resolve(source, []); 7995 resolve(source);
4556 assertErrors([StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]); 7996 assertErrors([StaticWarningCode.UNDEFINED_CLASS_BOOLEAN]);
4557 } 7997 }
4558 void test_undefinedIdentifier_commentReference() {
4559 Source source = addSource(EngineTestCase.createSource(["/** [m] xxx [new B.c ] */", "class A {", "}"]));
4560 resolve(source, []);
4561 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER, StaticWarningCode.UNDE FINED_IDENTIFIER]);
4562 }
4563 void test_undefinedIdentifier_initializer() { 7998 void test_undefinedIdentifier_initializer() {
4564 Source source = addSource(EngineTestCase.createSource(["var a = b;"])); 7999 Source source = addSource(EngineTestCase.createSource(["var a = b;"]));
4565 resolve(source, []); 8000 resolve(source);
4566 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); 8001 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
4567 } 8002 }
4568 void test_undefinedIdentifier_metadata() { 8003 void test_undefinedIdentifier_metadata() {
4569 Source source = addSource(EngineTestCase.createSource(["@undefined class A { }"])); 8004 Source source = addSource(EngineTestCase.createSource(["@undefined class A { }"]));
4570 resolve(source, []); 8005 resolve(source);
4571 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); 8006 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
4572 } 8007 }
4573 void test_undefinedIdentifier_methodInvocation() { 8008 void test_undefinedIdentifier_methodInvocation() {
4574 Source source = addSource(EngineTestCase.createSource(["f() { C.m(); }"])); 8009 Source source = addSource(EngineTestCase.createSource(["f() { C.m(); }"]));
4575 resolve(source, []); 8010 resolve(source);
4576 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]); 8011 assertErrors([StaticWarningCode.UNDEFINED_IDENTIFIER]);
4577 } 8012 }
8013 void test_undefinedNamedParameter() {
8014 Source source = addSource(EngineTestCase.createSource(["f({a, b}) {}", "main () {", " f(c: 1);", "}"]));
8015 resolve(source);
8016 assertErrors([StaticWarningCode.UNDEFINED_NAMED_PARAMETER]);
8017 }
4578 static dartSuite() { 8018 static dartSuite() {
4579 _ut.group('StaticWarningCodeTest', () { 8019 _ut.group('StaticWarningCodeTest', () {
8020 _ut.test('test_ambiguousImport_typeAnnotation', () {
8021 final __test = new StaticWarningCodeTest();
8022 runJUnitTest(__test, __test.test_ambiguousImport_typeAnnotation);
8023 });
8024 _ut.test('test_ambiguousImport_typeArgument_annotation', () {
8025 final __test = new StaticWarningCodeTest();
8026 runJUnitTest(__test, __test.test_ambiguousImport_typeArgument_annotation );
8027 });
8028 _ut.test('test_argumentTypeNotAssignable_binary', () {
8029 final __test = new StaticWarningCodeTest();
8030 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_binary);
8031 });
8032 _ut.test('test_argumentTypeNotAssignable_index', () {
8033 final __test = new StaticWarningCodeTest();
8034 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_index);
8035 });
8036 _ut.test('test_argumentTypeNotAssignable_invocation_callParameter', () {
8037 final __test = new StaticWarningCodeTest();
8038 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ca llParameter);
8039 });
8040 _ut.test('test_argumentTypeNotAssignable_invocation_callVariable', () {
8041 final __test = new StaticWarningCodeTest();
8042 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ca llVariable);
8043 });
8044 _ut.test('test_argumentTypeNotAssignable_invocation_functionParameter', () {
8045 final __test = new StaticWarningCodeTest();
8046 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_fu nctionParameter);
8047 });
8048 _ut.test('test_argumentTypeNotAssignable_invocation_generic', () {
8049 final __test = new StaticWarningCodeTest();
8050 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ge neric);
8051 });
8052 _ut.test('test_argumentTypeNotAssignable_invocation_named', () {
8053 final __test = new StaticWarningCodeTest();
8054 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_na med);
8055 });
8056 _ut.test('test_argumentTypeNotAssignable_invocation_optional', () {
8057 final __test = new StaticWarningCodeTest();
8058 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_op tional);
8059 });
8060 _ut.test('test_argumentTypeNotAssignable_invocation_required', () {
8061 final __test = new StaticWarningCodeTest();
8062 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_re quired);
8063 });
8064 _ut.test('test_argumentTypeNotAssignable_invocation_typedef_generic', () {
8065 final __test = new StaticWarningCodeTest();
8066 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ty pedef_generic);
8067 });
8068 _ut.test('test_argumentTypeNotAssignable_invocation_typedef_local', () {
8069 final __test = new StaticWarningCodeTest();
8070 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ty pedef_local);
8071 });
8072 _ut.test('test_argumentTypeNotAssignable_invocation_typedef_parameter', () {
8073 final __test = new StaticWarningCodeTest();
8074 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_invocation_ty pedef_parameter);
8075 });
8076 _ut.test('test_argumentTypeNotAssignable_new_generic', () {
8077 final __test = new StaticWarningCodeTest();
8078 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_new_generic);
8079 });
8080 _ut.test('test_argumentTypeNotAssignable_new_optional', () {
8081 final __test = new StaticWarningCodeTest();
8082 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_new_optional) ;
8083 });
8084 _ut.test('test_argumentTypeNotAssignable_new_required', () {
8085 final __test = new StaticWarningCodeTest();
8086 runJUnitTest(__test, __test.test_argumentTypeNotAssignable_new_required) ;
8087 });
8088 _ut.test('test_assignmentToFinal_instanceVariable', () {
8089 final __test = new StaticWarningCodeTest();
8090 runJUnitTest(__test, __test.test_assignmentToFinal_instanceVariable);
8091 });
8092 _ut.test('test_assignmentToFinal_localVariable', () {
8093 final __test = new StaticWarningCodeTest();
8094 runJUnitTest(__test, __test.test_assignmentToFinal_localVariable);
8095 });
8096 _ut.test('test_assignmentToFinal_prefixMinusMinus', () {
8097 final __test = new StaticWarningCodeTest();
8098 runJUnitTest(__test, __test.test_assignmentToFinal_prefixMinusMinus);
8099 });
8100 _ut.test('test_assignmentToFinal_prefixPlusPlus', () {
8101 final __test = new StaticWarningCodeTest();
8102 runJUnitTest(__test, __test.test_assignmentToFinal_prefixPlusPlus);
8103 });
8104 _ut.test('test_assignmentToFinal_propertyAccess', () {
8105 final __test = new StaticWarningCodeTest();
8106 runJUnitTest(__test, __test.test_assignmentToFinal_propertyAccess);
8107 });
8108 _ut.test('test_assignmentToFinal_suffixMinusMinus', () {
8109 final __test = new StaticWarningCodeTest();
8110 runJUnitTest(__test, __test.test_assignmentToFinal_suffixMinusMinus);
8111 });
8112 _ut.test('test_assignmentToFinal_suffixPlusPlus', () {
8113 final __test = new StaticWarningCodeTest();
8114 runJUnitTest(__test, __test.test_assignmentToFinal_suffixPlusPlus);
8115 });
8116 _ut.test('test_assignmentToFinal_topLevelVariable', () {
8117 final __test = new StaticWarningCodeTest();
8118 runJUnitTest(__test, __test.test_assignmentToFinal_topLevelVariable);
8119 });
8120 _ut.test('test_caseBlockNotTerminated', () {
8121 final __test = new StaticWarningCodeTest();
8122 runJUnitTest(__test, __test.test_caseBlockNotTerminated);
8123 });
4580 _ut.test('test_concreteClassWithAbstractMember', () { 8124 _ut.test('test_concreteClassWithAbstractMember', () {
4581 final __test = new StaticWarningCodeTest(); 8125 final __test = new StaticWarningCodeTest();
4582 runJUnitTest(__test, __test.test_concreteClassWithAbstractMember); 8126 runJUnitTest(__test, __test.test_concreteClassWithAbstractMember);
4583 }); 8127 });
8128 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_field', () {
8129 final __test = new StaticWarningCodeTest();
8130 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_direct_field);
8131 });
8132 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_getter' , () {
8133 final __test = new StaticWarningCodeTest();
8134 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_direct_getter);
8135 });
8136 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_method' , () {
8137 final __test = new StaticWarningCodeTest();
8138 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_direct_method);
8139 });
8140 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_direct_setter' , () {
8141 final __test = new StaticWarningCodeTest();
8142 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_direct_setter);
8143 });
8144 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_indirect', () {
8145 final __test = new StaticWarningCodeTest();
8146 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_indirect);
8147 });
8148 _ut.test('test_conflictingInstanceGetterAndSuperclassMember_mixin', () {
8149 final __test = new StaticWarningCodeTest();
8150 runJUnitTest(__test, __test.test_conflictingInstanceGetterAndSuperclassM ember_mixin);
8151 });
8152 _ut.test('test_conflictingInstanceSetterAndSuperclassMember', () {
8153 final __test = new StaticWarningCodeTest();
8154 runJUnitTest(__test, __test.test_conflictingInstanceSetterAndSuperclassM ember);
8155 });
8156 _ut.test('test_conflictingStaticGetterAndInstanceSetter_mixin', () {
8157 final __test = new StaticWarningCodeTest();
8158 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette r_mixin);
8159 });
8160 _ut.test('test_conflictingStaticGetterAndInstanceSetter_superClass', () {
8161 final __test = new StaticWarningCodeTest();
8162 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette r_superClass);
8163 });
8164 _ut.test('test_conflictingStaticGetterAndInstanceSetter_thisClass', () {
8165 final __test = new StaticWarningCodeTest();
8166 runJUnitTest(__test, __test.test_conflictingStaticGetterAndInstanceSette r_thisClass);
8167 });
8168 _ut.test('test_conflictingStaticSetterAndInstanceMember_thisClass_getter', () {
8169 final __test = new StaticWarningCodeTest();
8170 runJUnitTest(__test, __test.test_conflictingStaticSetterAndInstanceMembe r_thisClass_getter);
8171 });
8172 _ut.test('test_conflictingStaticSetterAndInstanceMember_thisClass_method', () {
8173 final __test = new StaticWarningCodeTest();
8174 runJUnitTest(__test, __test.test_conflictingStaticSetterAndInstanceMembe r_thisClass_method);
8175 });
4584 _ut.test('test_constWithAbstractClass', () { 8176 _ut.test('test_constWithAbstractClass', () {
4585 final __test = new StaticWarningCodeTest(); 8177 final __test = new StaticWarningCodeTest();
4586 runJUnitTest(__test, __test.test_constWithAbstractClass); 8178 runJUnitTest(__test, __test.test_constWithAbstractClass);
4587 }); 8179 });
4588 _ut.test('test_equalKeysInMap', () { 8180 _ut.test('test_equalKeysInMap', () {
4589 final __test = new StaticWarningCodeTest(); 8181 final __test = new StaticWarningCodeTest();
4590 runJUnitTest(__test, __test.test_equalKeysInMap); 8182 runJUnitTest(__test, __test.test_equalKeysInMap);
4591 }); 8183 });
4592 _ut.test('test_fieldInitializerWithInvalidType', () { 8184 _ut.test('test_exportDuplicatedLibraryName', () {
4593 final __test = new StaticWarningCodeTest(); 8185 final __test = new StaticWarningCodeTest();
4594 runJUnitTest(__test, __test.test_fieldInitializerWithInvalidType); 8186 runJUnitTest(__test, __test.test_exportDuplicatedLibraryName);
8187 });
8188 _ut.test('test_extraPositionalArguments', () {
8189 final __test = new StaticWarningCodeTest();
8190 runJUnitTest(__test, __test.test_extraPositionalArguments);
8191 });
8192 _ut.test('test_fieldInitializerNotAssignable', () {
8193 final __test = new StaticWarningCodeTest();
8194 runJUnitTest(__test, __test.test_fieldInitializerNotAssignable);
8195 });
8196 _ut.test('test_fieldInitializingFormalNotAssignable', () {
8197 final __test = new StaticWarningCodeTest();
8198 runJUnitTest(__test, __test.test_fieldInitializingFormalNotAssignable);
8199 });
8200 _ut.test('test_importDuplicatedLibraryName', () {
8201 final __test = new StaticWarningCodeTest();
8202 runJUnitTest(__test, __test.test_importDuplicatedLibraryName);
8203 });
8204 _ut.test('test_inconsistentMethodInheritance', () {
8205 final __test = new StaticWarningCodeTest();
8206 runJUnitTest(__test, __test.test_inconsistentMethodInheritance);
8207 });
8208 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_field', () {
8209 final __test = new StaticWarningCodeTest();
8210 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_field);
8211 });
8212 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_field2', () {
8213 final __test = new StaticWarningCodeTest();
8214 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_field2);
8215 });
8216 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_getter', () {
8217 final __test = new StaticWarningCodeTest();
8218 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_getter);
8219 });
8220 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_getter2', () {
8221 final __test = new StaticWarningCodeTest();
8222 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_getter2);
8223 });
8224 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_method', () {
8225 final __test = new StaticWarningCodeTest();
8226 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_method);
8227 });
8228 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_method2', () {
8229 final __test = new StaticWarningCodeTest();
8230 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_method2);
8231 });
8232 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_setter', () {
8233 final __test = new StaticWarningCodeTest();
8234 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_setter);
8235 });
8236 _ut.test('test_instanceMethodNameCollidesWithSuperclassStatic_setter2', () {
8237 final __test = new StaticWarningCodeTest();
8238 runJUnitTest(__test, __test.test_instanceMethodNameCollidesWithSuperclas sStatic_setter2);
8239 });
8240 _ut.test('test_invalidGetterOverrideReturnType', () {
8241 final __test = new StaticWarningCodeTest();
8242 runJUnitTest(__test, __test.test_invalidGetterOverrideReturnType);
8243 });
8244 _ut.test('test_invalidMethodOverrideNamedParamType', () {
8245 final __test = new StaticWarningCodeTest();
8246 runJUnitTest(__test, __test.test_invalidMethodOverrideNamedParamType);
8247 });
8248 _ut.test('test_invalidMethodOverrideNormalParamType', () {
8249 final __test = new StaticWarningCodeTest();
8250 runJUnitTest(__test, __test.test_invalidMethodOverrideNormalParamType);
8251 });
8252 _ut.test('test_invalidMethodOverrideOptionalParamType', () {
8253 final __test = new StaticWarningCodeTest();
8254 runJUnitTest(__test, __test.test_invalidMethodOverrideOptionalParamType) ;
8255 });
8256 _ut.test('test_invalidMethodOverrideReturnType_interface', () {
8257 final __test = new StaticWarningCodeTest();
8258 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_interfa ce);
8259 });
8260 _ut.test('test_invalidMethodOverrideReturnType_interface2', () {
8261 final __test = new StaticWarningCodeTest();
8262 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_interfa ce2);
8263 });
8264 _ut.test('test_invalidMethodOverrideReturnType_mixin', () {
8265 final __test = new StaticWarningCodeTest();
8266 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_mixin);
8267 });
8268 _ut.test('test_invalidMethodOverrideReturnType_superclass', () {
8269 final __test = new StaticWarningCodeTest();
8270 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_supercl ass);
8271 });
8272 _ut.test('test_invalidMethodOverrideReturnType_superclass2', () {
8273 final __test = new StaticWarningCodeTest();
8274 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_supercl ass2);
8275 });
8276 _ut.test('test_invalidMethodOverrideReturnType_void', () {
8277 final __test = new StaticWarningCodeTest();
8278 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_void);
8279 });
8280 _ut.test('test_invalidSetterOverrideNormalParamType', () {
8281 final __test = new StaticWarningCodeTest();
8282 runJUnitTest(__test, __test.test_invalidSetterOverrideNormalParamType);
8283 });
8284 _ut.test('test_mismatchedAccessorTypes_class', () {
8285 final __test = new StaticWarningCodeTest();
8286 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_class);
8287 });
8288 _ut.test('test_mismatchedAccessorTypes_topLevel', () {
8289 final __test = new StaticWarningCodeTest();
8290 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_topLevel);
4595 }); 8291 });
4596 _ut.test('test_newWithAbstractClass', () { 8292 _ut.test('test_newWithAbstractClass', () {
4597 final __test = new StaticWarningCodeTest(); 8293 final __test = new StaticWarningCodeTest();
4598 runJUnitTest(__test, __test.test_newWithAbstractClass); 8294 runJUnitTest(__test, __test.test_newWithAbstractClass);
4599 }); 8295 });
8296 _ut.test('test_newWithNonType', () {
8297 final __test = new StaticWarningCodeTest();
8298 runJUnitTest(__test, __test.test_newWithNonType);
8299 });
8300 _ut.test('test_newWithUndefinedConstructor', () {
8301 final __test = new StaticWarningCodeTest();
8302 runJUnitTest(__test, __test.test_newWithUndefinedConstructor);
8303 });
8304 _ut.test('test_newWithUndefinedConstructorDefault', () {
8305 final __test = new StaticWarningCodeTest();
8306 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault);
8307 });
8308 _ut.test('test_nonAbstractClassInheritsAbstractMemberFivePlus', () {
8309 final __test = new StaticWarningCodeTest();
8310 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF ivePlus);
8311 });
8312 _ut.test('test_nonAbstractClassInheritsAbstractMemberFour', () {
8313 final __test = new StaticWarningCodeTest();
8314 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF our);
8315 });
8316 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterf ace', () {
8317 final __test = new StaticWarningCodeTest();
8318 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_getter_fromInterface);
8319 });
8320 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_getter_fromSuperc lass', () {
8321 final __test = new StaticWarningCodeTest();
8322 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_getter_fromSuperclass);
8323 });
8324 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_method_fromInterf ace', () {
8325 final __test = new StaticWarningCodeTest();
8326 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_method_fromInterface);
8327 });
8328 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_method_fromSuperc lass', () {
8329 final __test = new StaticWarningCodeTest();
8330 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_method_fromSuperclass);
8331 });
8332 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterf ace', () {
8333 final __test = new StaticWarningCodeTest();
8334 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_setter_fromInterface);
8335 });
8336 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperc lass', () {
8337 final __test = new StaticWarningCodeTest();
8338 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_setter_fromSuperclass);
8339 });
8340 _ut.test('test_nonAbstractClassInheritsAbstractMemberThree', () {
8341 final __test = new StaticWarningCodeTest();
8342 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberT hree);
8343 });
8344 _ut.test('test_nonAbstractClassInheritsAbstractMemberTwo', () {
8345 final __test = new StaticWarningCodeTest();
8346 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberT wo);
8347 });
8348 _ut.test('test_nonTypeInCatchClause_noElement', () {
8349 final __test = new StaticWarningCodeTest();
8350 runJUnitTest(__test, __test.test_nonTypeInCatchClause_noElement);
8351 });
8352 _ut.test('test_nonTypeInCatchClause_notType', () {
8353 final __test = new StaticWarningCodeTest();
8354 runJUnitTest(__test, __test.test_nonTypeInCatchClause_notType);
8355 });
8356 _ut.test('test_nonVoidReturnForOperator', () {
8357 final __test = new StaticWarningCodeTest();
8358 runJUnitTest(__test, __test.test_nonVoidReturnForOperator);
8359 });
8360 _ut.test('test_nonVoidReturnForSetter_function', () {
8361 final __test = new StaticWarningCodeTest();
8362 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_function);
8363 });
8364 _ut.test('test_nonVoidReturnForSetter_method', () {
8365 final __test = new StaticWarningCodeTest();
8366 runJUnitTest(__test, __test.test_nonVoidReturnForSetter_method);
8367 });
8368 _ut.test('test_notEnoughRequiredArguments', () {
8369 final __test = new StaticWarningCodeTest();
8370 runJUnitTest(__test, __test.test_notEnoughRequiredArguments);
8371 });
4600 _ut.test('test_partOfDifferentLibrary', () { 8372 _ut.test('test_partOfDifferentLibrary', () {
4601 final __test = new StaticWarningCodeTest(); 8373 final __test = new StaticWarningCodeTest();
4602 runJUnitTest(__test, __test.test_partOfDifferentLibrary); 8374 runJUnitTest(__test, __test.test_partOfDifferentLibrary);
4603 }); 8375 });
8376 _ut.test('test_redirectToInvalidFunctionType', () {
8377 final __test = new StaticWarningCodeTest();
8378 runJUnitTest(__test, __test.test_redirectToInvalidFunctionType);
8379 });
8380 _ut.test('test_redirectToInvalidReturnType', () {
8381 final __test = new StaticWarningCodeTest();
8382 runJUnitTest(__test, __test.test_redirectToInvalidReturnType);
8383 });
4604 _ut.test('test_returnWithoutValue', () { 8384 _ut.test('test_returnWithoutValue', () {
4605 final __test = new StaticWarningCodeTest(); 8385 final __test = new StaticWarningCodeTest();
4606 runJUnitTest(__test, __test.test_returnWithoutValue); 8386 runJUnitTest(__test, __test.test_returnWithoutValue);
4607 }); 8387 });
8388 _ut.test('test_staticAccessToInstanceMember_method_invocation', () {
8389 final __test = new StaticWarningCodeTest();
8390 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method_inv ocation);
8391 });
8392 _ut.test('test_staticAccessToInstanceMember_method_reference', () {
8393 final __test = new StaticWarningCodeTest();
8394 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_method_ref erence);
8395 });
8396 _ut.test('test_staticAccessToInstanceMember_propertyAccess_field', () {
8397 final __test = new StaticWarningCodeTest();
8398 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_field);
8399 });
8400 _ut.test('test_staticAccessToInstanceMember_propertyAccess_getter', () {
8401 final __test = new StaticWarningCodeTest();
8402 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_getter);
8403 });
8404 _ut.test('test_staticAccessToInstanceMember_propertyAccess_setter', () {
8405 final __test = new StaticWarningCodeTest();
8406 runJUnitTest(__test, __test.test_staticAccessToInstanceMember_propertyAc cess_setter);
8407 });
8408 _ut.test('test_switchExpressionNotAssignable', () {
8409 final __test = new StaticWarningCodeTest();
8410 runJUnitTest(__test, __test.test_switchExpressionNotAssignable);
8411 });
4608 _ut.test('test_undefinedClassBoolean_variableDeclaration', () { 8412 _ut.test('test_undefinedClassBoolean_variableDeclaration', () {
4609 final __test = new StaticWarningCodeTest(); 8413 final __test = new StaticWarningCodeTest();
4610 runJUnitTest(__test, __test.test_undefinedClassBoolean_variableDeclarati on); 8414 runJUnitTest(__test, __test.test_undefinedClassBoolean_variableDeclarati on);
4611 }); 8415 });
4612 _ut.test('test_undefinedClass_instanceCreation', () { 8416 _ut.test('test_undefinedClass_instanceCreation', () {
4613 final __test = new StaticWarningCodeTest(); 8417 final __test = new StaticWarningCodeTest();
4614 runJUnitTest(__test, __test.test_undefinedClass_instanceCreation); 8418 runJUnitTest(__test, __test.test_undefinedClass_instanceCreation);
4615 }); 8419 });
4616 _ut.test('test_undefinedClass_variableDeclaration', () { 8420 _ut.test('test_undefinedClass_variableDeclaration', () {
4617 final __test = new StaticWarningCodeTest(); 8421 final __test = new StaticWarningCodeTest();
4618 runJUnitTest(__test, __test.test_undefinedClass_variableDeclaration); 8422 runJUnitTest(__test, __test.test_undefinedClass_variableDeclaration);
4619 }); 8423 });
4620 _ut.test('test_undefinedIdentifier_commentReference', () {
4621 final __test = new StaticWarningCodeTest();
4622 runJUnitTest(__test, __test.test_undefinedIdentifier_commentReference);
4623 });
4624 _ut.test('test_undefinedIdentifier_initializer', () { 8424 _ut.test('test_undefinedIdentifier_initializer', () {
4625 final __test = new StaticWarningCodeTest(); 8425 final __test = new StaticWarningCodeTest();
4626 runJUnitTest(__test, __test.test_undefinedIdentifier_initializer); 8426 runJUnitTest(__test, __test.test_undefinedIdentifier_initializer);
4627 }); 8427 });
4628 _ut.test('test_undefinedIdentifier_metadata', () { 8428 _ut.test('test_undefinedIdentifier_metadata', () {
4629 final __test = new StaticWarningCodeTest(); 8429 final __test = new StaticWarningCodeTest();
4630 runJUnitTest(__test, __test.test_undefinedIdentifier_metadata); 8430 runJUnitTest(__test, __test.test_undefinedIdentifier_metadata);
4631 }); 8431 });
4632 _ut.test('test_undefinedIdentifier_methodInvocation', () { 8432 _ut.test('test_undefinedIdentifier_methodInvocation', () {
4633 final __test = new StaticWarningCodeTest(); 8433 final __test = new StaticWarningCodeTest();
4634 runJUnitTest(__test, __test.test_undefinedIdentifier_methodInvocation); 8434 runJUnitTest(__test, __test.test_undefinedIdentifier_methodInvocation);
4635 }); 8435 });
8436 _ut.test('test_undefinedNamedParameter', () {
8437 final __test = new StaticWarningCodeTest();
8438 runJUnitTest(__test, __test.test_undefinedNamedParameter);
8439 });
4636 }); 8440 });
4637 } 8441 }
4638 } 8442 }
4639 class ErrorResolverTest extends ResolverTestCase { 8443 class ErrorResolverTest extends ResolverTestCase {
4640 void test_breakLabelOnSwitchMember() { 8444 void test_breakLabelOnSwitchMember() {
4641 Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " l: case 0:", " break;", " ca se 1:", " break l;", " }", " }", "}"])); 8445 Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " l: case 0:", " break;", " ca se 1:", " break l;", " }", " }", "}"]));
4642 resolve(source, []); 8446 resolve(source);
4643 assertErrors([ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]); 8447 assertErrors([ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]);
4644 verify([source]); 8448 verify([source]);
4645 } 8449 }
4646 void test_continueLabelOnSwitch() { 8450 void test_continueLabelOnSwitch() {
4647 Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " l: switch (i) {", " case 0:", " continue l;", " }", " }", "}"])); 8451 Source source = addSource(EngineTestCase.createSource(["class A {", " void m(int i) {", " l: switch (i) {", " case 0:", " continue l;", " }", " }", "}"]));
4648 resolve(source, []); 8452 resolve(source);
4649 assertErrors([ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]); 8453 assertErrors([ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]);
4650 verify([source]); 8454 verify([source]);
4651 } 8455 }
4652 static dartSuite() { 8456 static dartSuite() {
4653 _ut.group('ErrorResolverTest', () { 8457 _ut.group('ErrorResolverTest', () {
4654 _ut.test('test_breakLabelOnSwitchMember', () { 8458 _ut.test('test_breakLabelOnSwitchMember', () {
4655 final __test = new ErrorResolverTest(); 8459 final __test = new ErrorResolverTest();
4656 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember); 8460 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember);
4657 }); 8461 });
4658 _ut.test('test_continueLabelOnSwitch', () { 8462 _ut.test('test_continueLabelOnSwitch', () {
4659 final __test = new ErrorResolverTest(); 8463 final __test = new ErrorResolverTest();
4660 runJUnitTest(__test, __test.test_continueLabelOnSwitch); 8464 runJUnitTest(__test, __test.test_continueLabelOnSwitch);
4661 }); 8465 });
4662 }); 8466 });
4663 } 8467 }
4664 } 8468 }
8469
4665 /** 8470 /**
4666 * Instances of the class {@code TestTypeProvider} implement a type provider tha t can be used by 8471 * Instances of the class {@code TestTypeProvider} implement a type provider tha t can be used by
4667 * tests without creating the element model for the core library. 8472 * tests without creating the element model for the core library.
4668 */ 8473 */
4669 class TestTypeProvider implements TypeProvider { 8474 class TestTypeProvider implements TypeProvider {
8475
4670 /** 8476 /**
4671 * The type representing the built-in type 'bool'. 8477 * The type representing the built-in type 'bool'.
4672 */ 8478 */
4673 InterfaceType _boolType; 8479 InterfaceType _boolType;
8480
4674 /** 8481 /**
4675 * The type representing the type 'bottom'. 8482 * The type representing the type 'bottom'.
4676 */ 8483 */
4677 Type2 _bottomType; 8484 Type2 _bottomType;
8485
4678 /** 8486 /**
4679 * The type representing the built-in type 'double'. 8487 * The type representing the built-in type 'double'.
4680 */ 8488 */
4681 InterfaceType _doubleType; 8489 InterfaceType _doubleType;
8490
4682 /** 8491 /**
4683 * The type representing the built-in type 'dynamic'. 8492 * The type representing the built-in type 'dynamic'.
4684 */ 8493 */
4685 Type2 _dynamicType; 8494 Type2 _dynamicType;
8495
4686 /** 8496 /**
4687 * The type representing the built-in type 'Function'. 8497 * The type representing the built-in type 'Function'.
4688 */ 8498 */
4689 InterfaceType _functionType; 8499 InterfaceType _functionType;
8500
4690 /** 8501 /**
4691 * The type representing the built-in type 'int'. 8502 * The type representing the built-in type 'int'.
4692 */ 8503 */
4693 InterfaceType _intType; 8504 InterfaceType _intType;
8505
4694 /** 8506 /**
4695 * The type representing the built-in type 'Iterable'. 8507 * The type representing the built-in type 'Iterable'.
4696 */ 8508 */
4697 InterfaceType _iterableType; 8509 InterfaceType _iterableType;
8510
4698 /** 8511 /**
4699 * The type representing the built-in type 'Iterator'. 8512 * The type representing the built-in type 'Iterator'.
4700 */ 8513 */
4701 InterfaceType _iteratorType; 8514 InterfaceType _iteratorType;
8515
4702 /** 8516 /**
4703 * The type representing the built-in type 'List'. 8517 * The type representing the built-in type 'List'.
4704 */ 8518 */
4705 InterfaceType _listType; 8519 InterfaceType _listType;
8520
4706 /** 8521 /**
4707 * The type representing the built-in type 'Map'. 8522 * The type representing the built-in type 'Map'.
4708 */ 8523 */
4709 InterfaceType _mapType; 8524 InterfaceType _mapType;
8525
4710 /** 8526 /**
4711 * The type representing the built-in type 'num'. 8527 * The type representing the built-in type 'num'.
4712 */ 8528 */
4713 InterfaceType _numType; 8529 InterfaceType _numType;
8530
4714 /** 8531 /**
4715 * The type representing the built-in type 'Object'. 8532 * The type representing the built-in type 'Object'.
4716 */ 8533 */
4717 InterfaceType _objectType; 8534 InterfaceType _objectType;
8535
4718 /** 8536 /**
4719 * The type representing the built-in type 'StackTrace'. 8537 * The type representing the built-in type 'StackTrace'.
4720 */ 8538 */
4721 InterfaceType _stackTraceType; 8539 InterfaceType _stackTraceType;
8540
4722 /** 8541 /**
4723 * The type representing the built-in type 'String'. 8542 * The type representing the built-in type 'String'.
4724 */ 8543 */
4725 InterfaceType _stringType; 8544 InterfaceType _stringType;
8545
4726 /** 8546 /**
4727 * The type representing the built-in type 'Type'. 8547 * The type representing the built-in type 'Type'.
4728 */ 8548 */
4729 InterfaceType _typeType; 8549 InterfaceType _typeType;
4730 /**
4731 * Initialize a newly created type provider to provide stand-ins for the types defined in the core
4732 * library.
4733 */
4734 TestTypeProvider() : super() {
4735 }
4736 InterfaceType get boolType { 8550 InterfaceType get boolType {
4737 if (_boolType == null) { 8551 if (_boolType == null) {
4738 _boolType = ElementFactory.classElement2("bool", []).type; 8552 _boolType = ElementFactory.classElement2("bool", []).type;
4739 } 8553 }
4740 return _boolType; 8554 return _boolType;
4741 } 8555 }
4742 Type2 get bottomType { 8556 Type2 get bottomType {
4743 if (_bottomType == null) { 8557 if (_bottomType == null) {
4744 _bottomType = BottomTypeImpl.instance; 8558 _bottomType = BottomTypeImpl.instance;
4745 } 8559 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
4783 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator" , ["E"]); 8597 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator" , ["E"]);
4784 _iteratorType = iteratorElement.type; 8598 _iteratorType = iteratorElement.type;
4785 Type2 eType = iteratorElement.typeVariables[0].type; 8599 Type2 eType = iteratorElement.typeVariables[0].type;
4786 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("current", false, eType)]; 8600 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("current", false, eType)];
4787 } 8601 }
4788 return _iteratorType; 8602 return _iteratorType;
4789 } 8603 }
4790 InterfaceType get listType { 8604 InterfaceType get listType {
4791 if (_listType == null) { 8605 if (_listType == null) {
4792 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]) ; 8606 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]) ;
8607 listElement.constructors = <ConstructorElement> [ElementFactory.constructo rElement(listElement, null)];
4793 _listType = listElement.type; 8608 _listType = listElement.type;
4794 Type2 eType = listElement.typeVariables[0].type; 8609 Type2 eType = listElement.typeVariables[0].type;
4795 InterfaceType supertype = iterableType.substitute5(<Type2> [eType]); 8610 InterfaceType supertype = iterableType.substitute5(<Type2> [eType]);
4796 listElement.supertype = supertype; 8611 listElement.supertype = supertype;
4797 listElement.methods = <MethodElement> [ElementFactory.methodElement("[]", eType, [_intType]), ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [ _intType, eType])]; 8612 listElement.methods = <MethodElement> [ElementFactory.methodElement("[]", eType, [_intType]), ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [ _intType, eType])];
4798 } 8613 }
4799 return _listType; 8614 return _listType;
4800 } 8615 }
4801 InterfaceType get mapType { 8616 InterfaceType get mapType {
4802 if (_mapType == null) { 8617 if (_mapType == null) {
4803 _mapType = ElementFactory.classElement2("Map", ["K", "V"]).type; 8618 ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V "]);
8619 _mapType = mapElement.type;
8620 mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEle ment("length", false, _intType)];
4804 } 8621 }
4805 return _mapType; 8622 return _mapType;
4806 } 8623 }
4807 InterfaceType get numType { 8624 InterfaceType get numType {
4808 if (_numType == null) { 8625 if (_numType == null) {
4809 initializeNumericTypes(); 8626 initializeNumericTypes();
4810 } 8627 }
4811 return _numType; 8628 return _numType;
4812 } 8629 }
4813 InterfaceType get objectType { 8630 InterfaceType get objectType {
4814 if (_objectType == null) { 8631 if (_objectType == null) {
4815 ClassElementImpl objectElement = ElementFactory.object; 8632 ClassElementImpl objectElement = ElementFactory.object;
4816 _objectType = objectElement.type; 8633 _objectType = objectElement.type;
4817 if (objectElement.methods.length == 0) { 8634 if (objectElement.methods.length == 0) {
4818 objectElement.methods = <MethodElement> [ElementFactory.methodElement("t oString", stringType, []), ElementFactory.methodElement("==", _boolType, [_objec tType])]; 8635 objectElement.constructors = <ConstructorElement> [ElementFactory.constr uctorElement(objectElement, null)];
4819 objectElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("hashCode", false, intType)]; 8636 objectElement.methods = <MethodElement> [ElementFactory.methodElement("t oString", stringType, []), ElementFactory.methodElement("==", _boolType, [_objec tType]), ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType] )];
8637 objectElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("hashCode", false, intType), ElementFactory.getterElement("runtimeType ", false, typeType)];
4820 } 8638 }
4821 } 8639 }
4822 return _objectType; 8640 return _objectType;
4823 } 8641 }
4824 InterfaceType get stackTraceType { 8642 InterfaceType get stackTraceType {
4825 if (_stackTraceType == null) { 8643 if (_stackTraceType == null) {
4826 _stackTraceType = ElementFactory.classElement2("StackTrace", []).type; 8644 _stackTraceType = ElementFactory.classElement2("StackTrace", []).type;
4827 } 8645 }
4828 return _stackTraceType; 8646 return _stackTraceType;
4829 } 8647 }
4830 InterfaceType get stringType { 8648 InterfaceType get stringType {
4831 if (_stringType == null) { 8649 if (_stringType == null) {
4832 _stringType = ElementFactory.classElement2("String", []).type; 8650 _stringType = ElementFactory.classElement2("String", []).type;
4833 ClassElementImpl stringElement = _stringType.element as ClassElementImpl; 8651 ClassElementImpl stringElement = _stringType.element as ClassElementImpl;
4834 stringElement.accessors = <PropertyAccessorElement> [ElementFactory.getter Element("isEmpty", false, boolType), ElementFactory.getterElement("length", fals e, intType)]; 8652 stringElement.accessors = <PropertyAccessorElement> [ElementFactory.getter Element("isEmpty", false, boolType), ElementFactory.getterElement("length", fals e, intType), ElementFactory.getterElement("codeUnits", false, listType.substitut e5(<Type2> [intType]))];
4835 stringElement.methods = <MethodElement> [ElementFactory.methodElement("toL owerCase", _stringType, []), ElementFactory.methodElement("toUpperCase", _string Type, [])]; 8653 stringElement.methods = <MethodElement> [ElementFactory.methodElement("toL owerCase", _stringType, []), ElementFactory.methodElement("toUpperCase", _string Type, [])];
4836 } 8654 }
4837 return _stringType; 8655 return _stringType;
4838 } 8656 }
4839 InterfaceType get typeType { 8657 InterfaceType get typeType {
4840 if (_typeType == null) { 8658 if (_typeType == null) {
4841 _typeType = ElementFactory.classElement2("Type", []).type; 8659 _typeType = ElementFactory.classElement2("Type", []).type;
4842 } 8660 }
4843 return _typeType; 8661 return _typeType;
4844 } 8662 }
8663
4845 /** 8664 /**
4846 * Initialize the numeric types. They are created as a group so that we can (a ) create the right 8665 * Initialize the numeric types. They are created as a group so that we can (a ) create the right
4847 * hierarchy and (b) add members to them. 8666 * hierarchy and (b) add members to them.
4848 */ 8667 */
4849 void initializeNumericTypes() { 8668 void initializeNumericTypes() {
4850 ClassElementImpl numElement = ElementFactory.classElement2("num", []); 8669 ClassElementImpl numElement = ElementFactory.classElement2("num", []);
4851 _numType = numElement.type; 8670 _numType = numElement.type;
4852 ClassElementImpl intElement = ElementFactory.classElement("int", _numType, [ ]); 8671 ClassElementImpl intElement = ElementFactory.classElement("int", _numType, [ ]);
4853 _intType = intElement.type; 8672 _intType = intElement.type;
4854 ClassElementImpl doubleElement = ElementFactory.classElement("double", _numT ype, []); 8673 ClassElementImpl doubleElement = ElementFactory.classElement("double", _numT ype, []);
4855 _doubleType = doubleElement.type; 8674 _doubleType = doubleElement.type;
4856 boolType; 8675 boolType;
4857 stringType; 8676 stringType;
4858 numElement.methods = <MethodElement> [ElementFactory.methodElement("+", _num Type, [_numType]), ElementFactory.methodElement("-", _numType, [_numType]), Elem entFactory.methodElement("*", _numType, [_numType]), ElementFactory.methodElemen t("%", _numType, [_numType]), ElementFactory.methodElement("/", _doubleType, [_n umType]), ElementFactory.methodElement("~/", _numType, [_numType]), ElementFacto ry.methodElement("-", _numType, []), ElementFactory.methodElement("remainder", _ numType, [_numType]), ElementFactory.methodElement("<", _boolType, [_numType]), ElementFactory.methodElement("<=", _boolType, [_numType]), ElementFactory.method Element(">", _boolType, [_numType]), ElementFactory.methodElement(">=", _boolTyp e, [_numType]), ElementFactory.methodElement("isNaN", _boolType, []), ElementFac tory.methodElement("isNegative", _boolType, []), ElementFactory.methodElement("i sInfinite", _boolType, []), ElementFactory.methodElement("abs", _numType, []), E lementFactory.methodElement("floor", _numType, []), ElementFactory.methodElement ("ceil", _numType, []), ElementFactory.methodElement("round", _numType, []), Ele mentFactory.methodElement("truncate", _numType, []), ElementFactory.methodElemen t("toInt", _intType, []), ElementFactory.methodElement("toDouble", _doubleType, []), ElementFactory.methodElement("toStringAsFixed", _stringType, [_intType]), E lementFactory.methodElement("toStringAsExponential", _stringType, [_intType]), E lementFactory.methodElement("toStringAsPrecision", _stringType, [_intType]), Ele mentFactory.methodElement("toRadixString", _stringType, [_intType])]; 8677 numElement.methods = <MethodElement> [ElementFactory.methodElement("+", _num Type, [_numType]), ElementFactory.methodElement("-", _numType, [_numType]), Elem entFactory.methodElement("*", _numType, [_numType]), ElementFactory.methodElemen t("%", _numType, [_numType]), ElementFactory.methodElement("/", _doubleType, [_n umType]), ElementFactory.methodElement("~/", _numType, [_numType]), ElementFacto ry.methodElement("-", _numType, []), ElementFactory.methodElement("remainder", _ numType, [_numType]), ElementFactory.methodElement("<", _boolType, [_numType]), ElementFactory.methodElement("<=", _boolType, [_numType]), ElementFactory.method Element(">", _boolType, [_numType]), ElementFactory.methodElement(">=", _boolTyp e, [_numType]), ElementFactory.methodElement("isNaN", _boolType, []), ElementFac tory.methodElement("isNegative", _boolType, []), ElementFactory.methodElement("i sInfinite", _boolType, []), ElementFactory.methodElement("abs", _numType, []), E lementFactory.methodElement("floor", _numType, []), ElementFactory.methodElement ("ceil", _numType, []), ElementFactory.methodElement("round", _numType, []), Ele mentFactory.methodElement("truncate", _numType, []), ElementFactory.methodElemen t("toInt", _intType, []), ElementFactory.methodElement("toDouble", _doubleType, []), ElementFactory.methodElement("toStringAsFixed", _stringType, [_intType]), E lementFactory.methodElement("toStringAsExponential", _stringType, [_intType]), E lementFactory.methodElement("toStringAsPrecision", _stringType, [_intType]), Ele mentFactory.methodElement("toRadixString", _stringType, [_intType])];
4859 intElement.methods = <MethodElement> [ElementFactory.methodElement("&", _int Type, [_intType]), ElementFactory.methodElement("|", _intType, [_intType]), Elem entFactory.methodElement("^", _intType, [_intType]), ElementFactory.methodElemen t("~", _intType, []), ElementFactory.methodElement("<<", _intType, [_intType]), ElementFactory.methodElement(">>", _intType, [_intType]), ElementFactory.methodE lement("-", _intType, []), ElementFactory.methodElement("abs", _intType, []), El ementFactory.methodElement("round", _intType, []), ElementFactory.methodElement( "floor", _intType, []), ElementFactory.methodElement("ceil", _intType, []), Elem entFactory.methodElement("truncate", _intType, []), ElementFactory.methodElement ("toString", _stringType, [])]; 8678 intElement.methods = <MethodElement> [ElementFactory.methodElement("&", _int Type, [_intType]), ElementFactory.methodElement("|", _intType, [_intType]), Elem entFactory.methodElement("^", _intType, [_intType]), ElementFactory.methodElemen t("~", _intType, []), ElementFactory.methodElement("<<", _intType, [_intType]), ElementFactory.methodElement(">>", _intType, [_intType]), ElementFactory.methodE lement("-", _intType, []), ElementFactory.methodElement("abs", _intType, []), El ementFactory.methodElement("round", _intType, []), ElementFactory.methodElement( "floor", _intType, []), ElementFactory.methodElement("ceil", _intType, []), Elem entFactory.methodElement("truncate", _intType, []), ElementFactory.methodElement ("toString", _stringType, [])];
4860 List<FieldElement> fields = <FieldElement> [ElementFactory.fieldElement("NAN ", true, false, true, _doubleType), ElementFactory.fieldElement("INFINITY", true , false, true, _doubleType), ElementFactory.fieldElement("NEGATIVE_INFINITY", tr ue, false, true, _doubleType), ElementFactory.fieldElement("MIN_POSITIVE", true, false, true, _doubleType), ElementFactory.fieldElement("MAX_FINITE", true, fals e, true, _doubleType)]; 8679 List<FieldElement> fields = <FieldElement> [ElementFactory.fieldElement("NAN ", true, false, true, _doubleType), ElementFactory.fieldElement("INFINITY", true , false, true, _doubleType), ElementFactory.fieldElement("NEGATIVE_INFINITY", tr ue, false, true, _doubleType), ElementFactory.fieldElement("MIN_POSITIVE", true, false, true, _doubleType), ElementFactory.fieldElement("MAX_FINITE", true, fals e, true, _doubleType)];
4861 doubleElement.fields = fields; 8680 doubleElement.fields = fields;
4862 int fieldCount = fields.length; 8681 int fieldCount = fields.length;
4863 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount); 8682 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount);
4864 for (int i = 0; i < fieldCount; i++) { 8683 for (int i = 0; i < fieldCount; i++) {
4865 accessors[i] = fields[i].getter; 8684 accessors[i] = fields[i].getter;
4866 } 8685 }
4867 doubleElement.accessors = accessors; 8686 doubleElement.accessors = accessors;
4868 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, [])]; 8687 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, [])];
4869 } 8688 }
4870 } 8689 }
8690
4871 /** 8691 /**
4872 * The class {@code AnalysisContextFactory} defines utility methods used to crea te analysis contexts 8692 * The class {@code AnalysisContextFactory} defines utility methods used to crea te analysis contexts
4873 * for testing purposes. 8693 * for testing purposes.
4874 */ 8694 */
4875 class AnalysisContextFactory { 8695 class AnalysisContextFactory {
8696
4876 /** 8697 /**
4877 * Create an analysis context that has a fake core library already resolved. 8698 * Create an analysis context that has a fake core library already resolved.
4878 * @return the analysis context that was created 8699 * @return the analysis context that was created
4879 */ 8700 */
4880 static AnalysisContextImpl contextWithCore() { 8701 static AnalysisContextImpl contextWithCore() {
4881 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl; 8702 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl;
4882 SourceFactory sourceFactory2 = sdkContext.sourceFactory; 8703 SourceFactory sourceFactory2 = sdkContext.sourceFactory;
4883 TestTypeProvider provider = new TestTypeProvider(); 8704 TestTypeProvider provider = new TestTypeProvider();
4884 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art"); 8705 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art");
4885 Source coreSource = sourceFactory2.forUri(DartSdk.DART_CORE); 8706 Source coreSource = sourceFactory2.forUri(DartSdk.DART_CORE);
4886 sdkContext.setContents(coreSource, ""); 8707 sdkContext.setContents(coreSource, "");
4887 coreUnit.source = coreSource; 8708 coreUnit.source = coreSource;
4888 coreUnit.types = <ClassElement> [provider.boolType.element, provider.doubleT ype.element, provider.functionType.element, provider.intType.element, provider.l istType.element, provider.mapType.element, provider.numType.element, provider.ob jectType.element, provider.stackTraceType.element, provider.stringType.element, provider.typeType.element]; 8709 coreUnit.types = <ClassElement> [provider.boolType.element, provider.doubleT ype.element, provider.functionType.element, provider.intType.element, provider.l istType.element, provider.mapType.element, provider.numType.element, provider.ob jectType.element, provider.stackTraceType.element, provider.stringType.element, provider.typeType.element];
4889 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "core"])); 8710 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "core"]));
4890 coreLibrary.definingCompilationUnit = coreUnit; 8711 coreLibrary.definingCompilationUnit = coreUnit;
4891 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d artium.dart"); 8712 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d artium.dart");
4892 Source htmlSource = sourceFactory2.forUri(DartSdk.DART_HTML); 8713 Source htmlSource = sourceFactory2.forUri(DartSdk.DART_HTML);
4893 sdkContext.setContents(htmlSource, ""); 8714 sdkContext.setContents(htmlSource, "");
4894 htmlUnit.source = htmlSource; 8715 htmlUnit.source = htmlSource;
4895 ClassElementImpl elementElement = ElementFactory.classElement2("Element", [] ); 8716 ClassElementImpl elementElement = ElementFactory.classElement2("Element", [] );
4896 InterfaceType elementType = elementElement.type; 8717 InterfaceType elementType = elementElement.type;
4897 ClassElementImpl documentElement = ElementFactory.classElement("Document", e lementType, []); 8718 ClassElementImpl documentElement = ElementFactory.classElement("Document", e lementType, []);
4898 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu ment", documentElement.type, []); 8719 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu ment", documentElement.type, []);
4899 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement( "query", elementType, <Type2> [provider.stringType])]; 8720 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement( "query", elementType, <Type2> [provider.stringType])];
4900 htmlUnit.types = <ClassElement> [ElementFactory.classElement("AnchorElement" , elementType, []), ElementFactory.classElement("BodyElement", elementType, []), ElementFactory.classElement("ButtonElement", elementType, []), ElementFactory.c lassElement("DivElement", elementType, []), documentElement, elementElement, htm lDocumentElement, ElementFactory.classElement("InputElement", elementType, []), ElementFactory.classElement("SelectElement", elementType, [])]; 8721 htmlUnit.types = <ClassElement> [ElementFactory.classElement("AnchorElement" , elementType, []), ElementFactory.classElement("BodyElement", elementType, []), ElementFactory.classElement("ButtonElement", elementType, []), ElementFactory.c lassElement("DivElement", elementType, []), documentElement, elementElement, htm lDocumentElement, ElementFactory.classElement("InputElement", elementType, []), ElementFactory.classElement("SelectElement", elementType, [])];
4901 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI mpl.EMPTY_ARRAY)]; 8722 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI mpl.EMPTY_ARRAY)];
4902 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen t2("document"); 8723 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen t3("document", true, htmlDocumentElement.type);
4903 document.type = htmlDocumentElement.type;
4904 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; 8724 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document];
8725 htmlUnit.accessors = <PropertyAccessorElement> [document.getter];
4905 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "dom", "html"])); 8726 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "dom", "html"]));
4906 htmlLibrary.definingCompilationUnit = htmlUnit; 8727 htmlLibrary.definingCompilationUnit = htmlUnit;
4907 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); 8728 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
4908 elementMap[coreSource] = coreLibrary; 8729 elementMap[coreSource] = coreLibrary;
4909 elementMap[htmlSource] = htmlLibrary; 8730 elementMap[htmlSource] = htmlLibrary;
4910 sdkContext.recordLibraryElements(elementMap); 8731 sdkContext.recordLibraryElements(elementMap);
4911 AnalysisContextImpl context = new DelegatingAnalysisContextImpl(); 8732 AnalysisContextImpl context = new DelegatingAnalysisContextImpl();
4912 sourceFactory2 = new SourceFactory.con2([new DartUriResolver(sdkContext.sour ceFactory.dartSdk), new FileUriResolver()]); 8733 sourceFactory2 = new SourceFactory.con2([new DartUriResolver(sdkContext.sour ceFactory.dartSdk), new FileUriResolver()]);
4913 context.sourceFactory = sourceFactory2; 8734 context.sourceFactory = sourceFactory2;
4914 return context; 8735 return context;
4915 } 8736 }
4916 /**
4917 * Prevent the creation of instances of this class.
4918 */
4919 AnalysisContextFactory() {
4920 }
4921 } 8737 }
4922 class LibraryImportScopeTest extends ResolverTestCase { 8738 class LibraryImportScopeTest extends ResolverTestCase {
4923 void test_conflictingImports() { 8739 void test_conflictingImports() {
4924 AnalysisContext context = new AnalysisContextImpl(); 8740 AnalysisContext context = new AnalysisContextImpl();
4925 String typeNameA = "A"; 8741 String typeNameA = "A";
4926 String typeNameB = "B"; 8742 String typeNameB = "B";
4927 String typeNameC = "C"; 8743 String typeNameC = "C";
4928 ClassElement typeA = new ClassElementImpl(ASTFactory.identifier3(typeNameA)) ; 8744 ClassElement typeA = ElementFactory.classElement2(typeNameA, []);
4929 ClassElement typeB1 = new ClassElementImpl(ASTFactory.identifier3(typeNameB) ); 8745 ClassElement typeB1 = ElementFactory.classElement2(typeNameB, []);
4930 ClassElement typeB2 = new ClassElementImpl(ASTFactory.identifier3(typeNameB) ); 8746 ClassElement typeB2 = ElementFactory.classElement2(typeNameB, []);
4931 ClassElement typeC = new ClassElementImpl(ASTFactory.identifier3(typeNameC)) ; 8747 ClassElement typeC = ElementFactory.classElement2(typeNameC, []);
4932 LibraryElement importedLibrary1 = createTestLibrary2(context, "imported1", [ ]); 8748 LibraryElement importedLibrary1 = createTestLibrary2(context, "imported1", [ ]);
4933 ((importedLibrary1.definingCompilationUnit as CompilationUnitElementImpl)).t ypes = <ClassElement> [typeA, typeB1]; 8749 ((importedLibrary1.definingCompilationUnit as CompilationUnitElementImpl)).t ypes = <ClassElement> [typeA, typeB1];
4934 ImportElementImpl import1 = new ImportElementImpl(); 8750 ImportElementImpl import1 = ElementFactory.importFor(importedLibrary1, null, []);
4935 import1.importedLibrary = importedLibrary1;
4936 LibraryElement importedLibrary2 = createTestLibrary2(context, "imported2", [ ]); 8751 LibraryElement importedLibrary2 = createTestLibrary2(context, "imported2", [ ]);
4937 ((importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl)).t ypes = <ClassElement> [typeB2, typeC]; 8752 ((importedLibrary2.definingCompilationUnit as CompilationUnitElementImpl)).t ypes = <ClassElement> [typeB2, typeC];
4938 ImportElementImpl import2 = new ImportElementImpl(); 8753 ImportElementImpl import2 = ElementFactory.importFor(importedLibrary2, null, []);
4939 import2.importedLibrary = importedLibrary2;
4940 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing ", []); 8754 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing ", []);
4941 importingLibrary.imports = <ImportElement> [import1, import2]; 8755 importingLibrary.imports = <ImportElement> [import1, import2];
4942 GatheringErrorListener errorListener = new GatheringErrorListener(); 8756 {
4943 Scope scope = new LibraryImportScope(importingLibrary, errorListener); 8757 GatheringErrorListener errorListener = new GatheringErrorListener();
4944 JUnitTestCase.assertEquals(typeA, scope.lookup3(typeNameA, importingLibrary) ); 8758 Scope scope = new LibraryImportScope(importingLibrary, errorListener);
4945 errorListener.assertNoErrors(); 8759 JUnitTestCase.assertEquals(typeA, scope.lookup(ASTFactory.identifier3(type NameA), importingLibrary));
4946 JUnitTestCase.assertEquals(typeC, scope.lookup3(typeNameC, importingLibrary) ); 8760 errorListener.assertNoErrors();
4947 errorListener.assertNoErrors(); 8761 JUnitTestCase.assertEquals(typeC, scope.lookup(ASTFactory.identifier3(type NameC), importingLibrary));
4948 Element element = scope.lookup3(typeNameB, importingLibrary); 8762 errorListener.assertNoErrors();
4949 errorListener.assertNoErrors(); 8763 Element element = scope.lookup(ASTFactory.identifier3(typeNameB), importin gLibrary);
4950 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element); 8764 errorListener.assertErrors2([CompileTimeErrorCode.AMBIGUOUS_IMPORT]);
4951 List<Element> conflictingElements2 = ((element as MultiplyDefinedElement)).c onflictingElements; 8765 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element);
4952 JUnitTestCase.assertEquals(typeB1, conflictingElements2[0]); 8766 List<Element> conflictingElements2 = ((element as MultiplyDefinedElement)) .conflictingElements;
4953 JUnitTestCase.assertEquals(typeB2, conflictingElements2[1]); 8767 JUnitTestCase.assertEquals(typeB1, conflictingElements2[0]);
4954 JUnitTestCase.assertEquals(2, conflictingElements2.length); 8768 JUnitTestCase.assertEquals(typeB2, conflictingElements2[1]);
8769 JUnitTestCase.assertEquals(2, conflictingElements2.length);
8770 }
8771 {
8772 GatheringErrorListener errorListener = new GatheringErrorListener();
8773 Scope scope = new LibraryImportScope(importingLibrary, errorListener);
8774 Identifier identifier = ASTFactory.identifier3(typeNameB);
8775 ASTFactory.methodDeclaration(null, ASTFactory.typeName3(identifier, []), n ull, null, ASTFactory.identifier3("foo"), null);
8776 Element element = scope.lookup(identifier, importingLibrary);
8777 errorListener.assertErrors2([StaticWarningCode.AMBIGUOUS_IMPORT]);
8778 EngineTestCase.assertInstanceOf(MultiplyDefinedElement, element);
8779 }
4955 } 8780 }
4956 void test_creation_empty() { 8781 void test_creation_empty() {
4957 LibraryElement definingLibrary = createTestLibrary(); 8782 LibraryElement definingLibrary = createTestLibrary();
4958 GatheringErrorListener errorListener = new GatheringErrorListener(); 8783 GatheringErrorListener errorListener = new GatheringErrorListener();
4959 new LibraryImportScope(definingLibrary, errorListener); 8784 new LibraryImportScope(definingLibrary, errorListener);
4960 } 8785 }
4961 void test_creation_nonEmpty() { 8786 void test_creation_nonEmpty() {
4962 AnalysisContext context = new AnalysisContextImpl(); 8787 AnalysisContext context = new AnalysisContextImpl();
4963 String importedTypeName = "A"; 8788 String importedTypeName = "A";
4964 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo rtedTypeName)); 8789 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo rtedTypeName));
4965 LibraryElement importedLibrary = createTestLibrary2(context, "imported", []) ; 8790 LibraryElement importedLibrary = createTestLibrary2(context, "imported", []) ;
4966 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [importedType]; 8791 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [importedType];
4967 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing" , []); 8792 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing" , []);
4968 ImportElementImpl importElement = new ImportElementImpl(); 8793 ImportElementImpl importElement = new ImportElementImpl();
4969 importElement.importedLibrary = importedLibrary; 8794 importElement.importedLibrary = importedLibrary;
4970 definingLibrary.imports = <ImportElement> [importElement]; 8795 definingLibrary.imports = <ImportElement> [importElement];
4971 GatheringErrorListener errorListener = new GatheringErrorListener(); 8796 GatheringErrorListener errorListener = new GatheringErrorListener();
4972 Scope scope = new LibraryImportScope(definingLibrary, errorListener); 8797 Scope scope = new LibraryImportScope(definingLibrary, errorListener);
4973 JUnitTestCase.assertEquals(importedType, scope.lookup3(importedTypeName, def iningLibrary)); 8798 JUnitTestCase.assertEquals(importedType, scope.lookup(ASTFactory.identifier3 (importedTypeName), definingLibrary));
4974 } 8799 }
4975 void test_getDefiningLibrary() { 8800 void test_getDefiningLibrary() {
4976 LibraryElement definingLibrary = createTestLibrary(); 8801 LibraryElement definingLibrary = createTestLibrary();
4977 GatheringErrorListener errorListener = new GatheringErrorListener(); 8802 GatheringErrorListener errorListener = new GatheringErrorListener();
4978 Scope scope = new LibraryImportScope(definingLibrary, errorListener); 8803 Scope scope = new LibraryImportScope(definingLibrary, errorListener);
4979 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary); 8804 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary);
4980 } 8805 }
4981 void test_getErrorListener() { 8806 void test_getErrorListener() {
4982 LibraryElement definingLibrary = createTestLibrary(); 8807 LibraryElement definingLibrary = createTestLibrary();
4983 GatheringErrorListener errorListener = new GatheringErrorListener(); 8808 GatheringErrorListener errorListener = new GatheringErrorListener();
4984 Scope scope = new LibraryImportScope(definingLibrary, errorListener); 8809 Scope scope = new LibraryImportScope(definingLibrary, errorListener);
4985 JUnitTestCase.assertEquals(errorListener, scope.errorListener); 8810 JUnitTestCase.assertEquals(errorListener, scope.errorListener);
4986 } 8811 }
8812 void test_prefixedAndNonPrefixed() {
8813 AnalysisContext context = new AnalysisContextImpl();
8814 String typeName = "C";
8815 String prefixName = "p";
8816 ClassElement prefixedType = ElementFactory.classElement2(typeName, []);
8817 ClassElement nonPrefixedType = ElementFactory.classElement2(typeName, []);
8818 LibraryElement prefixedLibrary = createTestLibrary2(context, "import.prefixe d", []);
8819 ((prefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [prefixedType];
8820 ImportElementImpl prefixedImport = ElementFactory.importFor(prefixedLibrary, ElementFactory.prefix(prefixName), []);
8821 LibraryElement nonPrefixedLibrary = createTestLibrary2(context, "import.nonP refixed", []);
8822 ((nonPrefixedLibrary.definingCompilationUnit as CompilationUnitElementImpl)) .types = <ClassElement> [nonPrefixedType];
8823 ImportElementImpl nonPrefixedImport = ElementFactory.importFor(nonPrefixedLi brary, null, []);
8824 LibraryElementImpl importingLibrary = createTestLibrary2(context, "importing ", []);
8825 importingLibrary.imports = <ImportElement> [prefixedImport, nonPrefixedImpor t];
8826 GatheringErrorListener errorListener = new GatheringErrorListener();
8827 Scope scope = new LibraryImportScope(importingLibrary, errorListener);
8828 Element prefixedElement = scope.lookup(ASTFactory.identifier5(prefixName, ty peName), importingLibrary);
8829 errorListener.assertNoErrors();
8830 JUnitTestCase.assertSame(prefixedType, prefixedElement);
8831 Element nonPrefixedElement = scope.lookup(ASTFactory.identifier3(typeName), importingLibrary);
8832 errorListener.assertNoErrors();
8833 JUnitTestCase.assertSame(nonPrefixedType, nonPrefixedElement);
8834 }
4987 static dartSuite() { 8835 static dartSuite() {
4988 _ut.group('LibraryImportScopeTest', () { 8836 _ut.group('LibraryImportScopeTest', () {
4989 _ut.test('test_conflictingImports', () { 8837 _ut.test('test_conflictingImports', () {
4990 final __test = new LibraryImportScopeTest(); 8838 final __test = new LibraryImportScopeTest();
4991 runJUnitTest(__test, __test.test_conflictingImports); 8839 runJUnitTest(__test, __test.test_conflictingImports);
4992 }); 8840 });
4993 _ut.test('test_creation_empty', () { 8841 _ut.test('test_creation_empty', () {
4994 final __test = new LibraryImportScopeTest(); 8842 final __test = new LibraryImportScopeTest();
4995 runJUnitTest(__test, __test.test_creation_empty); 8843 runJUnitTest(__test, __test.test_creation_empty);
4996 }); 8844 });
4997 _ut.test('test_creation_nonEmpty', () { 8845 _ut.test('test_creation_nonEmpty', () {
4998 final __test = new LibraryImportScopeTest(); 8846 final __test = new LibraryImportScopeTest();
4999 runJUnitTest(__test, __test.test_creation_nonEmpty); 8847 runJUnitTest(__test, __test.test_creation_nonEmpty);
5000 }); 8848 });
5001 _ut.test('test_getDefiningLibrary', () { 8849 _ut.test('test_getDefiningLibrary', () {
5002 final __test = new LibraryImportScopeTest(); 8850 final __test = new LibraryImportScopeTest();
5003 runJUnitTest(__test, __test.test_getDefiningLibrary); 8851 runJUnitTest(__test, __test.test_getDefiningLibrary);
5004 }); 8852 });
5005 _ut.test('test_getErrorListener', () { 8853 _ut.test('test_getErrorListener', () {
5006 final __test = new LibraryImportScopeTest(); 8854 final __test = new LibraryImportScopeTest();
5007 runJUnitTest(__test, __test.test_getErrorListener); 8855 runJUnitTest(__test, __test.test_getErrorListener);
5008 }); 8856 });
8857 _ut.test('test_prefixedAndNonPrefixed', () {
8858 final __test = new LibraryImportScopeTest();
8859 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed);
8860 });
5009 }); 8861 });
5010 } 8862 }
5011 } 8863 }
8864
5012 /** 8865 /**
5013 * Instances of the class {@code ResolutionVerifier} verify that all of the node s in an AST 8866 * Instances of the class {@code ResolutionVerifier} verify that all of the node s in an AST
5014 * structure that should have been resolved were resolved. 8867 * structure that should have been resolved were resolved.
5015 */ 8868 */
5016 class ResolutionVerifier extends RecursiveASTVisitor<Object> { 8869 class ResolutionVerifier extends RecursiveASTVisitor<Object> {
8870
5017 /** 8871 /**
5018 * A set containing nodes that are known to not be resolvable and should there fore not cause the 8872 * A set containing nodes that are known to not be resolvable and should there fore not cause the
5019 * test to fail. 8873 * test to fail.
5020 */ 8874 */
5021 Set<ASTNode> _knownExceptions; 8875 Set<ASTNode> _knownExceptions;
8876
5022 /** 8877 /**
5023 * A list containing all of the AST nodes that were not resolved. 8878 * A list containing all of the AST nodes that were not resolved.
5024 */ 8879 */
5025 List<ASTNode> _unresolvedNodes = new List<ASTNode>(); 8880 List<ASTNode> _unresolvedNodes = new List<ASTNode>();
8881
5026 /** 8882 /**
5027 * A list containing all of the AST nodes that were resolved to an element of the wrong type. 8883 * A list containing all of the AST nodes that were resolved to an element of the wrong type.
5028 */ 8884 */
5029 List<ASTNode> _wrongTypedNodes = new List<ASTNode>(); 8885 List<ASTNode> _wrongTypedNodes = new List<ASTNode>();
8886
5030 /** 8887 /**
5031 * Initialize a newly created verifier to verify that all of the nodes in the visited AST 8888 * Initialize a newly created verifier to verify that all of the nodes in the visited AST
5032 * structures that are expected to have been resolved have an element associat ed with them. 8889 * structures that are expected to have been resolved have an element associat ed with them.
5033 */ 8890 */
5034 ResolutionVerifier() { 8891 ResolutionVerifier() {
5035 _jtd_constructor_351_impl(); 8892 _jtd_constructor_359_impl();
5036 } 8893 }
5037 _jtd_constructor_351_impl() { 8894 _jtd_constructor_359_impl() {
5038 _jtd_constructor_352_impl(null); 8895 _jtd_constructor_360_impl(null);
5039 } 8896 }
8897
5040 /** 8898 /**
5041 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST 8899 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST
5042 * structures that are expected to have been resolved have an element associat ed with them. Nodes 8900 * structures that are expected to have been resolved have an element associat ed with them. Nodes
5043 * in the set of known exceptions are not expected to have been resolved, even if they normally 8901 * in the set of known exceptions are not expected to have been resolved, even if they normally
5044 * would have been expected to have been resolved. 8902 * would have been expected to have been resolved.
5045 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should 8903 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should
5046 * therefore not cause the test to fail 8904 * therefore not cause the test to fail
5047 */ 8905 */
5048 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) { 8906 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) {
5049 _jtd_constructor_352_impl(knownExceptions2); 8907 _jtd_constructor_360_impl(knownExceptions2);
5050 } 8908 }
5051 _jtd_constructor_352_impl(Set<ASTNode> knownExceptions2) { 8909 _jtd_constructor_360_impl(Set<ASTNode> knownExceptions2) {
5052 this._knownExceptions = knownExceptions2; 8910 this._knownExceptions = knownExceptions2;
5053 } 8911 }
8912
5054 /** 8913 /**
5055 * Assert that all of the visited identifiers were resolved. 8914 * Assert that all of the visited identifiers were resolved.
5056 */ 8915 */
5057 void assertResolved() { 8916 void assertResolved() {
5058 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) { 8917 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) {
5059 PrintStringWriter writer = new PrintStringWriter(); 8918 PrintStringWriter writer = new PrintStringWriter();
5060 if (!_unresolvedNodes.isEmpty) { 8919 if (!_unresolvedNodes.isEmpty) {
5061 writer.print("Failed to resolve "); 8920 writer.print("Failed to resolve ");
5062 writer.print(_unresolvedNodes.length); 8921 writer.print(_unresolvedNodes.length);
5063 writer.println(" nodes:"); 8922 writer.println(" nodes:");
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5185 String importedTypeName = "A"; 9044 String importedTypeName = "A";
5186 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo rtedTypeName)); 9045 ClassElement importedType = new ClassElementImpl(ASTFactory.identifier3(impo rtedTypeName));
5187 LibraryElement importedLibrary = createTestLibrary2(context, "imported", []) ; 9046 LibraryElement importedLibrary = createTestLibrary2(context, "imported", []) ;
5188 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [importedType]; 9047 ((importedLibrary.definingCompilationUnit as CompilationUnitElementImpl)).ty pes = <ClassElement> [importedType];
5189 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing" , []); 9048 LibraryElementImpl definingLibrary = createTestLibrary2(context, "importing" , []);
5190 ImportElementImpl importElement = new ImportElementImpl(); 9049 ImportElementImpl importElement = new ImportElementImpl();
5191 importElement.importedLibrary = importedLibrary; 9050 importElement.importedLibrary = importedLibrary;
5192 definingLibrary.imports = <ImportElement> [importElement]; 9051 definingLibrary.imports = <ImportElement> [importElement];
5193 GatheringErrorListener errorListener = new GatheringErrorListener(); 9052 GatheringErrorListener errorListener = new GatheringErrorListener();
5194 Scope scope = new LibraryScope(definingLibrary, errorListener); 9053 Scope scope = new LibraryScope(definingLibrary, errorListener);
5195 JUnitTestCase.assertEquals(importedType, scope.lookup3(importedTypeName, def iningLibrary)); 9054 JUnitTestCase.assertEquals(importedType, scope.lookup(ASTFactory.identifier3 (importedTypeName), definingLibrary));
5196 } 9055 }
5197 void test_getDefiningLibrary() { 9056 void test_getDefiningLibrary() {
5198 LibraryElement definingLibrary = createTestLibrary(); 9057 LibraryElement definingLibrary = createTestLibrary();
5199 GatheringErrorListener errorListener = new GatheringErrorListener(); 9058 GatheringErrorListener errorListener = new GatheringErrorListener();
5200 Scope scope = new LibraryScope(definingLibrary, errorListener); 9059 Scope scope = new LibraryScope(definingLibrary, errorListener);
5201 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary); 9060 JUnitTestCase.assertEquals(definingLibrary, scope.definingLibrary);
5202 } 9061 }
5203 void test_getErrorListener() { 9062 void test_getErrorListener() {
5204 LibraryElement definingLibrary = createTestLibrary(); 9063 LibraryElement definingLibrary = createTestLibrary();
5205 GatheringErrorListener errorListener = new GatheringErrorListener(); 9064 GatheringErrorListener errorListener = new GatheringErrorListener();
(...skipping 15 matching lines...) Expand all
5221 runJUnitTest(__test, __test.test_getDefiningLibrary); 9080 runJUnitTest(__test, __test.test_getDefiningLibrary);
5222 }); 9081 });
5223 _ut.test('test_getErrorListener', () { 9082 _ut.test('test_getErrorListener', () {
5224 final __test = new LibraryScopeTest(); 9083 final __test = new LibraryScopeTest();
5225 runJUnitTest(__test, __test.test_getErrorListener); 9084 runJUnitTest(__test, __test.test_getErrorListener);
5226 }); 9085 });
5227 }); 9086 });
5228 } 9087 }
5229 } 9088 }
5230 class StaticTypeAnalyzerTest extends EngineTestCase { 9089 class StaticTypeAnalyzerTest extends EngineTestCase {
9090
5231 /** 9091 /**
5232 * The error listener to which errors will be reported. 9092 * The error listener to which errors will be reported.
5233 */ 9093 */
5234 GatheringErrorListener _listener; 9094 GatheringErrorListener _listener;
9095
9096 /**
9097 * The resolver visitor used to create the analyzer.
9098 */
9099 ResolverVisitor _visitor;
9100
5235 /** 9101 /**
5236 * The analyzer being used to analyze the test cases. 9102 * The analyzer being used to analyze the test cases.
5237 */ 9103 */
5238 StaticTypeAnalyzer _analyzer; 9104 StaticTypeAnalyzer _analyzer;
9105
5239 /** 9106 /**
5240 * The type provider used to access the types. 9107 * The type provider used to access the types.
5241 */ 9108 */
5242 TestTypeProvider _typeProvider; 9109 TestTypeProvider _typeProvider;
5243 void fail_visitFunctionExpressionInvocation() { 9110 void fail_visitFunctionExpressionInvocation() {
5244 JUnitTestCase.fail("Not yet tested"); 9111 JUnitTestCase.fail("Not yet tested");
5245 _listener.assertNoErrors(); 9112 _listener.assertNoErrors();
5246 } 9113 }
5247 void fail_visitMethodInvocation() { 9114 void fail_visitMethodInvocation() {
5248 JUnitTestCase.fail("Not yet tested"); 9115 JUnitTestCase.fail("Not yet tested");
(...skipping 23 matching lines...) Expand all
5272 InterfaceType superclassType = superclass.type; 9139 InterfaceType superclassType = superclass.type;
5273 ClassElement subclass = ElementFactory.classElement("B", superclassType, []) ; 9140 ClassElement subclass = ElementFactory.classElement("B", superclassType, []) ;
5274 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa ctory.typeName(subclass, [])); 9141 Expression node = ASTFactory.asExpression(ASTFactory.thisExpression(), ASTFa ctory.typeName(subclass, []));
5275 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType)); 9142 JUnitTestCase.assertSame(subclass.type, analyze2(node, superclassType));
5276 _listener.assertNoErrors(); 9143 _listener.assertNoErrors();
5277 } 9144 }
5278 void test_visitAssignmentExpression_compound() { 9145 void test_visitAssignmentExpression_compound() {
5279 InterfaceType numType2 = _typeProvider.numType; 9146 InterfaceType numType2 = _typeProvider.numType;
5280 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i"); 9147 SimpleIdentifier identifier = resolvedVariable(_typeProvider.intType, "i");
5281 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke nType.PLUS_EQ, resolvedInteger(1)); 9148 AssignmentExpression node = ASTFactory.assignmentExpression(identifier, Toke nType.PLUS_EQ, resolvedInteger(1));
5282 node.element = getMethod(numType2, "+"); 9149 MethodElement plusMethod = getMethod(numType2, "+");
9150 node.staticElement = plusMethod;
9151 node.element = plusMethod;
5283 JUnitTestCase.assertSame(numType2, analyze(node)); 9152 JUnitTestCase.assertSame(numType2, analyze(node));
5284 _listener.assertNoErrors(); 9153 _listener.assertNoErrors();
5285 } 9154 }
5286 void test_visitAssignmentExpression_simple() { 9155 void test_visitAssignmentExpression_simple() {
5287 InterfaceType intType2 = _typeProvider.intType; 9156 InterfaceType intType2 = _typeProvider.intType;
5288 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType2, "i"), TokenType.EQ, resolvedInteger(0)); 9157 Expression node = ASTFactory.assignmentExpression(resolvedVariable(intType2, "i"), TokenType.EQ, resolvedInteger(0));
5289 JUnitTestCase.assertSame(intType2, analyze(node)); 9158 JUnitTestCase.assertSame(intType2, analyze(node));
5290 _listener.assertNoErrors(); 9159 _listener.assertNoErrors();
5291 } 9160 }
5292 void test_visitBinaryExpression_equals() { 9161 void test_visitBinaryExpression_equals() {
5293 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. EQ_EQ, resolvedInteger(3)); 9162 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. EQ_EQ, resolvedInteger(3));
5294 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9163 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5295 _listener.assertNoErrors(); 9164 _listener.assertNoErrors();
5296 } 9165 }
5297 void test_visitBinaryExpression_logicalAnd() { 9166 void test_visitBinaryExpression_logicalAnd() {
5298 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true)); 9167 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.AMPERSAND_AMPERSAND, ASTFactory.booleanLiteral(true));
5299 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9168 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5300 _listener.assertNoErrors(); 9169 _listener.assertNoErrors();
5301 } 9170 }
5302 void test_visitBinaryExpression_logicalOr() { 9171 void test_visitBinaryExpression_logicalOr() {
5303 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.BAR_BAR, ASTFactory.booleanLiteral(true)); 9172 Expression node = ASTFactory.binaryExpression(ASTFactory.booleanLiteral(fals e), TokenType.BAR_BAR, ASTFactory.booleanLiteral(true));
5304 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9173 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5305 _listener.assertNoErrors(); 9174 _listener.assertNoErrors();
5306 } 9175 }
5307 void test_visitBinaryExpression_notEquals() { 9176 void test_visitBinaryExpression_notEquals() {
5308 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. BANG_EQ, resolvedInteger(3)); 9177 Expression node = ASTFactory.binaryExpression(resolvedInteger(2), TokenType. BANG_EQ, resolvedInteger(3));
5309 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9178 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5310 _listener.assertNoErrors(); 9179 _listener.assertNoErrors();
5311 } 9180 }
5312 void test_visitBinaryExpression_plus() { 9181 void test_visitBinaryExpression_plusID() {
5313 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(2), Toke nType.PLUS, resolvedInteger(2)); 9182 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke nType.PLUS, resolvedDouble(2.0));
5314 node.element = getMethod(_typeProvider.numType, "+"); 9183 setStaticElement(node, getMethod(_typeProvider.numType, "+"));
9184 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node));
9185 _listener.assertNoErrors();
9186 }
9187 void test_visitBinaryExpression_plusII() {
9188 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke nType.PLUS, resolvedInteger(2));
9189 setStaticElement(node, getMethod(_typeProvider.numType, "+"));
5315 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); 9190 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
5316 _listener.assertNoErrors(); 9191 _listener.assertNoErrors();
5317 } 9192 }
9193 void test_visitBinaryExpression_slash() {
9194 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(2), Toke nType.SLASH, resolvedInteger(2));
9195 setStaticElement(node, getMethod(_typeProvider.numType, "/"));
9196 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node));
9197 _listener.assertNoErrors();
9198 }
9199 void test_visitBinaryExpression_starID() {
9200 BinaryExpression node = ASTFactory.binaryExpression(resolvedInteger(1), Toke nType.PLUS, resolvedDouble(2.0));
9201 setStaticElement(node, getMethod(_typeProvider.numType, "*"));
9202 JUnitTestCase.assertSame(_typeProvider.doubleType, analyze(node));
9203 _listener.assertNoErrors();
9204 }
5318 void test_visitBooleanLiteral_false() { 9205 void test_visitBooleanLiteral_false() {
5319 Expression node = ASTFactory.booleanLiteral(false); 9206 Expression node = ASTFactory.booleanLiteral(false);
5320 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9207 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5321 _listener.assertNoErrors(); 9208 _listener.assertNoErrors();
5322 } 9209 }
5323 void test_visitBooleanLiteral_true() { 9210 void test_visitBooleanLiteral_true() {
5324 Expression node = ASTFactory.booleanLiteral(true); 9211 Expression node = ASTFactory.booleanLiteral(true);
5325 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9212 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5326 _listener.assertNoErrors(); 9213 _listener.assertNoErrors();
5327 } 9214 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
5470 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0))); 9357 FunctionExpression node = resolvedFunctionExpression(ASTFactory.formalParame terList([p]), ASTFactory.expressionFunctionBody(resolvedInteger(0)));
5471 analyze3(p); 9358 analyze3(p);
5472 Type2 resultType = analyze(node); 9359 Type2 resultType = analyze(node);
5473 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType2], null , resultType); 9360 assertFunctionType(_typeProvider.intType, null, <Type2> [dynamicType2], null , resultType);
5474 _listener.assertNoErrors(); 9361 _listener.assertNoErrors();
5475 } 9362 }
5476 void test_visitIndexExpression_getter() { 9363 void test_visitIndexExpression_getter() {
5477 InterfaceType listType2 = _typeProvider.listType; 9364 InterfaceType listType2 = _typeProvider.listType;
5478 SimpleIdentifier identifier = resolvedVariable(listType2, "a"); 9365 SimpleIdentifier identifier = resolvedVariable(listType2, "a");
5479 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2)); 9366 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2));
5480 node.element = listType2.element.methods[0]; 9367 MethodElement indexMethod = listType2.element.methods[0];
9368 node.staticElement = indexMethod;
9369 node.element = indexMethod;
5481 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node)); 9370 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node));
5482 _listener.assertNoErrors(); 9371 _listener.assertNoErrors();
5483 } 9372 }
5484 void test_visitIndexExpression_setter() { 9373 void test_visitIndexExpression_setter() {
5485 InterfaceType listType2 = _typeProvider.listType; 9374 InterfaceType listType2 = _typeProvider.listType;
5486 SimpleIdentifier identifier = resolvedVariable(listType2, "a"); 9375 SimpleIdentifier identifier = resolvedVariable(listType2, "a");
5487 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2)); 9376 IndexExpression node = ASTFactory.indexExpression(identifier, resolvedIntege r(2));
5488 node.element = listType2.element.methods[1]; 9377 MethodElement indexMethod = listType2.element.methods[1];
9378 node.staticElement = indexMethod;
9379 node.element = indexMethod;
5489 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); 9380 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0));
5490 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node)); 9381 JUnitTestCase.assertSame(listType2.typeArguments[0], analyze(node));
5491 _listener.assertNoErrors(); 9382 _listener.assertNoErrors();
5492 } 9383 }
5493 void test_visitIndexExpression_typeParameters() { 9384 void test_visitIndexExpression_typeParameters() {
5494 InterfaceType intType2 = _typeProvider.intType; 9385 InterfaceType intType2 = _typeProvider.intType;
5495 InterfaceType listType2 = _typeProvider.listType; 9386 InterfaceType listType2 = _typeProvider.listType;
5496 MethodElement methodElement = getMethod(listType2, "[]"); 9387 MethodElement methodElement = getMethod(listType2, "[]");
5497 SimpleIdentifier identifier = ASTFactory.identifier3("list"); 9388 SimpleIdentifier identifier = ASTFactory.identifier3("list");
5498 InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]); 9389 InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]);
5499 identifier.staticType = listOfIntType; 9390 identifier.staticType = listOfIntType;
5500 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0)); 9391 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0));
5501 indexExpression2.element = MethodMember.from(methodElement, listOfIntType); 9392 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType);
9393 indexExpression2.staticElement = indexMethod;
9394 indexExpression2.element = indexMethod;
5502 JUnitTestCase.assertSame(intType2, analyze(indexExpression2)); 9395 JUnitTestCase.assertSame(intType2, analyze(indexExpression2));
5503 _listener.assertNoErrors(); 9396 _listener.assertNoErrors();
5504 } 9397 }
5505 void test_visitIndexExpression_typeParameters_inSetterContext() { 9398 void test_visitIndexExpression_typeParameters_inSetterContext() {
5506 InterfaceType intType2 = _typeProvider.intType; 9399 InterfaceType intType2 = _typeProvider.intType;
5507 InterfaceType listType2 = _typeProvider.listType; 9400 InterfaceType listType2 = _typeProvider.listType;
5508 MethodElement methodElement = getMethod(listType2, "[]="); 9401 MethodElement methodElement = getMethod(listType2, "[]=");
5509 SimpleIdentifier identifier = ASTFactory.identifier3("list"); 9402 SimpleIdentifier identifier = ASTFactory.identifier3("list");
5510 InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]); 9403 InterfaceType listOfIntType = listType2.substitute5(<Type2> [intType2]);
5511 identifier.staticType = listOfIntType; 9404 identifier.staticType = listOfIntType;
5512 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0)); 9405 IndexExpression indexExpression2 = ASTFactory.indexExpression(identifier, AS TFactory.integer(0));
5513 indexExpression2.element = MethodMember.from(methodElement, listOfIntType); 9406 MethodElement indexMethod = MethodMember.from(methodElement, listOfIntType);
9407 indexExpression2.staticElement = indexMethod;
9408 indexExpression2.element = indexMethod;
5514 ASTFactory.assignmentExpression(indexExpression2, TokenType.EQ, ASTFactory.i nteger(0)); 9409 ASTFactory.assignmentExpression(indexExpression2, TokenType.EQ, ASTFactory.i nteger(0));
5515 JUnitTestCase.assertSame(intType2, analyze(indexExpression2)); 9410 JUnitTestCase.assertSame(intType2, analyze(indexExpression2));
5516 _listener.assertNoErrors(); 9411 _listener.assertNoErrors();
5517 } 9412 }
5518 void test_visitInstanceCreationExpression_named() { 9413 void test_visitInstanceCreationExpression_named() {
5519 ClassElementImpl classElement = ElementFactory.classElement2("C", []); 9414 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
5520 String constructorName = "m"; 9415 String constructorName = "m";
5521 ConstructorElementImpl constructor = ElementFactory.constructorElement(const ructorName); 9416 ConstructorElementImpl constructor = ElementFactory.constructorElement(class Element, constructorName);
5522 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 9417 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
5523 constructorType.returnType = classElement.type; 9418 constructorType.returnType = classElement.type;
5524 constructor.type = constructorType; 9419 constructor.type = constructorType;
5525 classElement.constructors = <ConstructorElement> [constructor]; 9420 classElement.constructors = <ConstructorElement> [constructor];
5526 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam e)]); 9421 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam e)]);
5527 node.element = constructor; 9422 node.element = constructor;
5528 JUnitTestCase.assertSame(classElement.type, analyze(node)); 9423 JUnitTestCase.assertSame(classElement.type, analyze(node));
5529 _listener.assertNoErrors(); 9424 _listener.assertNoErrors();
5530 } 9425 }
5531 void test_visitInstanceCreationExpression_typeParameters() { 9426 void test_visitInstanceCreationExpression_typeParameters() {
5532 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); 9427 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]);
5533 ClassElementImpl elementI = ElementFactory.classElement2("I", []); 9428 ClassElementImpl elementI = ElementFactory.classElement2("I", []);
5534 ConstructorElementImpl constructor = ElementFactory.constructorElement(null) ; 9429 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme ntC, null);
5535 elementC.constructors = <ConstructorElement> [constructor]; 9430 elementC.constructors = <ConstructorElement> [constructor];
5536 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 9431 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
5537 constructorType.returnType = elementC.type; 9432 constructorType.returnType = elementC.type;
5538 constructor.type = constructorType; 9433 constructor.type = constructorType;
5539 TypeName typeName2 = ASTFactory.typeName(elementC, [ASTFactory.typeName(elem entI, [])]); 9434 TypeName typeName2 = ASTFactory.typeName(elementC, [ASTFactory.typeName(elem entI, [])]);
5540 typeName2.type = elementC.type.substitute5(<Type2> [elementI.type]); 9435 typeName2.type = elementC.type.substitute5(<Type2> [elementI.type]);
5541 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, typeName2, []); 9436 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, typeName2, []);
5542 node.element = constructor; 9437 node.element = constructor;
5543 InterfaceType interfaceType = analyze(node) as InterfaceType; 9438 InterfaceType interfaceType = analyze(node) as InterfaceType;
5544 List<Type2> typeArgs = interfaceType.typeArguments; 9439 List<Type2> typeArgs = interfaceType.typeArguments;
5545 JUnitTestCase.assertEquals(1, typeArgs.length); 9440 JUnitTestCase.assertEquals(1, typeArgs.length);
5546 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); 9441 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]);
5547 _listener.assertNoErrors(); 9442 _listener.assertNoErrors();
5548 } 9443 }
5549 void test_visitInstanceCreationExpression_unnamed() { 9444 void test_visitInstanceCreationExpression_unnamed() {
5550 ClassElementImpl classElement = ElementFactory.classElement2("C", []); 9445 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
5551 ConstructorElementImpl constructor = ElementFactory.constructorElement(null) ; 9446 ConstructorElementImpl constructor = ElementFactory.constructorElement(class Element, null);
5552 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 9447 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
5553 constructorType.returnType = classElement.type; 9448 constructorType.returnType = classElement.type;
5554 constructor.type = constructorType; 9449 constructor.type = constructorType;
5555 classElement.constructors = <ConstructorElement> [constructor]; 9450 classElement.constructors = <ConstructorElement> [constructor];
5556 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), []); 9451 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), []);
5557 node.element = constructor; 9452 node.element = constructor;
5558 JUnitTestCase.assertSame(classElement.type, analyze(node)); 9453 JUnitTestCase.assertSame(classElement.type, analyze(node));
5559 _listener.assertNoErrors(); 9454 _listener.assertNoErrors();
5560 } 9455 }
5561 void test_visitIntegerLiteral() { 9456 void test_visitIntegerLiteral() {
(...skipping 19 matching lines...) Expand all
5581 } 9476 }
5582 void test_visitListLiteral_nonEmpty() { 9477 void test_visitListLiteral_nonEmpty() {
5583 Expression node = ASTFactory.listLiteral([resolvedInteger(0)]); 9478 Expression node = ASTFactory.listLiteral([resolvedInteger(0)]);
5584 Type2 resultType = analyze(node); 9479 Type2 resultType = analyze(node);
5585 assertType2(_typeProvider.listType.substitute5(<Type2> [_typeProvider.dynami cType]), resultType); 9480 assertType2(_typeProvider.listType.substitute5(<Type2> [_typeProvider.dynami cType]), resultType);
5586 _listener.assertNoErrors(); 9481 _listener.assertNoErrors();
5587 } 9482 }
5588 void test_visitMapLiteral_empty() { 9483 void test_visitMapLiteral_empty() {
5589 Expression node = ASTFactory.mapLiteral2([]); 9484 Expression node = ASTFactory.mapLiteral2([]);
5590 Type2 resultType = analyze(node); 9485 Type2 resultType = analyze(node);
5591 assertType2(_typeProvider.mapType.substitute5(<Type2> [_typeProvider.stringT ype, _typeProvider.dynamicType]), resultType); 9486 assertType2(_typeProvider.mapType.substitute5(<Type2> [_typeProvider.dynamic Type, _typeProvider.dynamicType]), resultType);
5592 _listener.assertNoErrors(); 9487 _listener.assertNoErrors();
5593 } 9488 }
5594 void test_visitMapLiteral_nonEmpty() { 9489 void test_visitMapLiteral_nonEmpty() {
5595 Expression node = ASTFactory.mapLiteral2([ASTFactory.mapLiteralEntry("k", re solvedInteger(0))]); 9490 Expression node = ASTFactory.mapLiteral2([ASTFactory.mapLiteralEntry("k", re solvedInteger(0))]);
5596 Type2 resultType = analyze(node); 9491 Type2 resultType = analyze(node);
5597 assertType2(_typeProvider.mapType.substitute5(<Type2> [_typeProvider.stringT ype, _typeProvider.dynamicType]), resultType); 9492 assertType2(_typeProvider.mapType.substitute5(<Type2> [_typeProvider.dynamic Type, _typeProvider.dynamicType]), resultType);
5598 _listener.assertNoErrors(); 9493 _listener.assertNoErrors();
5599 } 9494 }
5600 void test_visitNamedExpression() { 9495 void test_visitNamedExpression() {
5601 Expression node = ASTFactory.namedExpression2("n", resolvedString("a")); 9496 Expression node = ASTFactory.namedExpression2("n", resolvedString("a"));
5602 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); 9497 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
5603 _listener.assertNoErrors(); 9498 _listener.assertNoErrors();
5604 } 9499 }
5605 void test_visitNullLiteral() { 9500 void test_visitNullLiteral() {
5606 Expression node = ASTFactory.nullLiteral(); 9501 Expression node = ASTFactory.nullLiteral();
5607 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); 9502 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5647 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9542 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5648 _listener.assertNoErrors(); 9543 _listener.assertNoErrors();
5649 } 9544 }
5650 void test_visitPrefixExpression_bang() { 9545 void test_visitPrefixExpression_bang() {
5651 PrefixExpression node = ASTFactory.prefixExpression(TokenType.BANG, resolved Integer(0)); 9546 PrefixExpression node = ASTFactory.prefixExpression(TokenType.BANG, resolved Integer(0));
5652 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9547 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5653 _listener.assertNoErrors(); 9548 _listener.assertNoErrors();
5654 } 9549 }
5655 void test_visitPrefixExpression_minus() { 9550 void test_visitPrefixExpression_minus() {
5656 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS, resolve dInteger(0)); 9551 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS, resolve dInteger(0));
5657 node.element = getMethod(_typeProvider.numType, "-"); 9552 MethodElement minusMethod = getMethod(_typeProvider.numType, "-");
9553 node.staticElement = minusMethod;
9554 node.element = minusMethod;
5658 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node)); 9555 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node));
5659 _listener.assertNoErrors(); 9556 _listener.assertNoErrors();
5660 } 9557 }
5661 void test_visitPrefixExpression_minusMinus() { 9558 void test_visitPrefixExpression_minusMinus() {
5662 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS_MINUS, r esolvedInteger(0)); 9559 PrefixExpression node = ASTFactory.prefixExpression(TokenType.MINUS_MINUS, r esolvedInteger(0));
5663 node.element = getMethod(_typeProvider.numType, "-"); 9560 MethodElement minusMethod = getMethod(_typeProvider.numType, "-");
5664 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node)); 9561 node.staticElement = minusMethod;
9562 node.element = minusMethod;
9563 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
5665 _listener.assertNoErrors(); 9564 _listener.assertNoErrors();
5666 } 9565 }
5667 void test_visitPrefixExpression_not() { 9566 void test_visitPrefixExpression_not() {
5668 Expression node = ASTFactory.prefixExpression(TokenType.BANG, ASTFactory.boo leanLiteral(true)); 9567 Expression node = ASTFactory.prefixExpression(TokenType.BANG, ASTFactory.boo leanLiteral(true));
5669 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node)); 9568 JUnitTestCase.assertSame(_typeProvider.boolType, analyze(node));
5670 _listener.assertNoErrors(); 9569 _listener.assertNoErrors();
5671 } 9570 }
5672 void test_visitPrefixExpression_plusPlus() { 9571 void test_visitPrefixExpression_plusPlus() {
5673 PrefixExpression node = ASTFactory.prefixExpression(TokenType.PLUS_PLUS, res olvedInteger(0)); 9572 PrefixExpression node = ASTFactory.prefixExpression(TokenType.PLUS_PLUS, res olvedInteger(0));
5674 node.element = getMethod(_typeProvider.numType, "+"); 9573 MethodElement plusMethod = getMethod(_typeProvider.numType, "+");
5675 JUnitTestCase.assertSame(_typeProvider.numType, analyze(node)); 9574 node.staticElement = plusMethod;
9575 node.element = plusMethod;
9576 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
5676 _listener.assertNoErrors(); 9577 _listener.assertNoErrors();
5677 } 9578 }
5678 void test_visitPrefixExpression_tilde() { 9579 void test_visitPrefixExpression_tilde() {
5679 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve dInteger(0)); 9580 PrefixExpression node = ASTFactory.prefixExpression(TokenType.TILDE, resolve dInteger(0));
5680 node.element = getMethod(_typeProvider.intType, "~"); 9581 MethodElement tildeMethod = getMethod(_typeProvider.intType, "~");
9582 node.staticElement = tildeMethod;
9583 node.element = tildeMethod;
5681 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); 9584 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
5682 _listener.assertNoErrors(); 9585 _listener.assertNoErrors();
5683 } 9586 }
5684 void test_visitPropertyAccess_getter() { 9587 void test_visitPropertyAccess_getter() {
5685 Type2 boolType2 = _typeProvider.boolType; 9588 Type2 boolType2 = _typeProvider.boolType;
5686 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false , boolType2); 9589 PropertyAccessorElementImpl getter = ElementFactory.getterElement("b", false , boolType2);
5687 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a") , "b"); 9590 PropertyAccess node = ASTFactory.propertyAccess2(ASTFactory.identifier3("a") , "b");
5688 node.propertyName.element = getter; 9591 node.propertyName.element = getter;
5689 JUnitTestCase.assertSame(boolType2, analyze(node)); 9592 JUnitTestCase.assertSame(boolType2, analyze(node));
5690 _listener.assertNoErrors(); 9593 _listener.assertNoErrors();
(...skipping 14 matching lines...) Expand all
5705 } 9608 }
5706 void test_visitStringInterpolation() { 9609 void test_visitStringInterpolation() {
5707 Expression node = ASTFactory.string([ASTFactory.interpolationString("a", "a" ), ASTFactory.interpolationExpression(resolvedString("b")), ASTFactory.interpola tionString("c", "c")]); 9610 Expression node = ASTFactory.string([ASTFactory.interpolationString("a", "a" ), ASTFactory.interpolationExpression(resolvedString("b")), ASTFactory.interpola tionString("c", "c")]);
5708 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node)); 9611 JUnitTestCase.assertSame(_typeProvider.stringType, analyze(node));
5709 _listener.assertNoErrors(); 9612 _listener.assertNoErrors();
5710 } 9613 }
5711 void test_visitSuperExpression() { 9614 void test_visitSuperExpression() {
5712 InterfaceType superType = ElementFactory.classElement2("A", []).type; 9615 InterfaceType superType = ElementFactory.classElement2("A", []).type;
5713 InterfaceType thisType = ElementFactory.classElement("B", superType, []).typ e; 9616 InterfaceType thisType = ElementFactory.classElement("B", superType, []).typ e;
5714 Expression node = ASTFactory.superExpression(); 9617 Expression node = ASTFactory.superExpression();
5715 JUnitTestCase.assertSame(superType, analyze2(node, thisType)); 9618 JUnitTestCase.assertSame(thisType, analyze2(node, thisType));
5716 _listener.assertNoErrors(); 9619 _listener.assertNoErrors();
5717 } 9620 }
5718 void test_visitThisExpression() { 9621 void test_visitThisExpression() {
5719 InterfaceType thisType = ElementFactory.classElement("B", ElementFactory.cla ssElement2("A", []).type, []).type; 9622 InterfaceType thisType = ElementFactory.classElement("B", ElementFactory.cla ssElement2("A", []).type, []).type;
5720 Expression node = ASTFactory.thisExpression(); 9623 Expression node = ASTFactory.thisExpression();
5721 JUnitTestCase.assertSame(thisType, analyze2(node, thisType)); 9624 JUnitTestCase.assertSame(thisType, analyze2(node, thisType));
5722 _listener.assertNoErrors(); 9625 _listener.assertNoErrors();
5723 } 9626 }
5724 void test_visitThrowExpression_withoutValue() { 9627 void test_visitThrowExpression_withoutValue() {
5725 Expression node = ASTFactory.throwExpression(); 9628 Expression node = ASTFactory.throwExpression();
5726 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); 9629 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node));
5727 _listener.assertNoErrors(); 9630 _listener.assertNoErrors();
5728 } 9631 }
5729 void test_visitThrowExpression_withValue() { 9632 void test_visitThrowExpression_withValue() {
5730 Expression node = ASTFactory.throwExpression2(resolvedInteger(0)); 9633 Expression node = ASTFactory.throwExpression2(resolvedInteger(0));
5731 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node)); 9634 JUnitTestCase.assertSame(_typeProvider.bottomType, analyze(node));
5732 _listener.assertNoErrors(); 9635 _listener.assertNoErrors();
5733 } 9636 }
9637
5734 /** 9638 /**
5735 * Return the type associated with the given expression after the static type analyzer has 9639 * Return the type associated with the given expression after the static type analyzer has
5736 * computed a type for it. 9640 * computed a type for it.
5737 * @param node the expression with which the type is associated 9641 * @param node the expression with which the type is associated
5738 * @return the type associated with the expression 9642 * @return the type associated with the expression
5739 */ 9643 */
5740 Type2 analyze(Expression node) => analyze2(node, null); 9644 Type2 analyze(Expression node) => analyze2(node, null);
9645
5741 /** 9646 /**
5742 * Return the type associated with the given expression after the static type analyzer has 9647 * Return the type associated with the given expression after the static type analyzer has
5743 * computed a type for it. 9648 * computed a type for it.
5744 * @param node the expression with which the type is associated 9649 * @param node the expression with which the type is associated
5745 * @param thisType the type of 'this' 9650 * @param thisType the type of 'this'
5746 * @return the type associated with the expression 9651 * @return the type associated with the expression
5747 */ 9652 */
5748 Type2 analyze2(Expression node, InterfaceType thisType) { 9653 Type2 analyze2(Expression node, InterfaceType thisType) {
5749 try { 9654 try {
5750 _analyzer.thisType_J2DAccessor = thisType; 9655 _analyzer.thisType_J2DAccessor = thisType;
5751 } catch (exception) { 9656 } catch (exception) {
5752 throw new IllegalArgumentException("Could not set type of 'this'", excepti on); 9657 throw new IllegalArgumentException("Could not set type of 'this'", excepti on);
5753 } 9658 }
5754 node.accept(_analyzer); 9659 node.accept(_analyzer);
5755 return node.staticType; 9660 return node.staticType;
5756 } 9661 }
9662
5757 /** 9663 /**
5758 * Return the type associated with the given parameter after the static type a nalyzer has computed 9664 * Return the type associated with the given parameter after the static type a nalyzer has computed
5759 * a type for it. 9665 * a type for it.
5760 * @param node the parameter with which the type is associated 9666 * @param node the parameter with which the type is associated
5761 * @return the type associated with the parameter 9667 * @return the type associated with the parameter
5762 */ 9668 */
5763 Type2 analyze3(FormalParameter node) { 9669 Type2 analyze3(FormalParameter node) {
5764 node.accept(_analyzer); 9670 node.accept(_analyzer);
5765 return ((node.identifier.element as ParameterElement)).type; 9671 return ((node.identifier.element as ParameterElement)).type;
5766 } 9672 }
9673
5767 /** 9674 /**
5768 * Assert that the actual type is a function type with the expected characteri stics. 9675 * Assert that the actual type is a function type with the expected characteri stics.
5769 * @param expectedReturnType the expected return type of the function 9676 * @param expectedReturnType the expected return type of the function
5770 * @param expectedNormalTypes the expected types of the normal parameters 9677 * @param expectedNormalTypes the expected types of the normal parameters
5771 * @param expectedOptionalTypes the expected types of the optional parameters 9678 * @param expectedOptionalTypes the expected types of the optional parameters
5772 * @param expectedNamedTypes the expected types of the named parameters 9679 * @param expectedNamedTypes the expected types of the named parameters
5773 * @param actualType the type being tested 9680 * @param actualType the type being tested
5774 */ 9681 */
5775 void assertFunctionType(Type2 expectedReturnType, List<Type2> expectedNormalTy pes, List<Type2> expectedOptionalTypes, Map<String, Type2> expectedNamedTypes, T ype2 actualType) { 9682 void assertFunctionType(Type2 expectedReturnType, List<Type2> expectedNormalTy pes, List<Type2> expectedOptionalTypes, Map<String, Type2> expectedNamedTypes, T ype2 actualType) {
5776 EngineTestCase.assertInstanceOf(FunctionType, actualType); 9683 EngineTestCase.assertInstanceOf(FunctionType, actualType);
(...skipping 23 matching lines...) Expand all
5800 EngineTestCase.assertSize2(0, namedTypes); 9707 EngineTestCase.assertSize2(0, namedTypes);
5801 } else { 9708 } else {
5802 EngineTestCase.assertSize2(expectedNamedTypes.length, namedTypes); 9709 EngineTestCase.assertSize2(expectedNamedTypes.length, namedTypes);
5803 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes)) { 9710 for (MapEntry<String, Type2> entry in getMapEntrySet(expectedNamedTypes)) {
5804 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]); 9711 JUnitTestCase.assertSame(entry.getValue(), namedTypes[entry.getKey()]);
5805 } 9712 }
5806 } 9713 }
5807 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType); 9714 JUnitTestCase.assertSame(expectedReturnType, functionType.returnType);
5808 } 9715 }
5809 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType) { 9716 void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType) {
5810 JUnitTestCase.assertEquals(expectedType.name, actualType.name); 9717 JUnitTestCase.assertEquals(expectedType.displayName, actualType.displayName) ;
5811 JUnitTestCase.assertEquals(expectedType.element, actualType.element); 9718 JUnitTestCase.assertEquals(expectedType.element, actualType.element);
5812 List<Type2> expectedArguments = expectedType.typeArguments; 9719 List<Type2> expectedArguments = expectedType.typeArguments;
5813 int length2 = expectedArguments.length; 9720 int length2 = expectedArguments.length;
5814 List<Type2> actualArguments = actualType.typeArguments; 9721 List<Type2> actualArguments = actualType.typeArguments;
5815 EngineTestCase.assertLength(length2, actualArguments); 9722 EngineTestCase.assertLength(length2, actualArguments);
5816 for (int i = 0; i < length2; i++) { 9723 for (int i = 0; i < length2; i++) {
5817 assertType2(expectedArguments[i], actualArguments[i]); 9724 assertType2(expectedArguments[i], actualArguments[i]);
5818 } 9725 }
5819 } 9726 }
5820 void assertType2(Type2 expectedType, Type2 actualType) { 9727 void assertType2(Type2 expectedType, Type2 actualType) {
5821 if (expectedType is InterfaceTypeImpl) { 9728 if (expectedType is InterfaceTypeImpl) {
5822 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); 9729 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType);
5823 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy peImpl)); 9730 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy peImpl));
5824 } 9731 }
5825 } 9732 }
9733
5826 /** 9734 /**
5827 * Create the analyzer used by the tests. 9735 * Create the analyzer used by the tests.
5828 * @return the analyzer to be used by the tests 9736 * @return the analyzer to be used by the tests
5829 */ 9737 */
5830 StaticTypeAnalyzer createAnalyzer() { 9738 StaticTypeAnalyzer createAnalyzer() {
5831 AnalysisContextImpl context = new AnalysisContextImpl(); 9739 AnalysisContextImpl context = new AnalysisContextImpl();
5832 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Di rectoryBasedDartSdk.defaultSdk)]); 9740 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Di rectoryBasedDartSdk.defaultSdk)]);
5833 context.sourceFactory = sourceFactory; 9741 context.sourceFactory = sourceFactory;
5834 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache , FileUtilities2.createFile("/lib.dart")); 9742 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache , FileUtilities2.createFile("/lib.dart"));
5835 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("lib.dart"); 9743 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("lib.dart");
5836 definingCompilationUnit.source = source; 9744 definingCompilationUnit.source = source;
5837 LibraryElementImpl definingLibrary = new LibraryElementImpl(context, null); 9745 LibraryElementImpl definingLibrary = new LibraryElementImpl(context, null);
5838 definingLibrary.definingCompilationUnit = definingCompilationUnit; 9746 definingLibrary.definingCompilationUnit = definingCompilationUnit;
5839 Library library = new Library(context, _listener, source); 9747 Library library = new Library(context, _listener, source);
5840 library.libraryElement = definingLibrary; 9748 library.libraryElement = definingLibrary;
5841 ResolverVisitor visitor = new ResolverVisitor.con1(library, source, _typePro vider); 9749 _visitor = new ResolverVisitor.con1(library, source, _typeProvider);
5842 visitor.overrideManager.enterScope(); 9750 _visitor.overrideManager.enterScope();
5843 try { 9751 try {
5844 return visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer; 9752 return _visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer;
5845 } catch (exception) { 9753 } catch (exception) {
5846 throw new IllegalArgumentException("Could not create analyzer", exception) ; 9754 throw new IllegalArgumentException("Could not create analyzer", exception) ;
5847 } 9755 }
5848 } 9756 }
9757
5849 /** 9758 /**
5850 * Return an integer literal that has been resolved to the correct type. 9759 * Return an integer literal that has been resolved to the correct type.
5851 * @param value the value of the literal 9760 * @param value the value of the literal
5852 * @return an integer literal that has been resolved to the correct type 9761 * @return an integer literal that has been resolved to the correct type
5853 */ 9762 */
5854 DoubleLiteral resolvedDouble(double value) { 9763 DoubleLiteral resolvedDouble(double value) {
5855 DoubleLiteral literal = ASTFactory.doubleLiteral(value); 9764 DoubleLiteral literal = ASTFactory.doubleLiteral(value);
5856 literal.staticType = _typeProvider.doubleType; 9765 literal.staticType = _typeProvider.doubleType;
5857 return literal; 9766 return literal;
5858 } 9767 }
9768
5859 /** 9769 /**
5860 * Create a function expression that has an element associated with it, where the element has an 9770 * Create a function expression that has an element associated with it, where the element has an
5861 * incomplete type associated with it (just like the one{@link ElementBuilder# visitFunctionExpression(FunctionExpression)} would have built if we had 9771 * incomplete type associated with it (just like the one{@link ElementBuilder# visitFunctionExpression(FunctionExpression)} would have built if we had
5862 * run it). 9772 * run it).
5863 * @param parameters the parameters to the function 9773 * @param parameters the parameters to the function
5864 * @param body the body of the function 9774 * @param body the body of the function
5865 * @return a resolved function expression 9775 * @return a resolved function expression
5866 */ 9776 */
5867 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters2, FunctionBody body) { 9777 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters2, FunctionBody body) {
5868 for (FormalParameter parameter in parameters2.parameters) { 9778 for (FormalParameter parameter in parameters2.parameters) {
5869 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er); 9779 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er);
5870 element.parameterKind = parameter.kind; 9780 element.parameterKind = parameter.kind;
5871 element.type = _typeProvider.dynamicType; 9781 element.type = _typeProvider.dynamicType;
5872 parameter.identifier.element = element; 9782 parameter.identifier.element = element;
5873 } 9783 }
5874 FunctionExpression node = ASTFactory.functionExpression2(parameters2, body); 9784 FunctionExpression node = ASTFactory.functionExpression2(parameters2, body);
5875 FunctionElementImpl element = new FunctionElementImpl.con1(null); 9785 FunctionElementImpl element = new FunctionElementImpl.con1(null);
5876 element.type = new FunctionTypeImpl.con1(element); 9786 element.type = new FunctionTypeImpl.con1(element);
5877 node.element = element; 9787 node.element = element;
5878 return node; 9788 return node;
5879 } 9789 }
9790
5880 /** 9791 /**
5881 * Return an integer literal that has been resolved to the correct type. 9792 * Return an integer literal that has been resolved to the correct type.
5882 * @param value the value of the literal 9793 * @param value the value of the literal
5883 * @return an integer literal that has been resolved to the correct type 9794 * @return an integer literal that has been resolved to the correct type
5884 */ 9795 */
5885 IntegerLiteral resolvedInteger(int value) { 9796 IntegerLiteral resolvedInteger(int value) {
5886 IntegerLiteral literal = ASTFactory.integer(value); 9797 IntegerLiteral literal = ASTFactory.integer(value);
5887 literal.staticType = _typeProvider.intType; 9798 literal.staticType = _typeProvider.intType;
5888 return literal; 9799 return literal;
5889 } 9800 }
9801
5890 /** 9802 /**
5891 * Return a string literal that has been resolved to the correct type. 9803 * Return a string literal that has been resolved to the correct type.
5892 * @param value the value of the literal 9804 * @param value the value of the literal
5893 * @return a string literal that has been resolved to the correct type 9805 * @return a string literal that has been resolved to the correct type
5894 */ 9806 */
5895 SimpleStringLiteral resolvedString(String value) { 9807 SimpleStringLiteral resolvedString(String value) {
5896 SimpleStringLiteral string = ASTFactory.string2(value); 9808 SimpleStringLiteral string = ASTFactory.string2(value);
5897 string.staticType = _typeProvider.stringType; 9809 string.staticType = _typeProvider.stringType;
5898 return string; 9810 return string;
5899 } 9811 }
9812
5900 /** 9813 /**
5901 * Return a simple identifier that has been resolved to a variable element wit h the given type. 9814 * Return a simple identifier that has been resolved to a variable element wit h the given type.
5902 * @param type the type of the variable being represented 9815 * @param type the type of the variable being represented
5903 * @param variableName the name of the variable 9816 * @param variableName the name of the variable
5904 * @return a simple identifier that has been resolved to a variable element wi th the given type 9817 * @return a simple identifier that has been resolved to a variable element wi th the given type
5905 */ 9818 */
5906 SimpleIdentifier resolvedVariable(InterfaceType type2, String variableName) { 9819 SimpleIdentifier resolvedVariable(InterfaceType type2, String variableName) {
5907 SimpleIdentifier identifier = ASTFactory.identifier3(variableName); 9820 SimpleIdentifier identifier = ASTFactory.identifier3(variableName);
5908 VariableElementImpl element = ElementFactory.localVariableElement(identifier ); 9821 VariableElementImpl element = ElementFactory.localVariableElement(identifier );
5909 element.type = type2; 9822 element.type = type2;
5910 identifier.element = element; 9823 identifier.element = element;
5911 identifier.staticType = type2; 9824 identifier.staticType = type2;
5912 return identifier; 9825 return identifier;
5913 } 9826 }
9827
9828 /**
9829 * Sets the element for the node and remembers it as the static resolution.
9830 */
9831 void setStaticElement(BinaryExpression node, MethodElement element2) {
9832 node.staticElement = element2;
9833 node.element = element2;
9834 }
9835
5914 /** 9836 /**
5915 * Set the type of the given parameter to the given type. 9837 * Set the type of the given parameter to the given type.
5916 * @param parameter the parameter whose type is to be set 9838 * @param parameter the parameter whose type is to be set
5917 * @param type the new type of the given parameter 9839 * @param type the new type of the given parameter
5918 */ 9840 */
5919 void setType(FormalParameter parameter, Type2 type2) { 9841 void setType(FormalParameter parameter, Type2 type2) {
5920 SimpleIdentifier identifier2 = parameter.identifier; 9842 SimpleIdentifier identifier2 = parameter.identifier;
5921 Element element2 = identifier2.element; 9843 Element element2 = identifier2.element;
5922 if (element2 is! ParameterElement) { 9844 if (element2 is! ParameterElement) {
5923 element2 = new ParameterElementImpl(identifier2); 9845 element2 = new ParameterElementImpl(identifier2);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5956 runJUnitTest(__test, __test.test_visitBinaryExpression_logicalAnd); 9878 runJUnitTest(__test, __test.test_visitBinaryExpression_logicalAnd);
5957 }); 9879 });
5958 _ut.test('test_visitBinaryExpression_logicalOr', () { 9880 _ut.test('test_visitBinaryExpression_logicalOr', () {
5959 final __test = new StaticTypeAnalyzerTest(); 9881 final __test = new StaticTypeAnalyzerTest();
5960 runJUnitTest(__test, __test.test_visitBinaryExpression_logicalOr); 9882 runJUnitTest(__test, __test.test_visitBinaryExpression_logicalOr);
5961 }); 9883 });
5962 _ut.test('test_visitBinaryExpression_notEquals', () { 9884 _ut.test('test_visitBinaryExpression_notEquals', () {
5963 final __test = new StaticTypeAnalyzerTest(); 9885 final __test = new StaticTypeAnalyzerTest();
5964 runJUnitTest(__test, __test.test_visitBinaryExpression_notEquals); 9886 runJUnitTest(__test, __test.test_visitBinaryExpression_notEquals);
5965 }); 9887 });
5966 _ut.test('test_visitBinaryExpression_plus', () { 9888 _ut.test('test_visitBinaryExpression_plusID', () {
5967 final __test = new StaticTypeAnalyzerTest(); 9889 final __test = new StaticTypeAnalyzerTest();
5968 runJUnitTest(__test, __test.test_visitBinaryExpression_plus); 9890 runJUnitTest(__test, __test.test_visitBinaryExpression_plusID);
9891 });
9892 _ut.test('test_visitBinaryExpression_plusII', () {
9893 final __test = new StaticTypeAnalyzerTest();
9894 runJUnitTest(__test, __test.test_visitBinaryExpression_plusII);
9895 });
9896 _ut.test('test_visitBinaryExpression_slash', () {
9897 final __test = new StaticTypeAnalyzerTest();
9898 runJUnitTest(__test, __test.test_visitBinaryExpression_slash);
9899 });
9900 _ut.test('test_visitBinaryExpression_starID', () {
9901 final __test = new StaticTypeAnalyzerTest();
9902 runJUnitTest(__test, __test.test_visitBinaryExpression_starID);
5969 }); 9903 });
5970 _ut.test('test_visitBooleanLiteral_false', () { 9904 _ut.test('test_visitBooleanLiteral_false', () {
5971 final __test = new StaticTypeAnalyzerTest(); 9905 final __test = new StaticTypeAnalyzerTest();
5972 runJUnitTest(__test, __test.test_visitBooleanLiteral_false); 9906 runJUnitTest(__test, __test.test_visitBooleanLiteral_false);
5973 }); 9907 });
5974 _ut.test('test_visitBooleanLiteral_true', () { 9908 _ut.test('test_visitBooleanLiteral_true', () {
5975 final __test = new StaticTypeAnalyzerTest(); 9909 final __test = new StaticTypeAnalyzerTest();
5976 runJUnitTest(__test, __test.test_visitBooleanLiteral_true); 9910 runJUnitTest(__test, __test.test_visitBooleanLiteral_true);
5977 }); 9911 });
5978 _ut.test('test_visitCascadeExpression', () { 9912 _ut.test('test_visitCascadeExpression', () {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
6175 final __test = new StaticTypeAnalyzerTest(); 10109 final __test = new StaticTypeAnalyzerTest();
6176 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue); 10110 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue);
6177 }); 10111 });
6178 }); 10112 });
6179 } 10113 }
6180 } 10114 }
6181 class EnclosedScopeTest extends ResolverTestCase { 10115 class EnclosedScopeTest extends ResolverTestCase {
6182 void test_define_duplicate() { 10116 void test_define_duplicate() {
6183 LibraryElement definingLibrary2 = createTestLibrary(); 10117 LibraryElement definingLibrary2 = createTestLibrary();
6184 GatheringErrorListener errorListener2 = new GatheringErrorListener(); 10118 GatheringErrorListener errorListener2 = new GatheringErrorListener();
6185 Scope rootScope = new Scope_16(definingLibrary2, errorListener2); 10119 Scope rootScope = new Scope_17(definingLibrary2, errorListener2);
6186 EnclosedScope scope = new EnclosedScope(rootScope); 10120 EnclosedScope scope = new EnclosedScope(rootScope);
6187 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 10121 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
6188 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 10122 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
6189 scope.define(element1); 10123 scope.define(element1);
6190 scope.define(element2); 10124 scope.define(element2);
6191 errorListener2.assertErrors3([ErrorSeverity.ERROR]); 10125 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
6192 } 10126 }
6193 void test_define_normal() { 10127 void test_define_normal() {
6194 LibraryElement definingLibrary3 = createTestLibrary(); 10128 LibraryElement definingLibrary3 = createTestLibrary();
6195 GatheringErrorListener errorListener3 = new GatheringErrorListener(); 10129 GatheringErrorListener errorListener3 = new GatheringErrorListener();
6196 Scope rootScope = new Scope_17(definingLibrary3, errorListener3); 10130 Scope rootScope = new Scope_18(definingLibrary3, errorListener3);
6197 EnclosedScope outerScope = new EnclosedScope(rootScope); 10131 EnclosedScope outerScope = new EnclosedScope(rootScope);
6198 EnclosedScope innerScope = new EnclosedScope(outerScope); 10132 EnclosedScope innerScope = new EnclosedScope(outerScope);
6199 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 10133 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
6200 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2")); 10134 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
6201 outerScope.define(element1); 10135 outerScope.define(element1);
6202 innerScope.define(element2); 10136 innerScope.define(element2);
6203 errorListener3.assertNoErrors(); 10137 errorListener3.assertNoErrors();
6204 } 10138 }
6205 static dartSuite() { 10139 static dartSuite() {
6206 _ut.group('EnclosedScopeTest', () { 10140 _ut.group('EnclosedScopeTest', () {
6207 _ut.test('test_define_duplicate', () { 10141 _ut.test('test_define_duplicate', () {
6208 final __test = new EnclosedScopeTest(); 10142 final __test = new EnclosedScopeTest();
6209 runJUnitTest(__test, __test.test_define_duplicate); 10143 runJUnitTest(__test, __test.test_define_duplicate);
6210 }); 10144 });
6211 _ut.test('test_define_normal', () { 10145 _ut.test('test_define_normal', () {
6212 final __test = new EnclosedScopeTest(); 10146 final __test = new EnclosedScopeTest();
6213 runJUnitTest(__test, __test.test_define_normal); 10147 runJUnitTest(__test, __test.test_define_normal);
6214 }); 10148 });
6215 }); 10149 });
6216 } 10150 }
6217 } 10151 }
6218 class Scope_16 extends Scope { 10152 class Scope_17 extends Scope {
6219 LibraryElement definingLibrary2; 10153 LibraryElement definingLibrary2;
6220 GatheringErrorListener errorListener2; 10154 GatheringErrorListener errorListener2;
6221 Scope_16(this.definingLibrary2, this.errorListener2) : super(); 10155 Scope_17(this.definingLibrary2, this.errorListener2) : super();
6222 LibraryElement get definingLibrary => definingLibrary2; 10156 LibraryElement get definingLibrary => definingLibrary2;
6223 AnalysisErrorListener get errorListener => errorListener2; 10157 AnalysisErrorListener get errorListener => errorListener2;
6224 Element lookup3(String name, LibraryElement referencingLibrary) => null; 10158 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
6225 } 10159 }
6226 class Scope_17 extends Scope { 10160 class Scope_18 extends Scope {
6227 LibraryElement definingLibrary3; 10161 LibraryElement definingLibrary3;
6228 GatheringErrorListener errorListener3; 10162 GatheringErrorListener errorListener3;
6229 Scope_17(this.definingLibrary3, this.errorListener3) : super(); 10163 Scope_18(this.definingLibrary3, this.errorListener3) : super();
6230 LibraryElement get definingLibrary => definingLibrary3; 10164 LibraryElement get definingLibrary => definingLibrary3;
6231 AnalysisErrorListener get errorListener => errorListener3; 10165 AnalysisErrorListener get errorListener => errorListener3;
6232 Element lookup3(String name, LibraryElement referencingLibrary) => null; 10166 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
6233 } 10167 }
6234 class LibraryElementBuilderTest extends EngineTestCase { 10168 class LibraryElementBuilderTest extends EngineTestCase {
10169
6235 /** 10170 /**
6236 * The source factory used to create {@link Source sources}. 10171 * The source factory used to create {@link Source sources}.
6237 */ 10172 */
6238 SourceFactory _sourceFactory; 10173 SourceFactory _sourceFactory;
6239 void setUp() { 10174 void setUp() {
6240 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); 10175 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
6241 } 10176 }
10177 void test_accessorsAcrossFiles() {
10178 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "part 'first.dart';", "part 'second.dart';"]));
10179 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "int g et V => 0;"]));
10180 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "void set V(int v) {}"]));
10181 LibraryElement element = buildLibrary(librarySource, []);
10182 JUnitTestCase.assertNotNull(element);
10183 List<CompilationUnitElement> sourcedUnits = element.parts;
10184 EngineTestCase.assertLength(2, sourcedUnits);
10185 List<PropertyAccessorElement> firstAccessors = sourcedUnits[0].accessors;
10186 EngineTestCase.assertLength(1, firstAccessors);
10187 List<PropertyAccessorElement> secondAccessors = sourcedUnits[1].accessors;
10188 EngineTestCase.assertLength(1, secondAccessors);
10189 JUnitTestCase.assertSame(firstAccessors[0].variable, secondAccessors[0].vari able);
10190 }
6242 void test_empty() { 10191 void test_empty() {
6243 Source librarySource = addSource("/lib.dart", "library lib;"); 10192 Source librarySource = addSource("/lib.dart", "library lib;");
6244 LibraryElement element = buildLibrary(librarySource, []); 10193 LibraryElement element = buildLibrary(librarySource, []);
6245 JUnitTestCase.assertNotNull(element); 10194 JUnitTestCase.assertNotNull(element);
6246 JUnitTestCase.assertEquals("lib", element.name); 10195 JUnitTestCase.assertEquals("lib", element.name);
6247 JUnitTestCase.assertNull(element.entryPoint); 10196 JUnitTestCase.assertNull(element.entryPoint);
6248 EngineTestCase.assertLength(0, element.importedLibraries); 10197 EngineTestCase.assertLength(0, element.importedLibraries);
6249 EngineTestCase.assertLength(0, element.imports); 10198 EngineTestCase.assertLength(0, element.imports);
6250 JUnitTestCase.assertSame(element, element.library); 10199 JUnitTestCase.assertSame(element, element.library);
6251 EngineTestCase.assertLength(0, element.prefixes); 10200 EngineTestCase.assertLength(0, element.prefixes);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6293 assertTypes(sourcedUnits[0], ["C"]); 10242 assertTypes(sourcedUnits[0], ["C"]);
6294 assertTypes(sourcedUnits[1], ["B"]); 10243 assertTypes(sourcedUnits[1], ["B"]);
6295 } 10244 }
6296 } 10245 }
6297 void test_singleFile() { 10246 void test_singleFile() {
6298 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "class A {}"])); 10247 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "", "class A {}"]));
6299 LibraryElement element = buildLibrary(librarySource, []); 10248 LibraryElement element = buildLibrary(librarySource, []);
6300 JUnitTestCase.assertNotNull(element); 10249 JUnitTestCase.assertNotNull(element);
6301 assertTypes(element.definingCompilationUnit, ["A"]); 10250 assertTypes(element.definingCompilationUnit, ["A"]);
6302 } 10251 }
10252
6303 /** 10253 /**
6304 * Add a source file to the content provider. The file path should be absolute . 10254 * Add a source file to the content provider. The file path should be absolute .
6305 * @param filePath the path of the file being added 10255 * @param filePath the path of the file being added
6306 * @param contents the contents to be returned by the content provider for the specified file 10256 * @param contents the contents to be returned by the content provider for the specified file
6307 * @return the source object representing the added file 10257 * @return the source object representing the added file
6308 */ 10258 */
6309 Source addSource(String filePath, String contents) { 10259 Source addSource(String filePath, String contents) {
6310 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath)); 10260 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath));
6311 _sourceFactory.setContents(source, contents); 10261 _sourceFactory.setContents(source, contents);
6312 return source; 10262 return source;
6313 } 10263 }
10264
6314 /** 10265 /**
6315 * Ensure that there are elements representing all of the types in the given a rray of type names. 10266 * Ensure that there are elements representing all of the types in the given a rray of type names.
6316 * @param unit the compilation unit containing the types 10267 * @param unit the compilation unit containing the types
6317 * @param typeNames the names of the types that should be found 10268 * @param typeNames the names of the types that should be found
6318 */ 10269 */
6319 void assertTypes(CompilationUnitElement unit, List<String> typeNames) { 10270 void assertTypes(CompilationUnitElement unit, List<String> typeNames) {
6320 JUnitTestCase.assertNotNull(unit); 10271 JUnitTestCase.assertNotNull(unit);
6321 List<ClassElement> types2 = unit.types; 10272 List<ClassElement> types2 = unit.types;
6322 EngineTestCase.assertLength(typeNames.length, types2); 10273 EngineTestCase.assertLength(typeNames.length, types2);
6323 for (ClassElement type in types2) { 10274 for (ClassElement type in types2) {
6324 JUnitTestCase.assertNotNull(type); 10275 JUnitTestCase.assertNotNull(type);
6325 String actualTypeName = type.name; 10276 String actualTypeName = type.displayName;
6326 bool wasExpected = false; 10277 bool wasExpected = false;
6327 for (String expectedTypeName in typeNames) { 10278 for (String expectedTypeName in typeNames) {
6328 if (expectedTypeName == actualTypeName) { 10279 if (expectedTypeName == actualTypeName) {
6329 wasExpected = true; 10280 wasExpected = true;
6330 } 10281 }
6331 } 10282 }
6332 if (!wasExpected) { 10283 if (!wasExpected) {
6333 JUnitTestCase.fail("Found unexpected type ${actualTypeName}"); 10284 JUnitTestCase.fail("Found unexpected type ${actualTypeName}");
6334 } 10285 }
6335 } 10286 }
6336 } 10287 }
10288
6337 /** 10289 /**
6338 * Build the element model for the library whose defining compilation unit has the given source. 10290 * Build the element model for the library whose defining compilation unit has the given source.
6339 * @param librarySource the source of the defining compilation unit for the li brary 10291 * @param librarySource the source of the defining compilation unit for the li brary
6340 * @param expectedErrorCodes the errors that are expected to be found while bu ilding the element 10292 * @param expectedErrorCodes the errors that are expected to be found while bu ilding the element
6341 * model 10293 * model
6342 * @return the element model that was built for the library 10294 * @return the element model that was built for the library
6343 * @throws Exception if the element model could not be built 10295 * @throws Exception if the element model could not be built
6344 */ 10296 */
6345 LibraryElement buildLibrary(Source librarySource, List<ErrorCode> expectedErro rCodes) { 10297 LibraryElement buildLibrary(Source librarySource, List<ErrorCode> expectedErro rCodes) {
6346 AnalysisContextImpl context = new AnalysisContextImpl(); 10298 AnalysisContextImpl context = new AnalysisContextImpl();
6347 context.sourceFactory = new SourceFactory.con2([new DartUriResolver(Director yBasedDartSdk.defaultSdk), new FileUriResolver()]); 10299 context.sourceFactory = new SourceFactory.con2([new DartUriResolver(Director yBasedDartSdk.defaultSdk), new FileUriResolver()]);
6348 GatheringErrorListener listener = new GatheringErrorListener(); 10300 LibraryResolver resolver = new LibraryResolver(context);
6349 LibraryResolver resolver = new LibraryResolver.con2(context, listener);
6350 LibraryElementBuilder builder = new LibraryElementBuilder(resolver); 10301 LibraryElementBuilder builder = new LibraryElementBuilder(resolver);
6351 Library library = resolver.createLibrary(librarySource) as Library; 10302 Library library = resolver.createLibrary(librarySource) as Library;
6352 LibraryElement element = builder.buildLibrary(library); 10303 LibraryElement element = builder.buildLibrary(library);
10304 GatheringErrorListener listener = new GatheringErrorListener();
10305 listener.addAll(resolver.errorListener);
6353 listener.assertErrors2(expectedErrorCodes); 10306 listener.assertErrors2(expectedErrorCodes);
6354 return element; 10307 return element;
6355 } 10308 }
6356 static dartSuite() { 10309 static dartSuite() {
6357 _ut.group('LibraryElementBuilderTest', () { 10310 _ut.group('LibraryElementBuilderTest', () {
10311 _ut.test('test_accessorsAcrossFiles', () {
10312 final __test = new LibraryElementBuilderTest();
10313 runJUnitTest(__test, __test.test_accessorsAcrossFiles);
10314 });
6358 _ut.test('test_empty', () { 10315 _ut.test('test_empty', () {
6359 final __test = new LibraryElementBuilderTest(); 10316 final __test = new LibraryElementBuilderTest();
6360 runJUnitTest(__test, __test.test_empty); 10317 runJUnitTest(__test, __test.test_empty);
6361 }); 10318 });
6362 _ut.test('test_invalidUri_part', () { 10319 _ut.test('test_invalidUri_part', () {
6363 final __test = new LibraryElementBuilderTest(); 10320 final __test = new LibraryElementBuilderTest();
6364 runJUnitTest(__test, __test.test_invalidUri_part); 10321 runJUnitTest(__test, __test.test_invalidUri_part);
6365 }); 10322 });
6366 _ut.test('test_missingLibraryDirectiveWithPart', () { 10323 _ut.test('test_missingLibraryDirectiveWithPart', () {
6367 final __test = new LibraryElementBuilderTest(); 10324 final __test = new LibraryElementBuilderTest();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
6442 final __test = new ScopeTest(); 10399 final __test = new ScopeTest();
6443 runJUnitTest(__test, __test.test_isPrivateName_nonPrivate); 10400 runJUnitTest(__test, __test.test_isPrivateName_nonPrivate);
6444 }); 10401 });
6445 _ut.test('test_isPrivateName_private', () { 10402 _ut.test('test_isPrivateName_private', () {
6446 final __test = new ScopeTest(); 10403 final __test = new ScopeTest();
6447 runJUnitTest(__test, __test.test_isPrivateName_private); 10404 runJUnitTest(__test, __test.test_isPrivateName_private);
6448 }); 10405 });
6449 }); 10406 });
6450 } 10407 }
6451 } 10408 }
10409
6452 /** 10410 /**
6453 * A non-abstract subclass that can be used for testing purposes. 10411 * A non-abstract subclass that can be used for testing purposes.
6454 */ 10412 */
6455 class ScopeTest_TestScope extends Scope { 10413 class ScopeTest_TestScope extends Scope {
10414
6456 /** 10415 /**
6457 * The element representing the library in which this scope is enclosed. 10416 * The element representing the library in which this scope is enclosed.
6458 */ 10417 */
6459 LibraryElement _definingLibrary; 10418 LibraryElement _definingLibrary;
10419
6460 /** 10420 /**
6461 * The listener that is to be informed when an error is encountered. 10421 * The listener that is to be informed when an error is encountered.
6462 */ 10422 */
6463 AnalysisErrorListener _errorListener; 10423 AnalysisErrorListener _errorListener;
6464 ScopeTest_TestScope(LibraryElement definingLibrary, AnalysisErrorListener erro rListener) { 10424 ScopeTest_TestScope(LibraryElement definingLibrary, AnalysisErrorListener erro rListener) {
6465 this._definingLibrary = definingLibrary; 10425 this._definingLibrary = definingLibrary;
6466 this._errorListener = errorListener; 10426 this._errorListener = errorListener;
6467 } 10427 }
6468 LibraryElement get definingLibrary => _definingLibrary; 10428 LibraryElement get definingLibrary => _definingLibrary;
6469 AnalysisErrorListener get errorListener => _errorListener; 10429 AnalysisErrorListener get errorListener => _errorListener;
6470 Element lookup3(String name, LibraryElement referencingLibrary) => localLookup (name, referencingLibrary); 10430 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => localLookup(name, referencingLibrary);
6471 } 10431 }
6472 class SimpleResolverTest extends ResolverTestCase { 10432 class SimpleResolverTest extends ResolverTestCase {
6473 void fail_staticInvocation() { 10433 void fail_staticInvocation() {
6474 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int get g => (a,b) => 0;", "}", "class B {", " f() {", " A.g(1,0);", " }" , "}"])); 10434 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int get g => (a,b) => 0;", "}", "class B {", " f() {", " A.g(1,0);", " }" , "}"]));
6475 resolve(source, []); 10435 resolve(source);
6476 assertNoErrors(); 10436 assertNoErrors();
6477 verify([source]); 10437 verify([source]);
6478 } 10438 }
10439 void test_argumentResolution_required_matching() {
10440 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2, 3);", " }", " void g(a, b, c) {}", "}"]));
10441 validateArgumentResolution(source, [0, 1, 2]);
10442 }
10443 void test_argumentResolution_required_tooFew() {
10444 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2);", " }", " void g(a, b, c) {}", "}"]));
10445 validateArgumentResolution(source, [0, 1]);
10446 }
10447 void test_argumentResolution_required_tooMany() {
10448 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2, 3);", " }", " void g(a, b) {}", "}"]));
10449 validateArgumentResolution(source, [0, 1, -1]);
10450 }
10451 void test_argumentResolution_requiredAndNamed_extra() {
10452 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2, c: 3, d: 4);", " }", " void g(a, b, {c}) {}", "}"]));
10453 validateArgumentResolution(source, [0, 1, 2, -1]);
10454 }
10455 void test_argumentResolution_requiredAndNamed_matching() {
10456 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2, c: 3);", " }", " void g(a, b, {c}) {}", "}"]));
10457 validateArgumentResolution(source, [0, 1, 2]);
10458 }
10459 void test_argumentResolution_requiredAndNamed_missing() {
10460 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2, d: 3);", " }", " void g(a, b, {c, d}) {}", "}"]));
10461 validateArgumentResolution(source, [0, 1, 3]);
10462 }
10463 void test_argumentResolution_requiredAndPositional_fewer() {
10464 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2, 3);", " }", " void g(a, b, [c, d]) {}", "}"]));
10465 validateArgumentResolution(source, [0, 1, 2]);
10466 }
10467 void test_argumentResolution_requiredAndPositional_matching() {
10468 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2, 3, 4);", " }", " void g(a, b, [c, d]) {}", "}"]));
10469 validateArgumentResolution(source, [0, 1, 2, 3]);
10470 }
10471 void test_argumentResolution_requiredAndPositional_more() {
10472 Source source = addSource(EngineTestCase.createSource(["class A {", " void f() {", " g(1, 2, 3, 4);", " }", " void g(a, b, [c]) {}", "}"]));
10473 validateArgumentResolution(source, [0, 1, 2, -1]);
10474 }
6479 void test_class_definesCall() { 10475 void test_class_definesCall() {
6480 Source source = addSource(EngineTestCase.createSource(["class A {", " int c all(int x) { return x; }", "}", "int f(A a) {", " return a(0);", "}"])); 10476 Source source = addSource(EngineTestCase.createSource(["class A {", " int c all(int x) { return x; }", "}", "int f(A a) {", " return a(0);", "}"]));
6481 resolve(source, []); 10477 resolve(source);
6482 assertNoErrors(); 10478 assertNoErrors();
6483 verify([source]); 10479 verify([source]);
6484 } 10480 }
6485 void test_class_extends_implements() { 10481 void test_class_extends_implements() {
6486 Source source = addSource(EngineTestCase.createSource(["class A extends B im plements C {}", "class B {}", "class C {}"])); 10482 Source source = addSource(EngineTestCase.createSource(["class A extends B im plements C {}", "class B {}", "class C {}"]));
6487 resolve(source, []); 10483 resolve(source);
6488 assertNoErrors(); 10484 assertNoErrors();
6489 verify([source]); 10485 verify([source]);
6490 } 10486 }
6491 void test_commentReference_class() { 10487 void test_commentReference_class() {
6492 Source source = addSource(EngineTestCase.createSource(["f() {}", "/** [A] [n ew A] [A.n] [new A.n] [m] [f] */", "class A {", " A() {}", " A.n() {}", " m() {}", "}"])); 10488 Source source = addSource(EngineTestCase.createSource(["f() {}", "/** [A] [n ew A] [A.n] [new A.n] [m] [f] */", "class A {", " A() {}", " A.n() {}", " m() {}", "}"]));
6493 resolve(source, []); 10489 resolve(source);
6494 assertNoErrors(); 10490 assertNoErrors();
6495 verify([source]); 10491 verify([source]);
6496 } 10492 }
6497 void test_commentReference_parameter() { 10493 void test_commentReference_parameter() {
6498 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", " A.n() {}", " /** [e] [f] */", " m(e, f()) {}", "}"])); 10494 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", " A.n() {}", " /** [e] [f] */", " m(e, f()) {}", "}"]));
6499 resolve(source, []); 10495 resolve(source);
6500 assertNoErrors(); 10496 assertNoErrors();
6501 verify([source]); 10497 verify([source]);
6502 } 10498 }
6503 void test_commentReference_singleLine() { 10499 void test_commentReference_singleLine() {
6504 Source source = addSource(EngineTestCase.createSource(["/// [A]", "class A { }"])); 10500 Source source = addSource(EngineTestCase.createSource(["/// [A]", "class A { }"]));
6505 resolve(source, []); 10501 resolve(source);
6506 assertNoErrors(); 10502 assertNoErrors();
6507 verify([source]); 10503 verify([source]);
6508 } 10504 }
6509 void test_empty() { 10505 void test_empty() {
6510 Source source = addSource(""); 10506 Source source = addSource("");
6511 resolve(source, []); 10507 resolve(source);
6512 assertNoErrors(); 10508 assertNoErrors();
6513 verify([source]); 10509 verify([source]);
6514 } 10510 }
6515 void test_extractedMethodAsConstant() { 10511 void test_extractedMethodAsConstant() {
6516 Source source = addSource(EngineTestCase.createSource(["abstract class Compa rable<T> {", " int compareTo(T other);", " static int compare(Comparable a, Co mparable b) => a.compareTo(b);", "}", "class A {", " void sort([compare = Compa rable.compare]) {}", "}"])); 10512 Source source = addSource(EngineTestCase.createSource(["abstract class Compa rable<T> {", " int compareTo(T other);", " static int compare(Comparable a, Co mparable b) => a.compareTo(b);", "}", "class A {", " void sort([compare = Compa rable.compare]) {}", "}"]));
6517 resolve(source, []); 10513 resolve(source);
6518 assertNoErrors(); 10514 assertNoErrors();
6519 verify([source]); 10515 verify([source]);
6520 } 10516 }
6521 void test_fieldFormalParameter() { 10517 void test_fieldFormalParameter() {
6522 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"])); 10518 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A(this.x) {}", "}"]));
6523 resolve(source, []); 10519 resolve(source);
6524 assertNoErrors(); 10520 assertNoErrors();
6525 verify([source]); 10521 verify([source]);
6526 } 10522 }
6527 void test_forEachLoops_nonConflicting() { 10523 void test_forEachLoops_nonConflicting() {
6528 Source source = addSource(EngineTestCase.createSource(["f() {", " List list = [1,2,3];", " for (int x in list) {}", " for (int x in list) {}", "}"])); 10524 Source source = addSource(EngineTestCase.createSource(["f() {", " List list = [1,2,3];", " for (int x in list) {}", " for (int x in list) {}", "}"]));
6529 resolve(source, []); 10525 resolve(source);
6530 assertNoErrors(); 10526 assertNoErrors();
6531 verify([source]); 10527 verify([source]);
6532 } 10528 }
6533 void test_forLoops_nonConflicting() { 10529 void test_forLoops_nonConflicting() {
6534 Source source = addSource(EngineTestCase.createSource(["f() {", " for (int i = 0; i < 3; i++) {", " }", " for (int i = 0; i < 3; i++) {", " }", "}"])); 10530 Source source = addSource(EngineTestCase.createSource(["f() {", " for (int i = 0; i < 3; i++) {", " }", " for (int i = 0; i < 3; i++) {", " }", "}"]));
6535 resolve(source, []); 10531 resolve(source);
6536 assertNoErrors(); 10532 assertNoErrors();
6537 verify([source]); 10533 verify([source]);
6538 } 10534 }
6539 void test_functionTypeAlias() { 10535 void test_functionTypeAlias() {
6540 Source source = addSource(EngineTestCase.createSource(["typedef bool P(e);", "class A {", " P p;", " m(e) {", " if (p(e)) {}", " }", "}"])); 10536 Source source = addSource(EngineTestCase.createSource(["typedef bool P(e);", "class A {", " P p;", " m(e) {", " if (p(e)) {}", " }", "}"]));
6541 resolve(source, []); 10537 resolve(source);
6542 assertNoErrors(); 10538 assertNoErrors();
6543 verify([source]); 10539 verify([source]);
6544 } 10540 }
6545 void test_getterAndSetterWithDifferentTypes() { 10541 void test_getterAndSetterWithDifferentTypes() {
6546 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et f => 0;", " void set f(String s) {}", "}", "g (A a) {", " a.f = a.f.toStrin g();", "}"])); 10542 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et f => 0;", " void set f(String s) {}", "}", "g (A a) {", " a.f = a.f.toStrin g();", "}"]));
6547 resolve(source, []); 10543 resolve(source);
10544 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
10545 verify([source]);
10546 }
10547 void test_hasReferenceToSuper() {
10548 Source source = addSource(EngineTestCase.createSource(["class A {}", "class B {toString() => super.toString();}"]));
10549 LibraryElement library = resolve(source);
10550 JUnitTestCase.assertNotNull(library);
10551 CompilationUnitElement unit = library.definingCompilationUnit;
10552 JUnitTestCase.assertNotNull(unit);
10553 List<ClassElement> classes = unit.types;
10554 EngineTestCase.assertLength(2, classes);
10555 JUnitTestCase.assertFalse(classes[0].hasReferenceToSuper());
10556 JUnitTestCase.assertTrue(classes[1].hasReferenceToSuper());
6548 assertNoErrors(); 10557 assertNoErrors();
6549 verify([source]); 10558 verify([source]);
6550 } 10559 }
6551 void test_importWithPrefix() { 10560 void test_importWithPrefix() {
6552 addSource2("/two.dart", EngineTestCase.createSource(["library two;", "f(int x) {", " return x * x;", "}"])); 10561 addSource2("/two.dart", EngineTestCase.createSource(["library two;", "f(int x) {", " return x * x;", "}"]));
6553 Source source = addSource2("/one.dart", EngineTestCase.createSource(["librar y one;", "import 'two.dart' as _two;", "main() {", " _two.f(0);", "}"])); 10562 Source source = addSource2("/one.dart", EngineTestCase.createSource(["librar y one;", "import 'two.dart' as _two;", "main() {", " _two.f(0);", "}"]));
6554 resolve(source, []); 10563 resolve(source);
6555 assertNoErrors(); 10564 assertNoErrors();
6556 verify([source]); 10565 verify([source]);
6557 } 10566 }
6558 void test_indexExpression_typeParameters() { 10567 void test_indexExpression_typeParameters() {
6559 Source source = addSource(EngineTestCase.createSource(["f() {", " List<int> a;", " a[0];", " List<List<int>> b;", " b[0][0];", " List<List<List<int>>> c;", " c[0][0][0];", "}"])); 10568 Source source = addSource(EngineTestCase.createSource(["f() {", " List<int> a;", " a[0];", " List<List<int>> b;", " b[0][0];", " List<List<List<int>>> c;", " c[0][0][0];", "}"]));
6560 resolve(source, []); 10569 resolve(source);
6561 assertNoErrors(); 10570 assertNoErrors();
6562 verify([source]); 10571 verify([source]);
6563 } 10572 }
6564 void test_indexExpression_typeParameters_invalidAssignmentWarning() { 10573 void test_indexExpression_typeParameters_invalidAssignmentWarning() {
6565 Source source = addSource(EngineTestCase.createSource(["f() {", " List<List <int>> b;", " b[0][0] = 'hi';", "}"])); 10574 Source source = addSource(EngineTestCase.createSource(["f() {", " List<List <int>> b;", " b[0][0] = 'hi';", "}"]));
6566 resolve(source, []); 10575 resolve(source);
6567 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); 10576 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
6568 verify([source]); 10577 verify([source]);
6569 } 10578 }
10579 void test_indirectOperatorThroughCall() {
10580 Source source = addSource(EngineTestCase.createSource(["class A {", " B cal l() { return new B(); }", "}", "", "class B {", " int operator [](int i) { retu rn i; }", "}", "", "A f = new A();", "", "g(int x) {}", "", "main() {", " g(f() [0]);", "}"]));
10581 resolve(source);
10582 assertNoErrors();
10583 verify([source]);
10584 }
6570 void test_invoke_dynamicThroughGetter() { 10585 void test_invoke_dynamicThroughGetter() {
6571 Source source = addSource(EngineTestCase.createSource(["class A {", " List get X => [() => 0];", " m(A a) {", " X.last;", " }", "}"])); 10586 Source source = addSource(EngineTestCase.createSource(["class A {", " List get X => [() => 0];", " m(A a) {", " X.last;", " }", "}"]));
6572 resolve(source, []); 10587 resolve(source);
6573 assertNoErrors(); 10588 assertNoErrors();
6574 verify([source]); 10589 verify([source]);
6575 } 10590 }
6576 void test_isValidMixin_badSuperclass() { 10591 void test_isValidMixin_badSuperclass() {
6577 Source source = addSource(EngineTestCase.createSource(["class A extends B {} ", "class B {}"])); 10592 Source source = addSource(EngineTestCase.createSource(["class A extends B {} ", "class B {}"]));
6578 LibraryElement library = resolve(source, []); 10593 LibraryElement library = resolve(source);
6579 JUnitTestCase.assertNotNull(library); 10594 JUnitTestCase.assertNotNull(library);
6580 CompilationUnitElement unit = library.definingCompilationUnit; 10595 CompilationUnitElement unit = library.definingCompilationUnit;
6581 JUnitTestCase.assertNotNull(unit); 10596 JUnitTestCase.assertNotNull(unit);
6582 List<ClassElement> classes = unit.types; 10597 List<ClassElement> classes = unit.types;
6583 EngineTestCase.assertLength(2, classes); 10598 EngineTestCase.assertLength(2, classes);
6584 JUnitTestCase.assertFalse(classes[0].isValidMixin()); 10599 JUnitTestCase.assertFalse(classes[0].isValidMixin());
6585 assertNoErrors(); 10600 assertNoErrors();
6586 verify([source]); 10601 verify([source]);
6587 } 10602 }
6588 void test_isValidMixin_constructor() { 10603 void test_isValidMixin_constructor() {
6589 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}"])); 10604 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}"]));
6590 LibraryElement library = resolve(source, []); 10605 LibraryElement library = resolve(source);
6591 JUnitTestCase.assertNotNull(library); 10606 JUnitTestCase.assertNotNull(library);
6592 CompilationUnitElement unit = library.definingCompilationUnit; 10607 CompilationUnitElement unit = library.definingCompilationUnit;
6593 JUnitTestCase.assertNotNull(unit); 10608 JUnitTestCase.assertNotNull(unit);
6594 List<ClassElement> classes = unit.types; 10609 List<ClassElement> classes = unit.types;
6595 EngineTestCase.assertLength(1, classes); 10610 EngineTestCase.assertLength(1, classes);
6596 JUnitTestCase.assertFalse(classes[0].isValidMixin()); 10611 JUnitTestCase.assertFalse(classes[0].isValidMixin());
6597 assertNoErrors(); 10612 assertNoErrors();
6598 verify([source]); 10613 verify([source]);
6599 } 10614 }
6600 void test_isValidMixin_super() { 10615 void test_isValidMixin_super() {
6601 Source source = addSource(EngineTestCase.createSource(["class A {", " toStr ing() {", " return super.toString();", " }", "}"])); 10616 Source source = addSource(EngineTestCase.createSource(["class A {", " toStr ing() {", " return super.toString();", " }", "}"]));
6602 LibraryElement library = resolve(source, []); 10617 LibraryElement library = resolve(source);
6603 JUnitTestCase.assertNotNull(library); 10618 JUnitTestCase.assertNotNull(library);
6604 CompilationUnitElement unit = library.definingCompilationUnit; 10619 CompilationUnitElement unit = library.definingCompilationUnit;
6605 JUnitTestCase.assertNotNull(unit); 10620 JUnitTestCase.assertNotNull(unit);
6606 List<ClassElement> classes = unit.types; 10621 List<ClassElement> classes = unit.types;
6607 EngineTestCase.assertLength(1, classes); 10622 EngineTestCase.assertLength(1, classes);
6608 JUnitTestCase.assertFalse(classes[0].isValidMixin()); 10623 JUnitTestCase.assertFalse(classes[0].isValidMixin());
6609 assertNoErrors(); 10624 assertNoErrors();
6610 verify([source]); 10625 verify([source]);
6611 } 10626 }
6612 void test_isValidMixin_valid() { 10627 void test_isValidMixin_valid() {
6613 Source source = addSource(EngineTestCase.createSource(["class A {}"])); 10628 Source source = addSource(EngineTestCase.createSource(["class A {}"]));
6614 LibraryElement library = resolve(source, []); 10629 LibraryElement library = resolve(source);
6615 JUnitTestCase.assertNotNull(library); 10630 JUnitTestCase.assertNotNull(library);
6616 CompilationUnitElement unit = library.definingCompilationUnit; 10631 CompilationUnitElement unit = library.definingCompilationUnit;
6617 JUnitTestCase.assertNotNull(unit); 10632 JUnitTestCase.assertNotNull(unit);
6618 List<ClassElement> classes = unit.types; 10633 List<ClassElement> classes = unit.types;
6619 EngineTestCase.assertLength(1, classes); 10634 EngineTestCase.assertLength(1, classes);
6620 JUnitTestCase.assertTrue(classes[0].isValidMixin()); 10635 JUnitTestCase.assertTrue(classes[0].isValidMixin());
6621 assertNoErrors(); 10636 assertNoErrors();
6622 verify([source]); 10637 verify([source]);
6623 } 10638 }
10639 void test_labels_switch() {
10640 Source source = addSource(EngineTestCase.createSource(["void doSwitch(int ta rget) {", " switch (target) {", " l0: case 0:", " continue l1;", " l 1: case 1:", " continue l0;", " default:", " continue l1;", " }", "}"]));
10641 LibraryElement library = resolve(source);
10642 JUnitTestCase.assertNotNull(library);
10643 assertNoErrors();
10644 verify([source]);
10645 }
10646 void test_metadata_class() {
10647 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@ A class C {}"]));
10648 LibraryElement library = resolve(source);
10649 JUnitTestCase.assertNotNull(library);
10650 CompilationUnitElement unit = library.definingCompilationUnit;
10651 JUnitTestCase.assertNotNull(unit);
10652 List<ClassElement> classes = unit.types;
10653 EngineTestCase.assertLength(1, classes);
10654 List<Annotation> annotations = classes[0].metadata;
10655 EngineTestCase.assertLength(1, annotations);
10656 assertNoErrors();
10657 verify([source]);
10658 }
10659 void test_metadata_field() {
10660 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c lass C {", " @A int f;", "}"]));
10661 LibraryElement library = resolve(source);
10662 JUnitTestCase.assertNotNull(library);
10663 CompilationUnitElement unit = library.definingCompilationUnit;
10664 JUnitTestCase.assertNotNull(unit);
10665 List<ClassElement> classes = unit.types;
10666 EngineTestCase.assertLength(1, classes);
10667 FieldElement field = classes[0].fields[0];
10668 List<Annotation> annotations = field.metadata;
10669 EngineTestCase.assertLength(1, annotations);
10670 assertNoErrors();
10671 verify([source]);
10672 }
10673 void test_metadata_libraryDirective() {
10674 Source source = addSource(EngineTestCase.createSource(["@A library lib;", "c onst A = null;"]));
10675 LibraryElement library = resolve(source);
10676 JUnitTestCase.assertNotNull(library);
10677 List<Annotation> annotations = library.metadata;
10678 EngineTestCase.assertLength(1, annotations);
10679 assertNoErrors();
10680 verify([source]);
10681 }
10682 void test_metadata_method() {
10683 Source source = addSource(EngineTestCase.createSource(["const A = null;", "c lass C {", " @A void m() {}", "}"]));
10684 LibraryElement library = resolve(source);
10685 JUnitTestCase.assertNotNull(library);
10686 CompilationUnitElement unit = library.definingCompilationUnit;
10687 JUnitTestCase.assertNotNull(unit);
10688 List<ClassElement> classes = unit.types;
10689 EngineTestCase.assertLength(1, classes);
10690 MethodElement method = classes[0].methods[0];
10691 List<Annotation> annotations = method.metadata;
10692 EngineTestCase.assertLength(1, annotations);
10693 assertNoErrors();
10694 verify([source]);
10695 }
10696 void test_method_fromMixin() {
10697 Source source = addSource(EngineTestCase.createSource(["class B {", " bar() => 1;", "}", "class A {", " foo() => 2;", "}", "", "class C extends B with A { ", " bar() => super.bar();", " foo() => super.foo();", "}"]));
10698 resolve(source);
10699 assertNoErrors();
10700 verify([source]);
10701 }
6624 void test_method_fromSuperclassMixin() { 10702 void test_method_fromSuperclassMixin() {
6625 Source source = addSource(EngineTestCase.createSource(["class A {", " void m1() {}", "}", "class B with A {", "}", "class C extends B {", "}", "f(C c) {", " c.m1()", "}"])); 10703 Source source = addSource(EngineTestCase.createSource(["class A {", " void m1() {}", "}", "class B extends Object with A {", "}", "class C extends B {", "} ", "f(C c) {", " c.m1();", "}"]));
6626 resolve(source, []); 10704 resolve(source);
6627 assertNoErrors(); 10705 assertNoErrors();
6628 verify([source]); 10706 verify([source]);
6629 } 10707 }
6630 void test_methodCascades() { 10708 void test_methodCascades() {
6631 Source source = addSource(EngineTestCase.createSource(["class A {", " void m1() {}", " void m2() {}", " void m() {", " A a = new A();", " a..m1()", " ..m2();", " }", "}"])); 10709 Source source = addSource(EngineTestCase.createSource(["class A {", " void m1() {}", " void m2() {}", " void m() {", " A a = new A();", " a..m1()", " ..m2();", " }", "}"]));
6632 resolve(source, []); 10710 resolve(source);
6633 assertNoErrors(); 10711 assertNoErrors();
6634 verify([source]); 10712 verify([source]);
6635 } 10713 }
6636 void test_methodCascades_withSetter() { 10714 void test_methodCascades_withSetter() {
6637 Source source = addSource(EngineTestCase.createSource(["class A {", " Strin g name;", " void m1() {}", " void m2() {}", " void m() {", " A a = new A() ;", " a..m1()", " ..name = 'name'", " ..m2();", " }", "}"])); 10715 Source source = addSource(EngineTestCase.createSource(["class A {", " Strin g name;", " void m1() {}", " void m2() {}", " void m() {", " A a = new A() ;", " a..m1()", " ..name = 'name'", " ..m2();", " }", "}"]));
6638 resolve(source, []); 10716 resolve(source);
6639 assertNoErrors(); 10717 assertNoErrors();
6640 verify([source]); 10718 verify([source]);
6641 } 10719 }
6642 void test_resolveAgainstNull() { 10720 void test_resolveAgainstNull() {
6643 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu rn null == p;", "}"])); 10721 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu rn null == p;", "}"]));
6644 resolve(source, []); 10722 resolve(source);
6645 assertNoErrors(); 10723 assertNoErrors();
6646 verify([source]); 10724 verify([source]);
6647 } 10725 }
10726 void test_setter_inherited() {
10727 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et x => 0;", " set x(int p) {}", "}", "class B extends A {", " int get x => su per.x == null ? 0 : super.x;", " void f() => x = 1;", "}"]));
10728 resolve(source);
10729 assertNoErrors();
10730 verify([source]);
10731 }
10732 void test_setter_static() {
10733 Source source = addSource(EngineTestCase.createSource(["set s(x) {", "}", "" , "main() {", " s = 123;", "}"]));
10734 resolve(source);
10735 assertNoErrors();
10736 verify([source]);
10737 }
10738
10739 /**
10740 * Resolve the given source and verify that the arguments in a specific method invocation were
10741 * correctly resolved.
10742 * <p>
10743 * The source is expected to be source for a compilation unit, the first decla ration is expected
10744 * to be a class, the first member of which is expected to be a method with a block body, and the
10745 * first statement in the body is expected to be an expression statement whose expression is a
10746 * method invocation. It is the arguments to that method invocation that are t ested. The method
10747 * invocation can contain errors.
10748 * <p>
10749 * The arguments were resolved correctly if the number of expressions in the l ist matches the
10750 * length of the array of indices and if, for each index in the array of indic es, the parameter to
10751 * which the argument expression was resolved is the parameter in the invoked method's list of
10752 * parameters at that index. Arguments that should not be resolved to a parame ter because of an
10753 * error can be denoted by including a negative index in the array of indices.
10754 * @param source the source to be resolved
10755 * @param indices the array of indices used to associate arguments with parame ters
10756 * @throws Exception if the source could not be resolved or if the structure o f the source is not
10757 * valid
10758 */
10759 void validateArgumentResolution(Source source, List<int> indices) {
10760 LibraryElement library = resolve(source);
10761 JUnitTestCase.assertNotNull(library);
10762 ClassElement classElement = library.definingCompilationUnit.types[0];
10763 List<ParameterElement> parameters2 = classElement.methods[1].parameters;
10764 CompilationUnit unit = resolveCompilationUnit(source, library);
10765 JUnitTestCase.assertNotNull(unit);
10766 ClassDeclaration classDeclaration = unit.declarations[0] as ClassDeclaration ;
10767 MethodDeclaration methodDeclaration = (classDeclaration.members[0] as Method Declaration);
10768 Block block2 = ((methodDeclaration.body as BlockFunctionBody)).block;
10769 ExpressionStatement statement = block2.statements[0] as ExpressionStatement;
10770 MethodInvocation invocation = statement.expression as MethodInvocation;
10771 NodeList<Expression> arguments2 = invocation.argumentList.arguments;
10772 int argumentCount = arguments2.length;
10773 JUnitTestCase.assertEquals(indices.length, argumentCount);
10774 for (int i = 0; i < argumentCount; i++) {
10775 Expression argument = arguments2[i];
10776 ParameterElement element = argument.parameterElement;
10777 int index = indices[i];
10778 if (index < 0) {
10779 JUnitTestCase.assertNull(element);
10780 } else {
10781 JUnitTestCase.assertSame(parameters2[index], element);
10782 }
10783 }
10784 }
6648 static dartSuite() { 10785 static dartSuite() {
6649 _ut.group('SimpleResolverTest', () { 10786 _ut.group('SimpleResolverTest', () {
10787 _ut.test('test_argumentResolution_requiredAndNamed_extra', () {
10788 final __test = new SimpleResolverTest();
10789 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_ext ra);
10790 });
10791 _ut.test('test_argumentResolution_requiredAndNamed_matching', () {
10792 final __test = new SimpleResolverTest();
10793 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_mat ching);
10794 });
10795 _ut.test('test_argumentResolution_requiredAndNamed_missing', () {
10796 final __test = new SimpleResolverTest();
10797 runJUnitTest(__test, __test.test_argumentResolution_requiredAndNamed_mis sing);
10798 });
10799 _ut.test('test_argumentResolution_requiredAndPositional_fewer', () {
10800 final __test = new SimpleResolverTest();
10801 runJUnitTest(__test, __test.test_argumentResolution_requiredAndPositiona l_fewer);
10802 });
10803 _ut.test('test_argumentResolution_requiredAndPositional_matching', () {
10804 final __test = new SimpleResolverTest();
10805 runJUnitTest(__test, __test.test_argumentResolution_requiredAndPositiona l_matching);
10806 });
10807 _ut.test('test_argumentResolution_requiredAndPositional_more', () {
10808 final __test = new SimpleResolverTest();
10809 runJUnitTest(__test, __test.test_argumentResolution_requiredAndPositiona l_more);
10810 });
10811 _ut.test('test_argumentResolution_required_matching', () {
10812 final __test = new SimpleResolverTest();
10813 runJUnitTest(__test, __test.test_argumentResolution_required_matching);
10814 });
10815 _ut.test('test_argumentResolution_required_tooFew', () {
10816 final __test = new SimpleResolverTest();
10817 runJUnitTest(__test, __test.test_argumentResolution_required_tooFew);
10818 });
10819 _ut.test('test_argumentResolution_required_tooMany', () {
10820 final __test = new SimpleResolverTest();
10821 runJUnitTest(__test, __test.test_argumentResolution_required_tooMany);
10822 });
6650 _ut.test('test_class_definesCall', () { 10823 _ut.test('test_class_definesCall', () {
6651 final __test = new SimpleResolverTest(); 10824 final __test = new SimpleResolverTest();
6652 runJUnitTest(__test, __test.test_class_definesCall); 10825 runJUnitTest(__test, __test.test_class_definesCall);
6653 }); 10826 });
6654 _ut.test('test_class_extends_implements', () { 10827 _ut.test('test_class_extends_implements', () {
6655 final __test = new SimpleResolverTest(); 10828 final __test = new SimpleResolverTest();
6656 runJUnitTest(__test, __test.test_class_extends_implements); 10829 runJUnitTest(__test, __test.test_class_extends_implements);
6657 }); 10830 });
6658 _ut.test('test_commentReference_class', () { 10831 _ut.test('test_commentReference_class', () {
6659 final __test = new SimpleResolverTest(); 10832 final __test = new SimpleResolverTest();
(...skipping 28 matching lines...) Expand all
6688 runJUnitTest(__test, __test.test_forLoops_nonConflicting); 10861 runJUnitTest(__test, __test.test_forLoops_nonConflicting);
6689 }); 10862 });
6690 _ut.test('test_functionTypeAlias', () { 10863 _ut.test('test_functionTypeAlias', () {
6691 final __test = new SimpleResolverTest(); 10864 final __test = new SimpleResolverTest();
6692 runJUnitTest(__test, __test.test_functionTypeAlias); 10865 runJUnitTest(__test, __test.test_functionTypeAlias);
6693 }); 10866 });
6694 _ut.test('test_getterAndSetterWithDifferentTypes', () { 10867 _ut.test('test_getterAndSetterWithDifferentTypes', () {
6695 final __test = new SimpleResolverTest(); 10868 final __test = new SimpleResolverTest();
6696 runJUnitTest(__test, __test.test_getterAndSetterWithDifferentTypes); 10869 runJUnitTest(__test, __test.test_getterAndSetterWithDifferentTypes);
6697 }); 10870 });
10871 _ut.test('test_hasReferenceToSuper', () {
10872 final __test = new SimpleResolverTest();
10873 runJUnitTest(__test, __test.test_hasReferenceToSuper);
10874 });
6698 _ut.test('test_importWithPrefix', () { 10875 _ut.test('test_importWithPrefix', () {
6699 final __test = new SimpleResolverTest(); 10876 final __test = new SimpleResolverTest();
6700 runJUnitTest(__test, __test.test_importWithPrefix); 10877 runJUnitTest(__test, __test.test_importWithPrefix);
6701 }); 10878 });
6702 _ut.test('test_indexExpression_typeParameters', () { 10879 _ut.test('test_indexExpression_typeParameters', () {
6703 final __test = new SimpleResolverTest(); 10880 final __test = new SimpleResolverTest();
6704 runJUnitTest(__test, __test.test_indexExpression_typeParameters); 10881 runJUnitTest(__test, __test.test_indexExpression_typeParameters);
6705 }); 10882 });
6706 _ut.test('test_indexExpression_typeParameters_invalidAssignmentWarning', ( ) { 10883 _ut.test('test_indexExpression_typeParameters_invalidAssignmentWarning', ( ) {
6707 final __test = new SimpleResolverTest(); 10884 final __test = new SimpleResolverTest();
6708 runJUnitTest(__test, __test.test_indexExpression_typeParameters_invalidA ssignmentWarning); 10885 runJUnitTest(__test, __test.test_indexExpression_typeParameters_invalidA ssignmentWarning);
6709 }); 10886 });
10887 _ut.test('test_indirectOperatorThroughCall', () {
10888 final __test = new SimpleResolverTest();
10889 runJUnitTest(__test, __test.test_indirectOperatorThroughCall);
10890 });
6710 _ut.test('test_invoke_dynamicThroughGetter', () { 10891 _ut.test('test_invoke_dynamicThroughGetter', () {
6711 final __test = new SimpleResolverTest(); 10892 final __test = new SimpleResolverTest();
6712 runJUnitTest(__test, __test.test_invoke_dynamicThroughGetter); 10893 runJUnitTest(__test, __test.test_invoke_dynamicThroughGetter);
6713 }); 10894 });
6714 _ut.test('test_isValidMixin_badSuperclass', () { 10895 _ut.test('test_isValidMixin_badSuperclass', () {
6715 final __test = new SimpleResolverTest(); 10896 final __test = new SimpleResolverTest();
6716 runJUnitTest(__test, __test.test_isValidMixin_badSuperclass); 10897 runJUnitTest(__test, __test.test_isValidMixin_badSuperclass);
6717 }); 10898 });
6718 _ut.test('test_isValidMixin_constructor', () { 10899 _ut.test('test_isValidMixin_constructor', () {
6719 final __test = new SimpleResolverTest(); 10900 final __test = new SimpleResolverTest();
6720 runJUnitTest(__test, __test.test_isValidMixin_constructor); 10901 runJUnitTest(__test, __test.test_isValidMixin_constructor);
6721 }); 10902 });
6722 _ut.test('test_isValidMixin_super', () { 10903 _ut.test('test_isValidMixin_super', () {
6723 final __test = new SimpleResolverTest(); 10904 final __test = new SimpleResolverTest();
6724 runJUnitTest(__test, __test.test_isValidMixin_super); 10905 runJUnitTest(__test, __test.test_isValidMixin_super);
6725 }); 10906 });
6726 _ut.test('test_isValidMixin_valid', () { 10907 _ut.test('test_isValidMixin_valid', () {
6727 final __test = new SimpleResolverTest(); 10908 final __test = new SimpleResolverTest();
6728 runJUnitTest(__test, __test.test_isValidMixin_valid); 10909 runJUnitTest(__test, __test.test_isValidMixin_valid);
6729 }); 10910 });
10911 _ut.test('test_labels_switch', () {
10912 final __test = new SimpleResolverTest();
10913 runJUnitTest(__test, __test.test_labels_switch);
10914 });
10915 _ut.test('test_metadata_class', () {
10916 final __test = new SimpleResolverTest();
10917 runJUnitTest(__test, __test.test_metadata_class);
10918 });
10919 _ut.test('test_metadata_field', () {
10920 final __test = new SimpleResolverTest();
10921 runJUnitTest(__test, __test.test_metadata_field);
10922 });
10923 _ut.test('test_metadata_libraryDirective', () {
10924 final __test = new SimpleResolverTest();
10925 runJUnitTest(__test, __test.test_metadata_libraryDirective);
10926 });
10927 _ut.test('test_metadata_method', () {
10928 final __test = new SimpleResolverTest();
10929 runJUnitTest(__test, __test.test_metadata_method);
10930 });
6730 _ut.test('test_methodCascades', () { 10931 _ut.test('test_methodCascades', () {
6731 final __test = new SimpleResolverTest(); 10932 final __test = new SimpleResolverTest();
6732 runJUnitTest(__test, __test.test_methodCascades); 10933 runJUnitTest(__test, __test.test_methodCascades);
6733 }); 10934 });
6734 _ut.test('test_methodCascades_withSetter', () { 10935 _ut.test('test_methodCascades_withSetter', () {
6735 final __test = new SimpleResolverTest(); 10936 final __test = new SimpleResolverTest();
6736 runJUnitTest(__test, __test.test_methodCascades_withSetter); 10937 runJUnitTest(__test, __test.test_methodCascades_withSetter);
6737 }); 10938 });
10939 _ut.test('test_method_fromMixin', () {
10940 final __test = new SimpleResolverTest();
10941 runJUnitTest(__test, __test.test_method_fromMixin);
10942 });
6738 _ut.test('test_method_fromSuperclassMixin', () { 10943 _ut.test('test_method_fromSuperclassMixin', () {
6739 final __test = new SimpleResolverTest(); 10944 final __test = new SimpleResolverTest();
6740 runJUnitTest(__test, __test.test_method_fromSuperclassMixin); 10945 runJUnitTest(__test, __test.test_method_fromSuperclassMixin);
6741 }); 10946 });
6742 _ut.test('test_resolveAgainstNull', () { 10947 _ut.test('test_resolveAgainstNull', () {
6743 final __test = new SimpleResolverTest(); 10948 final __test = new SimpleResolverTest();
6744 runJUnitTest(__test, __test.test_resolveAgainstNull); 10949 runJUnitTest(__test, __test.test_resolveAgainstNull);
6745 }); 10950 });
10951 _ut.test('test_setter_inherited', () {
10952 final __test = new SimpleResolverTest();
10953 runJUnitTest(__test, __test.test_setter_inherited);
10954 });
10955 _ut.test('test_setter_static', () {
10956 final __test = new SimpleResolverTest();
10957 runJUnitTest(__test, __test.test_setter_static);
10958 });
6746 }); 10959 });
6747 } 10960 }
6748 } 10961 }
6749 main() { 10962 main() {
6750 // ElementResolverTest.dartSuite(); 10963 // ElementResolverTest.dartSuite();
10964 // InheritanceManagerTest.dartSuite();
6751 // LibraryElementBuilderTest.dartSuite(); 10965 // LibraryElementBuilderTest.dartSuite();
6752 // LibraryTest.dartSuite(); 10966 // LibraryTest.dartSuite();
6753 // StaticTypeAnalyzerTest.dartSuite(); 10967 // StaticTypeAnalyzerTest.dartSuite();
6754 // TypeOverrideManagerTest.dartSuite(); 10968 // TypeOverrideManagerTest.dartSuite();
6755 // TypeProviderImplTest.dartSuite(); 10969 // TypeProviderImplTest.dartSuite();
6756 // TypeResolverVisitorTest.dartSuite(); 10970 // TypeResolverVisitorTest.dartSuite();
6757 // EnclosedScopeTest.dartSuite(); 10971 // EnclosedScopeTest.dartSuite();
6758 // LibraryImportScopeTest.dartSuite(); 10972 // LibraryImportScopeTest.dartSuite();
6759 // LibraryScopeTest.dartSuite(); 10973 // LibraryScopeTest.dartSuite();
6760 // ScopeTest.dartSuite(); 10974 // ScopeTest.dartSuite();
6761 // CompileTimeErrorCodeTest.dartSuite(); 10975 // CompileTimeErrorCodeTest.dartSuite();
6762 // ErrorResolverTest.dartSuite(); 10976 // ErrorResolverTest.dartSuite();
6763 // NonErrorResolverTest.dartSuite(); 10977 // NonErrorResolverTest.dartSuite();
6764 // SimpleResolverTest.dartSuite(); 10978 // SimpleResolverTest.dartSuite();
6765 // StaticTypeWarningCodeTest.dartSuite(); 10979 // StaticTypeWarningCodeTest.dartSuite();
6766 // StaticWarningCodeTest.dartSuite(); 10980 // StaticWarningCodeTest.dartSuite();
6767 // TypePropagationTest.dartSuite(); 10981 // TypePropagationTest.dartSuite();
6768 } 10982 }
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