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

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

Issue 19590006: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 'dart:collection'; 4 import 'dart:collection';
5 import 'package:analyzer_experimental/src/generated/java_core.dart'; 5 import 'package:analyzer_experimental/src/generated/java_core.dart';
6 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 6 import 'package:analyzer_experimental/src/generated/java_engine.dart';
7 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 7 import 'package:analyzer_experimental/src/generated/java_junit.dart';
8 import 'package:analyzer_experimental/src/generated/source_io.dart'; 8 import 'package:analyzer_experimental/src/generated/source_io.dart';
9 import 'package:analyzer_experimental/src/generated/error.dart'; 9 import 'package:analyzer_experimental/src/generated/error.dart';
10 import 'package:analyzer_experimental/src/generated/scanner.dart'; 10 import 'package:analyzer_experimental/src/generated/scanner.dart';
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 resolve(source); 2135 resolve(source);
2136 assertNoErrors(); 2136 assertNoErrors();
2137 verify([source]); 2137 verify([source]);
2138 } 2138 }
2139 void test_newWithUndefinedConstructorDefault() { 2139 void test_newWithUndefinedConstructorDefault() {
2140 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A();", "}"])); 2140 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A();", "}"]));
2141 resolve(source); 2141 resolve(source);
2142 assertNoErrors(); 2142 assertNoErrors();
2143 verify([source]); 2143 verify([source]);
2144 } 2144 }
2145 void test_nonBoolExpression_assert_bool() { 2145 void test_nonBoolExpression_functionType() {
2146 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr ue);", "}"]));
2147 resolve(source);
2148 assertNoErrors();
2149 verify([source]);
2150 }
2151 void test_nonBoolExpression_assert_functionType() {
2152 Source source = addSource(EngineTestCase.createSource([ 2146 Source source = addSource(EngineTestCase.createSource([
2153 "bool makeAssertion() => true;", 2147 "bool makeAssertion() => true;",
2154 "f() {", 2148 "f() {",
2155 " assert(makeAssertion);", 2149 " assert(makeAssertion);",
2156 "}"])); 2150 "}"]));
2157 resolve(source); 2151 resolve(source);
2158 assertNoErrors(); 2152 assertNoErrors();
2159 verify([source]); 2153 verify([source]);
2160 } 2154 }
2155 void test_nonBoolExpression_interfaceType() {
2156 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(tr ue);", "}"]));
2157 resolve(source);
2158 assertNoErrors();
2159 verify([source]);
2160 }
2161 void test_nonConstantDefaultValue_function_named() { 2161 void test_nonConstantDefaultValue_function_named() {
2162 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"]) ); 2162 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"]) );
2163 resolve(source); 2163 resolve(source);
2164 assertNoErrors(); 2164 assertNoErrors();
2165 verify([source]); 2165 verify([source]);
2166 } 2166 }
2167 void test_nonConstantDefaultValue_function_positional() { 2167 void test_nonConstantDefaultValue_function_positional() {
2168 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"]) ); 2168 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"]) );
2169 resolve(source); 2169 resolve(source);
2170 assertNoErrors(); 2170 assertNoErrors();
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
3520 runJUnitTest(__test, __test.test_newWithAbstractClass_factory); 3520 runJUnitTest(__test, __test.test_newWithAbstractClass_factory);
3521 }); 3521 });
3522 _ut.test('test_newWithUndefinedConstructor', () { 3522 _ut.test('test_newWithUndefinedConstructor', () {
3523 final __test = new NonErrorResolverTest(); 3523 final __test = new NonErrorResolverTest();
3524 runJUnitTest(__test, __test.test_newWithUndefinedConstructor); 3524 runJUnitTest(__test, __test.test_newWithUndefinedConstructor);
3525 }); 3525 });
3526 _ut.test('test_newWithUndefinedConstructorDefault', () { 3526 _ut.test('test_newWithUndefinedConstructorDefault', () {
3527 final __test = new NonErrorResolverTest(); 3527 final __test = new NonErrorResolverTest();
3528 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault); 3528 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault);
3529 }); 3529 });
3530 _ut.test('test_nonBoolExpression_assert_bool', () { 3530 _ut.test('test_nonBoolExpression_functionType', () {
3531 final __test = new NonErrorResolverTest(); 3531 final __test = new NonErrorResolverTest();
3532 runJUnitTest(__test, __test.test_nonBoolExpression_assert_bool); 3532 runJUnitTest(__test, __test.test_nonBoolExpression_functionType);
3533 }); 3533 });
3534 _ut.test('test_nonBoolExpression_assert_functionType', () { 3534 _ut.test('test_nonBoolExpression_interfaceType', () {
3535 final __test = new NonErrorResolverTest(); 3535 final __test = new NonErrorResolverTest();
3536 runJUnitTest(__test, __test.test_nonBoolExpression_assert_functionType); 3536 runJUnitTest(__test, __test.test_nonBoolExpression_interfaceType);
3537 }); 3537 });
3538 _ut.test('test_nonConstCaseExpression', () { 3538 _ut.test('test_nonConstCaseExpression', () {
3539 final __test = new NonErrorResolverTest(); 3539 final __test = new NonErrorResolverTest();
3540 runJUnitTest(__test, __test.test_nonConstCaseExpression); 3540 runJUnitTest(__test, __test.test_nonConstCaseExpression);
3541 }); 3541 });
3542 _ut.test('test_nonConstMapAsExpressionStatement_const', () { 3542 _ut.test('test_nonConstMapAsExpressionStatement_const', () {
3543 final __test = new NonErrorResolverTest(); 3543 final __test = new NonErrorResolverTest();
3544 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_const) ; 3544 runJUnitTest(__test, __test.test_nonConstMapAsExpressionStatement_const) ;
3545 }); 3545 });
3546 _ut.test('test_nonConstMapAsExpressionStatement_notExpressionStatement', ( ) { 3546 _ut.test('test_nonConstMapAsExpressionStatement_notExpressionStatement', ( ) {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
3994 }); 3994 });
3995 } 3995 }
3996 } 3996 }
3997 class StaticTypeWarningCodeTest extends ResolverTestCase { 3997 class StaticTypeWarningCodeTest extends ResolverTestCase {
3998 void fail_inaccessibleSetter() { 3998 void fail_inaccessibleSetter() {
3999 Source source = addSource(EngineTestCase.createSource([])); 3999 Source source = addSource(EngineTestCase.createSource([]));
4000 resolve(source); 4000 resolve(source);
4001 assertErrors([StaticTypeWarningCode.INACCESSIBLE_SETTER]); 4001 assertErrors([StaticTypeWarningCode.INACCESSIBLE_SETTER]);
4002 verify([source]); 4002 verify([source]);
4003 } 4003 }
4004 void fail_invocationOfNonFunction_staticInSuperclass() {
4005 Source source = addSource(EngineTestCase.createSource([
4006 "class A {",
4007 " static void a() {}",
4008 "}",
4009 "",
4010 "class B extends A {",
4011 " void b() { a(); }",
4012 "}"]));
4013 resolve(source);
4014 assertErrors([StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION]);
4015 verify([source]);
4016 }
4004 void test_inconsistentMethodInheritance_paramCount() { 4017 void test_inconsistentMethodInheritance_paramCount() {
4005 Source source = addSource(EngineTestCase.createSource([ 4018 Source source = addSource(EngineTestCase.createSource([
4006 "abstract class A {", 4019 "abstract class A {",
4007 " int x();", 4020 " int x();",
4008 "}", 4021 "}",
4009 "abstract class B {", 4022 "abstract class B {",
4010 " int x(int y);", 4023 " int x(int y);",
4011 "}", 4024 "}",
4012 "class C implements A, B {", 4025 "class C implements A, B {",
4013 "}"])); 4026 "}"]));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
4166 resolve(source); 4179 resolve(source);
4167 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); 4180 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
4168 verify([source]); 4181 verify([source]);
4169 } 4182 }
4170 void test_nonBoolCondition_while() { 4183 void test_nonBoolCondition_while() {
4171 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3) {}", "}"])); 4184 Source source = addSource(EngineTestCase.createSource(["f() {", " while (3) {}", "}"]));
4172 resolve(source); 4185 resolve(source);
4173 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); 4186 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
4174 verify([source]); 4187 verify([source]);
4175 } 4188 }
4176 void test_nonBoolExpression() { 4189 void test_nonBoolExpression_functionType() {
4190 Source source = addSource(EngineTestCase.createSource([
4191 "int makeAssertion() => 1;",
4192 "f() {",
4193 " assert(makeAssertion);",
4194 "}"]));
4195 resolve(source);
4196 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
4197 verify([source]);
4198 }
4199 void test_nonBoolExpression_interfaceType() {
4177 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"])); 4200 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"]));
4178 resolve(source); 4201 resolve(source);
4179 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]); 4202 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
4180 verify([source]); 4203 verify([source]);
4181 } 4204 }
4182 void test_nonTypeAsTypeArgument_notAType() { 4205 void test_nonTypeAsTypeArgument_notAType() {
4183 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"])); 4206 Source source = addSource(EngineTestCase.createSource(["int A;", "class B<E> {}", "f(B<A> b) {}"]));
4184 resolve(source); 4207 resolve(source);
4185 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]); 4208 assertErrors([StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT]);
4186 verify([source]); 4209 verify([source]);
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
4617 runJUnitTest(__test, __test.test_nonBoolCondition_do); 4640 runJUnitTest(__test, __test.test_nonBoolCondition_do);
4618 }); 4641 });
4619 _ut.test('test_nonBoolCondition_if', () { 4642 _ut.test('test_nonBoolCondition_if', () {
4620 final __test = new StaticTypeWarningCodeTest(); 4643 final __test = new StaticTypeWarningCodeTest();
4621 runJUnitTest(__test, __test.test_nonBoolCondition_if); 4644 runJUnitTest(__test, __test.test_nonBoolCondition_if);
4622 }); 4645 });
4623 _ut.test('test_nonBoolCondition_while', () { 4646 _ut.test('test_nonBoolCondition_while', () {
4624 final __test = new StaticTypeWarningCodeTest(); 4647 final __test = new StaticTypeWarningCodeTest();
4625 runJUnitTest(__test, __test.test_nonBoolCondition_while); 4648 runJUnitTest(__test, __test.test_nonBoolCondition_while);
4626 }); 4649 });
4627 _ut.test('test_nonBoolExpression', () { 4650 _ut.test('test_nonBoolExpression_functionType', () {
4628 final __test = new StaticTypeWarningCodeTest(); 4651 final __test = new StaticTypeWarningCodeTest();
4629 runJUnitTest(__test, __test.test_nonBoolExpression); 4652 runJUnitTest(__test, __test.test_nonBoolExpression_functionType);
4653 });
4654 _ut.test('test_nonBoolExpression_interfaceType', () {
4655 final __test = new StaticTypeWarningCodeTest();
4656 runJUnitTest(__test, __test.test_nonBoolExpression_interfaceType);
4630 }); 4657 });
4631 _ut.test('test_nonTypeAsTypeArgument_notAType', () { 4658 _ut.test('test_nonTypeAsTypeArgument_notAType', () {
4632 final __test = new StaticTypeWarningCodeTest(); 4659 final __test = new StaticTypeWarningCodeTest();
4633 runJUnitTest(__test, __test.test_nonTypeAsTypeArgument_notAType); 4660 runJUnitTest(__test, __test.test_nonTypeAsTypeArgument_notAType);
4634 }); 4661 });
4635 _ut.test('test_nonTypeAsTypeArgument_undefinedIdentifier', () { 4662 _ut.test('test_nonTypeAsTypeArgument_undefinedIdentifier', () {
4636 final __test = new StaticTypeWarningCodeTest(); 4663 final __test = new StaticTypeWarningCodeTest();
4637 runJUnitTest(__test, __test.test_nonTypeAsTypeArgument_undefinedIdentifi er); 4664 runJUnitTest(__test, __test.test_nonTypeAsTypeArgument_undefinedIdentifi er);
4638 }); 4665 });
4639 _ut.test('test_returnOfInvalidType_expressionFunctionBody_function', () { 4666 _ut.test('test_returnOfInvalidType_expressionFunctionBody_function', () {
(...skipping 2808 matching lines...) Expand 10 before | Expand all | Expand 10 after
7448 resolve(source); 7475 resolve(source);
7449 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]); 7476 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
7450 verify([source]); 7477 verify([source]);
7451 } 7478 }
7452 void test_initializingFormalForNonExistantField_optional() { 7479 void test_initializingFormalForNonExistantField_optional() {
7453 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th is.x]) {}", "}"])); 7480 Source source = addSource(EngineTestCase.createSource(["class A {", " A([th is.x]) {}", "}"]));
7454 resolve(source); 7481 resolve(source);
7455 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]); 7482 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
7456 verify([source]); 7483 verify([source]);
7457 } 7484 }
7458 void test_initializingFormalForNonExistantField_static() { 7485 void test_initializingFormalForNonExistantField_synthetic() {
7486 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et x => 1;", " A(this.x) {}", "}"]));
7487 resolve(source);
7488 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTANT_FIEL D]);
7489 verify([source]);
7490 }
7491 void test_initializingFormalForStaticField() {
7459 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " A([this.x]) {}", "}"])); 7492 Source source = addSource(EngineTestCase.createSource(["class A {", " stati c int x;", " A([this.x]) {}", "}"]));
7460 resolve(source); 7493 resolve(source);
7461 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]); 7494 assertErrors([CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD]);
7462 verify([source]); 7495 verify([source]);
7463 } 7496 }
7464 void test_instanceMemberAccessFromStatic_field() { 7497 void test_instanceMemberAccessFromStatic_field() {
7465 Source source = addSource(EngineTestCase.createSource([ 7498 Source source = addSource(EngineTestCase.createSource([
7466 "class A {", 7499 "class A {",
7467 " int f;", 7500 " int f;",
7468 " static foo() {", 7501 " static foo() {",
(...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
9380 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField); 9413 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField);
9381 }); 9414 });
9382 _ut.test('test_initializingFormalForNonExistantField_notInEnclosingClass', () { 9415 _ut.test('test_initializingFormalForNonExistantField_notInEnclosingClass', () {
9383 final __test = new CompileTimeErrorCodeTest(); 9416 final __test = new CompileTimeErrorCodeTest();
9384 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass); 9417 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_n otInEnclosingClass);
9385 }); 9418 });
9386 _ut.test('test_initializingFormalForNonExistantField_optional', () { 9419 _ut.test('test_initializingFormalForNonExistantField_optional', () {
9387 final __test = new CompileTimeErrorCodeTest(); 9420 final __test = new CompileTimeErrorCodeTest();
9388 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_o ptional); 9421 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_o ptional);
9389 }); 9422 });
9390 _ut.test('test_initializingFormalForNonExistantField_static', () { 9423 _ut.test('test_initializingFormalForNonExistantField_synthetic', () {
9391 final __test = new CompileTimeErrorCodeTest(); 9424 final __test = new CompileTimeErrorCodeTest();
9392 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_s tatic); 9425 runJUnitTest(__test, __test.test_initializingFormalForNonExistantField_s ynthetic);
9426 });
9427 _ut.test('test_initializingFormalForStaticField', () {
9428 final __test = new CompileTimeErrorCodeTest();
9429 runJUnitTest(__test, __test.test_initializingFormalForStaticField);
9393 }); 9430 });
9394 _ut.test('test_instanceMemberAccessFromStatic_field', () { 9431 _ut.test('test_instanceMemberAccessFromStatic_field', () {
9395 final __test = new CompileTimeErrorCodeTest(); 9432 final __test = new CompileTimeErrorCodeTest();
9396 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_field); 9433 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_field);
9397 }); 9434 });
9398 _ut.test('test_instanceMemberAccessFromStatic_getter', () { 9435 _ut.test('test_instanceMemberAccessFromStatic_getter', () {
9399 final __test = new CompileTimeErrorCodeTest(); 9436 final __test = new CompileTimeErrorCodeTest();
9400 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_getter); 9437 runJUnitTest(__test, __test.test_instanceMemberAccessFromStatic_getter);
9401 }); 9438 });
9402 _ut.test('test_instanceMemberAccessFromStatic_method', () { 9439 _ut.test('test_instanceMemberAccessFromStatic_method', () {
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
10039 * structure that should have a static type associated with them do have a stati c type. 10076 * structure that should have a static type associated with them do have a stati c type.
10040 */ 10077 */
10041 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> { 10078 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> {
10042 10079
10043 /** 10080 /**
10044 * A list containing all of the AST Expression nodes that were not resolved. 10081 * A list containing all of the AST Expression nodes that were not resolved.
10045 */ 10082 */
10046 List<Expression> _unresolvedExpressions = new List<Expression>(); 10083 List<Expression> _unresolvedExpressions = new List<Expression>();
10047 10084
10048 /** 10085 /**
10086 * A list containing all of the AST Expression nodes for which a propagated ty pe was computed but
10087 * where that type was not more specific than the static type.
10088 */
10089 List<Expression> _invalidlyPropagatedExpressions = new List<Expression>();
10090
10091 /**
10049 * A list containing all of the AST TypeName nodes that were not resolved. 10092 * A list containing all of the AST TypeName nodes that were not resolved.
10050 */ 10093 */
10051 List<TypeName> _unresolvedTypes = new List<TypeName>(); 10094 List<TypeName> _unresolvedTypes = new List<TypeName>();
10052 10095
10053 /** 10096 /**
10054 * Counter for the number of Expression nodes visited that are resolved. 10097 * Counter for the number of Expression nodes visited that are resolved.
10055 */ 10098 */
10056 int _resolvedExpressionCount = 0; 10099 int _resolvedExpressionCount = 0;
10057 10100
10058 /** 10101 /**
10102 * Counter for the number of Expression nodes visited that have propagated typ e information.
10103 */
10104 int _propagatedExpressionCount = 0;
10105
10106 /**
10059 * Counter for the number of TypeName nodes visited that are resolved. 10107 * Counter for the number of TypeName nodes visited that are resolved.
10060 */ 10108 */
10061 int _resolvedTypeCount = 0; 10109 int _resolvedTypeCount = 0;
10062 10110
10063 /** 10111 /**
10064 * Assert that all of the visited nodes have a static type associated with the m. 10112 * Assert that all of the visited nodes have a static type associated with the m.
10065 */ 10113 */
10066 void assertResolved() { 10114 void assertResolved() {
10067 if (!_unresolvedExpressions.isEmpty || !_unresolvedTypes.isEmpty) { 10115 if (!_unresolvedExpressions.isEmpty || !_unresolvedTypes.isEmpty) {
10068 int unresolvedExpressionCount = _unresolvedExpressions.length; 10116 PrintStringWriter writer = new PrintStringWriter();
10069 int unresolvedTypeCount = _unresolvedTypes.length; 10117 int unresolvedTypeCount = _unresolvedTypes.length;
10070 PrintStringWriter writer = new PrintStringWriter();
10071 writer.print("Failed to associate types with nodes: ");
10072 writer.print(unresolvedExpressionCount);
10073 writer.print("/");
10074 writer.print(_resolvedExpressionCount + unresolvedExpressionCount);
10075 writer.print(" Expressions and ");
10076 writer.print(unresolvedTypeCount);
10077 writer.print("/");
10078 writer.print(_resolvedTypeCount + unresolvedTypeCount);
10079 writer.println(" TypeNames.");
10080 if (unresolvedTypeCount > 0) { 10118 if (unresolvedTypeCount > 0) {
10081 writer.println("TypeNames:"); 10119 writer.print("Failed to resolve ");
10120 writer.print(unresolvedTypeCount);
10121 writer.print(" of ");
10122 writer.print(_resolvedTypeCount + unresolvedTypeCount);
10123 writer.println(" type names:");
10082 for (TypeName identifier in _unresolvedTypes) { 10124 for (TypeName identifier in _unresolvedTypes) {
10083 writer.print(" "); 10125 writer.print(" ");
10084 writer.print(identifier.toString()); 10126 writer.print(identifier.toString());
10085 writer.print(" ("); 10127 writer.print(" (");
10086 writer.print(getFileName(identifier)); 10128 writer.print(getFileName(identifier));
10087 writer.print(" : "); 10129 writer.print(" : ");
10088 writer.print(identifier.offset); 10130 writer.print(identifier.offset);
10089 writer.println(")"); 10131 writer.println(")");
10090 } 10132 }
10091 } 10133 }
10134 int unresolvedExpressionCount = _unresolvedExpressions.length;
10092 if (unresolvedExpressionCount > 0) { 10135 if (unresolvedExpressionCount > 0) {
10093 writer.println("Expressions:"); 10136 writer.println("Failed to resolve ");
10094 for (Expression identifier in _unresolvedExpressions) { 10137 writer.print(unresolvedExpressionCount);
10138 writer.print(" of ");
10139 writer.print(_resolvedExpressionCount + unresolvedExpressionCount);
10140 writer.println(" expressions:");
10141 for (Expression expression in _unresolvedExpressions) {
10095 writer.print(" "); 10142 writer.print(" ");
10096 writer.print(identifier.toString()); 10143 writer.print(expression.toString());
10097 writer.print(" ("); 10144 writer.print(" (");
10098 writer.print(getFileName(identifier)); 10145 writer.print(getFileName(expression));
10099 writer.print(" : "); 10146 writer.print(" : ");
10100 writer.print(identifier.offset); 10147 writer.print(expression.offset);
10101 writer.println(")"); 10148 writer.println(")");
10102 } 10149 }
10103 } 10150 }
10151 int invalidlyPropagatedExpressionCount = _invalidlyPropagatedExpressions.l ength;
10152 if (invalidlyPropagatedExpressionCount > 0) {
10153 writer.println("Incorrectly propagated ");
10154 writer.print(invalidlyPropagatedExpressionCount);
10155 writer.print(" of ");
10156 writer.print(_propagatedExpressionCount);
10157 writer.println(" expressions:");
10158 for (Expression expression in _invalidlyPropagatedExpressions) {
10159 writer.print(" ");
10160 writer.print(expression.toString());
10161 writer.print(" [");
10162 writer.print(expression.staticType.displayName);
10163 writer.print(", ");
10164 writer.print(expression.propagatedType.displayName);
10165 writer.println("]");
10166 writer.print(" ");
10167 writer.print(getFileName(expression));
10168 writer.print(" : ");
10169 writer.print(expression.offset);
10170 writer.println(")");
10171 }
10172 }
10104 JUnitTestCase.fail(writer.toString()); 10173 JUnitTestCase.fail(writer.toString());
10105 } 10174 }
10106 } 10175 }
10107 Object visitBreakStatement(BreakStatement node) => null; 10176 Object visitBreakStatement(BreakStatement node) => null;
10108 Object visitCommentReference(CommentReference node) => null; 10177 Object visitCommentReference(CommentReference node) => null;
10109 Object visitContinueStatement(ContinueStatement node) => null; 10178 Object visitContinueStatement(ContinueStatement node) => null;
10110 Object visitExportDirective(ExportDirective node) => null; 10179 Object visitExportDirective(ExportDirective node) => null;
10111 Object visitExpression(Expression node) { 10180 Object visitExpression(Expression node) {
10112 node.visitChildren(this); 10181 node.visitChildren(this);
10113 if (node.staticType == null) { 10182 Type2 staticType = node.staticType;
10183 if (staticType == null) {
10114 _unresolvedExpressions.add(node); 10184 _unresolvedExpressions.add(node);
10115 } else { 10185 } else {
10116 _resolvedExpressionCount++; 10186 _resolvedExpressionCount++;
10187 Type2 propagatedType = node.propagatedType;
10188 if (propagatedType != null) {
10189 _propagatedExpressionCount++;
10190 if (!propagatedType.isMoreSpecificThan(staticType)) {
10191 _invalidlyPropagatedExpressions.add(node);
10192 }
10193 }
10117 } 10194 }
10118 return null; 10195 return null;
10119 } 10196 }
10120 Object visitImportDirective(ImportDirective node) => null; 10197 Object visitImportDirective(ImportDirective node) => null;
10121 Object visitLabel(Label node) => null; 10198 Object visitLabel(Label node) => null;
10122 Object visitLibraryIdentifier(LibraryIdentifier node) => null; 10199 Object visitLibraryIdentifier(LibraryIdentifier node) => null;
10123 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 10200 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
10124 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) { 10201 if (node.staticType == null && identical(node.prefix.staticType, DynamicType Impl.instance)) {
10125 return null; 10202 return null;
10126 } 10203 }
(...skipping 3811 matching lines...) Expand 10 before | Expand all | Expand 10 after
13938 printNodes(writer, _wrongTypedNodes); 14015 printNodes(writer, _wrongTypedNodes);
13939 } 14016 }
13940 JUnitTestCase.fail(writer.toString()); 14017 JUnitTestCase.fail(writer.toString());
13941 } 14018 }
13942 } 14019 }
13943 Object visitBinaryExpression(BinaryExpression node) { 14020 Object visitBinaryExpression(BinaryExpression node) {
13944 node.visitChildren(this); 14021 node.visitChildren(this);
13945 if (!node.operator.isUserDefinableOperator) { 14022 if (!node.operator.isUserDefinableOperator) {
13946 return null; 14023 return null;
13947 } 14024 }
14025 Type2 operandType = node.leftOperand.staticType;
14026 if (operandType == null || operandType.isDynamic) {
14027 return null;
14028 }
13948 return checkResolved2(node, node.element, MethodElement); 14029 return checkResolved2(node, node.element, MethodElement);
13949 } 14030 }
14031 Object visitCommentReference(CommentReference node) => null;
13950 Object visitCompilationUnit(CompilationUnit node) { 14032 Object visitCompilationUnit(CompilationUnit node) {
13951 node.visitChildren(this); 14033 node.visitChildren(this);
13952 return checkResolved2(node, node.element, CompilationUnitElement); 14034 return checkResolved2(node, node.element, CompilationUnitElement);
13953 } 14035 }
13954 Object visitExportDirective(ExportDirective node) => checkResolved2(node, node .element, ExportElement); 14036 Object visitExportDirective(ExportDirective node) => checkResolved2(node, node .element, ExportElement);
13955 Object visitFunctionDeclaration(FunctionDeclaration node) { 14037 Object visitFunctionDeclaration(FunctionDeclaration node) {
13956 node.visitChildren(this); 14038 node.visitChildren(this);
13957 if (node.element is LibraryElement) { 14039 if (node.element is LibraryElement) {
13958 _wrongTypedNodes.add(node); 14040 _wrongTypedNodes.add(node);
13959 } 14041 }
13960 return null; 14042 return null;
13961 } 14043 }
13962 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 14044 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
13963 node.visitChildren(this); 14045 node.visitChildren(this);
13964 return checkResolved2(node, node.element, FunctionElement); 14046 return null;
13965 } 14047 }
13966 Object visitImportDirective(ImportDirective node) { 14048 Object visitImportDirective(ImportDirective node) {
13967 checkResolved2(node, node.element, ImportElement); 14049 checkResolved2(node, node.element, ImportElement);
13968 SimpleIdentifier prefix = node.prefix; 14050 SimpleIdentifier prefix = node.prefix;
13969 if (prefix == null) { 14051 if (prefix == null) {
13970 return null; 14052 return null;
13971 } 14053 }
13972 return checkResolved2(prefix, prefix.element, PrefixElement); 14054 return checkResolved2(prefix, prefix.element, PrefixElement);
13973 } 14055 }
13974 Object visitIndexExpression(IndexExpression node) { 14056 Object visitIndexExpression(IndexExpression node) {
13975 node.visitChildren(this); 14057 node.visitChildren(this);
14058 Type2 targetType = node.realTarget.staticType;
14059 if (targetType == null || targetType.isDynamic) {
14060 return null;
14061 }
13976 return checkResolved2(node, node.element, MethodElement); 14062 return checkResolved2(node, node.element, MethodElement);
13977 } 14063 }
13978 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no de.element, LibraryElement); 14064 Object visitLibraryDirective(LibraryDirective node) => checkResolved2(node, no de.element, LibraryElement);
14065 Object visitNamedExpression(NamedExpression node) => node.expression.accept(th is);
13979 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele ment, CompilationUnitElement); 14066 Object visitPartDirective(PartDirective node) => checkResolved2(node, node.ele ment, CompilationUnitElement);
13980 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node .element, LibraryElement); 14067 Object visitPartOfDirective(PartOfDirective node) => checkResolved2(node, node .element, LibraryElement);
13981 Object visitPostfixExpression(PostfixExpression node) { 14068 Object visitPostfixExpression(PostfixExpression node) {
13982 node.visitChildren(this); 14069 node.visitChildren(this);
13983 if (!node.operator.isUserDefinableOperator) { 14070 if (!node.operator.isUserDefinableOperator) {
13984 return null; 14071 return null;
13985 } 14072 }
14073 Type2 operandType = node.operand.staticType;
14074 if (operandType == null || operandType.isDynamic) {
14075 return null;
14076 }
13986 return checkResolved2(node, node.element, MethodElement); 14077 return checkResolved2(node, node.element, MethodElement);
13987 } 14078 }
14079 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
14080 SimpleIdentifier prefix = node.prefix;
14081 prefix.accept(this);
14082 Type2 prefixType = prefix.staticType;
14083 if (prefixType == null || prefixType.isDynamic) {
14084 return null;
14085 }
14086 return checkResolved(node, node.element);
14087 }
13988 Object visitPrefixExpression(PrefixExpression node) { 14088 Object visitPrefixExpression(PrefixExpression node) {
13989 node.visitChildren(this); 14089 node.visitChildren(this);
13990 if (!node.operator.isUserDefinableOperator) { 14090 if (!node.operator.isUserDefinableOperator) {
13991 return null; 14091 return null;
13992 } 14092 }
14093 Type2 operandType = node.operand.staticType;
14094 if (operandType == null || operandType.isDynamic) {
14095 return null;
14096 }
13993 return checkResolved2(node, node.element, MethodElement); 14097 return checkResolved2(node, node.element, MethodElement);
13994 } 14098 }
14099 Object visitPropertyAccess(PropertyAccess node) {
14100 Expression target = node.realTarget;
14101 target.accept(this);
14102 Type2 targetType = target.staticType;
14103 if (targetType == null || targetType.isDynamic) {
14104 return null;
14105 }
14106 return node.propertyName.accept(this);
14107 }
13995 Object visitSimpleIdentifier(SimpleIdentifier node) { 14108 Object visitSimpleIdentifier(SimpleIdentifier node) {
13996 if (node.name == "void") { 14109 if (node.name == "void") {
13997 return null; 14110 return null;
13998 } 14111 }
14112 ASTNode parent = node.parent;
14113 if (parent is MethodInvocation) {
14114 MethodInvocation invocation = (parent as MethodInvocation);
14115 if (identical(invocation.methodName, node)) {
14116 Expression target = invocation.realTarget;
14117 Type2 targetType = target == null ? null : target.staticType;
14118 if (targetType == null || targetType.isDynamic) {
14119 return null;
14120 }
14121 }
14122 }
13999 return checkResolved(node, node.element); 14123 return checkResolved(node, node.element);
14000 } 14124 }
14001 Object checkResolved(ASTNode node, Element element) => checkResolved2(node, el ement, null); 14125 Object checkResolved(ASTNode node, Element element) => checkResolved2(node, el ement, null);
14002 Object checkResolved2(ASTNode node, Element element, Type expectedClass) { 14126 Object checkResolved2(ASTNode node, Element element, Type expectedClass) {
14003 if (element == null) { 14127 if (element == null) {
14004 if (node.parent is CommentReference) {
14005 return null;
14006 }
14007 if (_knownExceptions == null || !_knownExceptions.contains(node)) { 14128 if (_knownExceptions == null || !_knownExceptions.contains(node)) {
14008 _unresolvedNodes.add(node); 14129 _unresolvedNodes.add(node);
14009 } 14130 }
14010 } else if (expectedClass != null) { 14131 } else if (expectedClass != null) {
14011 if (!isInstanceOf(element, expectedClass)) { 14132 if (!isInstanceOf(element, expectedClass)) {
14012 _wrongTypedNodes.add(node); 14133 _wrongTypedNodes.add(node);
14013 } 14134 }
14014 } 14135 }
14015 return null; 14136 return null;
14016 } 14137 }
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
15180 final __test = new NonHintCodeTest(); 15301 final __test = new NonHintCodeTest();
15181 runJUnitTest(__test, __test.test_deadCode_deadCatch_onCatchSubtype); 15302 runJUnitTest(__test, __test.test_deadCode_deadCatch_onCatchSubtype);
15182 }); 15303 });
15183 }); 15304 });
15184 } 15305 }
15185 } 15306 }
15186 class EnclosedScopeTest extends ResolverTestCase { 15307 class EnclosedScopeTest extends ResolverTestCase {
15187 void test_define_duplicate() { 15308 void test_define_duplicate() {
15188 LibraryElement definingLibrary2 = createTestLibrary(); 15309 LibraryElement definingLibrary2 = createTestLibrary();
15189 GatheringErrorListener errorListener2 = new GatheringErrorListener(); 15310 GatheringErrorListener errorListener2 = new GatheringErrorListener();
15190 Scope rootScope = new Scope_17(definingLibrary2, errorListener2); 15311 Scope rootScope = new Scope_18(definingLibrary2, errorListener2);
15191 EnclosedScope scope = new EnclosedScope(rootScope); 15312 EnclosedScope scope = new EnclosedScope(rootScope);
15192 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 15313 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
15193 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 15314 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
15194 scope.define(element1); 15315 scope.define(element1);
15195 scope.define(element2); 15316 scope.define(element2);
15196 errorListener2.assertErrors3([ErrorSeverity.ERROR]); 15317 errorListener2.assertErrors3([ErrorSeverity.ERROR]);
15197 } 15318 }
15198 void test_define_normal() { 15319 void test_define_normal() {
15199 LibraryElement definingLibrary3 = createTestLibrary(); 15320 LibraryElement definingLibrary3 = createTestLibrary();
15200 GatheringErrorListener errorListener3 = new GatheringErrorListener(); 15321 GatheringErrorListener errorListener3 = new GatheringErrorListener();
15201 Scope rootScope = new Scope_18(definingLibrary3, errorListener3); 15322 Scope rootScope = new Scope_19(definingLibrary3, errorListener3);
15202 EnclosedScope outerScope = new EnclosedScope(rootScope); 15323 EnclosedScope outerScope = new EnclosedScope(rootScope);
15203 EnclosedScope innerScope = new EnclosedScope(outerScope); 15324 EnclosedScope innerScope = new EnclosedScope(outerScope);
15204 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1")); 15325 VariableElement element1 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v1"));
15205 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2")); 15326 VariableElement element2 = ElementFactory.localVariableElement(ASTFactory.id entifier3("v2"));
15206 outerScope.define(element1); 15327 outerScope.define(element1);
15207 innerScope.define(element2); 15328 innerScope.define(element2);
15208 errorListener3.assertNoErrors(); 15329 errorListener3.assertNoErrors();
15209 } 15330 }
15210 static dartSuite() { 15331 static dartSuite() {
15211 _ut.group('EnclosedScopeTest', () { 15332 _ut.group('EnclosedScopeTest', () {
15212 _ut.test('test_define_duplicate', () { 15333 _ut.test('test_define_duplicate', () {
15213 final __test = new EnclosedScopeTest(); 15334 final __test = new EnclosedScopeTest();
15214 runJUnitTest(__test, __test.test_define_duplicate); 15335 runJUnitTest(__test, __test.test_define_duplicate);
15215 }); 15336 });
15216 _ut.test('test_define_normal', () { 15337 _ut.test('test_define_normal', () {
15217 final __test = new EnclosedScopeTest(); 15338 final __test = new EnclosedScopeTest();
15218 runJUnitTest(__test, __test.test_define_normal); 15339 runJUnitTest(__test, __test.test_define_normal);
15219 }); 15340 });
15220 }); 15341 });
15221 } 15342 }
15222 } 15343 }
15223 class Scope_17 extends Scope { 15344 class Scope_18 extends Scope {
15224 LibraryElement definingLibrary2; 15345 LibraryElement definingLibrary2;
15225 GatheringErrorListener errorListener2; 15346 GatheringErrorListener errorListener2;
15226 Scope_17(this.definingLibrary2, this.errorListener2) : super(); 15347 Scope_18(this.definingLibrary2, this.errorListener2) : super();
15227 LibraryElement get definingLibrary => definingLibrary2; 15348 LibraryElement get definingLibrary => definingLibrary2;
15228 AnalysisErrorListener get errorListener => errorListener2; 15349 AnalysisErrorListener get errorListener => errorListener2;
15229 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 15350 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
15230 } 15351 }
15231 class Scope_18 extends Scope { 15352 class Scope_19 extends Scope {
15232 LibraryElement definingLibrary3; 15353 LibraryElement definingLibrary3;
15233 GatheringErrorListener errorListener3; 15354 GatheringErrorListener errorListener3;
15234 Scope_18(this.definingLibrary3, this.errorListener3) : super(); 15355 Scope_19(this.definingLibrary3, this.errorListener3) : super();
15235 LibraryElement get definingLibrary => definingLibrary3; 15356 LibraryElement get definingLibrary => definingLibrary3;
15236 AnalysisErrorListener get errorListener => errorListener3; 15357 AnalysisErrorListener get errorListener => errorListener3;
15237 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 15358 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
15238 } 15359 }
15239 class LibraryElementBuilderTest extends EngineTestCase { 15360 class LibraryElementBuilderTest extends EngineTestCase {
15240 15361
15241 /** 15362 /**
15242 * The source factory used to create [Source]. 15363 * The source factory used to create [Source].
15243 */ 15364 */
15244 SourceFactory _sourceFactory; 15365 SourceFactory _sourceFactory;
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
16292 // ErrorResolverTest.dartSuite(); 16413 // ErrorResolverTest.dartSuite();
16293 // HintCodeTest.dartSuite(); 16414 // HintCodeTest.dartSuite();
16294 // NonHintCodeTest.dartSuite(); 16415 // NonHintCodeTest.dartSuite();
16295 // NonErrorResolverTest.dartSuite(); 16416 // NonErrorResolverTest.dartSuite();
16296 // SimpleResolverTest.dartSuite(); 16417 // SimpleResolverTest.dartSuite();
16297 // StaticTypeWarningCodeTest.dartSuite(); 16418 // StaticTypeWarningCodeTest.dartSuite();
16298 // StaticWarningCodeTest.dartSuite(); 16419 // StaticWarningCodeTest.dartSuite();
16299 // StrictModeTest.dartSuite(); 16420 // StrictModeTest.dartSuite();
16300 // TypePropagationTest.dartSuite(); 16421 // TypePropagationTest.dartSuite();
16301 } 16422 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/test/generated/parser_test.dart ('k') | tests/lib/analyzer/analyze_library.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698