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

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

Issue 1460123002: Clean-up the registration of plugins (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
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/context/context.dart' as newContext; 9 import 'package:analyzer/src/context/context.dart' as newContext;
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 _listener.assertNoErrors(); 1290 _listener.assertNoErrors();
1291 } 1291 }
1292 1292
1293 void fail_visitRedirectingConstructorInvocation() { 1293 void fail_visitRedirectingConstructorInvocation() {
1294 fail("Not yet tested"); 1294 fail("Not yet tested");
1295 _listener.assertNoErrors(); 1295 _listener.assertNoErrors();
1296 } 1296 }
1297 1297
1298 @override 1298 @override
1299 void setUp() { 1299 void setUp() {
1300 super.setUp();
1300 _listener = new GatheringErrorListener(); 1301 _listener = new GatheringErrorListener();
1301 _typeProvider = new TestTypeProvider(); 1302 _typeProvider = new TestTypeProvider();
1302 _resolver = _createResolver(); 1303 _resolver = _createResolver();
1303 } 1304 }
1304 1305
1305 void test_lookUpMethodInInterfaces() { 1306 void test_lookUpMethodInInterfaces() {
1306 InterfaceType intType = _typeProvider.intType; 1307 InterfaceType intType = _typeProvider.intType;
1307 // 1308 //
1308 // abstract class A { int operator[](int index); } 1309 // abstract class A { int operator[](int index); }
1309 // 1310 //
(...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after
4828 } 4829 }
4829 }'''); 4830 }''');
4830 computeLibrarySourceErrors(source); 4831 computeLibrarySourceErrors(source);
4831 assertErrors( 4832 assertErrors(
4832 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 4833 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
4833 verify([source]); 4834 verify([source]);
4834 } 4835 }
4835 } 4836 }
4836 4837
4837 @reflectiveTest 4838 @reflectiveTest
4838 class InheritanceManagerTest extends EngineTestCase { 4839 class InheritanceManagerTest {
4839 /** 4840 /**
4840 * The type provider used to access the types. 4841 * The type provider used to access the types.
4841 */ 4842 */
4842 TestTypeProvider _typeProvider; 4843 TestTypeProvider _typeProvider;
4843 4844
4844 /** 4845 /**
4845 * The library containing the code being resolved. 4846 * The library containing the code being resolved.
4846 */ 4847 */
4847 LibraryElementImpl _definingLibrary; 4848 LibraryElementImpl _definingLibrary;
4848 4849
4849 /** 4850 /**
4850 * The inheritance manager being tested. 4851 * The inheritance manager being tested.
4851 */ 4852 */
4852 InheritanceManager _inheritanceManager; 4853 InheritanceManager _inheritanceManager;
4853 4854
4854 /** 4855 /**
4855 * The number of members that Object implements (as determined by [TestTypePro vider]). 4856 * The number of members that Object implements (as determined by [TestTypePro vider]).
4856 */ 4857 */
4857 int _numOfMembersInObject = 0; 4858 int _numOfMembersInObject = 0;
4858 4859
4859 @override
4860 void setUp() { 4860 void setUp() {
4861 _typeProvider = new TestTypeProvider(); 4861 _typeProvider = new TestTypeProvider();
4862 _inheritanceManager = _createInheritanceManager(); 4862 _inheritanceManager = _createInheritanceManager();
4863 InterfaceType objectType = _typeProvider.objectType; 4863 InterfaceType objectType = _typeProvider.objectType;
4864 _numOfMembersInObject = 4864 _numOfMembersInObject =
4865 objectType.methods.length + objectType.accessors.length; 4865 objectType.methods.length + objectType.accessors.length;
4866 } 4866 }
4867 4867
4868 void test_getMapOfMembersInheritedFromClasses_accessor_extends() { 4868 void test_getMapOfMembersInheritedFromClasses_accessor_extends() {
4869 // class A { int get g; } 4869 // class A { int get g; }
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
6053 new CompilationUnitElementImpl("test.dart"); 6053 new CompilationUnitElementImpl("test.dart");
6054 definingCompilationUnit.librarySource = 6054 definingCompilationUnit.librarySource =
6055 definingCompilationUnit.source = source; 6055 definingCompilationUnit.source = source;
6056 _definingLibrary = ElementFactory.library(context, "test"); 6056 _definingLibrary = ElementFactory.library(context, "test");
6057 _definingLibrary.definingCompilationUnit = definingCompilationUnit; 6057 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
6058 return new InheritanceManager(_definingLibrary); 6058 return new InheritanceManager(_definingLibrary);
6059 } 6059 }
6060 } 6060 }
6061 6061
6062 @reflectiveTest 6062 @reflectiveTest
6063 class LibraryElementBuilderTest extends EngineTestCase { 6063 class LibraryElementBuilderTest {
6064 /** 6064 /**
6065 * The analysis context used to analyze sources. 6065 * The analysis context used to analyze sources.
6066 */ 6066 */
6067 InternalAnalysisContext _context; 6067 InternalAnalysisContext _context;
6068 6068
6069 /** 6069 /**
6070 * Add a source file to the content provider. The file path should be absolute . 6070 * Add a source file to the content provider. The file path should be absolute .
6071 * 6071 *
6072 * @param filePath the path of the file being added 6072 * @param filePath the path of the file being added
6073 * @param contents the contents to be returned by the content provider for the specified file 6073 * @param contents the contents to be returned by the content provider for the specified file
6074 * @return the source object representing the added file 6074 * @return the source object representing the added file
6075 */ 6075 */
6076 Source addSource(String filePath, String contents) { 6076 Source addSource(String filePath, String contents) {
6077 Source source = new FileBasedSource(FileUtilities2.createFile(filePath)); 6077 Source source = new FileBasedSource(FileUtilities2.createFile(filePath));
6078 _context.setContents(source, contents); 6078 _context.setContents(source, contents);
6079 return source; 6079 return source;
6080 } 6080 }
6081 6081
6082 @override
6083 void setUp() { 6082 void setUp() {
6084 _context = AnalysisContextFactory.contextWithCore(); 6083 _context = AnalysisContextFactory.contextWithCore();
6085 } 6084 }
6086 6085
6087 @override
6088 void tearDown() { 6086 void tearDown() {
6089 _context = null; 6087 _context = null;
6090 super.tearDown();
6091 } 6088 }
6092 6089
6093 void test_accessorsAcrossFiles() { 6090 void test_accessorsAcrossFiles() {
6094 Source librarySource = addSource( 6091 Source librarySource = addSource(
6095 "/lib.dart", 6092 "/lib.dart",
6096 r''' 6093 r'''
6097 library lib; 6094 library lib;
6098 part 'first.dart'; 6095 part 'first.dart';
6099 part 'second.dart';'''); 6096 part 'second.dart';''');
6100 addSource( 6097 addSource(
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
6578 6575
6579 void test_getErrorListener() { 6576 void test_getErrorListener() {
6580 LibraryElement definingLibrary = createDefaultTestLibrary(); 6577 LibraryElement definingLibrary = createDefaultTestLibrary();
6581 GatheringErrorListener errorListener = new GatheringErrorListener(); 6578 GatheringErrorListener errorListener = new GatheringErrorListener();
6582 LibraryScope scope = new LibraryScope(definingLibrary, errorListener); 6579 LibraryScope scope = new LibraryScope(definingLibrary, errorListener);
6583 expect(scope.errorListener, errorListener); 6580 expect(scope.errorListener, errorListener);
6584 } 6581 }
6585 } 6582 }
6586 6583
6587 @reflectiveTest 6584 @reflectiveTest
6588 class LibraryTest extends EngineTestCase { 6585 class LibraryTest {
6589 /** 6586 /**
6590 * The error listener to which all errors will be reported. 6587 * The error listener to which all errors will be reported.
6591 */ 6588 */
6592 GatheringErrorListener _errorListener; 6589 GatheringErrorListener _errorListener;
6593 6590
6594 /** 6591 /**
6595 * The analysis context to pass in to all libraries created by the tests. 6592 * The analysis context to pass in to all libraries created by the tests.
6596 */ 6593 */
6597 InternalAnalysisContext _analysisContext; 6594 InternalAnalysisContext _analysisContext;
6598 6595
6599 /** 6596 /**
6600 * The library used by the tests. 6597 * The library used by the tests.
6601 */ 6598 */
6602 Library _library; 6599 Library _library;
6603 6600
6604 @override
6605 void setUp() { 6601 void setUp() {
6606 _analysisContext = AnalysisContextFactory.contextWithCore(); 6602 _analysisContext = AnalysisContextFactory.contextWithCore();
6607 _errorListener = new GatheringErrorListener(); 6603 _errorListener = new GatheringErrorListener();
6608 _library = _createLibrary("/lib.dart"); 6604 _library = _createLibrary("/lib.dart");
6609 } 6605 }
6610 6606
6611 @override
6612 void tearDown() { 6607 void tearDown() {
6613 _errorListener = null; 6608 _errorListener = null;
6614 _analysisContext = null; 6609 _analysisContext = null;
6615 _library = null; 6610 _library = null;
6616 super.tearDown();
6617 } 6611 }
6618 6612
6619 void test_getExplicitlyImportsCore() { 6613 void test_getExplicitlyImportsCore() {
6620 expect(_library.explicitlyImportsCore, isFalse); 6614 expect(_library.explicitlyImportsCore, isFalse);
6621 _errorListener.assertNoErrors(); 6615 _errorListener.assertNoErrors();
6622 } 6616 }
6623 6617
6624 void test_getExports() { 6618 void test_getExports() {
6625 expect(_library.exports, hasLength(0)); 6619 expect(_library.exports, hasLength(0));
6626 _errorListener.assertNoErrors(); 6620 _errorListener.assertNoErrors();
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after
8414 8408
8415 void resolveWithErrors(List<String> strSources, List<ErrorCode> codes) { 8409 void resolveWithErrors(List<String> strSources, List<ErrorCode> codes) {
8416 // Analysis and assertions 8410 // Analysis and assertions
8417 Source source = resolveSources(strSources); 8411 Source source = resolveSources(strSources);
8418 assertErrors(source, codes); 8412 assertErrors(source, codes);
8419 verify([source]); 8413 verify([source]);
8420 } 8414 }
8421 8415
8422 @override 8416 @override
8423 void setUp() { 8417 void setUp() {
8418 super.setUp();
8424 reset(); 8419 reset();
8425 } 8420 }
8426 8421
8427 @override 8422 @override
8428 void tearDown() { 8423 void tearDown() {
8429 analysisContext2 = null; 8424 analysisContext2 = null;
8430 super.tearDown(); 8425 super.tearDown();
8431 } 8426 }
8432 8427
8433 /** 8428 /**
(...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after
10350 _listener.assertNoErrors(); 10345 _listener.assertNoErrors();
10351 } 10346 }
10352 10347
10353 void fail_visitSimpleIdentifier() { 10348 void fail_visitSimpleIdentifier() {
10354 fail("Not yet tested"); 10349 fail("Not yet tested");
10355 _listener.assertNoErrors(); 10350 _listener.assertNoErrors();
10356 } 10351 }
10357 10352
10358 @override 10353 @override
10359 void setUp() { 10354 void setUp() {
10355 super.setUp();
10360 _listener = new GatheringErrorListener(); 10356 _listener = new GatheringErrorListener();
10361 _typeProvider = new TestTypeProvider(); 10357 _typeProvider = new TestTypeProvider();
10362 _analyzer = _createAnalyzer(); 10358 _analyzer = _createAnalyzer();
10363 } 10359 }
10364 10360
10365 void test_flatten_derived() { 10361 void test_flatten_derived() {
10366 // class Derived<T> extends Future<T> { ... } 10362 // class Derived<T> extends Future<T> { ... }
10367 ClassElementImpl derivedClass = 10363 ClassElementImpl derivedClass =
10368 ElementFactory.classElement2('Derived', ['T']); 10364 ElementFactory.classElement2('Derived', ['T']);
10369 derivedClass.supertype = _typeProvider.futureType 10365 derivedClass.supertype = _typeProvider.futureType
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after
12620 v; // marker 12616 v; // marker
12621 } 12617 }
12622 int x = 3; 12618 int x = 3;
12623 '''; 12619 ''';
12624 _assertPropagatedAssignedType(code, typeProvider.intType, null); 12620 _assertPropagatedAssignedType(code, typeProvider.intType, null);
12625 _assertTypeOfMarkedExpression(code, typeProvider.intType, null); 12621 _assertTypeOfMarkedExpression(code, typeProvider.intType, null);
12626 } 12622 }
12627 } 12623 }
12628 12624
12629 @reflectiveTest 12625 @reflectiveTest
12630 class SubtypeManagerTest extends EngineTestCase { 12626 class SubtypeManagerTest {
12631 /** 12627 /**
12632 * The inheritance manager being tested. 12628 * The inheritance manager being tested.
12633 */ 12629 */
12634 SubtypeManager _subtypeManager; 12630 SubtypeManager _subtypeManager;
12635 12631
12636 /** 12632 /**
12637 * The compilation unit element containing all of the types setup in each test . 12633 * The compilation unit element containing all of the types setup in each test .
12638 */ 12634 */
12639 CompilationUnitElementImpl _definingCompilationUnit; 12635 CompilationUnitElementImpl _definingCompilationUnit;
12640 12636
12641 @override
12642 void setUp() { 12637 void setUp() {
12643 super.setUp();
12644 AnalysisContext context = AnalysisContextFactory.contextWithCore(); 12638 AnalysisContext context = AnalysisContextFactory.contextWithCore();
12645 FileBasedSource source = 12639 FileBasedSource source =
12646 new FileBasedSource(FileUtilities2.createFile("/test.dart")); 12640 new FileBasedSource(FileUtilities2.createFile("/test.dart"));
12647 _definingCompilationUnit = new CompilationUnitElementImpl("test.dart"); 12641 _definingCompilationUnit = new CompilationUnitElementImpl("test.dart");
12648 _definingCompilationUnit.librarySource = 12642 _definingCompilationUnit.librarySource =
12649 _definingCompilationUnit.source = source; 12643 _definingCompilationUnit.source = source;
12650 LibraryElementImpl definingLibrary = 12644 LibraryElementImpl definingLibrary =
12651 ElementFactory.library(context, "test"); 12645 ElementFactory.library(context, "test");
12652 definingLibrary.definingCompilationUnit = _definingCompilationUnit; 12646 definingLibrary.definingCompilationUnit = _definingCompilationUnit;
12653 _subtypeManager = new SubtypeManager(); 12647 _subtypeManager = new SubtypeManager();
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
14486 } 14480 }
14487 element.typeParameters = typeParameters; 14481 element.typeParameters = typeParameters;
14488 type.typeArguments = typeArguments; 14482 type.typeArguments = typeArguments;
14489 } 14483 }
14490 } 14484 }
14491 return element; 14485 return element;
14492 } 14486 }
14493 } 14487 }
14494 14488
14495 @reflectiveTest 14489 @reflectiveTest
14496 class TypeResolverVisitorTest extends EngineTestCase { 14490 class TypeResolverVisitorTest {
14497 /** 14491 /**
14498 * The error listener to which errors will be reported. 14492 * The error listener to which errors will be reported.
14499 */ 14493 */
14500 GatheringErrorListener _listener; 14494 GatheringErrorListener _listener;
14501 14495
14502 /** 14496 /**
14503 * The object representing the information about the library in which the type s are being 14497 * The object representing the information about the library in which the type s are being
14504 * resolved. 14498 * resolved.
14505 */ 14499 */
14506 Library _library; 14500 Library _library;
(...skipping 21 matching lines...) Expand all
14528 void fail_visitVariableDeclaration() { 14522 void fail_visitVariableDeclaration() {
14529 fail("Not yet tested"); 14523 fail("Not yet tested");
14530 ClassElement type = ElementFactory.classElement2("A"); 14524 ClassElement type = ElementFactory.classElement2("A");
14531 VariableDeclaration node = AstFactory.variableDeclaration("a"); 14525 VariableDeclaration node = AstFactory.variableDeclaration("a");
14532 AstFactory.variableDeclarationList(null, AstFactory.typeName(type), [node]); 14526 AstFactory.variableDeclarationList(null, AstFactory.typeName(type), [node]);
14533 //resolve(node); 14527 //resolve(node);
14534 expect(node.name.staticType, same(type.type)); 14528 expect(node.name.staticType, same(type.type));
14535 _listener.assertNoErrors(); 14529 _listener.assertNoErrors();
14536 } 14530 }
14537 14531
14538 @override
14539 void setUp() { 14532 void setUp() {
14540 _listener = new GatheringErrorListener(); 14533 _listener = new GatheringErrorListener();
14541 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); 14534 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
14542 Source librarySource = 14535 Source librarySource =
14543 new FileBasedSource(FileUtilities2.createFile("/lib.dart")); 14536 new FileBasedSource(FileUtilities2.createFile("/lib.dart"));
14544 _library = new Library(context, _listener, librarySource); 14537 _library = new Library(context, _listener, librarySource);
14545 LibraryElementImpl element = new LibraryElementImpl.forNode( 14538 LibraryElementImpl element = new LibraryElementImpl.forNode(
14546 context, AstFactory.libraryIdentifier2(["lib"])); 14539 context, AstFactory.libraryIdentifier2(["lib"]));
14547 element.definingCompilationUnit = 14540 element.definingCompilationUnit =
14548 new CompilationUnitElementImpl("lib.dart"); 14541 new CompilationUnitElementImpl("lib.dart");
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
15193 15186
15194 void _resolveTestUnit(String code) { 15187 void _resolveTestUnit(String code) {
15195 testCode = code; 15188 testCode = code;
15196 testSource = addSource(testCode); 15189 testSource = addSource(testCode);
15197 LibraryElement library = resolve2(testSource); 15190 LibraryElement library = resolve2(testSource);
15198 assertNoErrors(testSource); 15191 assertNoErrors(testSource);
15199 verify([testSource]); 15192 verify([testSource]);
15200 testUnit = resolveCompilationUnit(testSource, library); 15193 testUnit = resolveCompilationUnit(testSource, library);
15201 } 15194 }
15202 } 15195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698