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

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

Issue 23461019: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine.resolver_test; 3 library engine.resolver_test;
4 import 'package:analyzer_experimental/src/generated/java_core.dart'; 4 import 'package:analyzer_experimental/src/generated/java_core.dart';
5 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 5 import 'package:analyzer_experimental/src/generated/java_junit.dart';
6 import 'package:analyzer_experimental/src/generated/source_io.dart'; 6 import 'package:analyzer_experimental/src/generated/source_io.dart';
7 import 'package:analyzer_experimental/src/generated/error.dart'; 7 import 'package:analyzer_experimental/src/generated/error.dart';
8 import 'package:analyzer_experimental/src/generated/scanner.dart'; 8 import 'package:analyzer_experimental/src/generated/scanner.dart';
9 import 'package:analyzer_experimental/src/generated/ast.dart'; 9 import 'package:analyzer_experimental/src/generated/ast.dart';
10 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode; 10 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode;
(...skipping 14884 matching lines...) Expand 10 before | Expand all | Expand 10 after
14895 } 14895 }
14896 /** 14896 /**
14897 * The class `AnalysisContextFactory` defines utility methods used to create ana lysis contexts 14897 * The class `AnalysisContextFactory` defines utility methods used to create ana lysis contexts
14898 * for testing purposes. 14898 * for testing purposes.
14899 */ 14899 */
14900 class AnalysisContextFactory { 14900 class AnalysisContextFactory {
14901 14901
14902 /** 14902 /**
14903 * Create an analysis context that has a fake core library already resolved. 14903 * Create an analysis context that has a fake core library already resolved.
14904 * 14904 *
14905 * Added in order to test AnalysisContextImpl2.
14906 *
14907 * @return the analysis context that was created
14908 */
14909 static AnalysisContextImpl2 context2WithCore() {
14910 AnalysisContextImpl2 sdkContext = DirectoryBasedDartSdk.defaultSdk2.context as AnalysisContextImpl2;
14911 SourceFactory sourceFactory = sdkContext.sourceFactory;
14912 TestTypeProvider provider = new TestTypeProvider();
14913 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art");
14914 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
14915 sdkContext.setContents(coreSource, "");
14916 coreUnit.source = coreSource;
14917 coreUnit.types = <ClassElement> [
14918 provider.boolType.element,
14919 provider.doubleType.element,
14920 provider.functionType.element,
14921 provider.intType.element,
14922 provider.listType.element,
14923 provider.mapType.element,
14924 provider.nullType.element,
14925 provider.numType.element,
14926 provider.objectType.element,
14927 provider.stackTraceType.element,
14928 provider.stringType.element,
14929 provider.typeType.element];
14930 LibraryElementImpl coreLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "core"]));
14931 coreLibrary.definingCompilationUnit = coreUnit;
14932 CompilationUnitElementImpl htmlUnit = new CompilationUnitElementImpl("html_d artium.dart");
14933 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
14934 sdkContext.setContents(htmlSource, "");
14935 htmlUnit.source = htmlSource;
14936 ClassElementImpl elementElement = ElementFactory.classElement2("Element", [] );
14937 InterfaceType elementType = elementElement.type;
14938 ClassElementImpl documentElement = ElementFactory.classElement("Document", e lementType, []);
14939 ClassElementImpl htmlDocumentElement = ElementFactory.classElement("HtmlDocu ment", documentElement.type, []);
14940 htmlDocumentElement.methods = <MethodElement> [ElementFactory.methodElement( "query", elementType, <Type2> [provider.stringType])];
14941 htmlUnit.types = <ClassElement> [
14942 ElementFactory.classElement("AnchorElement", elementType, []),
14943 ElementFactory.classElement("BodyElement", elementType, []),
14944 ElementFactory.classElement("ButtonElement", elementType, []),
14945 ElementFactory.classElement("DivElement", elementType, []),
14946 documentElement,
14947 elementElement,
14948 htmlDocumentElement,
14949 ElementFactory.classElement("InputElement", elementType, []),
14950 ElementFactory.classElement("SelectElement", elementType, [])];
14951 htmlUnit.functions = <FunctionElement> [ElementFactory.functionElement3("que ry", elementElement, <ClassElement> [provider.stringType.element], ClassElementI mpl.EMPTY_ARRAY)];
14952 TopLevelVariableElementImpl document = ElementFactory.topLevelVariableElemen t3("document", true, htmlDocumentElement.type);
14953 htmlUnit.topLevelVariables = <TopLevelVariableElement> [document];
14954 htmlUnit.accessors = <PropertyAccessorElement> [document.getter];
14955 LibraryElementImpl htmlLibrary = new LibraryElementImpl(sdkContext, ASTFacto ry.libraryIdentifier2(["dart", "dom", "html"]));
14956 htmlLibrary.definingCompilationUnit = htmlUnit;
14957 Map<Source, LibraryElement> elementMap = new Map<Source, LibraryElement>();
14958 elementMap[coreSource] = coreLibrary;
14959 elementMap[htmlSource] = htmlLibrary;
14960 sdkContext.recordLibraryElements(elementMap);
14961 AnalysisContextImpl2 context = new DelegatingAnalysisContextImpl2();
14962 sourceFactory = new SourceFactory.con2([
14963 new DartUriResolver(sdkContext.sourceFactory.dartSdk),
14964 new FileUriResolver()]);
14965 context.sourceFactory = sourceFactory;
14966 return context;
14967 }
14968
14969 /**
14970 * Create an analysis context that has a fake core library already resolved.
14971 *
14905 * @return the analysis context that was created 14972 * @return the analysis context that was created
14906 */ 14973 */
14907 static AnalysisContextImpl contextWithCore() { 14974 static AnalysisContextImpl contextWithCore() {
14908 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl; 14975 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl;
14909 SourceFactory sourceFactory = sdkContext.sourceFactory; 14976 SourceFactory sourceFactory = sdkContext.sourceFactory;
14910 TestTypeProvider provider = new TestTypeProvider(); 14977 TestTypeProvider provider = new TestTypeProvider();
14911 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art"); 14978 CompilationUnitElementImpl coreUnit = new CompilationUnitElementImpl("core.d art");
14912 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 14979 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
14913 sdkContext.setContents(coreSource, ""); 14980 sdkContext.setContents(coreSource, "");
14914 coreUnit.source = coreSource; 14981 coreUnit.source = coreSource;
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
16484 final __test = new NonHintCodeTest(); 16551 final __test = new NonHintCodeTest();
16485 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction); 16552 runJUnitTest(__test, __test.test_unusedImport_prefix_topLevelFunction);
16486 }); 16553 });
16487 }); 16554 });
16488 } 16555 }
16489 } 16556 }
16490 class EnclosedScopeTest extends ResolverTestCase { 16557 class EnclosedScopeTest extends ResolverTestCase {
16491 void test_define_duplicate() { 16558 void test_define_duplicate() {
16492 LibraryElement definingLibrary2 = createTestLibrary(); 16559 LibraryElement definingLibrary2 = createTestLibrary();
16493 GatheringErrorListener errorListener2 = new GatheringErrorListener(); 16560 GatheringErrorListener errorListener2 = new GatheringErrorListener();
16494 Scope rootScope = new Scope_19(definingLibrary2, errorListener2); 16561 Scope rootScope = new Scope_23(definingLibrary2, errorListener2);
16495 EnclosedScope scope = new EnclosedScope(rootScope); 16562 EnclosedScope scope = new EnclosedScope(rootScope);
16496 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 16563 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
16497 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 16564 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
16498 scope.define(element1); 16565 scope.define(element1);
16499 scope.define(element2); 16566 scope.define(element2);
16500 errorListener2.assertErrors3([ErrorSeverity.ERROR]); 16567 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
16501 } 16568 }
16502 void test_define_normal() { 16569 void test_define_normal() {
16503 LibraryElement definingLibrary3 = createTestLibrary(); 16570 LibraryElement definingLibrary3 = createTestLibrary();
16504 GatheringErrorListener errorListener3 = new GatheringErrorListener(); 16571 GatheringErrorListener errorListener3 = new GatheringErrorListener();
16505 Scope rootScope = new Scope_20(definingLibrary3, errorListener3); 16572 Scope rootScope = new Scope_24(definingLibrary3, errorListener3);
16506 EnclosedScope outerScope = new EnclosedScope(rootScope); 16573 EnclosedScope outerScope = new EnclosedScope(rootScope);
16507 EnclosedScope innerScope = new EnclosedScope(outerScope); 16574 EnclosedScope innerScope = new EnclosedScope(outerScope);
16508 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 16575 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
16509 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2")); 16576 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
16510 outerScope.define(element1); 16577 outerScope.define(element1);
16511 innerScope.define(element2); 16578 innerScope.define(element2);
16512 errorListener3.assertNoErrors(); 16579 errorListener3.assertNoErrors();
16513 } 16580 }
16514 static dartSuite() { 16581 static dartSuite() {
16515 _ut.group('EnclosedScopeTest', () { 16582 _ut.group('EnclosedScopeTest', () {
16516 _ut.test('test_define_duplicate', () { 16583 _ut.test('test_define_duplicate', () {
16517 final __test = new EnclosedScopeTest(); 16584 final __test = new EnclosedScopeTest();
16518 runJUnitTest(__test, __test.test_define_duplicate); 16585 runJUnitTest(__test, __test.test_define_duplicate);
16519 }); 16586 });
16520 _ut.test('test_define_normal', () { 16587 _ut.test('test_define_normal', () {
16521 final __test = new EnclosedScopeTest(); 16588 final __test = new EnclosedScopeTest();
16522 runJUnitTest(__test, __test.test_define_normal); 16589 runJUnitTest(__test, __test.test_define_normal);
16523 }); 16590 });
16524 }); 16591 });
16525 } 16592 }
16526 } 16593 }
16527 class Scope_19 extends Scope { 16594 class Scope_23 extends Scope {
16528 LibraryElement definingLibrary2; 16595 LibraryElement definingLibrary2;
16529 GatheringErrorListener errorListener2; 16596 GatheringErrorListener errorListener2;
16530 Scope_19(this.definingLibrary2, this.errorListener2) : super(); 16597 Scope_23(this.definingLibrary2, this.errorListener2) : super();
16531 LibraryElement get definingLibrary => definingLibrary2; 16598 LibraryElement get definingLibrary => definingLibrary2;
16532 AnalysisErrorListener get errorListener => errorListener2; 16599 AnalysisErrorListener get errorListener => errorListener2;
16533 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 16600 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
16534 } 16601 }
16535 class Scope_20 extends Scope { 16602 class Scope_24 extends Scope {
16536 LibraryElement definingLibrary3; 16603 LibraryElement definingLibrary3;
16537 GatheringErrorListener errorListener3; 16604 GatheringErrorListener errorListener3;
16538 Scope_20(this.definingLibrary3, this.errorListener3) : super(); 16605 Scope_24(this.definingLibrary3, this.errorListener3) : super();
16539 LibraryElement get definingLibrary => definingLibrary3; 16606 LibraryElement get definingLibrary => definingLibrary3;
16540 AnalysisErrorListener get errorListener => errorListener3; 16607 AnalysisErrorListener get errorListener => errorListener3;
16541 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 16608 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
16542 } 16609 }
16543 class LibraryElementBuilderTest extends EngineTestCase { 16610 class LibraryElementBuilderTest extends EngineTestCase {
16544 16611
16545 /** 16612 /**
16546 * The source factory used to create [Source]. 16613 * The source factory used to create [Source].
16547 */ 16614 */
16548 SourceFactory _sourceFactory; 16615 SourceFactory _sourceFactory;
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
17613 // ErrorResolverTest.dartSuite(); 17680 // ErrorResolverTest.dartSuite();
17614 // HintCodeTest.dartSuite(); 17681 // HintCodeTest.dartSuite();
17615 // NonHintCodeTest.dartSuite(); 17682 // NonHintCodeTest.dartSuite();
17616 // NonErrorResolverTest.dartSuite(); 17683 // NonErrorResolverTest.dartSuite();
17617 // SimpleResolverTest.dartSuite(); 17684 // SimpleResolverTest.dartSuite();
17618 // StaticTypeWarningCodeTest.dartSuite(); 17685 // StaticTypeWarningCodeTest.dartSuite();
17619 // StaticWarningCodeTest.dartSuite(); 17686 // StaticWarningCodeTest.dartSuite();
17620 // StrictModeTest.dartSuite(); 17687 // StrictModeTest.dartSuite();
17621 // TypePropagationTest.dartSuite(); 17688 // TypePropagationTest.dartSuite();
17622 } 17689 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698