| OLD | NEW |
| 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 analyzer.test.generated.all_the_rest_test; | 5 library analyzer.test.generated.all_the_rest_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| 11 import 'package:analyzer/error/error.dart'; | 11 import 'package:analyzer/error/error.dart'; |
| 12 import 'package:analyzer/error/listener.dart'; | 12 import 'package:analyzer/error/listener.dart'; |
| 13 import 'package:analyzer/file_system/file_system.dart'; | 13 import 'package:analyzer/file_system/file_system.dart'; |
| 14 import 'package:analyzer/file_system/memory_file_system.dart'; | 14 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 15 import 'package:analyzer/file_system/physical_file_system.dart'; | 15 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 16 import 'package:analyzer/src/dart/ast/utilities.dart' hide ConstantEvaluator; | 16 import 'package:analyzer/src/dart/ast/utilities.dart' hide ConstantEvaluator; |
| 17 import 'package:analyzer/src/dart/element/builder.dart'; | 17 import 'package:analyzer/src/dart/element/builder.dart'; |
| 18 import 'package:analyzer/src/dart/element/element.dart'; | 18 import 'package:analyzer/src/dart/element/element.dart'; |
| 19 import 'package:analyzer/src/dart/sdk/sdk.dart' hide SdkLibrariesReader; | 19 import 'package:analyzer/src/dart/sdk/sdk.dart' hide SdkLibrariesReader; |
| 20 import 'package:analyzer/src/error/codes.dart'; | 20 import 'package:analyzer/src/error/codes.dart'; |
| 21 import 'package:analyzer/src/generated/engine.dart'; | 21 import 'package:analyzer/src/generated/engine.dart'; |
| 22 import 'package:analyzer/src/generated/java_engine_io.dart'; | 22 import 'package:analyzer/src/generated/java_engine_io.dart'; |
| 23 import 'package:analyzer/src/generated/java_io.dart'; | 23 import 'package:analyzer/src/generated/java_io.dart'; |
| 24 import 'package:analyzer/src/generated/resolver.dart'; | 24 import 'package:analyzer/src/generated/resolver.dart'; |
| 25 import 'package:analyzer/src/generated/sdk.dart'; | 25 import 'package:analyzer/src/generated/sdk.dart'; |
| 26 import 'package:analyzer/src/generated/sdk_io.dart'; | 26 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 27 import 'package:analyzer/src/generated/source.dart'; | 27 import 'package:analyzer/src/generated/source.dart'; |
| 28 import 'package:analyzer/src/generated/source_io.dart'; | 28 import 'package:analyzer/src/generated/source_io.dart'; |
| 29 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 29 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
| 30 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 30 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 31 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; | 31 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| 32 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 32 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| 33 import 'package:analyzer/src/generated/utilities_dart.dart'; | 33 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 34 import 'package:analyzer/src/source/source_resource.dart'; | 34 import 'package:analyzer/src/source/source_resource.dart'; |
| 35 import 'package:path/path.dart' as path; | 35 import 'package:path/path.dart' as path; |
| 36 import 'package:source_span/source_span.dart'; | 36 import 'package:source_span/source_span.dart'; |
| 37 import 'package:test/test.dart'; | 37 import 'package:test/test.dart'; |
| 38 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 38 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 39 | 39 |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 void main() { | 552 void main() { |
| 553 new A(); | 553 new A(); |
| 554 }'''); | 554 }'''); |
| 555 Element element = ElementLocator.locate(node); | 555 Element element = ElementLocator.locate(node); |
| 556 EngineTestCase.assertInstanceOf( | 556 EngineTestCase.assertInstanceOf( |
| 557 (obj) => obj is ConstructorElement, ConstructorElement, element); | 557 (obj) => obj is ConstructorElement, ConstructorElement, element); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void test_locate_InstanceCreationExpression_type_prefixedIdentifier() { | 560 void test_locate_InstanceCreationExpression_type_prefixedIdentifier() { |
| 561 // prepare: new pref.A() | 561 // prepare: new pref.A() |
| 562 SimpleIdentifier identifier = AstFactory.identifier3("A"); | 562 SimpleIdentifier identifier = AstTestFactory.identifier3("A"); |
| 563 PrefixedIdentifier prefixedIdentifier = | 563 PrefixedIdentifier prefixedIdentifier = |
| 564 AstFactory.identifier4("pref", identifier); | 564 AstTestFactory.identifier4("pref", identifier); |
| 565 InstanceCreationExpression creation = | 565 InstanceCreationExpression creation = |
| 566 AstFactory.instanceCreationExpression2( | 566 AstTestFactory.instanceCreationExpression2( |
| 567 Keyword.NEW, AstFactory.typeName3(prefixedIdentifier)); | 567 Keyword.NEW, AstTestFactory.typeName3(prefixedIdentifier)); |
| 568 // set ClassElement | 568 // set ClassElement |
| 569 ClassElement classElement = ElementFactory.classElement2("A"); | 569 ClassElement classElement = ElementFactory.classElement2("A"); |
| 570 identifier.staticElement = classElement; | 570 identifier.staticElement = classElement; |
| 571 // set ConstructorElement | 571 // set ConstructorElement |
| 572 ConstructorElement constructorElement = | 572 ConstructorElement constructorElement = |
| 573 ElementFactory.constructorElement2(classElement, null); | 573 ElementFactory.constructorElement2(classElement, null); |
| 574 creation.constructorName.staticElement = constructorElement; | 574 creation.constructorName.staticElement = constructorElement; |
| 575 // verify that "A" is resolved to ConstructorElement | 575 // verify that "A" is resolved to ConstructorElement |
| 576 Element element = ElementLocator.locate(identifier); | 576 Element element = ElementLocator.locate(identifier); |
| 577 expect(element, same(classElement)); | 577 expect(element, same(classElement)); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void test_locate_InstanceCreationExpression_type_simpleIdentifier() { | 580 void test_locate_InstanceCreationExpression_type_simpleIdentifier() { |
| 581 // prepare: new A() | 581 // prepare: new A() |
| 582 SimpleIdentifier identifier = AstFactory.identifier3("A"); | 582 SimpleIdentifier identifier = AstTestFactory.identifier3("A"); |
| 583 InstanceCreationExpression creation = | 583 InstanceCreationExpression creation = |
| 584 AstFactory.instanceCreationExpression2( | 584 AstTestFactory.instanceCreationExpression2( |
| 585 Keyword.NEW, AstFactory.typeName3(identifier)); | 585 Keyword.NEW, AstTestFactory.typeName3(identifier)); |
| 586 // set ClassElement | 586 // set ClassElement |
| 587 ClassElement classElement = ElementFactory.classElement2("A"); | 587 ClassElement classElement = ElementFactory.classElement2("A"); |
| 588 identifier.staticElement = classElement; | 588 identifier.staticElement = classElement; |
| 589 // set ConstructorElement | 589 // set ConstructorElement |
| 590 ConstructorElement constructorElement = | 590 ConstructorElement constructorElement = |
| 591 ElementFactory.constructorElement2(classElement, null); | 591 ElementFactory.constructorElement2(classElement, null); |
| 592 creation.constructorName.staticElement = constructorElement; | 592 creation.constructorName.staticElement = constructorElement; |
| 593 // verify that "A" is resolved to ConstructorElement | 593 // verify that "A" is resolved to ConstructorElement |
| 594 Element element = ElementLocator.locate(identifier); | 594 Element element = ElementLocator.locate(identifier); |
| 595 expect(element, same(classElement)); | 595 expect(element, same(classElement)); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 return analysisContext.resolveCompilationUnit(source, library); | 790 return analysisContext.resolveCompilationUnit(source, library); |
| 791 } | 791 } |
| 792 } | 792 } |
| 793 | 793 |
| 794 @reflectiveTest | 794 @reflectiveTest |
| 795 class EnumMemberBuilderTest extends EngineTestCase { | 795 class EnumMemberBuilderTest extends EngineTestCase { |
| 796 void test_visitEnumDeclaration_multiple() { | 796 void test_visitEnumDeclaration_multiple() { |
| 797 String firstName = "ONE"; | 797 String firstName = "ONE"; |
| 798 String secondName = "TWO"; | 798 String secondName = "TWO"; |
| 799 String thirdName = "THREE"; | 799 String thirdName = "THREE"; |
| 800 EnumDeclaration enumDeclaration = | 800 EnumDeclaration enumDeclaration = AstTestFactory |
| 801 AstFactory.enumDeclaration2("E", [firstName, secondName, thirdName]); | 801 .enumDeclaration2("E", [firstName, secondName, thirdName]); |
| 802 | 802 |
| 803 ClassElement enumElement = _buildElement(enumDeclaration); | 803 ClassElement enumElement = _buildElement(enumDeclaration); |
| 804 List<FieldElement> fields = enumElement.fields; | 804 List<FieldElement> fields = enumElement.fields; |
| 805 expect(fields, hasLength(5)); | 805 expect(fields, hasLength(5)); |
| 806 | 806 |
| 807 FieldElement constant = fields[2]; | 807 FieldElement constant = fields[2]; |
| 808 expect(constant, isNotNull); | 808 expect(constant, isNotNull); |
| 809 expect(constant.name, firstName); | 809 expect(constant.name, firstName); |
| 810 expect(constant.isStatic, isTrue); | 810 expect(constant.isStatic, isTrue); |
| 811 expect((constant as FieldElementImpl).evaluationResult, isNotNull); | 811 expect((constant as FieldElementImpl).evaluationResult, isNotNull); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 822 expect(constant, isNotNull); | 822 expect(constant, isNotNull); |
| 823 expect(constant.name, thirdName); | 823 expect(constant.name, thirdName); |
| 824 expect(constant.isStatic, isTrue); | 824 expect(constant.isStatic, isTrue); |
| 825 expect((constant as FieldElementImpl).evaluationResult, isNotNull); | 825 expect((constant as FieldElementImpl).evaluationResult, isNotNull); |
| 826 _assertGetter(constant); | 826 _assertGetter(constant); |
| 827 } | 827 } |
| 828 | 828 |
| 829 void test_visitEnumDeclaration_single() { | 829 void test_visitEnumDeclaration_single() { |
| 830 String firstName = "ONE"; | 830 String firstName = "ONE"; |
| 831 EnumDeclaration enumDeclaration = | 831 EnumDeclaration enumDeclaration = |
| 832 AstFactory.enumDeclaration2("E", [firstName]); | 832 AstTestFactory.enumDeclaration2("E", [firstName]); |
| 833 enumDeclaration.constants[0].documentationComment = AstFactory | 833 enumDeclaration.constants[0].documentationComment = AstTestFactory |
| 834 .documentationComment( | 834 .documentationComment( |
| 835 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 835 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 836 | 836 |
| 837 ClassElement enumElement = _buildElement(enumDeclaration); | 837 ClassElement enumElement = _buildElement(enumDeclaration); |
| 838 List<FieldElement> fields = enumElement.fields; | 838 List<FieldElement> fields = enumElement.fields; |
| 839 expect(fields, hasLength(3)); | 839 expect(fields, hasLength(3)); |
| 840 | 840 |
| 841 FieldElement field = fields[0]; | 841 FieldElement field = fields[0]; |
| 842 expect(field, isNotNull); | 842 expect(field, isNotNull); |
| 843 expect(field.name, "index"); | 843 expect(field.name, "index"); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 } | 960 } |
| 961 | 961 |
| 962 void test_reportTypeErrorForNode_differentNames() { | 962 void test_reportTypeErrorForNode_differentNames() { |
| 963 DartType firstType = createType("/test1.dart", "A"); | 963 DartType firstType = createType("/test1.dart", "A"); |
| 964 DartType secondType = createType("/test2.dart", "B"); | 964 DartType secondType = createType("/test2.dart", "B"); |
| 965 GatheringErrorListener listener = new GatheringErrorListener(); | 965 GatheringErrorListener listener = new GatheringErrorListener(); |
| 966 ErrorReporter reporter = | 966 ErrorReporter reporter = |
| 967 new ErrorReporter(listener, firstType.element.source); | 967 new ErrorReporter(listener, firstType.element.source); |
| 968 reporter.reportTypeErrorForNode( | 968 reporter.reportTypeErrorForNode( |
| 969 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, | 969 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, |
| 970 AstFactory.identifier3("x"), | 970 AstTestFactory.identifier3("x"), |
| 971 [firstType, secondType]); | 971 [firstType, secondType]); |
| 972 AnalysisError error = listener.errors[0]; | 972 AnalysisError error = listener.errors[0]; |
| 973 expect(error.message.indexOf("(") < 0, isTrue); | 973 expect(error.message.indexOf("(") < 0, isTrue); |
| 974 } | 974 } |
| 975 | 975 |
| 976 void test_reportTypeErrorForNode_sameName() { | 976 void test_reportTypeErrorForNode_sameName() { |
| 977 String typeName = "A"; | 977 String typeName = "A"; |
| 978 DartType firstType = createType("/test1.dart", typeName); | 978 DartType firstType = createType("/test1.dart", typeName); |
| 979 DartType secondType = createType("/test2.dart", typeName); | 979 DartType secondType = createType("/test2.dart", typeName); |
| 980 GatheringErrorListener listener = new GatheringErrorListener(); | 980 GatheringErrorListener listener = new GatheringErrorListener(); |
| 981 ErrorReporter reporter = | 981 ErrorReporter reporter = |
| 982 new ErrorReporter(listener, firstType.element.source); | 982 new ErrorReporter(listener, firstType.element.source); |
| 983 reporter.reportTypeErrorForNode( | 983 reporter.reportTypeErrorForNode( |
| 984 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, | 984 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, |
| 985 AstFactory.identifier3("x"), | 985 AstTestFactory.identifier3("x"), |
| 986 [firstType, secondType]); | 986 [firstType, secondType]); |
| 987 AnalysisError error = listener.errors[0]; | 987 AnalysisError error = listener.errors[0]; |
| 988 expect(error.message.indexOf("(") >= 0, isTrue); | 988 expect(error.message.indexOf("(") >= 0, isTrue); |
| 989 } | 989 } |
| 990 } | 990 } |
| 991 | 991 |
| 992 @reflectiveTest | 992 @reflectiveTest |
| 993 class ErrorSeverityTest extends EngineTestCase { | 993 class ErrorSeverityTest extends EngineTestCase { |
| 994 void test_max_error_error() { | 994 void test_max_error_error() { |
| 995 expect(ErrorSeverity.ERROR.max(ErrorSeverity.ERROR), | 995 expect(ErrorSeverity.ERROR.max(ErrorSeverity.ERROR), |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2269 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); | 2269 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); |
| 2270 expect(UriKind.fromEncoding(0x58), same(null)); | 2270 expect(UriKind.fromEncoding(0x58), same(null)); |
| 2271 } | 2271 } |
| 2272 | 2272 |
| 2273 void test_getEncoding() { | 2273 void test_getEncoding() { |
| 2274 expect(UriKind.DART_URI.encoding, 0x64); | 2274 expect(UriKind.DART_URI.encoding, 0x64); |
| 2275 expect(UriKind.FILE_URI.encoding, 0x66); | 2275 expect(UriKind.FILE_URI.encoding, 0x66); |
| 2276 expect(UriKind.PACKAGE_URI.encoding, 0x70); | 2276 expect(UriKind.PACKAGE_URI.encoding, 0x70); |
| 2277 } | 2277 } |
| 2278 } | 2278 } |
| OLD | NEW |