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

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

Issue 12803014: New Analysis Engine translation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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/element.dart'; 13 import 'package:analyzer_experimental/src/generated/element.dart';
14 import 'package:analyzer_experimental/src/generated/resolver.dart'; 14 import 'package:analyzer_experimental/src/generated/resolver.dart';
15 import 'package:analyzer_experimental/src/generated/engine.dart'; 15 import 'package:analyzer_experimental/src/generated/engine.dart';
16 import 'package:analyzer_experimental/src/generated/java_engine_io.dart'; 16 import 'package:analyzer_experimental/src/generated/java_engine_io.dart';
17 import 'package:analyzer_experimental/src/generated/ast.dart' hide Annotation; 17 import 'package:analyzer_experimental/src/generated/ast.dart' hide Annotation;
18 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk; 18 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk;
19 import 'package:unittest/unittest.dart' as _ut; 19 import 'package:unittest/unittest.dart' as _ut;
20 import 'test_support.dart'; 20 import 'test_support.dart';
21 import 'ast_test.dart' show ASTFactory; 21 import 'ast_test.dart' show ASTFactory;
22 import 'element_test.dart' show ElementFactory; 22 import 'element_test.dart' show ElementFactory;
23 23
24 class NonErrorResolverTest extends ResolverTestCase {
25 void test_argumentDefinitionTestNonParameter_formalParameter() {
26 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var v) {", " return ?v;", "}"]));
27 resolve(source, []);
28 assertNoErrors();
29 verify([source]);
30 }
31 void test_argumentDefinitionTestNonParameter_namedParameter() {
32 Source source = addSource("/test.dart", EngineTestCase.createSource(["f({var v : 0}) {", " return ?v;", "}"]));
33 resolve(source, []);
34 assertNoErrors();
35 verify([source]);
36 }
37 void test_argumentDefinitionTestNonParameter_optionalParameter() {
38 Source source = addSource("/test.dart", EngineTestCase.createSource(["f([var v]) {", " return ?v;", "}"]));
39 resolve(source, []);
40 assertNoErrors();
41 verify([source]);
42 }
43 void test_breakWithoutLabelInSwitch() {
44 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " case 0:", " break;" , " }", " }", "}"]));
45 resolve(source, []);
46 assertNoErrors();
47 verify([source]);
48 }
49 void test_builtInIdentifierAsType_dynamic() {
50 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " dynamic x;", "}"]));
51 resolve(source, []);
52 assertNoErrors();
53 verify([source]);
54 }
55 void test_caseExpressionTypeImplementsEquals_int() {
56 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(int i) {", " switch(i) {", " case(1) : return 1;", " default: return 0;", " }", "}"]));
57 resolve(source, []);
58 assertNoErrors();
59 verify([source]);
60 }
61 void test_caseExpressionTypeImplementsEquals_Object() {
62 Source source = addSource("/test.dart", EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", "}", "", "f(IntWrapper intWrapper) {", " switch(intWrapper) {", " case(const IntWrap per(1)) : return 1;", " default: return 0;", " }", "}"]));
63 resolve(source, []);
64 assertNoErrors();
65 verify([source]);
66 }
67 void test_caseExpressionTypeImplementsEquals_String() {
68 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(Stri ng s) {", " switch(s) {", " case('1') : return 1;", " default: return 0;" , " }", "}"]));
69 resolve(source, []);
70 assertNoErrors();
71 verify([source]);
72 }
73 void test_constConstructorWithNonFinalField_const() {
74 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const int x;", " const A() {}", "}"]));
75 resolve(source, []);
76 assertNoErrors();
77 verify([source]);
78 }
79 void test_constConstructorWithNonFinalField_final() {
80 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x;", " const A() {}", "}"]));
81 resolve(source, []);
82 assertNoErrors();
83 verify([source]);
84 }
85 void test_constConstructorWithNonFinalField_syntheticField() {
86 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"]));
87 resolve(source, []);
88 assertNoErrors();
89 verify([source]);
90 }
91 void test_defaultValueInFunctionTypeAlias() {
92 Source source = addSource("/test.dart", EngineTestCase.createSource(["typede f F([x]);"]));
93 resolve(source, []);
94 assertErrors([]);
95 verify([source]);
96 }
97 void test_duplicateDefinition_getter() {
98 Source source = addSource("/test.dart", EngineTestCase.createSource(["bool g et a => true;"]));
99 resolve(source, []);
100 assertNoErrors();
101 verify([source]);
102 }
103 void test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal() {
104 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x = 0;", " A() : x = 1 {}", "}"]));
105 resolve(source, []);
106 assertNoErrors();
107 verify([source]);
108 }
109 void test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSet() {
110 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x;", " A() : x = 1 {}", "}"]));
111 resolve(source, []);
112 assertNoErrors();
113 verify([source]);
114 }
115 void test_fieldInitializerOutsideConstructor() {
116 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(this.x) {}", "}"]));
117 resolve(source, []);
118 assertNoErrors();
119 verify([source]);
120 }
121 void test_fieldInitializerOutsideConstructor_defaultParameters() {
122 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A([this.x]) {}", "}"]));
123 resolve(source, []);
124 assertNoErrors();
125 verify([source]);
126 }
127 void test_invalidAssignment() {
128 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var x;", " var y;", " x = y;", "}"]));
129 resolve(source, []);
130 assertNoErrors();
131 verify([source]);
132 }
133 void test_invalidAssignment_toDynamic() {
134 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var g;", " g = () => 0;", "}"]));
135 resolve(source, []);
136 assertNoErrors();
137 verify([source]);
138 }
139 void test_invocationOfNonFunction_dynamic() {
140 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var f;", "}", "class B extends A {", " g() {", " f();", " }", "}"] ));
141 resolve(source, []);
142 assertNoErrors();
143 verify([source]);
144 }
145 void test_invocationOfNonFunction_getter() {
146 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var g;", "}", "f() {", " A a;", " a.g();", "}"]));
147 resolve(source, []);
148 assertNoErrors();
149 verify([source]);
150 }
151 void test_invocationOfNonFunction_localVariable() {
152 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var g;", " g();", "}"]));
153 resolve(source, []);
154 assertNoErrors();
155 verify([source]);
156 }
157 void test_newWithAbstractClass_factory() {
158 Source source = addSource("/test.dart", EngineTestCase.createSource(["abstra ct class A {", " factory A() { return new B(); }", "}", "class B implements A { ", " B() {}", "}", "A f() {", " return new A();", "}"]));
159 resolve(source, []);
160 assertNoErrors();
161 verify([source]);
162 }
163 void test_nonBoolExpression_assert_bool() {
164 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " assert(true);", "}"]));
165 resolve(source, []);
166 assertNoErrors();
167 verify([source]);
168 }
169 void test_nonBoolExpression_assert_functionType() {
170 Source source = addSource("/test.dart", EngineTestCase.createSource(["bool m akeAssertion() => true;", "f() {", " assert(makeAssertion);", "}"]));
171 resolve(source, []);
172 assertNoErrors();
173 verify([source]);
174 }
175 void test_rethrowOutsideCatch() {
176 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m() {", " try {} catch (e) {rethrow;}", " }", "}"]));
177 resolve(source, []);
178 assertNoErrors();
179 verify([source]);
180 }
181 void test_returnOfInvalidType_dynamic() {
182 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static void testLogicalOp() {", " testOr(a, b, onTypeError) {", " try {", " return a || b;", " } on TypeError catch (t) {", " return onTypeError;", " }", " }", " }", "}"]));
183 resolve(source, []);
184 assertNoErrors();
185 verify([source]);
186 }
187 void test_returnOfInvalidType_subtype() {
188 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "A f(B b) { return b; }"]));
189 resolve(source, []);
190 assertNoErrors();
191 verify([source]);
192 }
193 void test_returnOfInvalidType_supertype() {
194 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "B f(A a) { return a; }"]));
195 resolve(source, []);
196 assertNoErrors();
197 verify([source]);
198 }
199 void test_typeArgumentNotMatchingBounds_const() {
200 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {", " const G() {}", "}", "f() { return const G<B>(); }"]));
201 resolve(source, []);
202 assertNoErrors();
203 verify([source]);
204 }
205 void test_typeArgumentNotMatchingBounds_new() {
206 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {}", "f() { return new G<B> (); }"]));
207 resolve(source, []);
208 assertNoErrors();
209 verify([source]);
210 }
211 static dartSuite() {
212 _ut.group('NonErrorResolverTest', () {
213 _ut.test('test_argumentDefinitionTestNonParameter_formalParameter', () {
214 final __test = new NonErrorResolverTest();
215 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_form alParameter);
216 });
217 _ut.test('test_argumentDefinitionTestNonParameter_namedParameter', () {
218 final __test = new NonErrorResolverTest();
219 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_name dParameter);
220 });
221 _ut.test('test_argumentDefinitionTestNonParameter_optionalParameter', () {
222 final __test = new NonErrorResolverTest();
223 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_opti onalParameter);
224 });
225 _ut.test('test_breakWithoutLabelInSwitch', () {
226 final __test = new NonErrorResolverTest();
227 runJUnitTest(__test, __test.test_breakWithoutLabelInSwitch);
228 });
229 _ut.test('test_builtInIdentifierAsType_dynamic', () {
230 final __test = new NonErrorResolverTest();
231 runJUnitTest(__test, __test.test_builtInIdentifierAsType_dynamic);
232 });
233 _ut.test('test_caseExpressionTypeImplementsEquals_Object', () {
234 final __test = new NonErrorResolverTest();
235 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Obje ct);
236 });
237 _ut.test('test_caseExpressionTypeImplementsEquals_String', () {
238 final __test = new NonErrorResolverTest();
239 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Stri ng);
240 });
241 _ut.test('test_caseExpressionTypeImplementsEquals_int', () {
242 final __test = new NonErrorResolverTest();
243 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_int) ;
244 });
245 _ut.test('test_constConstructorWithNonFinalField_const', () {
246 final __test = new NonErrorResolverTest();
247 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_const );
248 });
249 _ut.test('test_constConstructorWithNonFinalField_final', () {
250 final __test = new NonErrorResolverTest();
251 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_final );
252 });
253 _ut.test('test_constConstructorWithNonFinalField_syntheticField', () {
254 final __test = new NonErrorResolverTest();
255 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField);
256 });
257 _ut.test('test_defaultValueInFunctionTypeAlias', () {
258 final __test = new NonErrorResolverTest();
259 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
260 });
261 _ut.test('test_duplicateDefinition_getter', () {
262 final __test = new NonErrorResolverTest();
263 runJUnitTest(__test, __test.test_duplicateDefinition_getter);
264 });
265 _ut.test('test_fieldInitializedInInitializerAndDeclaration_fieldNotFinal', () {
266 final __test = new NonErrorResolverTest();
267 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_fieldNotFinal);
268 });
269 _ut.test('test_fieldInitializedInInitializerAndDeclaration_finalFieldNotSe t', () {
270 final __test = new NonErrorResolverTest();
271 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_finalFieldNotSet);
272 });
273 _ut.test('test_fieldInitializerOutsideConstructor', () {
274 final __test = new NonErrorResolverTest();
275 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor);
276 });
277 _ut.test('test_fieldInitializerOutsideConstructor_defaultParameters', () {
278 final __test = new NonErrorResolverTest();
279 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor_defa ultParameters);
280 });
281 _ut.test('test_invalidAssignment', () {
282 final __test = new NonErrorResolverTest();
283 runJUnitTest(__test, __test.test_invalidAssignment);
284 });
285 _ut.test('test_invalidAssignment_toDynamic', () {
286 final __test = new NonErrorResolverTest();
287 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic);
288 });
289 _ut.test('test_invocationOfNonFunction_dynamic', () {
290 final __test = new NonErrorResolverTest();
291 runJUnitTest(__test, __test.test_invocationOfNonFunction_dynamic);
292 });
293 _ut.test('test_invocationOfNonFunction_getter', () {
294 final __test = new NonErrorResolverTest();
295 runJUnitTest(__test, __test.test_invocationOfNonFunction_getter);
296 });
297 _ut.test('test_invocationOfNonFunction_localVariable', () {
298 final __test = new NonErrorResolverTest();
299 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable);
300 });
301 _ut.test('test_newWithAbstractClass_factory', () {
302 final __test = new NonErrorResolverTest();
303 runJUnitTest(__test, __test.test_newWithAbstractClass_factory);
304 });
305 _ut.test('test_nonBoolExpression_assert_bool', () {
306 final __test = new NonErrorResolverTest();
307 runJUnitTest(__test, __test.test_nonBoolExpression_assert_bool);
308 });
309 _ut.test('test_nonBoolExpression_assert_functionType', () {
310 final __test = new NonErrorResolverTest();
311 runJUnitTest(__test, __test.test_nonBoolExpression_assert_functionType);
312 });
313 _ut.test('test_rethrowOutsideCatch', () {
314 final __test = new NonErrorResolverTest();
315 runJUnitTest(__test, __test.test_rethrowOutsideCatch);
316 });
317 _ut.test('test_returnOfInvalidType_dynamic', () {
318 final __test = new NonErrorResolverTest();
319 runJUnitTest(__test, __test.test_returnOfInvalidType_dynamic);
320 });
321 _ut.test('test_returnOfInvalidType_subtype', () {
322 final __test = new NonErrorResolverTest();
323 runJUnitTest(__test, __test.test_returnOfInvalidType_subtype);
324 });
325 _ut.test('test_returnOfInvalidType_supertype', () {
326 final __test = new NonErrorResolverTest();
327 runJUnitTest(__test, __test.test_returnOfInvalidType_supertype);
328 });
329 _ut.test('test_typeArgumentNotMatchingBounds_const', () {
330 final __test = new NonErrorResolverTest();
331 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
332 });
333 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
334 final __test = new NonErrorResolverTest();
335 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
336 });
337 });
338 }
339 }
24 class LibraryTest extends EngineTestCase { 340 class LibraryTest extends EngineTestCase {
25 /** 341 /**
26 * The error listener to which all errors will be reported. 342 * The error listener to which all errors will be reported.
27 */ 343 */
28 GatheringErrorListener _errorListener; 344 GatheringErrorListener _errorListener;
29 /** 345 /**
30 * The source factory used to create libraries. 346 * The source factory used to create libraries.
31 */ 347 */
32 SourceFactory _sourceFactory; 348 SourceFactory _sourceFactory;
33 /** 349 /**
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 } 1062 }
747 /** 1063 /**
748 * Add a source file to the content provider. The file path should be absolute . 1064 * Add a source file to the content provider. The file path should be absolute .
749 * @param filePath the path of the file being added 1065 * @param filePath the path of the file being added
750 * @param contents the contents to be returned by the content provider for the specified file 1066 * @param contents the contents to be returned by the content provider for the specified file
751 * @return the source object representing the added file 1067 * @return the source object representing the added file
752 */ 1068 */
753 Source addSource(String filePath, String contents) { 1069 Source addSource(String filePath, String contents) {
754 Source source = new FileBasedSource.con1(_sourceFactory, FileUtilities2.crea teFile(filePath)); 1070 Source source = new FileBasedSource.con1(_sourceFactory, FileUtilities2.crea teFile(filePath));
755 _sourceFactory.setContents(source, contents); 1071 _sourceFactory.setContents(source, contents);
1072 ChangeSet changeSet = new ChangeSet();
1073 changeSet.added(source);
1074 _analysisContext.applyChanges(changeSet);
756 return source; 1075 return source;
757 } 1076 }
758 /** 1077 /**
759 * Assert that no errors have been gathered. 1078 * Assert that no errors have been gathered.
760 * @throws AssertionFailedError if any errors have been gathered 1079 * @throws AssertionFailedError if any errors have been gathered
761 */ 1080 */
762 void assertNoErrors() { 1081 void assertNoErrors() {
763 _errorListener.assertNoErrors(); 1082 _errorListener.assertNoErrors();
764 } 1083 }
765 /** 1084 /**
766 * Create a library element that represents a library named {@code "test"} con taining a single 1085 * Create a library element that represents a library named {@code "test"} con taining a single
767 * empty compilation unit. 1086 * empty compilation unit.
768 * @return the library element that was created 1087 * @return the library element that was created
769 */ 1088 */
770 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []); 1089 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []);
771 /** 1090 /**
772 * Create a library element that represents a library with the given name cont aining a single 1091 * Create a library element that represents a library with the given name cont aining a single
773 * empty compilation unit. 1092 * empty compilation unit.
774 * @param libraryName the name of the library to be created 1093 * @param libraryName the name of the library to be created
775 * @return the library element that was created 1094 * @return the library element that was created
776 */ 1095 */
777 LibraryElementImpl createTestLibrary2(AnalysisContext context, String libraryN ame, List<String> typeNames) { 1096 LibraryElementImpl createTestLibrary2(AnalysisContext context, String libraryN ame, List<String> typeNames) {
778 int count = typeNames.length; 1097 int count = typeNames.length;
779 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat ionUnitElementImpl>(count); 1098 List<CompilationUnitElementImpl> sourcedCompilationUnits = new List<Compilat ionUnitElementImpl>(count);
780 for (int i = 0; i < count; i++) { 1099 for (int i = 0; i < count; i++) {
781 String typeName = typeNames[i]; 1100 String typeName = typeNames[i];
782 ClassElementImpl type = new ClassElementImpl(ASTFactory.identifier2(typeNa me)); 1101 ClassElementImpl type = new ClassElementImpl(ASTFactory.identifier2(typeNa me));
783 String fileName = "${typeName}.dart"; 1102 String fileName = "${typeName}.dart";
784 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImp l(fileName); 1103 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImp l(fileName);
785 compilationUnit.source = new FileBasedSource.con1(_sourceFactory, FileUtil ities2.createFile(fileName)); 1104 compilationUnit.source = createSource2(fileName);
786 compilationUnit.types = <ClassElement> [type]; 1105 compilationUnit.types = <ClassElement> [type];
787 sourcedCompilationUnits[i] = compilationUnit; 1106 sourcedCompilationUnits[i] = compilationUnit;
788 } 1107 }
789 String fileName = "${libraryName}.dart"; 1108 String fileName = "${libraryName}.dart";
790 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName); 1109 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName);
791 compilationUnit.source = new FileBasedSource.con1(_sourceFactory, FileUtilit ies2.createFile(fileName)); 1110 compilationUnit.source = createSource2(fileName);
792 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName])); 1111 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName]));
793 library.definingCompilationUnit = compilationUnit; 1112 library.definingCompilationUnit = compilationUnit;
794 library.parts = sourcedCompilationUnits; 1113 library.parts = sourcedCompilationUnits;
795 return library; 1114 return library;
796 } 1115 }
797 AnalysisContext get analysisContext => _analysisContext; 1116 AnalysisContext get analysisContext => _analysisContext;
798 GatheringErrorListener get errorListener => _errorListener; 1117 GatheringErrorListener get errorListener => _errorListener;
799 SourceFactory get sourceFactory => _sourceFactory; 1118 SourceFactory get sourceFactory => _sourceFactory;
800 /** 1119 /**
801 * Given a library and all of its parts, resolve the contents of the library a nd the contents of 1120 * Given a library and all of its parts, resolve the contents of the library a nd the contents of
(...skipping 12 matching lines...) Expand all
814 * Verify that all of the identifiers in the compilation units associated with the given sources 1133 * Verify that all of the identifiers in the compilation units associated with the given sources
815 * have been resolved. 1134 * have been resolved.
816 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element 1135 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element
817 * to which they were resolved 1136 * to which they were resolved
818 * @param sources the sources identifying the compilation units to be verified 1137 * @param sources the sources identifying the compilation units to be verified
819 * @throws Exception if the contents of the compilation unit cannot be accesse d 1138 * @throws Exception if the contents of the compilation unit cannot be accesse d
820 */ 1139 */
821 void verify(List<Source> sources) { 1140 void verify(List<Source> sources) {
822 ResolutionVerifier verifier = new ResolutionVerifier(); 1141 ResolutionVerifier verifier = new ResolutionVerifier();
823 for (Source source in sources) { 1142 for (Source source in sources) {
824 _analysisContext.parse3(source, _errorListener).accept(verifier); 1143 _analysisContext.parseCompilationUnit(source).accept(verifier);
825 } 1144 }
826 verifier.assertResolved(); 1145 verifier.assertResolved();
827 } 1146 }
1147 /**
1148 * Create a source object representing a file with the given name and give it an empty content.
1149 * @param fileName the name of the file for which a source is to be created
1150 * @return the source that was created
1151 */
1152 FileBasedSource createSource2(String fileName) {
1153 FileBasedSource source = new FileBasedSource.con1(_sourceFactory, FileUtilit ies2.createFile(fileName));
1154 _sourceFactory.setContents(source, "");
1155 return source;
1156 }
828 static dartSuite() { 1157 static dartSuite() {
829 _ut.group('ResolverTestCase', () { 1158 _ut.group('ResolverTestCase', () {
830 }); 1159 });
831 } 1160 }
832 } 1161 }
833 class TypeProviderImplTest extends EngineTestCase { 1162 class TypeProviderImplTest extends EngineTestCase {
834 void test_creation() { 1163 void test_creation() {
835 InterfaceType objectType = classElement("Object", null, []).type; 1164 InterfaceType objectType = classElement("Object", null, []).type;
836 InterfaceType boolType = classElement("bool", objectType, []).type; 1165 InterfaceType boolType = classElement("bool", objectType, []).type;
837 InterfaceType numType = classElement("num", objectType, []).type; 1166 InterfaceType numType = classElement("num", objectType, []).type;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 resolve(source, []); 1316 resolve(source, []);
988 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 1317 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
989 verify([source]); 1318 verify([source]);
990 } 1319 }
991 void fail_fieldInitializedByMultipleInitializers() { 1320 void fail_fieldInitializedByMultipleInitializers() {
992 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A() : x = 0, x = 1 {}", "}"])); 1321 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A() : x = 0, x = 1 {}", "}"]));
993 resolve(source, []); 1322 resolve(source, []);
994 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]); 1323 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]);
995 verify([source]); 1324 verify([source]);
996 } 1325 }
997 void fail_fieldInitializedInInitializerAndDeclaration() {
998 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x = 0;", " A() : x = 1 {}", "}"]));
999 resolve(source, []);
1000 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]);
1001 verify([source]);
1002 }
1003 void fail_fieldInitializeInParameterAndInitializer() {
1004 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(this.x) : x = 1 {}", "}"]));
1005 resolve(source, []);
1006 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA LIZER]);
1007 verify([source]);
1008 }
1009 void fail_fieldInitializerOutsideConstructor() {
1010 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " m(this.x) {}", "}"]));
1011 resolve(source, []);
1012 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
1013 verify([source]);
1014 }
1015 void fail_finalInitializedInDeclarationAndConstructor_assignment() { 1326 void fail_finalInitializedInDeclarationAndConstructor_assignment() {
1016 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x = 0;", " A() { x = 1; }", "}"])); 1327 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x = 0;", " A() { x = 1; }", "}"]));
1017 resolve(source, []); 1328 resolve(source, []);
1018 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONS TRUCTOR]); 1329 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONS TRUCTOR]);
1019 verify([source]); 1330 verify([source]);
1020 } 1331 }
1021 void fail_finalInitializedInDeclarationAndConstructor_initializingFormal() { 1332 void fail_finalInitializedInDeclarationAndConstructor_initializingFormal() {
1022 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"])); 1333 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"]));
1023 resolve(source, []); 1334 resolve(source, []);
1024 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONS TRUCTOR]); 1335 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONS TRUCTOR]);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 resolve(source, []); 1728 resolve(source, []);
1418 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 1729 assertErrors([CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
1419 verify([source]); 1730 verify([source]);
1420 } 1731 }
1421 void fail_superInitializerInObject() { 1732 void fail_superInitializerInObject() {
1422 Source source = addSource("/test.dart", EngineTestCase.createSource([])); 1733 Source source = addSource("/test.dart", EngineTestCase.createSource([]));
1423 resolve(source, []); 1734 resolve(source, []);
1424 assertErrors([CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]); 1735 assertErrors([CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT]);
1425 verify([source]); 1736 verify([source]);
1426 } 1737 }
1427 void fail_throwWithoutValueOutsideOn() {
1428 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " throw;", "}"]));
1429 resolve(source, []);
1430 assertErrors([CompileTimeErrorCode.THROW_WITHOUT_VALUE_OUTSIDE_ON]);
1431 verify([source]);
1432 }
1433 void fail_typeArgumentsForNonGenericClass_creation_const() { 1738 void fail_typeArgumentsForNonGenericClass_creation_const() {
1434 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f(p) {", " return const A<int>();", "}"])); 1739 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f(p) {", " return const A<int>();", "}"]));
1435 resolve(source, []); 1740 resolve(source, []);
1436 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]); 1741 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]);
1437 verify([source]); 1742 verify([source]);
1438 } 1743 }
1439 void fail_typeArgumentsForNonGenericClass_creation_new() { 1744 void fail_typeArgumentsForNonGenericClass_creation_new() {
1440 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f(p) {", " return new A<int>();", "}"])); 1745 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "f(p) {", " return new A<int>();", "}"]));
1441 resolve(source, []); 1746 resolve(source, []);
1442 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]); 1747 assertErrors([CompileTimeErrorCode.TYPE_ARGUMENTS_FOR_NON_GENERIC_CLASS]);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 resolve(source, []); 1994 resolve(source, []);
1690 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 1995 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1691 verify([source]); 1996 verify([source]);
1692 } 1997 }
1693 void test_extendsOrImplementsDisallowedClass_implements_String() { 1998 void test_extendsOrImplementsDisallowedClass_implements_String() {
1694 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements String {}"])); 1999 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A implements String {}"]));
1695 resolve(source, []); 2000 resolve(source, []);
1696 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 2001 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1697 verify([source]); 2002 verify([source]);
1698 } 2003 }
2004 void test_fieldInitializedInInitializerAndDeclaration_const() {
2005 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const int x = 0;", " A() : x = 1 {}", "}"]));
2006 resolve(source, []);
2007 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]);
2008 verify([source]);
2009 }
2010 void test_fieldInitializedInInitializerAndDeclaration_final() {
2011 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x = 0;", " A() : x = 1 {}", "}"]));
2012 resolve(source, []);
2013 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]);
2014 verify([source]);
2015 }
2016 void test_fieldInitializeInParameterAndInitializer() {
2017 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " A(this.x) : x = 1 {}", "}"]));
2018 resolve(source, []);
2019 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA LIZER]);
2020 verify([source]);
2021 }
2022 void test_fieldInitializerOutsideConstructor() {
2023 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " m(this.x) {}", "}"]));
2024 resolve(source, []);
2025 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
2026 verify([source]);
2027 }
2028 void test_fieldInitializerOutsideConstructor_defaultParameters() {
2029 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " int x;", " m([this.x]) {}", "}"]));
2030 resolve(source, []);
2031 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR]);
2032 verify([source]);
2033 }
1699 void test_implementsNonClass() { 2034 void test_implementsNonClass() {
1700 Source source = addSource("/test.dart", EngineTestCase.createSource(["int A; ", "class B implements A {}"])); 2035 Source source = addSource("/test.dart", EngineTestCase.createSource(["int A; ", "class B implements A {}"]));
1701 resolve(source, []); 2036 resolve(source, []);
1702 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]); 2037 assertErrors([CompileTimeErrorCode.IMPLEMENTS_NON_CLASS]);
1703 verify([source]); 2038 verify([source]);
1704 } 2039 }
1705 void test_labelInOuterScope() { 2040 void test_labelInOuterScope() {
1706 Source source = addSource("/test.dart", EngineTestCase.createSource(["class int {}", "", "class A {", " void m(int i) {", " l: while (i > 0) {", " void f() {", " break l;", " };", " }", " }", "}"])); 2041 Source source = addSource("/test.dart", EngineTestCase.createSource(["class int {}", "", "class A {", " void m(int i) {", " l: while (i > 0) {", " void f() {", " break l;", " };", " }", " }", "}"]));
1707 resolve(source, []); 2042 resolve(source, []);
1708 assertErrors([CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, ResolverErrorCode.C ANNOT_BE_RESOLVED]); 2043 assertErrors([CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, ResolverErrorCode.C ANNOT_BE_RESOLVED]);
(...skipping 25 matching lines...) Expand all
1734 resolve(source, []); 2069 resolve(source, []);
1735 assertErrors([CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); 2070 assertErrors([CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
1736 verify([source]); 2071 verify([source]);
1737 } 2072 }
1738 void test_nonConstMapValue() { 2073 void test_nonConstMapValue() {
1739 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(a) { ", " return const {'a' : a};", "}"])); 2074 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(a) { ", " return const {'a' : a};", "}"]));
1740 resolve(source, []); 2075 resolve(source, []);
1741 assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]); 2076 assertErrors([CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
1742 verify([source]); 2077 verify([source]);
1743 } 2078 }
2079 void test_rethrowOutsideCatch() {
2080 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " rethrow;", "}"]));
2081 resolve(source, []);
2082 assertErrors([CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH]);
2083 verify([source]);
2084 }
1744 void test_uriWithInterpolation_constant() { 2085 void test_uriWithInterpolation_constant() {
1745 Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'stuff_\$platform.dart';"])); 2086 Source source = addSource("/test.dart", EngineTestCase.createSource(["import 'stuff_\$platform.dart';"]));
1746 resolve(source, []); 2087 resolve(source, []);
1747 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION]); 2088 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION]);
1748 } 2089 }
1749 void test_uriWithInterpolation_nonConstant() { 2090 void test_uriWithInterpolation_nonConstant() {
1750 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y lib;", "part '\${'a'}.dart';"])); 2091 Source source = addSource("/test.dart", EngineTestCase.createSource(["librar y lib;", "part '\${'a'}.dart';"]));
1751 resolve(source, []); 2092 resolve(source, []);
1752 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION]); 2093 assertErrors([CompileTimeErrorCode.URI_WITH_INTERPOLATION]);
1753 } 2094 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_double); 2207 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_double);
1867 }); 2208 });
1868 _ut.test('test_extendsOrImplementsDisallowedClass_implements_int', () { 2209 _ut.test('test_extendsOrImplementsDisallowedClass_implements_int', () {
1869 final __test = new CompileTimeErrorCodeTest(); 2210 final __test = new CompileTimeErrorCodeTest();
1870 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_int); 2211 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_int);
1871 }); 2212 });
1872 _ut.test('test_extendsOrImplementsDisallowedClass_implements_num', () { 2213 _ut.test('test_extendsOrImplementsDisallowedClass_implements_num', () {
1873 final __test = new CompileTimeErrorCodeTest(); 2214 final __test = new CompileTimeErrorCodeTest();
1874 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_num); 2215 runJUnitTest(__test, __test.test_extendsOrImplementsDisallowedClass_impl ements_num);
1875 }); 2216 });
2217 _ut.test('test_fieldInitializeInParameterAndInitializer', () {
2218 final __test = new CompileTimeErrorCodeTest();
2219 runJUnitTest(__test, __test.test_fieldInitializeInParameterAndInitialize r);
2220 });
2221 _ut.test('test_fieldInitializedInInitializerAndDeclaration_const', () {
2222 final __test = new CompileTimeErrorCodeTest();
2223 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_const);
2224 });
2225 _ut.test('test_fieldInitializedInInitializerAndDeclaration_final', () {
2226 final __test = new CompileTimeErrorCodeTest();
2227 runJUnitTest(__test, __test.test_fieldInitializedInInitializerAndDeclara tion_final);
2228 });
2229 _ut.test('test_fieldInitializerOutsideConstructor', () {
2230 final __test = new CompileTimeErrorCodeTest();
2231 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor);
2232 });
2233 _ut.test('test_fieldInitializerOutsideConstructor_defaultParameters', () {
2234 final __test = new CompileTimeErrorCodeTest();
2235 runJUnitTest(__test, __test.test_fieldInitializerOutsideConstructor_defa ultParameters);
2236 });
1876 _ut.test('test_implementsNonClass', () { 2237 _ut.test('test_implementsNonClass', () {
1877 final __test = new CompileTimeErrorCodeTest(); 2238 final __test = new CompileTimeErrorCodeTest();
1878 runJUnitTest(__test, __test.test_implementsNonClass); 2239 runJUnitTest(__test, __test.test_implementsNonClass);
1879 }); 2240 });
1880 _ut.test('test_labelInOuterScope', () { 2241 _ut.test('test_labelInOuterScope', () {
1881 final __test = new CompileTimeErrorCodeTest(); 2242 final __test = new CompileTimeErrorCodeTest();
1882 runJUnitTest(__test, __test.test_labelInOuterScope); 2243 runJUnitTest(__test, __test.test_labelInOuterScope);
1883 }); 2244 });
1884 _ut.test('test_labelUndefined_break', () { 2245 _ut.test('test_labelUndefined_break', () {
1885 final __test = new CompileTimeErrorCodeTest(); 2246 final __test = new CompileTimeErrorCodeTest();
(...skipping 12 matching lines...) Expand all
1898 runJUnitTest(__test, __test.test_nonConstCaseExpression); 2259 runJUnitTest(__test, __test.test_nonConstCaseExpression);
1899 }); 2260 });
1900 _ut.test('test_nonConstListElement', () { 2261 _ut.test('test_nonConstListElement', () {
1901 final __test = new CompileTimeErrorCodeTest(); 2262 final __test = new CompileTimeErrorCodeTest();
1902 runJUnitTest(__test, __test.test_nonConstListElement); 2263 runJUnitTest(__test, __test.test_nonConstListElement);
1903 }); 2264 });
1904 _ut.test('test_nonConstMapValue', () { 2265 _ut.test('test_nonConstMapValue', () {
1905 final __test = new CompileTimeErrorCodeTest(); 2266 final __test = new CompileTimeErrorCodeTest();
1906 runJUnitTest(__test, __test.test_nonConstMapValue); 2267 runJUnitTest(__test, __test.test_nonConstMapValue);
1907 }); 2268 });
2269 _ut.test('test_rethrowOutsideCatch', () {
2270 final __test = new CompileTimeErrorCodeTest();
2271 runJUnitTest(__test, __test.test_rethrowOutsideCatch);
2272 });
1908 _ut.test('test_uriWithInterpolation_constant', () { 2273 _ut.test('test_uriWithInterpolation_constant', () {
1909 final __test = new CompileTimeErrorCodeTest(); 2274 final __test = new CompileTimeErrorCodeTest();
1910 runJUnitTest(__test, __test.test_uriWithInterpolation_constant); 2275 runJUnitTest(__test, __test.test_uriWithInterpolation_constant);
1911 }); 2276 });
1912 _ut.test('test_uriWithInterpolation_nonConstant', () { 2277 _ut.test('test_uriWithInterpolation_nonConstant', () {
1913 final __test = new CompileTimeErrorCodeTest(); 2278 final __test = new CompileTimeErrorCodeTest();
1914 runJUnitTest(__test, __test.test_uriWithInterpolation_nonConstant); 2279 runJUnitTest(__test, __test.test_uriWithInterpolation_nonConstant);
1915 }); 2280 });
1916 }); 2281 });
1917 } 2282 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 return null; 2363 return null;
1999 } 2364 }
2000 Object visitLibraryIdentifier(LibraryIdentifier node) => null; 2365 Object visitLibraryIdentifier(LibraryIdentifier node) => null;
2001 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 2366 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
2002 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) { 2367 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) {
2003 return null; 2368 return null;
2004 } 2369 }
2005 return super.visitPrefixedIdentifier(node); 2370 return super.visitPrefixedIdentifier(node);
2006 } 2371 }
2007 Object visitSimpleIdentifier(SimpleIdentifier node) { 2372 Object visitSimpleIdentifier(SimpleIdentifier node) {
2008 ASTNode parent19 = node.parent; 2373 ASTNode parent21 = node.parent;
2009 if (parent19 is MethodInvocation && identical(node, ((parent19 as MethodInvo cation)).methodName)) { 2374 if (parent21 is MethodInvocation && identical(node, ((parent21 as MethodInvo cation)).methodName)) {
2010 return null; 2375 return null;
2011 } else if (parent19 is RedirectingConstructorInvocation && identical(node, ( (parent19 as RedirectingConstructorInvocation)).constructorName)) { 2376 } else if (parent21 is RedirectingConstructorInvocation && identical(node, ( (parent21 as RedirectingConstructorInvocation)).constructorName)) {
2012 return null; 2377 return null;
2013 } else if (parent19 is SuperConstructorInvocation && identical(node, ((paren t19 as SuperConstructorInvocation)).constructorName)) { 2378 } else if (parent21 is SuperConstructorInvocation && identical(node, ((paren t21 as SuperConstructorInvocation)).constructorName)) {
2014 return null; 2379 return null;
2015 } else if (parent19 is ConstructorName && identical(node, ((parent19 as Cons tructorName)).name)) { 2380 } else if (parent21 is ConstructorName && identical(node, ((parent21 as Cons tructorName)).name)) {
2016 return null; 2381 return null;
2017 } else if (parent19 is Label && identical(node, ((parent19 as Label)).label) ) { 2382 } else if (parent21 is Label && identical(node, ((parent21 as Label)).label) ) {
2018 return null; 2383 return null;
2019 } else if (parent19 is ImportDirective && identical(node, ((parent19 as Impo rtDirective)).prefix)) { 2384 } else if (parent21 is ImportDirective && identical(node, ((parent21 as Impo rtDirective)).prefix)) {
2020 return null; 2385 return null;
2021 } else if (node.element is PrefixElement) { 2386 } else if (node.element is PrefixElement) {
2022 return null; 2387 return null;
2023 } 2388 }
2024 return super.visitSimpleIdentifier(node); 2389 return super.visitSimpleIdentifier(node);
2025 } 2390 }
2026 Object visitTypeName(TypeName node) { 2391 Object visitTypeName(TypeName node) {
2027 if (node.type == null) { 2392 if (node.type == null) {
2028 _unresolvedTypes.add(node); 2393 _unresolvedTypes.add(node);
2029 } else { 2394 } else {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 void test_visitSimpleIdentifier_lexicalScope_field_setter() { 2746 void test_visitSimpleIdentifier_lexicalScope_field_setter() {
2382 InterfaceType intType5 = _typeProvider.intType; 2747 InterfaceType intType5 = _typeProvider.intType;
2383 ClassElementImpl classA = ElementFactory.classElement2("A", []); 2748 ClassElementImpl classA = ElementFactory.classElement2("A", []);
2384 String fieldName = "a"; 2749 String fieldName = "a";
2385 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa lse, intType5); 2750 FieldElement field = ElementFactory.fieldElement(fieldName, false, false, fa lse, intType5);
2386 classA.fields = <FieldElement> [field]; 2751 classA.fields = <FieldElement> [field];
2387 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter]; 2752 classA.accessors = <PropertyAccessorElement> [field.getter, field.setter];
2388 SimpleIdentifier node = ASTFactory.identifier2(fieldName); 2753 SimpleIdentifier node = ASTFactory.identifier2(fieldName);
2389 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0)); 2754 ASTFactory.assignmentExpression(node, TokenType.EQ, ASTFactory.integer(0));
2390 resolveInClass(node, classA); 2755 resolveInClass(node, classA);
2391 Element element50 = node.element; 2756 Element element56 = node.element;
2392 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element50); 2757 EngineTestCase.assertInstanceOf(PropertyAccessorElement, element56);
2393 JUnitTestCase.assertTrue(((element50 as PropertyAccessorElement)).isSetter() ); 2758 JUnitTestCase.assertTrue(((element56 as PropertyAccessorElement)).isSetter() );
2394 _listener.assertNoErrors(); 2759 _listener.assertNoErrors();
2395 } 2760 }
2396 void test_visitSuperConstructorInvocation() { 2761 void test_visitSuperConstructorInvocation() {
2397 ClassElementImpl superclass = ElementFactory.classElement2("A", []); 2762 ClassElementImpl superclass = ElementFactory.classElement2("A", []);
2398 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( null); 2763 ConstructorElementImpl superConstructor = ElementFactory.constructorElement( null);
2399 superclass.constructors = <ConstructorElement> [superConstructor]; 2764 superclass.constructors = <ConstructorElement> [superConstructor];
2400 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []); 2765 ClassElementImpl subclass = ElementFactory.classElement("B", superclass.type , []);
2401 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(nu ll); 2766 ConstructorElementImpl subConstructor = ElementFactory.constructorElement(nu ll);
2402 subclass.constructors = <ConstructorElement> [subConstructor]; 2767 subclass.constructors = <ConstructorElement> [subConstructor];
2403 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([]); 2768 SuperConstructorInvocation invocation = ASTFactory.superConstructorInvocatio n([]);
(...skipping 18 matching lines...) Expand all
2422 _listener.assertNoErrors(); 2787 _listener.assertNoErrors();
2423 } 2788 }
2424 /** 2789 /**
2425 * Create the resolver used by the tests. 2790 * Create the resolver used by the tests.
2426 * @return the resolver that was created 2791 * @return the resolver that was created
2427 */ 2792 */
2428 ElementResolver createResolver() { 2793 ElementResolver createResolver() {
2429 AnalysisContextImpl context = new AnalysisContextImpl(); 2794 AnalysisContextImpl context = new AnalysisContextImpl();
2430 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Da rtSdk.defaultSdk)]); 2795 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Da rtSdk.defaultSdk)]);
2431 context.sourceFactory = sourceFactory; 2796 context.sourceFactory = sourceFactory;
2797 FileBasedSource source = new FileBasedSource.con1(sourceFactory, FileUtiliti es2.createFile("/test.dart"));
2432 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart"); 2798 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("test.dart");
2433 definingCompilationUnit.source = new FileBasedSource.con1(sourceFactory, Fil eUtilities2.createFile("/test.dart")); 2799 definingCompilationUnit.source = source;
2434 _definingLibrary = ElementFactory.library(context, "test"); 2800 _definingLibrary = ElementFactory.library(context, "test");
2435 _definingLibrary.definingCompilationUnit = definingCompilationUnit; 2801 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
2436 Library library = new Library(context, _listener, null); 2802 Library library = new Library(context, _listener, source);
2437 library.libraryElement = _definingLibrary; 2803 library.libraryElement = _definingLibrary;
2438 _visitor = new ResolverVisitor(library, null, _typeProvider); 2804 _visitor = new ResolverVisitor(library, source, _typeProvider);
2439 try { 2805 try {
2440 return _visitor.elementResolver_J2DAccessor as ElementResolver; 2806 return _visitor.elementResolver_J2DAccessor as ElementResolver;
2441 } on JavaException catch (exception) { 2807 } catch (exception) {
2442 throw new IllegalArgumentException("Could not create resolver", exception) ; 2808 throw new IllegalArgumentException("Could not create resolver", exception) ;
2443 } 2809 }
2444 } 2810 }
2445 /** 2811 /**
2446 * Return the element associated with the label of the given statement after t he resolver has 2812 * Return the element associated with the label of the given statement after t he resolver has
2447 * resolved the statement. 2813 * resolved the statement.
2448 * @param statement the statement to be resolved 2814 * @param statement the statement to be resolved
2449 * @param labelElement the label element to be defined in the statement's labe l scope 2815 * @param labelElement the label element to be defined in the statement's labe l scope
2450 * @return the element to which the statement's label was resolved 2816 * @return the element to which the statement's label was resolved
2451 */ 2817 */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope; 2866 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
2501 try { 2867 try {
2502 _visitor.enclosingClass_J2DAccessor = enclosingClass; 2868 _visitor.enclosingClass_J2DAccessor = enclosingClass;
2503 EnclosedScope innerScope = new ClassScope(outerScope, enclosingClass); 2869 EnclosedScope innerScope = new ClassScope(outerScope, enclosingClass);
2504 _visitor.nameScope_J2DAccessor = innerScope; 2870 _visitor.nameScope_J2DAccessor = innerScope;
2505 node.accept(_resolver); 2871 node.accept(_resolver);
2506 } finally { 2872 } finally {
2507 _visitor.enclosingClass_J2DAccessor = null; 2873 _visitor.enclosingClass_J2DAccessor = null;
2508 _visitor.nameScope_J2DAccessor = outerScope; 2874 _visitor.nameScope_J2DAccessor = outerScope;
2509 } 2875 }
2510 } on JavaException catch (exception) { 2876 } catch (exception) {
2511 throw new IllegalArgumentException("Could not resolve node", exception); 2877 throw new IllegalArgumentException("Could not resolve node", exception);
2512 } 2878 }
2513 } 2879 }
2514 /** 2880 /**
2515 * Return the element associated with the given identifier after the resolver has resolved the 2881 * Return the element associated with the given identifier after the resolver has resolved the
2516 * identifier. 2882 * identifier.
2517 * @param node the expression to be resolved 2883 * @param node the expression to be resolved
2518 * @param definedElements the elements that are to be defined in the scope in which the element is 2884 * @param definedElements the elements that are to be defined in the scope in which the element is
2519 * being resolved 2885 * being resolved
2520 * @return the element to which the expression was resolved 2886 * @return the element to which the expression was resolved
2521 */ 2887 */
2522 void resolveNode(ASTNode node, List<Element> definedElements) { 2888 void resolveNode(ASTNode node, List<Element> definedElements) {
2523 try { 2889 try {
2524 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope; 2890 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope;
2525 try { 2891 try {
2526 EnclosedScope innerScope = new EnclosedScope(outerScope); 2892 EnclosedScope innerScope = new EnclosedScope(outerScope);
2527 for (Element element in definedElements) { 2893 for (Element element in definedElements) {
2528 innerScope.define(element); 2894 innerScope.define(element);
2529 } 2895 }
2530 _visitor.nameScope_J2DAccessor = innerScope; 2896 _visitor.nameScope_J2DAccessor = innerScope;
2531 node.accept(_resolver); 2897 node.accept(_resolver);
2532 } finally { 2898 } finally {
2533 _visitor.nameScope_J2DAccessor = outerScope; 2899 _visitor.nameScope_J2DAccessor = outerScope;
2534 } 2900 }
2535 } on JavaException catch (exception) { 2901 } catch (exception) {
2536 throw new IllegalArgumentException("Could not resolve node", exception); 2902 throw new IllegalArgumentException("Could not resolve node", exception);
2537 } 2903 }
2538 } 2904 }
2539 /** 2905 /**
2540 * Return the element associated with the label of the given statement after t he resolver has 2906 * Return the element associated with the label of the given statement after t he resolver has
2541 * resolved the statement. 2907 * resolved the statement.
2542 * @param statement the statement to be resolved 2908 * @param statement the statement to be resolved
2543 * @param labelElement the label element to be defined in the statement's labe l scope 2909 * @param labelElement the label element to be defined in the statement's labe l scope
2544 * @return the element to which the statement's label was resolved 2910 * @return the element to which the statement's label was resolved
2545 */ 2911 */
2546 void resolveStatement(Statement statement, LabelElementImpl labelElement) { 2912 void resolveStatement(Statement statement, LabelElementImpl labelElement) {
2547 try { 2913 try {
2548 LabelScope outerScope = _visitor.labelScope_J2DAccessor as LabelScope; 2914 LabelScope outerScope = _visitor.labelScope_J2DAccessor as LabelScope;
2549 try { 2915 try {
2550 LabelScope innerScope; 2916 LabelScope innerScope;
2551 if (labelElement == null) { 2917 if (labelElement == null) {
2552 innerScope = new LabelScope.con1(outerScope, false, false); 2918 innerScope = new LabelScope.con1(outerScope, false, false);
2553 } else { 2919 } else {
2554 innerScope = new LabelScope.con2(outerScope, labelElement.name, labelE lement); 2920 innerScope = new LabelScope.con2(outerScope, labelElement.name, labelE lement);
2555 } 2921 }
2556 _visitor.labelScope_J2DAccessor = innerScope; 2922 _visitor.labelScope_J2DAccessor = innerScope;
2557 statement.accept(_resolver); 2923 statement.accept(_resolver);
2558 } finally { 2924 } finally {
2559 _visitor.labelScope_J2DAccessor = outerScope; 2925 _visitor.labelScope_J2DAccessor = outerScope;
2560 } 2926 }
2561 } on JavaException catch (exception) { 2927 } catch (exception) {
2562 throw new IllegalArgumentException("Could not resolve node", exception); 2928 throw new IllegalArgumentException("Could not resolve node", exception);
2563 } 2929 }
2564 } 2930 }
2565 static dartSuite() { 2931 static dartSuite() {
2566 _ut.group('ElementResolverTest', () { 2932 _ut.group('ElementResolverTest', () {
2567 _ut.test('test_visitAssignmentExpression_compound', () { 2933 _ut.test('test_visitAssignmentExpression_compound', () {
2568 final __test = new ElementResolverTest(); 2934 final __test = new ElementResolverTest();
2569 runJUnitTest(__test, __test.test_visitAssignmentExpression_compound); 2935 runJUnitTest(__test, __test.test_visitAssignmentExpression_compound);
2570 }); 2936 });
2571 _ut.test('test_visitAssignmentExpression_simple', () { 2937 _ut.test('test_visitAssignmentExpression_simple', () {
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
3034 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember); 3400 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember);
3035 }); 3401 });
3036 _ut.test('test_continueLabelOnSwitch', () { 3402 _ut.test('test_continueLabelOnSwitch', () {
3037 final __test = new ErrorResolverTest(); 3403 final __test = new ErrorResolverTest();
3038 runJUnitTest(__test, __test.test_continueLabelOnSwitch); 3404 runJUnitTest(__test, __test.test_continueLabelOnSwitch);
3039 }); 3405 });
3040 }); 3406 });
3041 } 3407 }
3042 } 3408 }
3043 /** 3409 /**
3044 * The class {@code AnalysisContextFactory} defines utility methods used to crea te analysis contexts
3045 * for testing purposes.
3046 */
3047 class AnalysisContextFactory {
3048 /**
3049 * Create an analysis context that has a fake core library already resolved.
3050 * @return the analysis context that was created
3051 */
3052 static AnalysisContextImpl contextWithCore() {
3053 AnalysisContextImpl context = new AnalysisContextImpl();
3054 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Da rtSdk.defaultSdk), new FileUriResolver()]);
3055 context.sourceFactory = sourceFactory;
3056 TestTypeProvider provider = new TestTypeProvider();
3057 CompilationUnitElementImpl unit = new CompilationUnitElementImpl("core.dart" );
3058 unit.types = <ClassElement> [provider.boolType.element, provider.doubleType. element, provider.functionType.element, provider.intType.element, provider.listT ype.element, provider.mapType.element, provider.numType.element, provider.object Type.element, provider.stackTraceType.element, provider.stringType.element, prov ider.typeType.element];
3059 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2(["dart", "core"]));
3060 library.definingCompilationUnit = unit;
3061 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
3062 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
3063 elementMap[coreSource] = library;
3064 context.recordLibraryElements(elementMap);
3065 unit.source = coreSource;
3066 return context;
3067 }
3068 /**
3069 * Prevent the creation of instances of this class.
3070 */
3071 AnalysisContextFactory() {
3072 }
3073 }
3074 /**
3075 * Instances of the class {@code TestTypeProvider} implement a type provider tha t can be used by 3410 * Instances of the class {@code TestTypeProvider} implement a type provider tha t can be used by
3076 * tests without creating the element model for the core library. 3411 * tests without creating the element model for the core library.
3077 */ 3412 */
3078 class TestTypeProvider implements TypeProvider { 3413 class TestTypeProvider implements TypeProvider {
3079 /** 3414 /**
3080 * The type representing the built-in type 'bool'. 3415 * The type representing the built-in type 'bool'.
3081 */ 3416 */
3082 InterfaceType _boolType; 3417 InterfaceType _boolType;
3083 /** 3418 /**
3084 * The type representing the type 'bottom'. 3419 * The type representing the type 'bottom'.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 doubleElement.fields = fields; 3577 doubleElement.fields = fields;
3243 int fieldCount = fields.length; 3578 int fieldCount = fields.length;
3244 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount); 3579 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount);
3245 for (int i = 0; i < fieldCount; i++) { 3580 for (int i = 0; i < fieldCount; i++) {
3246 accessors[i] = fields[i].getter; 3581 accessors[i] = fields[i].getter;
3247 } 3582 }
3248 doubleElement.accessors = accessors; 3583 doubleElement.accessors = accessors;
3249 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, [])]; 3584 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, [])];
3250 } 3585 }
3251 } 3586 }
3587 /**
3588 * The class {@code AnalysisContextFactory} defines utility methods used to crea te analysis contexts
3589 * for testing purposes.
3590 */
3591 class AnalysisContextFactory {
3592 /**
3593 * Create an analysis context that has a fake core library already resolved.
3594 * @return the analysis context that was created
3595 */
3596 static AnalysisContextImpl contextWithCore() {
3597 AnalysisContextImpl context = new AnalysisContextImpl();
3598 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Da rtSdk.defaultSdk), new FileUriResolver()]);
3599 context.sourceFactory = sourceFactory;
3600 TestTypeProvider provider = new TestTypeProvider();
3601 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art");
3602 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
3603 coreUnit.source = coreSource;
3604 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];
3605 LibraryElementImpl coreLibrary = new LibraryElementImpl(context, ASTFactory. libraryIdentifier2(["dart", "core"]));
3606 coreLibrary.definingCompilationUnit = coreUnit;
3607 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d artium.dart");
3608 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
3609 htmlUnit.source = htmlSource;
3610 LibraryElementImpl htmlLibrary = new LibraryElementImpl(context, ASTFactory. libraryIdentifier2(["dart", "dom", "html"]));
3611 htmlLibrary.definingCompilationUnit = htmlUnit;
3612 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
3613 elementMap[coreSource] = coreLibrary;
3614 elementMap[htmlSource] = htmlLibrary;
3615 context.setContents(coreSource, "");
3616 context.setContents(htmlSource, "");
3617 context.recordLibraryElements(elementMap);
3618 return context;
3619 }
3620 /**
3621 * Prevent the creation of instances of this class.
3622 */
3623 AnalysisContextFactory() {
3624 }
3625 }
3252 class LibraryImportScopeTest extends ResolverTestCase { 3626 class LibraryImportScopeTest extends ResolverTestCase {
3253 void test_conflictingImports() { 3627 void test_conflictingImports() {
3254 AnalysisContext context = new AnalysisContextImpl(); 3628 AnalysisContext context = new AnalysisContextImpl();
3255 String typeNameA = "A"; 3629 String typeNameA = "A";
3256 String typeNameB = "B"; 3630 String typeNameB = "B";
3257 String typeNameC = "C"; 3631 String typeNameC = "C";
3258 ClassElement typeA = new ClassElementImpl(ASTFactory.identifier2(typeNameA)) ; 3632 ClassElement typeA = new ClassElementImpl(ASTFactory.identifier2(typeNameA)) ;
3259 ClassElement typeB1 = new ClassElementImpl(ASTFactory.identifier2(typeNameB) ); 3633 ClassElement typeB1 = new ClassElementImpl(ASTFactory.identifier2(typeNameB) );
3260 ClassElement typeB2 = new ClassElementImpl(ASTFactory.identifier2(typeNameB) ); 3634 ClassElement typeB2 = new ClassElementImpl(ASTFactory.identifier2(typeNameB) );
3261 ClassElement typeC = new ClassElementImpl(ASTFactory.identifier2(typeNameC)) ; 3635 ClassElement typeC = new ClassElementImpl(ASTFactory.identifier2(typeNameC)) ;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3355 List<ASTNode> _unresolvedNodes = new List<ASTNode>(); 3729 List<ASTNode> _unresolvedNodes = new List<ASTNode>();
3356 /** 3730 /**
3357 * A list containing all of the AST nodes that were resolved to an element of the wrong type. 3731 * A list containing all of the AST nodes that were resolved to an element of the wrong type.
3358 */ 3732 */
3359 List<ASTNode> _wrongTypedNodes = new List<ASTNode>(); 3733 List<ASTNode> _wrongTypedNodes = new List<ASTNode>();
3360 /** 3734 /**
3361 * Initialize a newly created verifier to verify that all of the nodes in the visited AST 3735 * Initialize a newly created verifier to verify that all of the nodes in the visited AST
3362 * structures that are expected to have been resolved have an element associat ed with them. 3736 * structures that are expected to have been resolved have an element associat ed with them.
3363 */ 3737 */
3364 ResolutionVerifier() { 3738 ResolutionVerifier() {
3365 _jtd_constructor_319_impl(); 3739 _jtd_constructor_323_impl();
3366 } 3740 }
3367 _jtd_constructor_319_impl() { 3741 _jtd_constructor_323_impl() {
3368 _jtd_constructor_320_impl(null); 3742 _jtd_constructor_324_impl(null);
3369 } 3743 }
3370 /** 3744 /**
3371 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST 3745 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST
3372 * structures that are expected to have been resolved have an element associat ed with them. Nodes 3746 * structures that are expected to have been resolved have an element associat ed with them. Nodes
3373 * in the set of known exceptions are not expected to have been resolved, even if they normally 3747 * in the set of known exceptions are not expected to have been resolved, even if they normally
3374 * would have been expected to have been resolved. 3748 * would have been expected to have been resolved.
3375 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should 3749 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should
3376 * therefore not cause the test to fail 3750 * therefore not cause the test to fail
3377 */ 3751 */
3378 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) { 3752 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) {
3379 _jtd_constructor_320_impl(knownExceptions2); 3753 _jtd_constructor_324_impl(knownExceptions2);
3380 } 3754 }
3381 _jtd_constructor_320_impl(Set<ASTNode> knownExceptions2) { 3755 _jtd_constructor_324_impl(Set<ASTNode> knownExceptions2) {
3382 this._knownExceptions = knownExceptions2; 3756 this._knownExceptions = knownExceptions2;
3383 } 3757 }
3384 /** 3758 /**
3385 * Assert that all of the visited identifiers were resolved. 3759 * Assert that all of the visited identifiers were resolved.
3386 */ 3760 */
3387 void assertResolved() { 3761 void assertResolved() {
3388 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) { 3762 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) {
3389 PrintStringWriter writer = new PrintStringWriter(); 3763 PrintStringWriter writer = new PrintStringWriter();
3390 if (!_unresolvedNodes.isEmpty) { 3764 if (!_unresolvedNodes.isEmpty) {
3391 writer.print("Failed to resolve "); 3765 writer.print("Failed to resolve ");
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
4067 /** 4441 /**
4068 * Return the type associated with the given expression after the static type analyzer has 4442 * Return the type associated with the given expression after the static type analyzer has
4069 * computed a type for it. 4443 * computed a type for it.
4070 * @param node the expression with which the type is associated 4444 * @param node the expression with which the type is associated
4071 * @param thisType the type of 'this' 4445 * @param thisType the type of 'this'
4072 * @return the type associated with the expression 4446 * @return the type associated with the expression
4073 */ 4447 */
4074 Type2 analyze2(Expression node, InterfaceType thisType) { 4448 Type2 analyze2(Expression node, InterfaceType thisType) {
4075 try { 4449 try {
4076 _analyzer.thisType_J2DAccessor = thisType; 4450 _analyzer.thisType_J2DAccessor = thisType;
4077 } on JavaException catch (exception) { 4451 } catch (exception) {
4078 throw new IllegalArgumentException("Could not set type of 'this'", excepti on); 4452 throw new IllegalArgumentException("Could not set type of 'this'", excepti on);
4079 } 4453 }
4080 node.accept(_analyzer); 4454 node.accept(_analyzer);
4081 return node.staticType; 4455 return node.staticType;
4082 } 4456 }
4083 /** 4457 /**
4084 * Return the type associated with the given parameter after the static type a nalyzer has computed 4458 * Return the type associated with the given parameter after the static type a nalyzer has computed
4085 * a type for it. 4459 * a type for it.
4086 * @param node the parameter with which the type is associated 4460 * @param node the parameter with which the type is associated
4087 * @return the type associated with the parameter 4461 * @return the type associated with the parameter
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
4148 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType); 4522 EngineTestCase.assertInstanceOf(InterfaceTypeImpl, actualType);
4149 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy peImpl)); 4523 assertType((expectedType as InterfaceTypeImpl), (actualType as InterfaceTy peImpl));
4150 } 4524 }
4151 } 4525 }
4152 /** 4526 /**
4153 * Create the analyzer used by the tests. 4527 * Create the analyzer used by the tests.
4154 * @return the analyzer to be used by the tests 4528 * @return the analyzer to be used by the tests
4155 */ 4529 */
4156 StaticTypeAnalyzer createAnalyzer() { 4530 StaticTypeAnalyzer createAnalyzer() {
4157 AnalysisContextImpl context = new AnalysisContextImpl(); 4531 AnalysisContextImpl context = new AnalysisContextImpl();
4158 context.sourceFactory = new SourceFactory.con2([new DartUriResolver(DartSdk. defaultSdk)]); 4532 SourceFactory sourceFactory = new SourceFactory.con2([new DartUriResolver(Da rtSdk.defaultSdk)]);
4533 context.sourceFactory = sourceFactory;
4534 FileBasedSource source = new FileBasedSource.con1(sourceFactory, FileUtiliti es2.createFile("/lib.dart"));
4159 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("lib.dart"); 4535 CompilationUnitElementImpl definingCompilationUnit = new CompilationUnitElem entImpl("lib.dart");
4536 definingCompilationUnit.source = source;
4160 LibraryElementImpl definingLibrary = new LibraryElementImpl(context, null); 4537 LibraryElementImpl definingLibrary = new LibraryElementImpl(context, null);
4161 definingLibrary.definingCompilationUnit = definingCompilationUnit; 4538 definingLibrary.definingCompilationUnit = definingCompilationUnit;
4162 Library library = new Library(context, _listener, null); 4539 Library library = new Library(context, _listener, source);
4163 library.libraryElement = definingLibrary; 4540 library.libraryElement = definingLibrary;
4164 ResolverVisitor visitor = new ResolverVisitor(library, null, _typeProvider); 4541 ResolverVisitor visitor = new ResolverVisitor(library, source, _typeProvider );
4165 try { 4542 try {
4166 return visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer; 4543 return visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer;
4167 } on JavaException catch (exception) { 4544 } catch (exception) {
4168 throw new IllegalArgumentException("Could not create analyzer", exception) ; 4545 throw new IllegalArgumentException("Could not create analyzer", exception) ;
4169 } 4546 }
4170 } 4547 }
4171 /** 4548 /**
4172 * Return an integer literal that has been resolved to the correct type. 4549 * Return an integer literal that has been resolved to the correct type.
4173 * @param value the value of the literal 4550 * @param value the value of the literal
4174 * @return an integer literal that has been resolved to the correct type 4551 * @return an integer literal that has been resolved to the correct type
4175 */ 4552 */
4176 DoubleLiteral resolvedDouble(double value) { 4553 DoubleLiteral resolvedDouble(double value) {
4177 DoubleLiteral literal = ASTFactory.doubleLiteral(value); 4554 DoubleLiteral literal = ASTFactory.doubleLiteral(value);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4233 identifier.staticType = type37; 4610 identifier.staticType = type37;
4234 return identifier; 4611 return identifier;
4235 } 4612 }
4236 /** 4613 /**
4237 * Set the type of the given parameter to the given type. 4614 * Set the type of the given parameter to the given type.
4238 * @param parameter the parameter whose type is to be set 4615 * @param parameter the parameter whose type is to be set
4239 * @param type the new type of the given parameter 4616 * @param type the new type of the given parameter
4240 */ 4617 */
4241 void setType(FormalParameter parameter, Type2 type38) { 4618 void setType(FormalParameter parameter, Type2 type38) {
4242 SimpleIdentifier identifier17 = parameter.identifier; 4619 SimpleIdentifier identifier17 = parameter.identifier;
4243 Element element51 = identifier17.element; 4620 Element element57 = identifier17.element;
4244 if (element51 is! ParameterElement) { 4621 if (element57 is! ParameterElement) {
4245 element51 = new ParameterElementImpl(identifier17); 4622 element57 = new ParameterElementImpl(identifier17);
4246 identifier17.element = element51; 4623 identifier17.element = element57;
4247 } 4624 }
4248 ((element51 as ParameterElementImpl)).type = type38; 4625 ((element57 as ParameterElementImpl)).type = type38;
4249 } 4626 }
4250 static dartSuite() { 4627 static dartSuite() {
4251 _ut.group('StaticTypeAnalyzerTest', () { 4628 _ut.group('StaticTypeAnalyzerTest', () {
4252 _ut.test('test_visitAdjacentStrings', () { 4629 _ut.test('test_visitAdjacentStrings', () {
4253 final __test = new StaticTypeAnalyzerTest(); 4630 final __test = new StaticTypeAnalyzerTest();
4254 runJUnitTest(__test, __test.test_visitAdjacentStrings); 4631 runJUnitTest(__test, __test.test_visitAdjacentStrings);
4255 }); 4632 });
4256 _ut.test('test_visitArgumentDefinitionTest', () { 4633 _ut.test('test_visitArgumentDefinitionTest', () {
4257 final __test = new StaticTypeAnalyzerTest(); 4634 final __test = new StaticTypeAnalyzerTest();
4258 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest); 4635 runJUnitTest(__test, __test.test_visitArgumentDefinitionTest);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
4497 final __test = new StaticTypeAnalyzerTest(); 4874 final __test = new StaticTypeAnalyzerTest();
4498 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue); 4875 runJUnitTest(__test, __test.test_visitThrowExpression_withoutValue);
4499 }); 4876 });
4500 }); 4877 });
4501 } 4878 }
4502 } 4879 }
4503 class EnclosedScopeTest extends ResolverTestCase { 4880 class EnclosedScopeTest extends ResolverTestCase {
4504 void test_define_duplicate() { 4881 void test_define_duplicate() {
4505 LibraryElement definingLibrary2 = createTestLibrary(); 4882 LibraryElement definingLibrary2 = createTestLibrary();
4506 GatheringErrorListener errorListener2 = new GatheringErrorListener(); 4883 GatheringErrorListener errorListener2 = new GatheringErrorListener();
4507 Scope rootScope = new Scope_10(definingLibrary2, errorListener2); 4884 Scope rootScope = new Scope_12(definingLibrary2, errorListener2);
4508 EnclosedScope scope = new EnclosedScope(rootScope); 4885 EnclosedScope scope = new EnclosedScope(rootScope);
4509 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier2("v1")); 4886 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier2("v1"));
4510 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier2("v1")); 4887 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier2("v1"));
4511 scope.define(element1); 4888 scope.define(element1);
4512 scope.define(element2); 4889 scope.define(element2);
4513 errorListener2.assertErrors3([ErrorSeverity.ERROR]); 4890 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
4514 } 4891 }
4515 void test_define_normal() { 4892 void test_define_normal() {
4516 LibraryElement definingLibrary3 = createTestLibrary(); 4893 LibraryElement definingLibrary3 = createTestLibrary();
4517 GatheringErrorListener errorListener3 = new GatheringErrorListener(); 4894 GatheringErrorListener errorListener3 = new GatheringErrorListener();
4518 Scope rootScope = new Scope_11(definingLibrary3, errorListener3); 4895 Scope rootScope = new Scope_13(definingLibrary3, errorListener3);
4519 EnclosedScope outerScope = new EnclosedScope(rootScope); 4896 EnclosedScope outerScope = new EnclosedScope(rootScope);
4520 EnclosedScope innerScope = new EnclosedScope(outerScope); 4897 EnclosedScope innerScope = new EnclosedScope(outerScope);
4521 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier2("v1")); 4898 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier2("v1"));
4522 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier2("v2")); 4899 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier2("v2"));
4523 outerScope.define(element1); 4900 outerScope.define(element1);
4524 innerScope.define(element2); 4901 innerScope.define(element2);
4525 errorListener3.assertNoErrors(); 4902 errorListener3.assertNoErrors();
4526 } 4903 }
4527 static dartSuite() { 4904 static dartSuite() {
4528 _ut.group('EnclosedScopeTest', () { 4905 _ut.group('EnclosedScopeTest', () {
4529 _ut.test('test_define_duplicate', () { 4906 _ut.test('test_define_duplicate', () {
4530 final __test = new EnclosedScopeTest(); 4907 final __test = new EnclosedScopeTest();
4531 runJUnitTest(__test, __test.test_define_duplicate); 4908 runJUnitTest(__test, __test.test_define_duplicate);
4532 }); 4909 });
4533 _ut.test('test_define_normal', () { 4910 _ut.test('test_define_normal', () {
4534 final __test = new EnclosedScopeTest(); 4911 final __test = new EnclosedScopeTest();
4535 runJUnitTest(__test, __test.test_define_normal); 4912 runJUnitTest(__test, __test.test_define_normal);
4536 }); 4913 });
4537 }); 4914 });
4538 } 4915 }
4539 } 4916 }
4540 class Scope_10 extends Scope { 4917 class Scope_12 extends Scope {
4541 LibraryElement definingLibrary2; 4918 LibraryElement definingLibrary2;
4542 GatheringErrorListener errorListener2; 4919 GatheringErrorListener errorListener2;
4543 Scope_10(this.definingLibrary2, this.errorListener2) : super(); 4920 Scope_12(this.definingLibrary2, this.errorListener2) : super();
4544 LibraryElement get definingLibrary => definingLibrary2; 4921 LibraryElement get definingLibrary => definingLibrary2;
4545 AnalysisErrorListener get errorListener => errorListener2; 4922 AnalysisErrorListener get errorListener => errorListener2;
4546 Element lookup3(String name, LibraryElement referencingLibrary) => null; 4923 Element lookup3(String name, LibraryElement referencingLibrary) => null;
4547 } 4924 }
4548 class Scope_11 extends Scope { 4925 class Scope_13 extends Scope {
4549 LibraryElement definingLibrary3; 4926 LibraryElement definingLibrary3;
4550 GatheringErrorListener errorListener3; 4927 GatheringErrorListener errorListener3;
4551 Scope_11(this.definingLibrary3, this.errorListener3) : super(); 4928 Scope_13(this.definingLibrary3, this.errorListener3) : super();
4552 LibraryElement get definingLibrary => definingLibrary3; 4929 LibraryElement get definingLibrary => definingLibrary3;
4553 AnalysisErrorListener get errorListener => errorListener3; 4930 AnalysisErrorListener get errorListener => errorListener3;
4554 Element lookup3(String name, LibraryElement referencingLibrary) => null; 4931 Element lookup3(String name, LibraryElement referencingLibrary) => null;
4555 } 4932 }
4556 class LibraryElementBuilderTest extends EngineTestCase { 4933 class LibraryElementBuilderTest extends EngineTestCase {
4557 /** 4934 /**
4558 * The source factory used to create {@link Source sources}. 4935 * The source factory used to create {@link Source sources}.
4559 */ 4936 */
4560 SourceFactory _sourceFactory; 4937 SourceFactory _sourceFactory;
4561 void setUp() { 4938 void setUp() {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
4790 LibraryElement get definingLibrary => _definingLibrary; 5167 LibraryElement get definingLibrary => _definingLibrary;
4791 AnalysisErrorListener get errorListener => _errorListener; 5168 AnalysisErrorListener get errorListener => _errorListener;
4792 Element lookup3(String name, LibraryElement referencingLibrary) => localLookup (name, referencingLibrary); 5169 Element lookup3(String name, LibraryElement referencingLibrary) => localLookup (name, referencingLibrary);
4793 } 5170 }
4794 class SimpleResolverTest extends ResolverTestCase { 5171 class SimpleResolverTest extends ResolverTestCase {
4795 void fail_staticInvocation() { 5172 void fail_staticInvocation() {
4796 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static int get g => (a,b) => 0;", "}", "class B {", " f() {", " A.g (1,0);", " }", "}"])); 5173 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static int get g => (a,b) => 0;", "}", "class B {", " f() {", " A.g (1,0);", " }", "}"]));
4797 resolve(source, []); 5174 resolve(source, []);
4798 assertNoErrors(); 5175 assertNoErrors();
4799 verify([source]); 5176 verify([source]);
4800 }
4801 void test_argumentDefinitionTestNonParameter_formalParameter() {
4802 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var v) {", " return ?v;", "}"]));
4803 resolve(source, []);
4804 assertNoErrors();
4805 verify([source]);
4806 }
4807 void test_argumentDefinitionTestNonParameter_namedParameter() {
4808 Source source = addSource("/test.dart", EngineTestCase.createSource(["f({var v : 0}) {", " return ?v;", "}"]));
4809 resolve(source, []);
4810 assertNoErrors();
4811 verify([source]);
4812 }
4813 void test_argumentDefinitionTestNonParameter_optionalParameter() {
4814 Source source = addSource("/test.dart", EngineTestCase.createSource(["f([var v]) {", " return ?v;", "}"]));
4815 resolve(source, []);
4816 assertNoErrors();
4817 verify([source]);
4818 }
4819 void test_breakWithoutLabelInSwitch() {
4820 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " void m(int i) {", " switch (i) {", " case 0:", " break;" , " }", " }", "}"]));
4821 resolve(source, []);
4822 assertNoErrors();
4823 verify([source]);
4824 }
4825 void test_builtInIdentifierAsType_dynamic() {
4826 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " dynamic x;", "}"]));
4827 resolve(source, []);
4828 assertNoErrors();
4829 verify([source]);
4830 }
4831 void test_caseExpressionTypeImplementsEquals_int() {
4832 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(int i) {", " switch(i) {", " case(1) : return 1;", " default: return 0;", " }", "}"]));
4833 resolve(source, []);
4834 assertNoErrors();
4835 verify([source]);
4836 }
4837 void test_caseExpressionTypeImplementsEquals_Object() {
4838 Source source = addSource("/test.dart", EngineTestCase.createSource(["class IntWrapper {", " final int value;", " const IntWrapper(this.value);", "}", "", "f(IntWrapper intWrapper) {", " switch(intWrapper) {", " case(const IntWrap per(1)) : return 1;", " default: return 0;", " }", "}"]));
4839 resolve(source, []);
4840 assertNoErrors();
4841 verify([source]);
4842 }
4843 void test_caseExpressionTypeImplementsEquals_String() {
4844 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(Stri ng s) {", " switch(s) {", " case('1') : return 1;", " default: return 0;" , " }", "}"]));
4845 resolve(source, []);
4846 assertNoErrors();
4847 verify([source]);
4848 } 5177 }
4849 void test_class_extends_implements() { 5178 void test_class_extends_implements() {
4850 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends B implements C {}", "class B {}", "class C {}"])); 5179 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends B implements C {}", "class B {}", "class C {}"]));
4851 resolve(source, []); 5180 resolve(source, []);
4852 assertNoErrors(); 5181 assertNoErrors();
4853 verify([source]); 5182 verify([source]);
4854 } 5183 }
4855 void test_constConstructorWithNonFinalField_const() {
4856 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const int x;", " const A() {}", "}"]));
4857 resolve(source, []);
4858 assertNoErrors();
4859 verify([source]);
4860 }
4861 void test_constConstructorWithNonFinalField_final() {
4862 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " final int x;", " const A() {}", "}"]));
4863 resolve(source, []);
4864 assertNoErrors();
4865 verify([source]);
4866 }
4867 void test_constConstructorWithNonFinalField_syntheticField() {
4868 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " const A();", " set x(value) {}", " get x {return 0;}", "}"]));
4869 resolve(source, []);
4870 assertNoErrors();
4871 verify([source]);
4872 }
4873 void test_defaultValueInFunctionTypeAlias() {
4874 Source source = addSource("/test.dart", EngineTestCase.createSource(["typede f F([x]);"]));
4875 resolve(source, []);
4876 assertErrors([]);
4877 verify([source]);
4878 }
4879 void test_duplicateDefinition_getter() {
4880 Source source = addSource("/test.dart", EngineTestCase.createSource(["bool g et a => true;"]));
4881 resolve(source, []);
4882 assertNoErrors();
4883 verify([source]);
4884 }
4885 void test_empty() { 5184 void test_empty() {
4886 Source source = addSource("/test.dart", ""); 5185 Source source = addSource("/test.dart", "");
4887 resolve(source, []); 5186 resolve(source, []);
4888 assertNoErrors(); 5187 assertNoErrors();
4889 verify([source]); 5188 verify([source]);
4890 } 5189 }
4891 void test_forEachLoops_nonConflicting() { 5190 void test_forEachLoops_nonConflicting() {
4892 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " List list = [1,2,3];", " for (int x in list) {}", " for (int x in list) { }", "}"])); 5191 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " List list = [1,2,3];", " for (int x in list) {}", " for (int x in list) { }", "}"]));
4893 resolve(source, []); 5192 resolve(source, []);
4894 assertNoErrors(); 5193 assertNoErrors();
(...skipping 22 matching lines...) Expand all
4917 resolve(source, []); 5216 resolve(source, []);
4918 assertNoErrors(); 5217 assertNoErrors();
4919 verify([source]); 5218 verify([source]);
4920 } 5219 }
4921 void test_indexExpression_typeParameters_invalidAssignmentWarning() { 5220 void test_indexExpression_typeParameters_invalidAssignmentWarning() {
4922 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " List<List<int>> b;", " b[0][0] = 'hi';", "}"])); 5221 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " List<List<int>> b;", " b[0][0] = 'hi';", "}"]));
4923 resolve(source, []); 5222 resolve(source, []);
4924 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]); 5223 assertErrors([StaticTypeWarningCode.INVALID_ASSIGNMENT]);
4925 verify([source]); 5224 verify([source]);
4926 } 5225 }
4927 void test_invalidAssignment() {
4928 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var x;", " var y;", " x = y;", "}"]));
4929 resolve(source, []);
4930 assertNoErrors();
4931 verify([source]);
4932 }
4933 void test_invalidAssignment_toDynamic() {
4934 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var g;", " g = () => 0;", "}"]));
4935 resolve(source, []);
4936 assertNoErrors();
4937 verify([source]);
4938 }
4939 void test_invocationOfNonFunction_dynamic() {
4940 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var f;", "}", "class B extends A {", " g() {", " f();", " }", "}"] ));
4941 resolve(source, []);
4942 assertNoErrors();
4943 verify([source]);
4944 }
4945 void test_invocationOfNonFunction_getter() {
4946 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " var g;", "}", "f() {", " A a;", " a.g();", "}"]));
4947 resolve(source, []);
4948 assertNoErrors();
4949 verify([source]);
4950 }
4951 void test_invocationOfNonFunction_localVariable() {
4952 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " var g;", " g();", "}"]));
4953 resolve(source, []);
4954 assertNoErrors();
4955 verify([source]);
4956 }
4957 void test_invoke_dynamicThroughGetter() { 5226 void test_invoke_dynamicThroughGetter() {
4958 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " List get X => [() => 0];", " m(A a) {", " X.last();", " }", "}"])) ; 5227 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " List get X => [() => 0];", " m(A a) {", " X.last();", " }", "}"])) ;
4959 resolve(source, []); 5228 resolve(source, []);
4960 assertNoErrors(); 5229 assertNoErrors();
4961 verify([source]); 5230 verify([source]);
4962 } 5231 }
4963 void test_isValidMixin_badSuperclass() { 5232 void test_isValidMixin_badSuperclass() {
4964 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends B {}", "class B {}"])); 5233 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A extends B {}", "class B {}"]));
4965 LibraryElement library = resolve(source, []); 5234 LibraryElement library = resolve(source, []);
4966 JUnitTestCase.assertNotNull(library); 5235 JUnitTestCase.assertNotNull(library);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5013 resolve(source, []); 5282 resolve(source, []);
5014 assertNoErrors(); 5283 assertNoErrors();
5015 verify([source]); 5284 verify([source]);
5016 } 5285 }
5017 void test_methodCascades_withSetter() { 5286 void test_methodCascades_withSetter() {
5018 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " String name;", " void m1() {}", " void m2() {}", " void m() {", " A a = new A();", " a..m1()", " ..name = 'name'", " ..m2();", " }", "}"])); 5287 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " String name;", " void m1() {}", " void m2() {}", " void m() {", " A a = new A();", " a..m1()", " ..name = 'name'", " ..m2();", " }", "}"]));
5019 resolve(source, []); 5288 resolve(source, []);
5020 assertNoErrors(); 5289 assertNoErrors();
5021 verify([source]); 5290 verify([source]);
5022 } 5291 }
5023 void test_newWithAbstractClass_factory() {
5024 Source source = addSource("/test.dart", EngineTestCase.createSource(["abstra ct class A {", " factory A() { return new B(); }", "}", "class B implements A { ", " B() {}", "}", "A f() {", " return new A();", "}"]));
5025 resolve(source, []);
5026 assertNoErrors();
5027 verify([source]);
5028 }
5029 void test_nonBoolExpression_assert_bool() {
5030 Source source = addSource("/test.dart", EngineTestCase.createSource(["f() {" , " assert(true);", "}"]));
5031 resolve(source, []);
5032 assertNoErrors();
5033 verify([source]);
5034 }
5035 void test_nonBoolExpression_assert_functionType() {
5036 Source source = addSource("/test.dart", EngineTestCase.createSource(["bool m akeAssertion() => true;", "f() {", " assert(makeAssertion);", "}"]));
5037 resolve(source, []);
5038 assertNoErrors();
5039 verify([source]);
5040 }
5041 void test_resolveAgainstNull() { 5292 void test_resolveAgainstNull() {
5042 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " return null == p;", "}"])); 5293 Source source = addSource("/test.dart", EngineTestCase.createSource(["f(var p) {", " return null == p;", "}"]));
5043 resolve(source, []); 5294 resolve(source, []);
5044 assertNoErrors(); 5295 assertNoErrors();
5045 verify([source]); 5296 verify([source]);
5046 } 5297 }
5047 void test_returnOfInvalidType_dynamic() {
5048 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {", " static void testLogicalOp() {", " testOr(a, b, onTypeError) {", " try {", " return a || b;", " } on TypeError catch (t) {", " return onTypeError;", " }", " }", " }", "}"]));
5049 resolve(source, []);
5050 assertNoErrors();
5051 verify([source]);
5052 }
5053 void test_returnOfInvalidType_subtype() {
5054 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "A f(B b) { return b; }"]));
5055 resolve(source, []);
5056 assertNoErrors();
5057 verify([source]);
5058 }
5059 void test_returnOfInvalidType_supertype() {
5060 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "B f(A a) { return a; }"]));
5061 resolve(source, []);
5062 assertNoErrors();
5063 verify([source]);
5064 }
5065 void test_typeArgumentNotMatchingBounds_const() {
5066 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {", " const G() {}", "}", "f() { return const G<B>(); }"]));
5067 resolve(source, []);
5068 assertNoErrors();
5069 verify([source]);
5070 }
5071 void test_typeArgumentNotMatchingBounds_new() {
5072 Source source = addSource("/test.dart", EngineTestCase.createSource(["class A {}", "class B extends A {}", "class G<E extends A> {}", "f() { return new G<B> (); }"]));
5073 resolve(source, []);
5074 assertNoErrors();
5075 verify([source]);
5076 }
5077 static dartSuite() { 5298 static dartSuite() {
5078 _ut.group('SimpleResolverTest', () { 5299 _ut.group('SimpleResolverTest', () {
5079 _ut.test('test_argumentDefinitionTestNonParameter_formalParameter', () {
5080 final __test = new SimpleResolverTest();
5081 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_form alParameter);
5082 });
5083 _ut.test('test_argumentDefinitionTestNonParameter_namedParameter', () {
5084 final __test = new SimpleResolverTest();
5085 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_name dParameter);
5086 });
5087 _ut.test('test_argumentDefinitionTestNonParameter_optionalParameter', () {
5088 final __test = new SimpleResolverTest();
5089 runJUnitTest(__test, __test.test_argumentDefinitionTestNonParameter_opti onalParameter);
5090 });
5091 _ut.test('test_breakWithoutLabelInSwitch', () {
5092 final __test = new SimpleResolverTest();
5093 runJUnitTest(__test, __test.test_breakWithoutLabelInSwitch);
5094 });
5095 _ut.test('test_builtInIdentifierAsType_dynamic', () {
5096 final __test = new SimpleResolverTest();
5097 runJUnitTest(__test, __test.test_builtInIdentifierAsType_dynamic);
5098 });
5099 _ut.test('test_caseExpressionTypeImplementsEquals_Object', () {
5100 final __test = new SimpleResolverTest();
5101 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Obje ct);
5102 });
5103 _ut.test('test_caseExpressionTypeImplementsEquals_String', () {
5104 final __test = new SimpleResolverTest();
5105 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_Stri ng);
5106 });
5107 _ut.test('test_caseExpressionTypeImplementsEquals_int', () {
5108 final __test = new SimpleResolverTest();
5109 runJUnitTest(__test, __test.test_caseExpressionTypeImplementsEquals_int) ;
5110 });
5111 _ut.test('test_class_extends_implements', () { 5300 _ut.test('test_class_extends_implements', () {
5112 final __test = new SimpleResolverTest(); 5301 final __test = new SimpleResolverTest();
5113 runJUnitTest(__test, __test.test_class_extends_implements); 5302 runJUnitTest(__test, __test.test_class_extends_implements);
5114 }); 5303 });
5115 _ut.test('test_constConstructorWithNonFinalField_const', () {
5116 final __test = new SimpleResolverTest();
5117 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_const );
5118 });
5119 _ut.test('test_constConstructorWithNonFinalField_final', () {
5120 final __test = new SimpleResolverTest();
5121 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_final );
5122 });
5123 _ut.test('test_constConstructorWithNonFinalField_syntheticField', () {
5124 final __test = new SimpleResolverTest();
5125 runJUnitTest(__test, __test.test_constConstructorWithNonFinalField_synth eticField);
5126 });
5127 _ut.test('test_defaultValueInFunctionTypeAlias', () {
5128 final __test = new SimpleResolverTest();
5129 runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
5130 });
5131 _ut.test('test_duplicateDefinition_getter', () {
5132 final __test = new SimpleResolverTest();
5133 runJUnitTest(__test, __test.test_duplicateDefinition_getter);
5134 });
5135 _ut.test('test_empty', () { 5304 _ut.test('test_empty', () {
5136 final __test = new SimpleResolverTest(); 5305 final __test = new SimpleResolverTest();
5137 runJUnitTest(__test, __test.test_empty); 5306 runJUnitTest(__test, __test.test_empty);
5138 }); 5307 });
5139 _ut.test('test_forEachLoops_nonConflicting', () { 5308 _ut.test('test_forEachLoops_nonConflicting', () {
5140 final __test = new SimpleResolverTest(); 5309 final __test = new SimpleResolverTest();
5141 runJUnitTest(__test, __test.test_forEachLoops_nonConflicting); 5310 runJUnitTest(__test, __test.test_forEachLoops_nonConflicting);
5142 }); 5311 });
5143 _ut.test('test_forLoops_nonConflicting', () { 5312 _ut.test('test_forLoops_nonConflicting', () {
5144 final __test = new SimpleResolverTest(); 5313 final __test = new SimpleResolverTest();
5145 runJUnitTest(__test, __test.test_forLoops_nonConflicting); 5314 runJUnitTest(__test, __test.test_forLoops_nonConflicting);
5146 }); 5315 });
5147 _ut.test('test_functionTypeAlias', () { 5316 _ut.test('test_functionTypeAlias', () {
5148 final __test = new SimpleResolverTest(); 5317 final __test = new SimpleResolverTest();
5149 runJUnitTest(__test, __test.test_functionTypeAlias); 5318 runJUnitTest(__test, __test.test_functionTypeAlias);
5150 }); 5319 });
5151 _ut.test('test_getterAndSetterWithDifferentTypes', () { 5320 _ut.test('test_getterAndSetterWithDifferentTypes', () {
5152 final __test = new SimpleResolverTest(); 5321 final __test = new SimpleResolverTest();
5153 runJUnitTest(__test, __test.test_getterAndSetterWithDifferentTypes); 5322 runJUnitTest(__test, __test.test_getterAndSetterWithDifferentTypes);
5154 }); 5323 });
5155 _ut.test('test_indexExpression_typeParameters', () { 5324 _ut.test('test_indexExpression_typeParameters', () {
5156 final __test = new SimpleResolverTest(); 5325 final __test = new SimpleResolverTest();
5157 runJUnitTest(__test, __test.test_indexExpression_typeParameters); 5326 runJUnitTest(__test, __test.test_indexExpression_typeParameters);
5158 }); 5327 });
5159 _ut.test('test_indexExpression_typeParameters_invalidAssignmentWarning', ( ) { 5328 _ut.test('test_indexExpression_typeParameters_invalidAssignmentWarning', ( ) {
5160 final __test = new SimpleResolverTest(); 5329 final __test = new SimpleResolverTest();
5161 runJUnitTest(__test, __test.test_indexExpression_typeParameters_invalidA ssignmentWarning); 5330 runJUnitTest(__test, __test.test_indexExpression_typeParameters_invalidA ssignmentWarning);
5162 }); 5331 });
5163 _ut.test('test_invalidAssignment', () {
5164 final __test = new SimpleResolverTest();
5165 runJUnitTest(__test, __test.test_invalidAssignment);
5166 });
5167 _ut.test('test_invalidAssignment_toDynamic', () {
5168 final __test = new SimpleResolverTest();
5169 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic);
5170 });
5171 _ut.test('test_invocationOfNonFunction_dynamic', () {
5172 final __test = new SimpleResolverTest();
5173 runJUnitTest(__test, __test.test_invocationOfNonFunction_dynamic);
5174 });
5175 _ut.test('test_invocationOfNonFunction_getter', () {
5176 final __test = new SimpleResolverTest();
5177 runJUnitTest(__test, __test.test_invocationOfNonFunction_getter);
5178 });
5179 _ut.test('test_invocationOfNonFunction_localVariable', () {
5180 final __test = new SimpleResolverTest();
5181 runJUnitTest(__test, __test.test_invocationOfNonFunction_localVariable);
5182 });
5183 _ut.test('test_invoke_dynamicThroughGetter', () { 5332 _ut.test('test_invoke_dynamicThroughGetter', () {
5184 final __test = new SimpleResolverTest(); 5333 final __test = new SimpleResolverTest();
5185 runJUnitTest(__test, __test.test_invoke_dynamicThroughGetter); 5334 runJUnitTest(__test, __test.test_invoke_dynamicThroughGetter);
5186 }); 5335 });
5187 _ut.test('test_isValidMixin_badSuperclass', () { 5336 _ut.test('test_isValidMixin_badSuperclass', () {
5188 final __test = new SimpleResolverTest(); 5337 final __test = new SimpleResolverTest();
5189 runJUnitTest(__test, __test.test_isValidMixin_badSuperclass); 5338 runJUnitTest(__test, __test.test_isValidMixin_badSuperclass);
5190 }); 5339 });
5191 _ut.test('test_isValidMixin_constructor', () { 5340 _ut.test('test_isValidMixin_constructor', () {
5192 final __test = new SimpleResolverTest(); 5341 final __test = new SimpleResolverTest();
5193 runJUnitTest(__test, __test.test_isValidMixin_constructor); 5342 runJUnitTest(__test, __test.test_isValidMixin_constructor);
5194 }); 5343 });
5195 _ut.test('test_isValidMixin_super', () { 5344 _ut.test('test_isValidMixin_super', () {
5196 final __test = new SimpleResolverTest(); 5345 final __test = new SimpleResolverTest();
5197 runJUnitTest(__test, __test.test_isValidMixin_super); 5346 runJUnitTest(__test, __test.test_isValidMixin_super);
5198 }); 5347 });
5199 _ut.test('test_isValidMixin_valid', () { 5348 _ut.test('test_isValidMixin_valid', () {
5200 final __test = new SimpleResolverTest(); 5349 final __test = new SimpleResolverTest();
5201 runJUnitTest(__test, __test.test_isValidMixin_valid); 5350 runJUnitTest(__test, __test.test_isValidMixin_valid);
5202 }); 5351 });
5203 _ut.test('test_methodCascades', () { 5352 _ut.test('test_methodCascades', () {
5204 final __test = new SimpleResolverTest(); 5353 final __test = new SimpleResolverTest();
5205 runJUnitTest(__test, __test.test_methodCascades); 5354 runJUnitTest(__test, __test.test_methodCascades);
5206 }); 5355 });
5207 _ut.test('test_methodCascades_withSetter', () { 5356 _ut.test('test_methodCascades_withSetter', () {
5208 final __test = new SimpleResolverTest(); 5357 final __test = new SimpleResolverTest();
5209 runJUnitTest(__test, __test.test_methodCascades_withSetter); 5358 runJUnitTest(__test, __test.test_methodCascades_withSetter);
5210 }); 5359 });
5211 _ut.test('test_newWithAbstractClass_factory', () {
5212 final __test = new SimpleResolverTest();
5213 runJUnitTest(__test, __test.test_newWithAbstractClass_factory);
5214 });
5215 _ut.test('test_nonBoolExpression_assert_bool', () {
5216 final __test = new SimpleResolverTest();
5217 runJUnitTest(__test, __test.test_nonBoolExpression_assert_bool);
5218 });
5219 _ut.test('test_nonBoolExpression_assert_functionType', () {
5220 final __test = new SimpleResolverTest();
5221 runJUnitTest(__test, __test.test_nonBoolExpression_assert_functionType);
5222 });
5223 _ut.test('test_resolveAgainstNull', () { 5360 _ut.test('test_resolveAgainstNull', () {
5224 final __test = new SimpleResolverTest(); 5361 final __test = new SimpleResolverTest();
5225 runJUnitTest(__test, __test.test_resolveAgainstNull); 5362 runJUnitTest(__test, __test.test_resolveAgainstNull);
5226 }); 5363 });
5227 _ut.test('test_returnOfInvalidType_dynamic', () {
5228 final __test = new SimpleResolverTest();
5229 runJUnitTest(__test, __test.test_returnOfInvalidType_dynamic);
5230 });
5231 _ut.test('test_returnOfInvalidType_subtype', () {
5232 final __test = new SimpleResolverTest();
5233 runJUnitTest(__test, __test.test_returnOfInvalidType_subtype);
5234 });
5235 _ut.test('test_returnOfInvalidType_supertype', () {
5236 final __test = new SimpleResolverTest();
5237 runJUnitTest(__test, __test.test_returnOfInvalidType_supertype);
5238 });
5239 _ut.test('test_typeArgumentNotMatchingBounds_const', () {
5240 final __test = new SimpleResolverTest();
5241 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_const);
5242 });
5243 _ut.test('test_typeArgumentNotMatchingBounds_new', () {
5244 final __test = new SimpleResolverTest();
5245 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
5246 });
5247 }); 5364 });
5248 } 5365 }
5249 } 5366 }
5250 main() { 5367 main() {
5251 // ElementResolverTest.dartSuite(); 5368 // ElementResolverTest.dartSuite();
5252 // LibraryElementBuilderTest.dartSuite(); 5369 // LibraryElementBuilderTest.dartSuite();
5253 // LibraryTest.dartSuite(); 5370 // LibraryTest.dartSuite();
5254 // StaticTypeAnalyzerTest.dartSuite(); 5371 // StaticTypeAnalyzerTest.dartSuite();
5255 // TypeProviderImplTest.dartSuite(); 5372 // TypeProviderImplTest.dartSuite();
5256 // TypeResolverVisitorTest.dartSuite(); 5373 // TypeResolverVisitorTest.dartSuite();
5257 // EnclosedScopeTest.dartSuite(); 5374 // EnclosedScopeTest.dartSuite();
5258 // LibraryImportScopeTest.dartSuite(); 5375 // LibraryImportScopeTest.dartSuite();
5259 // LibraryScopeTest.dartSuite(); 5376 // LibraryScopeTest.dartSuite();
5260 // ScopeTest.dartSuite(); 5377 // ScopeTest.dartSuite();
5261 // CompileTimeErrorCodeTest.dartSuite(); 5378 // CompileTimeErrorCodeTest.dartSuite();
5262 // ErrorResolverTest.dartSuite(); 5379 // ErrorResolverTest.dartSuite();
5380 // NonErrorResolverTest.dartSuite();
5263 // SimpleResolverTest.dartSuite(); 5381 // SimpleResolverTest.dartSuite();
5264 // StaticTypeWarningCodeTest.dartSuite(); 5382 // StaticTypeWarningCodeTest.dartSuite();
5265 // StaticWarningCodeTest.dartSuite(); 5383 // StaticWarningCodeTest.dartSuite();
5266 } 5384 }
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