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

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

Issue 109853003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 7 years 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 'package:analyzer/src/generated/java_core.dart'; 6 import 'package:analyzer/src/generated/java_core.dart';
7 import 'package:analyzer/src/generated/java_junit.dart'; 7 import 'package:analyzer/src/generated/java_junit.dart';
8 import 'package:analyzer/src/generated/source_io.dart'; 8 import 'package:analyzer/src/generated/source_io.dart';
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/scanner.dart'; 10 import 'package:analyzer/src/generated/scanner.dart';
(...skipping 8792 matching lines...) Expand 10 before | Expand all | Expand 10 after
8803 runJUnitTest(__test, __test.test_visitTypeName_void); 8803 runJUnitTest(__test, __test.test_visitTypeName_void);
8804 }); 8804 });
8805 }); 8805 });
8806 } 8806 }
8807 } 8807 }
8808 8808
8809 class ResolverTestCase extends EngineTestCase { 8809 class ResolverTestCase extends EngineTestCase {
8810 /** 8810 /**
8811 * The source factory used to create [Source]. 8811 * The source factory used to create [Source].
8812 */ 8812 */
8813 SourceFactory sourceFactory; 8813 SourceFactory _sourceFactory;
8814 8814
8815 /** 8815 /**
8816 * The analysis context used to parse the compilation units being resolved. 8816 * The analysis context used to parse the compilation units being resolved.
8817 */ 8817 */
8818 AnalysisContextImpl analysisContext; 8818 AnalysisContextImpl _analysisContext;
8819 8819
8820 void setUp() { 8820 void setUp() {
8821 reset(); 8821 reset();
8822 } 8822 }
8823 8823
8824 /** 8824 /**
8825 * Add a source file to the content provider. 8825 * Add a source file to the content provider.
8826 * 8826 *
8827 * @param contents the contents to be returned by the content provider for the specified file 8827 * @param contents the contents to be returned by the content provider for the specified file
8828 * @return the source object representing the added file 8828 * @return the source object representing the added file
8829 */ 8829 */
8830 Source addSource(String contents) => addSource2("/test.dart", contents); 8830 Source addSource(String contents) => addSource2("/test.dart", contents);
8831 8831
8832 /** 8832 /**
8833 * Add a source file to the content provider. The file path should be absolute . 8833 * Add a source file to the content provider. The file path should be absolute .
8834 * 8834 *
8835 * @param filePath the path of the file being added 8835 * @param filePath the path of the file being added
8836 * @param contents the contents to be returned by the content provider for the specified file 8836 * @param contents the contents to be returned by the content provider for the specified file
8837 * @return the source object representing the added file 8837 * @return the source object representing the added file
8838 */ 8838 */
8839 Source addSource2(String filePath, String contents) { 8839 Source addSource2(String filePath, String contents) {
8840 Source source = cacheSource(filePath, contents); 8840 Source source = cacheSource(filePath, contents);
8841 ChangeSet changeSet = new ChangeSet(); 8841 ChangeSet changeSet = new ChangeSet();
8842 changeSet.added(source); 8842 changeSet.added(source);
8843 analysisContext.applyChanges(changeSet); 8843 _analysisContext.applyChanges(changeSet);
8844 return source; 8844 return source;
8845 } 8845 }
8846 8846
8847 /** 8847 /**
8848 * Assert that the number of errors reported against the given source matches the number of errors 8848 * Assert that the number of errors reported against the given source matches the number of errors
8849 * that are given and that they have the expected error codes. The order in wh ich the errors were 8849 * that are given and that they have the expected error codes. The order in wh ich the errors were
8850 * gathered is ignored. 8850 * gathered is ignored.
8851 * 8851 *
8852 * @param source the source against which the errors should have been reported 8852 * @param source the source against which the errors should have been reported
8853 * @param expectedErrorCodes the error codes of the errors that should have be en reported 8853 * @param expectedErrorCodes the error codes of the errors that should have be en reported
8854 * @throws AnalysisException if the reported errors could not be computed 8854 * @throws AnalysisException if the reported errors could not be computed
8855 * @throws AssertionFailedError if a different number of errors have been repo rted than were 8855 * @throws AssertionFailedError if a different number of errors have been repo rted than were
8856 * expected 8856 * expected
8857 */ 8857 */
8858 void assertErrors(Source source, List<ErrorCode> expectedErrorCodes) { 8858 void assertErrors(Source source, List<ErrorCode> expectedErrorCodes) {
8859 GatheringErrorListener errorListener = new GatheringErrorListener(); 8859 GatheringErrorListener errorListener = new GatheringErrorListener();
8860 for (AnalysisError error in analysisContext.computeErrors(source)) { 8860 for (AnalysisError error in _analysisContext.computeErrors(source)) {
8861 errorListener.onError(error); 8861 errorListener.onError(error);
8862 } 8862 }
8863 errorListener.assertErrors2(expectedErrorCodes); 8863 errorListener.assertErrors2(expectedErrorCodes);
8864 } 8864 }
8865 8865
8866 /** 8866 /**
8867 * Assert that no errors have been reported against the given source. 8867 * Assert that no errors have been reported against the given source.
8868 * 8868 *
8869 * @param source the source against which no errors should have been reported 8869 * @param source the source against which no errors should have been reported
8870 * @throws AnalysisException if the reported errors could not be computed 8870 * @throws AnalysisException if the reported errors could not be computed
8871 * @throws AssertionFailedError if any errors have been reported 8871 * @throws AssertionFailedError if any errors have been reported
8872 */ 8872 */
8873 void assertNoErrors(Source source) { 8873 void assertNoErrors(Source source) {
8874 assertErrors(source, []); 8874 assertErrors(source, []);
8875 } 8875 }
8876 8876
8877 /** 8877 /**
8878 * Cache the source file content in the source factory but don't add the sourc e to the analysis 8878 * Cache the source file content in the source factory but don't add the sourc e to the analysis
8879 * context. The file path should be absolute. 8879 * context. The file path should be absolute.
8880 * 8880 *
8881 * @param filePath the path of the file being cached 8881 * @param filePath the path of the file being cached
8882 * @param contents the contents to be returned by the content provider for the specified file 8882 * @param contents the contents to be returned by the content provider for the specified file
8883 * @return the source object representing the cached file 8883 * @return the source object representing the cached file
8884 */ 8884 */
8885 Source cacheSource(String filePath, String contents) { 8885 Source cacheSource(String filePath, String contents) {
8886 Source source = new FileBasedSource.con1(sourceFactory.contentCache, FileUti lities2.createFile(filePath)); 8886 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath));
8887 sourceFactory.setContents(source, contents); 8887 _sourceFactory.setContents(source, contents);
8888 return source; 8888 return source;
8889 } 8889 }
8890 8890
8891 /** 8891 /**
8892 * Create a library element that represents a library named `"test"` containin g a single 8892 * Create a library element that represents a library named `"test"` containin g a single
8893 * empty compilation unit. 8893 * empty compilation unit.
8894 * 8894 *
8895 * @return the library element that was created 8895 * @return the library element that was created
8896 */ 8896 */
8897 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []); 8897 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []);
(...skipping 19 matching lines...) Expand all
8917 } 8917 }
8918 String fileName = "${libraryName}.dart"; 8918 String fileName = "${libraryName}.dart";
8919 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName); 8919 CompilationUnitElementImpl compilationUnit = new CompilationUnitElementImpl( fileName);
8920 compilationUnit.source = createSource2(fileName); 8920 compilationUnit.source = createSource2(fileName);
8921 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName])); 8921 LibraryElementImpl library = new LibraryElementImpl(context, ASTFactory.libr aryIdentifier2([libraryName]));
8922 library.definingCompilationUnit = compilationUnit; 8922 library.definingCompilationUnit = compilationUnit;
8923 library.parts = sourcedCompilationUnits; 8923 library.parts = sourcedCompilationUnits;
8924 return library; 8924 return library;
8925 } 8925 }
8926 8926
8927 AnalysisContext get analysisContext => _analysisContext;
8928
8929 SourceFactory get sourceFactory => _sourceFactory;
8930
8927 /** 8931 /**
8928 * Return a type provider that can be used to test the results of resolution. 8932 * Return a type provider that can be used to test the results of resolution.
8929 * 8933 *
8930 * @return a type provider 8934 * @return a type provider
8935 * @throws AnalysisException if dart:core cannot be resolved
8931 */ 8936 */
8932 TypeProvider get typeProvider { 8937 TypeProvider get typeProvider => _analysisContext.typeProvider;
8933 Source coreSource = analysisContext.sourceFactory.forUri(DartSdk.DART_CORE);
8934 LibraryElement coreElement = analysisContext.getLibraryElement(coreSource);
8935 return new TypeProviderImpl(coreElement);
8936 }
8937 8938
8938 /** 8939 /**
8939 * In the rare cases we want to group several tests into single "test_" method , so need a way to 8940 * In the rare cases we want to group several tests into single "test_" method , so need a way to
8940 * reset test instance to reuse it. 8941 * reset test instance to reuse it.
8941 */ 8942 */
8942 void reset() { 8943 void reset() {
8943 analysisContext = AnalysisContextFactory.contextWithCore(); 8944 _analysisContext = AnalysisContextFactory.contextWithCore();
8944 sourceFactory = analysisContext.sourceFactory; 8945 _sourceFactory = _analysisContext.sourceFactory;
8945 } 8946 }
8946 8947
8947 /** 8948 /**
8948 * Given a library and all of its parts, resolve the contents of the library a nd the contents of 8949 * Given a library and all of its parts, resolve the contents of the library a nd the contents of
8949 * the parts. This assumes that the sources for the library and its parts have already been added 8950 * the parts. This assumes that the sources for the library and its parts have already been added
8950 * to the content provider using the method [addSource]. 8951 * to the content provider using the method [addSource].
8951 * 8952 *
8952 * @param librarySource the source for the compilation unit that defines the l ibrary 8953 * @param librarySource the source for the compilation unit that defines the l ibrary
8953 * @return the element representing the resolved library 8954 * @return the element representing the resolved library
8954 * @throws AnalysisException if the analysis could not be performed 8955 * @throws AnalysisException if the analysis could not be performed
8955 */ 8956 */
8956 LibraryElement resolve(Source librarySource) => analysisContext.computeLibrary Element(librarySource); 8957 LibraryElement resolve(Source librarySource) => _analysisContext.computeLibrar yElement(librarySource);
8957 8958
8958 /** 8959 /**
8959 * Return the resolved compilation unit corresponding to the given source in t he given library. 8960 * Return the resolved compilation unit corresponding to the given source in t he given library.
8960 * 8961 *
8961 * @param source the source of the compilation unit to be returned 8962 * @param source the source of the compilation unit to be returned
8962 * @param library the library in which the compilation unit is to be resolved 8963 * @param library the library in which the compilation unit is to be resolved
8963 * @return the resolved compilation unit 8964 * @return the resolved compilation unit
8964 * @throws Exception if the compilation unit could not be resolved 8965 * @throws Exception if the compilation unit could not be resolved
8965 */ 8966 */
8966 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) => analysisContext.resolveCompilationUnit(source, library); 8967 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library) => _analysisContext.resolveCompilationUnit(source, library);
8967 8968
8968 /** 8969 /**
8969 * Verify that all of the identifiers in the compilation units associated with the given sources 8970 * Verify that all of the identifiers in the compilation units associated with the given sources
8970 * have been resolved. 8971 * have been resolved.
8971 * 8972 *
8972 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element 8973 * @param resolvedElementMap a table mapping the AST nodes that have been reso lved to the element
8973 * to which they were resolved 8974 * to which they were resolved
8974 * @param sources the sources identifying the compilation units to be verified 8975 * @param sources the sources identifying the compilation units to be verified
8975 * @throws Exception if the contents of the compilation unit cannot be accesse d 8976 * @throws Exception if the contents of the compilation unit cannot be accesse d
8976 */ 8977 */
8977 void verify(List<Source> sources) { 8978 void verify(List<Source> sources) {
8978 ResolutionVerifier verifier = new ResolutionVerifier(); 8979 ResolutionVerifier verifier = new ResolutionVerifier();
8979 for (Source source in sources) { 8980 for (Source source in sources) {
8980 analysisContext.parseCompilationUnit(source).accept(verifier); 8981 _analysisContext.parseCompilationUnit(source).accept(verifier);
8981 } 8982 }
8982 verifier.assertResolved(); 8983 verifier.assertResolved();
8983 } 8984 }
8984 8985
8985 /** 8986 /**
8986 * Create a source object representing a file with the given name and give it an empty content. 8987 * Create a source object representing a file with the given name and give it an empty content.
8987 * 8988 *
8988 * @param fileName the name of the file for which a source is to be created 8989 * @param fileName the name of the file for which a source is to be created
8989 * @return the source that was created 8990 * @return the source that was created
8990 */ 8991 */
8991 FileBasedSource createSource2(String fileName) { 8992 FileBasedSource createSource2(String fileName) {
8992 FileBasedSource source = new FileBasedSource.con1(sourceFactory.contentCache , FileUtilities2.createFile(fileName)); 8993 FileBasedSource source = new FileBasedSource.con1(_sourceFactory.contentCach e, FileUtilities2.createFile(fileName));
8993 sourceFactory.setContents(source, ""); 8994 _sourceFactory.setContents(source, "");
8994 return source; 8995 return source;
8995 } 8996 }
8996 8997
8997 static dartSuite() { 8998 static dartSuite() {
8998 _ut.group('ResolverTestCase', () { 8999 _ut.group('ResolverTestCase', () {
8999 }); 9000 });
9000 } 9001 }
9001 } 9002 }
9002 9003
9003 class TypeProviderImplTest extends EngineTestCase { 9004 class TypeProviderImplTest extends EngineTestCase {
(...skipping 9942 matching lines...) Expand 10 before | Expand all | Expand 10 after
18946 /** 18947 /**
18947 * The class `AnalysisContextFactory` defines utility methods used to create ana lysis contexts 18948 * The class `AnalysisContextFactory` defines utility methods used to create ana lysis contexts
18948 * for testing purposes. 18949 * for testing purposes.
18949 */ 18950 */
18950 class AnalysisContextFactory { 18951 class AnalysisContextFactory {
18951 /** 18952 /**
18952 * Create an analysis context that has a fake core library already resolved. 18953 * Create an analysis context that has a fake core library already resolved.
18953 * 18954 *
18954 * @return the analysis context that was created 18955 * @return the analysis context that was created
18955 */ 18956 */
18956 static AnalysisContextImpl contextWithCore() { 18957 static AnalysisContextImpl contextWithCore() => initContextWithCore(new Delega tingAnalysisContextImpl());
18958
18959 /**
18960 * Initialize the given analysis context with a fake core library already reso lved.
18961 *
18962 * @param context the context to be initialized (not `null`)
18963 * @return the analysis context that was created
18964 */
18965 static AnalysisContextImpl initContextWithCore(AnalysisContextImpl context) {
18957 AnalysisContext sdkContext = DirectoryBasedDartSdk.defaultSdk.context; 18966 AnalysisContext sdkContext = DirectoryBasedDartSdk.defaultSdk.context;
18958 SourceFactory sourceFactory = sdkContext.sourceFactory; 18967 SourceFactory sourceFactory = sdkContext.sourceFactory;
18959 TestTypeProvider provider = new TestTypeProvider(); 18968 TestTypeProvider provider = new TestTypeProvider();
18960 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art"); 18969 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art");
18961 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 18970 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
18962 sdkContext.setContents(coreSource, ""); 18971 sdkContext.setContents(coreSource, "");
18963 coreUnit.source = coreSource; 18972 coreUnit.source = coreSource;
18964 coreUnit.types = <ClassElement> [ 18973 coreUnit.types = <ClassElement> [
18965 provider.boolType.element, 18974 provider.boolType.element,
18966 provider.deprecatedType.element, 18975 provider.deprecatedType.element,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
19009 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI mpl.EMPTY_ARRAY)]; 19018 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI mpl.EMPTY_ARRAY)];
19010 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen t3("document", false, true, htmlDocumentElement.type); 19019 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen t3("document", false, true, htmlDocumentElement.type);
19011 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document]; 19020 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document];
19012 htmlUnit.accessors = <PropertyAccessorElement> [document.getter]; 19021 htmlUnit.accessors = <PropertyAccessorElement> [document.getter];
19013 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "dom", "html"])); 19022 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "dom", "html"]));
19014 htmlLibrary.definingCompilationUnit = htmlUnit; 19023 htmlLibrary.definingCompilationUnit = htmlUnit;
19015 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>(); 19024 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
19016 elementMap[coreSource] = coreLibrary; 19025 elementMap[coreSource] = coreLibrary;
19017 elementMap[htmlSource] = htmlLibrary; 19026 elementMap[htmlSource] = htmlLibrary;
19018 (sdkContext as AnalysisContextImpl).recordLibraryElements(elementMap); 19027 (sdkContext as AnalysisContextImpl).recordLibraryElements(elementMap);
19019 AnalysisContextImpl context = new DelegatingAnalysisContextImpl();
19020 sourceFactory = new SourceFactory.con2([ 19028 sourceFactory = new SourceFactory.con2([
19021 new DartUriResolver(sdkContext.sourceFactory.dartSdk), 19029 new DartUriResolver(sdkContext.sourceFactory.dartSdk),
19022 new FileUriResolver()]); 19030 new FileUriResolver()]);
19023 context.sourceFactory = sourceFactory; 19031 context.sourceFactory = sourceFactory;
19024 return context; 19032 return context;
19025 } 19033 }
19026 } 19034 }
19027 19035
19028 class LibraryImportScopeTest extends ResolverTestCase { 19036 class LibraryImportScopeTest extends ResolverTestCase {
19029 void test_conflictingImports() { 19037 void test_conflictingImports() {
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after
21399 final __test = new NonHintCodeTest(); 21407 final __test = new NonHintCodeTest();
21400 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction); 21408 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction);
21401 }); 21409 });
21402 }); 21410 });
21403 } 21411 }
21404 } 21412 }
21405 21413
21406 class EnclosedScopeTest extends ResolverTestCase { 21414 class EnclosedScopeTest extends ResolverTestCase {
21407 void test_define_duplicate() { 21415 void test_define_duplicate() {
21408 GatheringErrorListener errorListener2 = new GatheringErrorListener(); 21416 GatheringErrorListener errorListener2 = new GatheringErrorListener();
21409 Scope rootScope = new Scope_23(errorListener2); 21417 Scope rootScope = new Scope_24(errorListener2);
21410 EnclosedScope scope = new EnclosedScope(rootScope); 21418 EnclosedScope scope = new EnclosedScope(rootScope);
21411 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 21419 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
21412 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 21420 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
21413 scope.define(element1); 21421 scope.define(element1);
21414 scope.define(element2); 21422 scope.define(element2);
21415 errorListener2.assertErrors3([ErrorSeverity.ERROR]); 21423 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
21416 } 21424 }
21417 21425
21418 void test_define_normal() { 21426 void test_define_normal() {
21419 GatheringErrorListener errorListener3 = new GatheringErrorListener(); 21427 GatheringErrorListener errorListener3 = new GatheringErrorListener();
21420 Scope rootScope = new Scope_24(errorListener3); 21428 Scope rootScope = new Scope_25(errorListener3);
21421 EnclosedScope outerScope = new EnclosedScope(rootScope); 21429 EnclosedScope outerScope = new EnclosedScope(rootScope);
21422 EnclosedScope innerScope = new EnclosedScope(outerScope); 21430 EnclosedScope innerScope = new EnclosedScope(outerScope);
21423 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 21431 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
21424 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2")); 21432 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
21425 outerScope.define(element1); 21433 outerScope.define(element1);
21426 innerScope.define(element2); 21434 innerScope.define(element2);
21427 errorListener3.assertNoErrors(); 21435 errorListener3.assertNoErrors();
21428 } 21436 }
21429 21437
21430 static dartSuite() { 21438 static dartSuite() {
21431 _ut.group('EnclosedScopeTest', () { 21439 _ut.group('EnclosedScopeTest', () {
21432 _ut.test('test_define_duplicate', () { 21440 _ut.test('test_define_duplicate', () {
21433 final __test = new EnclosedScopeTest(); 21441 final __test = new EnclosedScopeTest();
21434 runJUnitTest(__test, __test.test_define_duplicate); 21442 runJUnitTest(__test, __test.test_define_duplicate);
21435 }); 21443 });
21436 _ut.test('test_define_normal', () { 21444 _ut.test('test_define_normal', () {
21437 final __test = new EnclosedScopeTest(); 21445 final __test = new EnclosedScopeTest();
21438 runJUnitTest(__test, __test.test_define_normal); 21446 runJUnitTest(__test, __test.test_define_normal);
21439 }); 21447 });
21440 }); 21448 });
21441 } 21449 }
21442 } 21450 }
21443 21451
21444 class Scope_23 extends Scope { 21452 class Scope_24 extends Scope {
21445 GatheringErrorListener errorListener2; 21453 GatheringErrorListener errorListener2;
21446 21454
21447 Scope_23(this.errorListener2) : super(); 21455 Scope_24(this.errorListener2) : super();
21448 21456
21449 AnalysisErrorListener get errorListener => errorListener2; 21457 AnalysisErrorListener get errorListener => errorListener2;
21450 21458
21451 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 21459 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
21452 } 21460 }
21453 21461
21454 class Scope_24 extends Scope { 21462 class Scope_25 extends Scope {
21455 GatheringErrorListener errorListener3; 21463 GatheringErrorListener errorListener3;
21456 21464
21457 Scope_24(this.errorListener3) : super(); 21465 Scope_25(this.errorListener3) : super();
21458 21466
21459 AnalysisErrorListener get errorListener => errorListener3; 21467 AnalysisErrorListener get errorListener => errorListener3;
21460 21468
21461 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 21469 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
21462 } 21470 }
21463 21471
21464 class LibraryElementBuilderTest extends EngineTestCase { 21472 class LibraryElementBuilderTest extends EngineTestCase {
21465 /** 21473 /**
21466 * The source factory used to create [Source]. 21474 * The source factory used to create [Source].
21467 */ 21475 */
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
21718 } 21726 }
21719 } 21727 }
21720 21728
21721 /** 21729 /**
21722 * A non-abstract subclass that can be used for testing purposes. 21730 * A non-abstract subclass that can be used for testing purposes.
21723 */ 21731 */
21724 class ScopeTest_TestScope extends Scope { 21732 class ScopeTest_TestScope extends Scope {
21725 /** 21733 /**
21726 * The listener that is to be informed when an error is encountered. 21734 * The listener that is to be informed when an error is encountered.
21727 */ 21735 */
21728 AnalysisErrorListener _errorListener; 21736 final AnalysisErrorListener errorListener;
21729 21737
21730 ScopeTest_TestScope(AnalysisErrorListener errorListener) { 21738 ScopeTest_TestScope(this.errorListener);
21731 this._errorListener = errorListener;
21732 }
21733
21734 AnalysisErrorListener get errorListener => _errorListener;
21735 21739
21736 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => localLookup(name, referencingLibrary); 21740 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => localLookup(name, referencingLibrary);
21737 } 21741 }
21738 21742
21739 class SimpleResolverTest extends ResolverTestCase { 21743 class SimpleResolverTest extends ResolverTestCase {
21740 void fail_staticInvocation() { 21744 void fail_staticInvocation() {
21741 Source source = addSource(EngineTestCase.createSource([ 21745 Source source = addSource(EngineTestCase.createSource([
21742 "class A {", 21746 "class A {",
21743 " static int get g => (a,b) => 0;", 21747 " static int get g => (a,b) => 0;",
21744 "}", 21748 "}",
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
22182 "const A = null;", 22186 "const A = null;",
22183 "main() {", 22187 "main() {",
22184 " var myVar = (int p) => 'foo';", 22188 " var myVar = (int p) => 'foo';",
22185 " myVar(42);", 22189 " myVar(42);",
22186 "}"])); 22190 "}"]));
22187 LibraryElement library = resolve(source); 22191 LibraryElement library = resolve(source);
22188 JUnitTestCase.assertNotNull(library); 22192 JUnitTestCase.assertNotNull(library);
22189 CompilationUnit unit = analysisContext.getResolvedCompilationUnit(source, li brary); 22193 CompilationUnit unit = analysisContext.getResolvedCompilationUnit(source, li brary);
22190 JUnitTestCase.assertNotNull(unit); 22194 JUnitTestCase.assertNotNull(unit);
22191 List<bool> found = [false]; 22195 List<bool> found = [false];
22192 unit.accept(new RecursiveASTVisitor_27(this, found)); 22196 List<AnalysisException> thrownException = new List<AnalysisException>(1);
22197 unit.accept(new RecursiveASTVisitor_28(this, found, thrownException));
22198 if (thrownException[0] != null) {
22199 throw new AnalysisException.con3(thrownException[0]);
22200 }
22193 JUnitTestCase.assertTrue(found[0]); 22201 JUnitTestCase.assertTrue(found[0]);
22194 } 22202 }
22195 22203
22196 void test_metadata_class() { 22204 void test_metadata_class() {
22197 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@ A class C {}"])); 22205 Source source = addSource(EngineTestCase.createSource(["const A = null;", "@ A class C {}"]));
22198 LibraryElement library = resolve(source); 22206 LibraryElement library = resolve(source);
22199 JUnitTestCase.assertNotNull(library); 22207 JUnitTestCase.assertNotNull(library);
22200 CompilationUnitElement unit = library.definingCompilationUnit; 22208 CompilationUnitElement unit = library.definingCompilationUnit;
22201 JUnitTestCase.assertNotNull(unit); 22209 JUnitTestCase.assertNotNull(unit);
22202 List<ClassElement> classes = unit.types; 22210 List<ClassElement> classes = unit.types;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
22575 runJUnitTest(__test, __test.test_setter_inherited); 22583 runJUnitTest(__test, __test.test_setter_inherited);
22576 }); 22584 });
22577 _ut.test('test_setter_static', () { 22585 _ut.test('test_setter_static', () {
22578 final __test = new SimpleResolverTest(); 22586 final __test = new SimpleResolverTest();
22579 runJUnitTest(__test, __test.test_setter_static); 22587 runJUnitTest(__test, __test.test_setter_static);
22580 }); 22588 });
22581 }); 22589 });
22582 } 22590 }
22583 } 22591 }
22584 22592
22585 class RecursiveASTVisitor_27 extends RecursiveASTVisitor<Object> { 22593 class RecursiveASTVisitor_28 extends RecursiveASTVisitor<Object> {
22586 final SimpleResolverTest SimpleResolverTest_this; 22594 final SimpleResolverTest SimpleResolverTest_this;
22587 22595
22588 List<bool> found; 22596 List<bool> found;
22589 22597
22590 RecursiveASTVisitor_27(this.SimpleResolverTest_this, this.found) : super(); 22598 List<AnalysisException> thrownException;
22599
22600 RecursiveASTVisitor_28(this.SimpleResolverTest_this, this.found, this.thrownEx ception) : super();
22591 22601
22592 Object visitSimpleIdentifier(SimpleIdentifier node) { 22602 Object visitSimpleIdentifier(SimpleIdentifier node) {
22593 if (node.name == "myVar" && node.parent is MethodInvocation) { 22603 if (node.name == "myVar" && node.parent is MethodInvocation) {
22594 found[0] = true; 22604 try {
22595 Type2 staticType = node.staticType; 22605 found[0] = true;
22596 JUnitTestCase.assertSame(SimpleResolverTest_this.typeProvider.dynamicType, staticType); 22606 Type2 staticType = node.staticType;
22597 FunctionType propagatedType = node.propagatedType as FunctionType; 22607 JUnitTestCase.assertSame(SimpleResolverTest_this.typeProvider.dynamicTyp e, staticType);
22598 JUnitTestCase.assertEquals(SimpleResolverTest_this.typeProvider.stringType , propagatedType.returnType); 22608 FunctionType propagatedType = node.propagatedType as FunctionType;
22609 JUnitTestCase.assertEquals(SimpleResolverTest_this.typeProvider.stringTy pe, propagatedType.returnType);
22610 } on AnalysisException catch (e) {
22611 thrownException[0] = e;
22612 }
22599 } 22613 }
22600 return null; 22614 return null;
22601 } 22615 }
22602 } 22616 }
22603 22617
22604 class SubtypeManagerTest extends EngineTestCase { 22618 class SubtypeManagerTest extends EngineTestCase {
22605 /** 22619 /**
22606 * The inheritance manager being tested. 22620 * The inheritance manager being tested.
22607 */ 22621 */
22608 SubtypeManager _subtypeManager; 22622 SubtypeManager _subtypeManager;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
22941 // HintCodeTest.dartSuite(); 22955 // HintCodeTest.dartSuite();
22942 // MemberMapTest.dartSuite(); 22956 // MemberMapTest.dartSuite();
22943 // NonHintCodeTest.dartSuite(); 22957 // NonHintCodeTest.dartSuite();
22944 // NonErrorResolverTest.dartSuite(); 22958 // NonErrorResolverTest.dartSuite();
22945 // SimpleResolverTest.dartSuite(); 22959 // SimpleResolverTest.dartSuite();
22946 // StaticTypeWarningCodeTest.dartSuite(); 22960 // StaticTypeWarningCodeTest.dartSuite();
22947 // StaticWarningCodeTest.dartSuite(); 22961 // StaticWarningCodeTest.dartSuite();
22948 // StrictModeTest.dartSuite(); 22962 // StrictModeTest.dartSuite();
22949 // TypePropagationTest.dartSuite(); 22963 // TypePropagationTest.dartSuite();
22950 } 22964 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_test.dart ('k') | pkg/analyzer/test/generated/test_support.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698