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

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

Issue 849863002: Replace @ReflectiveTestCase() with @reflectiveTest. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 void runTasks() { 458 void runTasks() {
459 AnalysisResult result = context.performAnalysisTask(); 459 AnalysisResult result = context.performAnalysisTask();
460 while (result.changeNotices != null) { 460 while (result.changeNotices != null) {
461 result = context.performAnalysisTask(); 461 result = context.performAnalysisTask();
462 } 462 }
463 } 463 }
464 } 464 }
465 465
466 @ReflectiveTestCase() 466 @reflectiveTest
467 class AnalysisDeltaTest extends EngineTestCase { 467 class AnalysisDeltaTest extends EngineTestCase {
468 TestSource source1 = new TestSource('/1.dart'); 468 TestSource source1 = new TestSource('/1.dart');
469 TestSource source2 = new TestSource('/2.dart'); 469 TestSource source2 = new TestSource('/2.dart');
470 TestSource source3 = new TestSource('/3.dart'); 470 TestSource source3 = new TestSource('/3.dart');
471 471
472 void test_getAddedSources() { 472 void test_getAddedSources() {
473 AnalysisDelta delta = new AnalysisDelta(); 473 AnalysisDelta delta = new AnalysisDelta();
474 delta.setAnalysisLevel(source1, AnalysisLevel.ALL); 474 delta.setAnalysisLevel(source1, AnalysisLevel.ALL);
475 delta.setAnalysisLevel(source2, AnalysisLevel.ERRORS); 475 delta.setAnalysisLevel(source2, AnalysisLevel.ERRORS);
476 delta.setAnalysisLevel(source3, AnalysisLevel.NONE); 476 delta.setAnalysisLevel(source3, AnalysisLevel.NONE);
(...skipping 19 matching lines...) Expand all
496 496
497 void test_toString() { 497 void test_toString() {
498 AnalysisDelta delta = new AnalysisDelta(); 498 AnalysisDelta delta = new AnalysisDelta();
499 delta.setAnalysisLevel(new TestSource(), AnalysisLevel.ALL); 499 delta.setAnalysisLevel(new TestSource(), AnalysisLevel.ALL);
500 String result = delta.toString(); 500 String result = delta.toString();
501 expect(result, isNotNull); 501 expect(result, isNotNull);
502 expect(result.length > 0, isTrue); 502 expect(result.length > 0, isTrue);
503 } 503 }
504 } 504 }
505 505
506 @ReflectiveTestCase() 506 @reflectiveTest
507 class ChangeSetTest extends EngineTestCase { 507 class ChangeSetTest extends EngineTestCase {
508 void test_changedContent() { 508 void test_changedContent() {
509 TestSource source = new TestSource(); 509 TestSource source = new TestSource();
510 String content = ""; 510 String content = "";
511 ChangeSet changeSet = new ChangeSet(); 511 ChangeSet changeSet = new ChangeSet();
512 changeSet.changedContent(source, content); 512 changeSet.changedContent(source, content);
513 expect(changeSet.addedSources, hasLength(0)); 513 expect(changeSet.addedSources, hasLength(0));
514 expect(changeSet.changedSources, hasLength(0)); 514 expect(changeSet.changedSources, hasLength(0));
515 Map<Source, String> map = changeSet.changedContents; 515 Map<Source, String> map = changeSet.changedContents;
516 expect(map, hasLength(1)); 516 expect(map, hasLength(1));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 changeSet.changedContent(new TestSource(), ""); 549 changeSet.changedContent(new TestSource(), "");
550 changeSet.changedRange(new TestSource(), "", 0, 0, 0); 550 changeSet.changedRange(new TestSource(), "", 0, 0, 0);
551 changeSet.deletedSource(new TestSource()); 551 changeSet.deletedSource(new TestSource());
552 changeSet.removedSource(new TestSource()); 552 changeSet.removedSource(new TestSource());
553 changeSet.removedContainer( 553 changeSet.removedContainer(
554 new SourceContainer_ChangeSetTest_test_toString()); 554 new SourceContainer_ChangeSetTest_test_toString());
555 expect(changeSet.toString(), isNotNull); 555 expect(changeSet.toString(), isNotNull);
556 } 556 }
557 } 557 }
558 558
559 @ReflectiveTestCase() 559 @reflectiveTest
560 class CheckedModeCompileTimeErrorCodeTest extends ResolverTestCase { 560 class CheckedModeCompileTimeErrorCodeTest extends ResolverTestCase {
561 void test_fieldFormalParameterAssignableToField_extends() { 561 void test_fieldFormalParameterAssignableToField_extends() {
562 // According to checked-mode type checking rules, a value of type B is 562 // According to checked-mode type checking rules, a value of type B is
563 // assignable to a field of type A, because B extends A (and hence is a 563 // assignable to a field of type A, because B extends A (and hence is a
564 // subtype of A). 564 // subtype of A).
565 Source source = addSource(r''' 565 Source source = addSource(r'''
566 class A { 566 class A {
567 const A(); 567 const A();
568 } 568 }
569 class B extends A { 569 class B extends A {
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 resolve(source); 1135 resolve(source);
1136 assertErrors( 1136 assertErrors(
1137 source, 1137 source,
1138 [ 1138 [
1139 CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, 1139 CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
1140 StaticWarningCode.UNDEFINED_CLASS]); 1140 StaticWarningCode.UNDEFINED_CLASS]);
1141 verify([source]); 1141 verify([source]);
1142 } 1142 }
1143 } 1143 }
1144 1144
1145 @ReflectiveTestCase() 1145 @reflectiveTest
1146 class ElementResolverTest extends EngineTestCase { 1146 class ElementResolverTest extends EngineTestCase {
1147 /** 1147 /**
1148 * The error listener to which errors will be reported. 1148 * The error listener to which errors will be reported.
1149 */ 1149 */
1150 GatheringErrorListener _listener; 1150 GatheringErrorListener _listener;
1151 1151
1152 /** 1152 /**
1153 * The type provider used to access the types. 1153 * The type provider used to access the types.
1154 */ 1154 */
1155 TestTypeProvider _typeProvider; 1155 TestTypeProvider _typeProvider;
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 statement.accept(_resolver); 2069 statement.accept(_resolver);
2070 } finally { 2070 } finally {
2071 _visitor.labelScope_J2DAccessor = outerScope; 2071 _visitor.labelScope_J2DAccessor = outerScope;
2072 } 2072 }
2073 } catch (exception) { 2073 } catch (exception) {
2074 throw new IllegalArgumentException("Could not resolve node", exception); 2074 throw new IllegalArgumentException("Could not resolve node", exception);
2075 } 2075 }
2076 } 2076 }
2077 } 2077 }
2078 2078
2079 @ReflectiveTestCase() 2079 @reflectiveTest
2080 class EnclosedScopeTest extends ResolverTestCase { 2080 class EnclosedScopeTest extends ResolverTestCase {
2081 void test_define_duplicate() { 2081 void test_define_duplicate() {
2082 GatheringErrorListener listener = new GatheringErrorListener(); 2082 GatheringErrorListener listener = new GatheringErrorListener();
2083 Scope rootScope = 2083 Scope rootScope =
2084 new Scope_EnclosedScopeTest_test_define_duplicate(listener); 2084 new Scope_EnclosedScopeTest_test_define_duplicate(listener);
2085 EnclosedScope scope = new EnclosedScope(rootScope); 2085 EnclosedScope scope = new EnclosedScope(rootScope);
2086 VariableElement element1 = 2086 VariableElement element1 =
2087 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 2087 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
2088 VariableElement element2 = 2088 VariableElement element2 =
2089 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 2089 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
(...skipping 10 matching lines...) Expand all
2100 VariableElement element1 = 2100 VariableElement element1 =
2101 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 2101 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
2102 VariableElement element2 = 2102 VariableElement element2 =
2103 ElementFactory.localVariableElement(AstFactory.identifier3("v2")); 2103 ElementFactory.localVariableElement(AstFactory.identifier3("v2"));
2104 outerScope.define(element1); 2104 outerScope.define(element1);
2105 innerScope.define(element2); 2105 innerScope.define(element2);
2106 listener.assertNoErrors(); 2106 listener.assertNoErrors();
2107 } 2107 }
2108 } 2108 }
2109 2109
2110 @ReflectiveTestCase() 2110 @reflectiveTest
2111 class ErrorResolverTest extends ResolverTestCase { 2111 class ErrorResolverTest extends ResolverTestCase {
2112 void test_breakLabelOnSwitchMember() { 2112 void test_breakLabelOnSwitchMember() {
2113 Source source = addSource(r''' 2113 Source source = addSource(r'''
2114 class A { 2114 class A {
2115 void m(int i) { 2115 void m(int i) {
2116 switch (i) { 2116 switch (i) {
2117 l: case 0: 2117 l: case 0:
2118 break; 2118 break;
2119 case 1: 2119 case 1:
2120 break l; 2120 break l;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 ConstructorElement constructor = constructors[0]; 2163 ConstructorElement constructor = constructors[0];
2164 expect(constructor, isNotNull); 2164 expect(constructor, isNotNull);
2165 List<FunctionElement> functions = constructor.functions; 2165 List<FunctionElement> functions = constructor.functions;
2166 expect(functions, isNotNull); 2166 expect(functions, isNotNull);
2167 expect(functions, hasLength(1)); 2167 expect(functions, hasLength(1));
2168 expect(functions[0].enclosingElement, constructor); 2168 expect(functions[0].enclosingElement, constructor);
2169 assertErrors(source, [ParserErrorCode.GETTER_IN_FUNCTION]); 2169 assertErrors(source, [ParserErrorCode.GETTER_IN_FUNCTION]);
2170 } 2170 }
2171 } 2171 }
2172 2172
2173 @ReflectiveTestCase() 2173 @reflectiveTest
2174 class HintCodeTest extends ResolverTestCase { 2174 class HintCodeTest extends ResolverTestCase {
2175 void fail_deadCode_statementAfterRehrow() { 2175 void fail_deadCode_statementAfterRehrow() {
2176 Source source = addSource(r''' 2176 Source source = addSource(r'''
2177 f() { 2177 f() {
2178 try { 2178 try {
2179 var one = 1; 2179 var one = 1;
2180 } catch (e) { 2180 } catch (e) {
2181 rethrow; 2181 rethrow;
2182 var two = 2; 2182 var two = 2;
2183 } 2183 }
(...skipping 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after
4433 } 4433 }
4434 }'''); 4434 }''');
4435 resolve(source); 4435 resolve(source);
4436 assertErrors( 4436 assertErrors(
4437 source, 4437 source,
4438 [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 4438 [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
4439 verify([source]); 4439 verify([source]);
4440 } 4440 }
4441 } 4441 }
4442 4442
4443 @ReflectiveTestCase() 4443 @reflectiveTest
4444 class InheritanceManagerTest extends EngineTestCase { 4444 class InheritanceManagerTest extends EngineTestCase {
4445 /** 4445 /**
4446 * The type provider used to access the types. 4446 * The type provider used to access the types.
4447 */ 4447 */
4448 TestTypeProvider _typeProvider; 4448 TestTypeProvider _typeProvider;
4449 4449
4450 /** 4450 /**
4451 * The library containing the code being resolved. 4451 * The library containing the code being resolved.
4452 */ 4452 */
4453 LibraryElementImpl _definingLibrary; 4453 LibraryElementImpl _definingLibrary;
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
5651 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); 5651 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
5652 CompilationUnitElementImpl definingCompilationUnit = 5652 CompilationUnitElementImpl definingCompilationUnit =
5653 new CompilationUnitElementImpl("test.dart"); 5653 new CompilationUnitElementImpl("test.dart");
5654 definingCompilationUnit.source = source; 5654 definingCompilationUnit.source = source;
5655 _definingLibrary = ElementFactory.library(context, "test"); 5655 _definingLibrary = ElementFactory.library(context, "test");
5656 _definingLibrary.definingCompilationUnit = definingCompilationUnit; 5656 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
5657 return new InheritanceManager(_definingLibrary); 5657 return new InheritanceManager(_definingLibrary);
5658 } 5658 }
5659 } 5659 }
5660 5660
5661 @ReflectiveTestCase() 5661 @reflectiveTest
5662 class LibraryElementBuilderTest extends EngineTestCase { 5662 class LibraryElementBuilderTest extends EngineTestCase {
5663 /** 5663 /**
5664 * The analysis context used to analyze sources. 5664 * The analysis context used to analyze sources.
5665 */ 5665 */
5666 AnalysisContextImpl _context; 5666 AnalysisContextImpl _context;
5667 5667
5668 /** 5668 /**
5669 * Add a source file to the content provider. The file path should be absolute . 5669 * Add a source file to the content provider. The file path should be absolute .
5670 * 5670 *
5671 * @param filePath the path of the file being added 5671 * @param filePath the path of the file being added
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
5835 new LibraryElementBuilder(resolver.analysisContext, resolver.errorListen er); 5835 new LibraryElementBuilder(resolver.analysisContext, resolver.errorListen er);
5836 Library library = resolver.createLibrary(librarySource); 5836 Library library = resolver.createLibrary(librarySource);
5837 LibraryElement element = builder.buildLibrary(library); 5837 LibraryElement element = builder.buildLibrary(library);
5838 GatheringErrorListener listener = new GatheringErrorListener(); 5838 GatheringErrorListener listener = new GatheringErrorListener();
5839 listener.addAll2(resolver.errorListener); 5839 listener.addAll2(resolver.errorListener);
5840 listener.assertErrorsWithCodes(expectedErrorCodes); 5840 listener.assertErrorsWithCodes(expectedErrorCodes);
5841 return element; 5841 return element;
5842 } 5842 }
5843 } 5843 }
5844 5844
5845 @ReflectiveTestCase() 5845 @reflectiveTest
5846 class LibraryImportScopeTest extends ResolverTestCase { 5846 class LibraryImportScopeTest extends ResolverTestCase {
5847 void test_conflictingImports() { 5847 void test_conflictingImports() {
5848 AnalysisContext context = new AnalysisContextImpl(); 5848 AnalysisContext context = new AnalysisContextImpl();
5849 context.sourceFactory = new SourceFactory([]); 5849 context.sourceFactory = new SourceFactory([]);
5850 String typeNameA = "A"; 5850 String typeNameA = "A";
5851 String typeNameB = "B"; 5851 String typeNameB = "B";
5852 String typeNameC = "C"; 5852 String typeNameC = "C";
5853 ClassElement typeA = ElementFactory.classElement2(typeNameA); 5853 ClassElement typeA = ElementFactory.classElement2(typeNameA);
5854 ClassElement typeB1 = ElementFactory.classElement2(typeNameB); 5854 ClassElement typeB1 = ElementFactory.classElement2(typeNameB);
5855 ClassElement typeB2 = ElementFactory.classElement2(typeNameB); 5855 ClassElement typeB2 = ElementFactory.classElement2(typeNameB);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
6031 scope.lookup(AstFactory.identifier5(prefixName, typeName), importingLibr ary); 6031 scope.lookup(AstFactory.identifier5(prefixName, typeName), importingLibr ary);
6032 errorListener.assertNoErrors(); 6032 errorListener.assertNoErrors();
6033 expect(prefixedElement, same(prefixedType)); 6033 expect(prefixedElement, same(prefixedType));
6034 Element nonPrefixedElement = 6034 Element nonPrefixedElement =
6035 scope.lookup(AstFactory.identifier3(typeName), importingLibrary); 6035 scope.lookup(AstFactory.identifier3(typeName), importingLibrary);
6036 errorListener.assertNoErrors(); 6036 errorListener.assertNoErrors();
6037 expect(nonPrefixedElement, same(nonPrefixedType)); 6037 expect(nonPrefixedElement, same(nonPrefixedType));
6038 } 6038 }
6039 } 6039 }
6040 6040
6041 @ReflectiveTestCase() 6041 @reflectiveTest
6042 class LibraryResolver2Test extends ResolverTestCase { 6042 class LibraryResolver2Test extends ResolverTestCase {
6043 LibraryResolver2 _resolver; 6043 LibraryResolver2 _resolver;
6044 6044
6045 Source _coreLibrarySource; 6045 Source _coreLibrarySource;
6046 6046
6047 @override 6047 @override
6048 void setUp() { 6048 void setUp() {
6049 super.setUp(); 6049 super.setUp();
6050 _resolver = new LibraryResolver2(analysisContext2); 6050 _resolver = new LibraryResolver2(analysisContext2);
6051 _coreLibrarySource = 6051 _coreLibrarySource =
(...skipping 26 matching lines...) Expand all
6078 6078
6079 ResolvableLibrary _createResolvableLibrary(Source source) { 6079 ResolvableLibrary _createResolvableLibrary(Source source) {
6080 CompilationUnit unit = analysisContext2.parseCompilationUnit(source); 6080 CompilationUnit unit = analysisContext2.parseCompilationUnit(source);
6081 ResolvableLibrary resolvableLibrary = new ResolvableLibrary(source); 6081 ResolvableLibrary resolvableLibrary = new ResolvableLibrary(source);
6082 resolvableLibrary.resolvableCompilationUnits = 6082 resolvableLibrary.resolvableCompilationUnits =
6083 <ResolvableCompilationUnit>[new ResolvableCompilationUnit(source, unit)] ; 6083 <ResolvableCompilationUnit>[new ResolvableCompilationUnit(source, unit)] ;
6084 return resolvableLibrary; 6084 return resolvableLibrary;
6085 } 6085 }
6086 } 6086 }
6087 6087
6088 @ReflectiveTestCase() 6088 @reflectiveTest
6089 class LibraryResolverTest extends ResolverTestCase { 6089 class LibraryResolverTest extends ResolverTestCase {
6090 LibraryResolver _resolver; 6090 LibraryResolver _resolver;
6091 6091
6092 @override 6092 @override
6093 void setUp() { 6093 void setUp() {
6094 super.setUp(); 6094 super.setUp();
6095 _resolver = new LibraryResolver(analysisContext2); 6095 _resolver = new LibraryResolver(analysisContext2);
6096 } 6096 }
6097 6097
6098 void test_imports_dart_html() { 6098 void test_imports_dart_html() {
(...skipping 20 matching lines...) Expand all
6119 Source source = addSource(r''' 6119 Source source = addSource(r'''
6120 library libA; 6120 library libA;
6121 import 'libB.dart'; 6121 import 'libB.dart';
6122 class A {}'''); 6122 class A {}''');
6123 LibraryElement library = _resolver.resolveLibrary(source, true); 6123 LibraryElement library = _resolver.resolveLibrary(source, true);
6124 List<LibraryElement> importedLibraries = library.importedLibraries; 6124 List<LibraryElement> importedLibraries = library.importedLibraries;
6125 assertNamedElements(importedLibraries, ["dart.core", "libB"]); 6125 assertNamedElements(importedLibraries, ["dart.core", "libB"]);
6126 } 6126 }
6127 } 6127 }
6128 6128
6129 @ReflectiveTestCase() 6129 @reflectiveTest
6130 class LibraryScopeTest extends ResolverTestCase { 6130 class LibraryScopeTest extends ResolverTestCase {
6131 void test_creation_empty() { 6131 void test_creation_empty() {
6132 LibraryElement definingLibrary = createDefaultTestLibrary(); 6132 LibraryElement definingLibrary = createDefaultTestLibrary();
6133 GatheringErrorListener errorListener = new GatheringErrorListener(); 6133 GatheringErrorListener errorListener = new GatheringErrorListener();
6134 new LibraryScope(definingLibrary, errorListener); 6134 new LibraryScope(definingLibrary, errorListener);
6135 } 6135 }
6136 6136
6137 void test_creation_nonEmpty() { 6137 void test_creation_nonEmpty() {
6138 AnalysisContext context = new AnalysisContextImpl(); 6138 AnalysisContext context = new AnalysisContextImpl();
6139 context.sourceFactory = new SourceFactory([]); 6139 context.sourceFactory = new SourceFactory([]);
(...skipping 16 matching lines...) Expand all
6156 } 6156 }
6157 6157
6158 void test_getErrorListener() { 6158 void test_getErrorListener() {
6159 LibraryElement definingLibrary = createDefaultTestLibrary(); 6159 LibraryElement definingLibrary = createDefaultTestLibrary();
6160 GatheringErrorListener errorListener = new GatheringErrorListener(); 6160 GatheringErrorListener errorListener = new GatheringErrorListener();
6161 LibraryScope scope = new LibraryScope(definingLibrary, errorListener); 6161 LibraryScope scope = new LibraryScope(definingLibrary, errorListener);
6162 expect(scope.errorListener, errorListener); 6162 expect(scope.errorListener, errorListener);
6163 } 6163 }
6164 } 6164 }
6165 6165
6166 @ReflectiveTestCase() 6166 @reflectiveTest
6167 class LibraryTest extends EngineTestCase { 6167 class LibraryTest extends EngineTestCase {
6168 /** 6168 /**
6169 * The error listener to which all errors will be reported. 6169 * The error listener to which all errors will be reported.
6170 */ 6170 */
6171 GatheringErrorListener _errorListener; 6171 GatheringErrorListener _errorListener;
6172 6172
6173 /** 6173 /**
6174 * The source factory used to create libraries. 6174 * The source factory used to create libraries.
6175 */ 6175 */
6176 SourceFactory _sourceFactory; 6176 SourceFactory _sourceFactory;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
6273 } 6273 }
6274 6274
6275 Library _createLibrary(String definingCompilationUnitPath) => 6275 Library _createLibrary(String definingCompilationUnitPath) =>
6276 new Library( 6276 new Library(
6277 _analysisContext, 6277 _analysisContext,
6278 _errorListener, 6278 _errorListener,
6279 new FileBasedSource.con1( 6279 new FileBasedSource.con1(
6280 FileUtilities2.createFile(definingCompilationUnitPath))); 6280 FileUtilities2.createFile(definingCompilationUnitPath)));
6281 } 6281 }
6282 6282
6283 @ReflectiveTestCase() 6283 @reflectiveTest
6284 class MemberMapTest { 6284 class MemberMapTest {
6285 /** 6285 /**
6286 * The null type. 6286 * The null type.
6287 */ 6287 */
6288 InterfaceType _nullType; 6288 InterfaceType _nullType;
6289 6289
6290 void setUp() { 6290 void setUp() {
6291 _nullType = new TestTypeProvider().nullType; 6291 _nullType = new TestTypeProvider().nullType;
6292 } 6292 }
6293 6293
(...skipping 25 matching lines...) Expand all
6319 void test_MemberMap_put() { 6319 void test_MemberMap_put() {
6320 MethodElement m1 = ElementFactory.methodElement("m1", _nullType); 6320 MethodElement m1 = ElementFactory.methodElement("m1", _nullType);
6321 MemberMap map = new MemberMap(); 6321 MemberMap map = new MemberMap();
6322 expect(map.size, 0); 6322 expect(map.size, 0);
6323 map.put(m1.name, m1); 6323 map.put(m1.name, m1);
6324 expect(map.size, 1); 6324 expect(map.size, 1);
6325 expect(map.get("m1"), m1); 6325 expect(map.get("m1"), m1);
6326 } 6326 }
6327 } 6327 }
6328 6328
6329 @ReflectiveTestCase() 6329 @reflectiveTest
6330 class NonHintCodeTest extends ResolverTestCase { 6330 class NonHintCodeTest extends ResolverTestCase {
6331 void test_deadCode_deadBlock_conditionalElse_debugConst() { 6331 void test_deadCode_deadBlock_conditionalElse_debugConst() {
6332 Source source = addSource(r''' 6332 Source source = addSource(r'''
6333 const bool DEBUG = true; 6333 const bool DEBUG = true;
6334 f() { 6334 f() {
6335 DEBUG ? 1 : 2; 6335 DEBUG ? 1 : 2;
6336 }'''); 6336 }''');
6337 resolve(source); 6337 resolve(source);
6338 assertNoErrors(source); 6338 assertNoErrors(source);
6339 verify([source]); 6339 verify([source]);
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
7968 7968
7969 @override 7969 @override
7970 AnalysisErrorListener get errorListener => listener; 7970 AnalysisErrorListener get errorListener => listener;
7971 7971
7972 @override 7972 @override
7973 Element internalLookup(Identifier identifier, String name, 7973 Element internalLookup(Identifier identifier, String name,
7974 LibraryElement referencingLibrary) => 7974 LibraryElement referencingLibrary) =>
7975 null; 7975 null;
7976 } 7976 }
7977 7977
7978 @ReflectiveTestCase() 7978 @reflectiveTest
7979 class ScopeTest extends ResolverTestCase { 7979 class ScopeTest extends ResolverTestCase {
7980 void test_define_duplicate() { 7980 void test_define_duplicate() {
7981 GatheringErrorListener errorListener = new GatheringErrorListener(); 7981 GatheringErrorListener errorListener = new GatheringErrorListener();
7982 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); 7982 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener);
7983 VariableElement element1 = 7983 VariableElement element1 =
7984 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 7984 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
7985 VariableElement element2 = 7985 VariableElement element2 =
7986 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 7986 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
7987 scope.define(element1); 7987 scope.define(element1);
7988 scope.define(element2); 7988 scope.define(element2);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
8026 final AnalysisErrorListener errorListener; 8026 final AnalysisErrorListener errorListener;
8027 8027
8028 ScopeTest_TestScope(this.errorListener); 8028 ScopeTest_TestScope(this.errorListener);
8029 8029
8030 @override 8030 @override
8031 Element internalLookup(Identifier identifier, String name, 8031 Element internalLookup(Identifier identifier, String name,
8032 LibraryElement referencingLibrary) => 8032 LibraryElement referencingLibrary) =>
8033 localLookup(name, referencingLibrary); 8033 localLookup(name, referencingLibrary);
8034 } 8034 }
8035 8035
8036 @ReflectiveTestCase() 8036 @reflectiveTest
8037 class SimpleResolverTest extends ResolverTestCase { 8037 class SimpleResolverTest extends ResolverTestCase {
8038 void fail_staticInvocation() { 8038 void fail_staticInvocation() {
8039 Source source = addSource(r''' 8039 Source source = addSource(r'''
8040 class A { 8040 class A {
8041 static int get g => (a,b) => 0; 8041 static int get g => (a,b) => 0;
8042 } 8042 }
8043 class B { 8043 class B {
8044 f() { 8044 f() {
8045 A.g(1,0); 8045 A.g(1,0);
8046 } 8046 }
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
9368 } 9368 }
9369 9369
9370 class SourceContainer_ChangeSetTest_test_toString implements SourceContainer { 9370 class SourceContainer_ChangeSetTest_test_toString implements SourceContainer {
9371 @override 9371 @override
9372 bool contains(Source source) => false; 9372 bool contains(Source source) => false;
9373 } 9373 }
9374 9374
9375 /** 9375 /**
9376 * Like [StaticTypeAnalyzerTest], but as end-to-end tests. 9376 * Like [StaticTypeAnalyzerTest], but as end-to-end tests.
9377 */ 9377 */
9378 @ReflectiveTestCase() 9378 @reflectiveTest
9379 class StaticTypeAnalyzer2Test extends ResolverTestCase { 9379 class StaticTypeAnalyzer2Test extends ResolverTestCase {
9380 String testCode; 9380 String testCode;
9381 Source testSource; 9381 Source testSource;
9382 CompilationUnit testUnit; 9382 CompilationUnit testUnit;
9383 9383
9384 void test_MethodInvocation_nameType_localVariable() { 9384 void test_MethodInvocation_nameType_localVariable() {
9385 String code = r""" 9385 String code = r"""
9386 typedef Foo(); 9386 typedef Foo();
9387 main() { 9387 main() {
9388 Foo foo; 9388 Foo foo;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
9441 void _resolveTestUnit(String code) { 9441 void _resolveTestUnit(String code) {
9442 testCode = code; 9442 testCode = code;
9443 testSource = addSource(testCode); 9443 testSource = addSource(testCode);
9444 LibraryElement library = resolve(testSource); 9444 LibraryElement library = resolve(testSource);
9445 assertNoErrors(testSource); 9445 assertNoErrors(testSource);
9446 verify([testSource]); 9446 verify([testSource]);
9447 testUnit = resolveCompilationUnit(testSource, library); 9447 testUnit = resolveCompilationUnit(testSource, library);
9448 } 9448 }
9449 } 9449 }
9450 9450
9451 @ReflectiveTestCase() 9451 @reflectiveTest
9452 class StaticTypeAnalyzerTest extends EngineTestCase { 9452 class StaticTypeAnalyzerTest extends EngineTestCase {
9453 /** 9453 /**
9454 * The error listener to which errors will be reported. 9454 * The error listener to which errors will be reported.
9455 */ 9455 */
9456 GatheringErrorListener _listener; 9456 GatheringErrorListener _listener;
9457 9457
9458 /** 9458 /**
9459 * The resolver visitor used to create the analyzer. 9459 * The resolver visitor used to create the analyzer.
9460 */ 9460 */
9461 ResolverVisitor _visitor; 9461 ResolverVisitor _visitor;
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
10860 } 10860 }
10861 } 10861 }
10862 return "<unknown file- ASTNode is null>"; 10862 return "<unknown file- ASTNode is null>";
10863 } 10863 }
10864 } 10864 }
10865 10865
10866 /** 10866 /**
10867 * The class `StrictModeTest` contains tests to ensure that the correct errors a nd warnings 10867 * The class `StrictModeTest` contains tests to ensure that the correct errors a nd warnings
10868 * are reported when the analysis engine is run in strict mode. 10868 * are reported when the analysis engine is run in strict mode.
10869 */ 10869 */
10870 @ReflectiveTestCase() 10870 @reflectiveTest
10871 class StrictModeTest extends ResolverTestCase { 10871 class StrictModeTest extends ResolverTestCase {
10872 void fail_for() { 10872 void fail_for() {
10873 Source source = addSource(r''' 10873 Source source = addSource(r'''
10874 int f(List<int> list) { 10874 int f(List<int> list) {
10875 num sum = 0; 10875 num sum = 0;
10876 for (num i = 0; i < list.length; i++) { 10876 for (num i = 0; i < list.length; i++) {
10877 sum += list[i]; 10877 sum += list[i];
10878 } 10878 }
10879 }'''); 10879 }''');
10880 resolve(source); 10880 resolve(source);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
11012 Source source = addSource(r''' 11012 Source source = addSource(r'''
11013 int f() { 11013 int f() {
11014 num n = 1234; 11014 num n = 1234;
11015 return n & 0x0F; 11015 return n & 0x0F;
11016 }'''); 11016 }''');
11017 resolve(source); 11017 resolve(source);
11018 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 11018 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
11019 } 11019 }
11020 } 11020 }
11021 11021
11022 @ReflectiveTestCase() 11022 @reflectiveTest
11023 class SubtypeManagerTest extends EngineTestCase { 11023 class SubtypeManagerTest extends EngineTestCase {
11024 /** 11024 /**
11025 * The inheritance manager being tested. 11025 * The inheritance manager being tested.
11026 */ 11026 */
11027 SubtypeManager _subtypeManager; 11027 SubtypeManager _subtypeManager;
11028 11028
11029 /** 11029 /**
11030 * The compilation unit element containing all of the types setup in each test . 11030 * The compilation unit element containing all of the types setup in each test .
11031 */ 11031 */
11032 CompilationUnitElementImpl _definingCompilationUnit; 11032 CompilationUnitElementImpl _definingCompilationUnit;
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
11578 FunctionTypeImpl functionType = method.type as FunctionTypeImpl; 11578 FunctionTypeImpl functionType = method.type as FunctionTypeImpl;
11579 functionType.typeArguments = typeArguments; 11579 functionType.typeArguments = typeArguments;
11580 } 11580 }
11581 for (ConstructorElement constructor in classElement.constructors) { 11581 for (ConstructorElement constructor in classElement.constructors) {
11582 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl; 11582 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl;
11583 functionType.typeArguments = typeArguments; 11583 functionType.typeArguments = typeArguments;
11584 } 11584 }
11585 } 11585 }
11586 } 11586 }
11587 11587
11588 @ReflectiveTestCase() 11588 @reflectiveTest
11589 class TypeOverrideManagerTest extends EngineTestCase { 11589 class TypeOverrideManagerTest extends EngineTestCase {
11590 void test_exitScope_noScopes() { 11590 void test_exitScope_noScopes() {
11591 TypeOverrideManager manager = new TypeOverrideManager(); 11591 TypeOverrideManager manager = new TypeOverrideManager();
11592 try { 11592 try {
11593 manager.exitScope(); 11593 manager.exitScope();
11594 fail("Expected IllegalStateException"); 11594 fail("Expected IllegalStateException");
11595 } on IllegalStateException catch (exception) { 11595 } on IllegalStateException catch (exception) {
11596 // Expected 11596 // Expected
11597 } 11597 }
11598 } 11598 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
11649 manager.enterScope(); 11649 manager.enterScope();
11650 expect(manager.getType(ElementFactory.localVariableElement2("v")), isNull); 11650 expect(manager.getType(ElementFactory.localVariableElement2("v")), isNull);
11651 } 11651 }
11652 11652
11653 void test_getType_noScope() { 11653 void test_getType_noScope() {
11654 TypeOverrideManager manager = new TypeOverrideManager(); 11654 TypeOverrideManager manager = new TypeOverrideManager();
11655 expect(manager.getType(ElementFactory.localVariableElement2("v")), isNull); 11655 expect(manager.getType(ElementFactory.localVariableElement2("v")), isNull);
11656 } 11656 }
11657 } 11657 }
11658 11658
11659 @ReflectiveTestCase() 11659 @reflectiveTest
11660 class TypePropagationTest extends ResolverTestCase { 11660 class TypePropagationTest extends ResolverTestCase {
11661 void fail_mergePropagatedTypesAtJoinPoint_1() { 11661 void fail_mergePropagatedTypesAtJoinPoint_1() {
11662 // https://code.google.com/p/dart/issues/detail?id=19929 11662 // https://code.google.com/p/dart/issues/detail?id=19929
11663 _assertTypeOfMarkedExpression(r''' 11663 _assertTypeOfMarkedExpression(r'''
11664 f1(x) { 11664 f1(x) {
11665 var y = []; 11665 var y = [];
11666 if (x) { 11666 if (x) {
11667 y = 0; 11667 y = 0;
11668 } else { 11668 } else {
11669 y = ''; 11669 y = '';
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
13125 // assertion failure here should be a failure, in both "test_*" and 13125 // assertion failure here should be a failure, in both "test_*" and
13126 // "fail_*" tests. However, an assertion failure is success for the 13126 // "fail_*" tests. However, an assertion failure is success for the
13127 // purpose of "fail_*" tests, so without catching them here "fail_*" tests 13127 // purpose of "fail_*" tests, so without catching them here "fail_*" tests
13128 // can succeed by failing for the wrong reason. 13128 // can succeed by failing for the wrong reason.
13129 throw new JavaException("Unexexpected assertion failure: $exception"); 13129 throw new JavaException("Unexexpected assertion failure: $exception");
13130 } 13130 }
13131 } 13131 }
13132 } 13132 }
13133 13133
13134 13134
13135 @ReflectiveTestCase() 13135 @reflectiveTest
13136 class TypeProviderImplTest extends EngineTestCase { 13136 class TypeProviderImplTest extends EngineTestCase {
13137 void test_creation() { 13137 void test_creation() {
13138 // 13138 //
13139 // Create a mock library element with the types expected to be in dart:core. 13139 // Create a mock library element with the types expected to be in dart:core.
13140 // We cannot use either ElementFactory or TestTypeProvider (which uses 13140 // We cannot use either ElementFactory or TestTypeProvider (which uses
13141 // ElementFactory) because we side-effect the elements in ways that would 13141 // ElementFactory) because we side-effect the elements in ways that would
13142 // break other tests. 13142 // break other tests.
13143 // 13143 //
13144 InterfaceType objectType = _classElement("Object", null).type; 13144 InterfaceType objectType = _classElement("Object", null).type;
13145 InterfaceType boolType = _classElement("bool", objectType).type; 13145 InterfaceType boolType = _classElement("bool", objectType).type;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
13212 typeParameter.type = typeArguments[i]; 13212 typeParameter.type = typeArguments[i];
13213 } 13213 }
13214 element.typeParameters = typeParameters; 13214 element.typeParameters = typeParameters;
13215 type.typeArguments = typeArguments; 13215 type.typeArguments = typeArguments;
13216 } 13216 }
13217 } 13217 }
13218 return element; 13218 return element;
13219 } 13219 }
13220 } 13220 }
13221 13221
13222 @ReflectiveTestCase() 13222 @reflectiveTest
13223 class TypeResolverVisitorTest extends EngineTestCase { 13223 class TypeResolverVisitorTest extends EngineTestCase {
13224 /** 13224 /**
13225 * The error listener to which errors will be reported. 13225 * The error listener to which errors will be reported.
13226 */ 13226 */
13227 GatheringErrorListener _listener; 13227 GatheringErrorListener _listener;
13228 13228
13229 /** 13229 /**
13230 * The object representing the information about the library in which the type s are being 13230 * The object representing the information about the library in which the type s are being
13231 * resolved. 13231 * resolved.
13232 */ 13232 */
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
13811 // check propagated type 13811 // check propagated type
13812 FunctionType propagatedType = node.propagatedType as FunctionType; 13812 FunctionType propagatedType = node.propagatedType as FunctionType;
13813 expect(propagatedType.returnType, test.typeProvider.stringType); 13813 expect(propagatedType.returnType, test.typeProvider.stringType);
13814 } on AnalysisException catch (e, stackTrace) { 13814 } on AnalysisException catch (e, stackTrace) {
13815 thrownException[0] = new CaughtException(e, stackTrace); 13815 thrownException[0] = new CaughtException(e, stackTrace);
13816 } 13816 }
13817 } 13817 }
13818 return null; 13818 return null;
13819 } 13819 }
13820 } 13820 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698