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

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

Issue 17249003: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 resolve(source); 946 resolve(source);
947 assertNoErrors(); 947 assertNoErrors();
948 verify([source]); 948 verify([source]);
949 } 949 }
950 void test_invalidFactoryNameNotAClass() { 950 void test_invalidFactoryNameNotAClass() {
951 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}"])); 951 Source source = addSource(EngineTestCase.createSource(["class A {", " facto ry A() {}", "}"]));
952 resolve(source); 952 resolve(source);
953 assertNoErrors(); 953 assertNoErrors();
954 verify([source]); 954 verify([source]);
955 } 955 }
956 void test_invalidMethodOverrideNamedParamType() {
957 Source source = addSource(EngineTestCase.createSource(["class A {", " m({in t a}) {}", "}", "class B implements A {", " m({int a, int b}) {}", "}"]));
958 resolve(source);
959 assertNoErrors();
960 verify([source]);
961 }
962 void test_invalidOverrideDifferentDefaultValues_named() {
963 Source source = addSource(EngineTestCase.createSource(["class A {", " m({in t p : 0}) {}", "}", "class B extends A {", " m({int p : 0}) {}", "}"]));
964 resolve(source);
965 assertNoErrors();
966 verify([source]);
967 }
968 void test_invalidOverrideDifferentDefaultValues_positional() {
969 Source source = addSource(EngineTestCase.createSource(["class A {", " m([in t p = 0]) {}", "}", "class B extends A {", " m([int p = 0]) {}", "}"]));
970 resolve(source);
971 assertNoErrors();
972 verify([source]);
973 }
974 void test_invalidOverrideDifferentDefaultValues_positional_changedOrder() {
975 Source source = addSource(EngineTestCase.createSource(["class A {", " m([in t a = 0, String b = '0']) {}", "}", "class B extends A {", " m([int b = 0, Stri ng a = '0']) {}", "}"]));
976 resolve(source);
977 assertNoErrors();
978 verify([source]);
979 }
956 void test_invalidOverrideNamed_unorderedNamedParameter() { 980 void test_invalidOverrideNamed_unorderedNamedParameter() {
957 Source source = addSource(EngineTestCase.createSource(["class A {", " m({a, b}) {}", "}", "class B extends A {", " m({b, a}) {}", "}"])); 981 Source source = addSource(EngineTestCase.createSource(["class A {", " m({a, b}) {}", "}", "class B extends A {", " m({b, a}) {}", "}"]));
958 resolve(source); 982 resolve(source);
959 assertNoErrors(); 983 assertNoErrors();
960 verify([source]); 984 verify([source]);
961 } 985 }
962 void test_invalidOverrideReturnType_returnType_interface() { 986 void test_invalidOverrideReturnType_returnType_interface() {
963 Source source = addSource2("/test.dart", EngineTestCase.createSource(["abstr act class A {", " num m();", "}", "class B implements A {", " int m() { return 1; }", "}"])); 987 Source source = addSource2("/test.dart", EngineTestCase.createSource(["abstr act class A {", " num m();", "}", "class B implements A {", " int m() { return 1; }", "}"]));
964 resolve(source); 988 resolve(source);
965 assertNoErrors(); 989 assertNoErrors();
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 resolve(source); 1174 resolve(source);
1151 assertNoErrors(); 1175 assertNoErrors();
1152 verify([source]); 1176 verify([source]);
1153 } 1177 }
1154 void test_nonBoolExpression_assert_functionType() { 1178 void test_nonBoolExpression_assert_functionType() {
1155 Source source = addSource(EngineTestCase.createSource(["bool makeAssertion() => true;", "f() {", " assert(makeAssertion);", "}"])); 1179 Source source = addSource(EngineTestCase.createSource(["bool makeAssertion() => true;", "f() {", " assert(makeAssertion);", "}"]));
1156 resolve(source); 1180 resolve(source);
1157 assertNoErrors(); 1181 assertNoErrors();
1158 verify([source]); 1182 verify([source]);
1159 } 1183 }
1184 void test_nonConstantDefaultValue_function_named() {
1185 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"]) );
1186 resolve(source);
1187 assertNoErrors();
1188 verify([source]);
1189 }
1190 void test_nonConstantDefaultValue_function_positional() {
1191 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"]) );
1192 resolve(source);
1193 assertNoErrors();
1194 verify([source]);
1195 }
1196 void test_nonConstantDefaultValue_inConstructor_named() {
1197 Source source = addSource(EngineTestCase.createSource(["class A {", " A({x : 2 + 3}) {}", "}"]));
1198 resolve(source);
1199 assertNoErrors();
1200 verify([source]);
1201 }
1202 void test_nonConstantDefaultValue_inConstructor_positional() {
1203 Source source = addSource(EngineTestCase.createSource(["class A {", " A([x = 2 + 3]) {}", "}"]));
1204 resolve(source);
1205 assertNoErrors();
1206 verify([source]);
1207 }
1208 void test_nonConstantDefaultValue_method_named() {
1209 Source source = addSource(EngineTestCase.createSource(["class A {", " m({x : 2 + 3}) {}", "}"]));
1210 resolve(source);
1211 assertNoErrors();
1212 verify([source]);
1213 }
1214 void test_nonConstantDefaultValue_method_positional() {
1215 Source source = addSource(EngineTestCase.createSource(["class A {", " m([x = 2 + 3]) {}", "}"]));
1216 resolve(source);
1217 assertNoErrors();
1218 verify([source]);
1219 }
1160 void test_nonConstCaseExpression() { 1220 void test_nonConstCaseExpression() {
1161 Source source = addSource(EngineTestCase.createSource(["f(Type t) {", " swi tch (t) {", " case bool:", " case int:", " return true;", " defaul t:", " return false;", " }", "}"])); 1221 Source source = addSource(EngineTestCase.createSource(["f(Type t) {", " swi tch (t) {", " case bool:", " case int:", " return true;", " defaul t:", " return false;", " }", "}"]));
1162 resolve(source); 1222 resolve(source);
1163 assertNoErrors(); 1223 assertNoErrors();
1164 verify([source]); 1224 verify([source]);
1165 } 1225 }
1166 void test_nonConstMapAsExpressionStatement_const() { 1226 void test_nonConstMapAsExpressionStatement_const() {
1167 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a ' : 0, 'b' : 1};", "}"])); 1227 Source source = addSource(EngineTestCase.createSource(["f() {", " const {'a ' : 0, 'b' : 1};", "}"]));
1168 resolve(source); 1228 resolve(source);
1169 assertNoErrors(); 1229 assertNoErrors();
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 resolve(source); 1498 resolve(source);
1439 assertNoErrors(); 1499 assertNoErrors();
1440 verify([source]); 1500 verify([source]);
1441 } 1501 }
1442 void test_undefinedConstructorInInitializer_explicit_unnamed() { 1502 void test_undefinedConstructorInInitializer_explicit_unnamed() {
1443 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " B() : super();", "}"])); 1503 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " B() : super();", "}"]));
1444 resolve(source); 1504 resolve(source);
1445 assertNoErrors(); 1505 assertNoErrors();
1446 verify([source]); 1506 verify([source]);
1447 } 1507 }
1508 void test_undefinedConstructorInInitializer_hasOptionalParameters() {
1509 Source source = addSource(EngineTestCase.createSource(["class A {", " A([p] ) {}", "}", "class B extends A {", " B();", "}"]));
1510 resolve(source);
1511 assertNoErrors();
1512 verify([source]);
1513 }
1448 void test_undefinedConstructorInInitializer_implicit() { 1514 void test_undefinedConstructorInInitializer_implicit() {
1449 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " B();", "}"])); 1515 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "class B extends A {", " B();", "}"]));
1450 resolve(source); 1516 resolve(source);
1451 assertNoErrors(); 1517 assertNoErrors();
1452 verify([source]); 1518 verify([source]);
1453 } 1519 }
1454 void test_undefinedConstructorInInitializer_implicit_typedef() { 1520 void test_undefinedConstructorInInitializer_implicit_typedef() {
1455 Source source = addSource(EngineTestCase.createSource(["class M {}", "typede f A = Object with M;", "class B extends A {", " B();", "}"])); 1521 Source source = addSource(EngineTestCase.createSource(["class M {}", "typede f A = Object with M;", "class B extends A {", " B();", "}"]));
1456 resolve(source); 1522 resolve(source);
1457 assertNoErrors(); 1523 assertNoErrors();
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment); 1928 runJUnitTest(__test, __test.test_invalidAssignment_compoundAssignment);
1863 }); 1929 });
1864 _ut.test('test_invalidAssignment_toDynamic', () { 1930 _ut.test('test_invalidAssignment_toDynamic', () {
1865 final __test = new NonErrorResolverTest(); 1931 final __test = new NonErrorResolverTest();
1866 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic); 1932 runJUnitTest(__test, __test.test_invalidAssignment_toDynamic);
1867 }); 1933 });
1868 _ut.test('test_invalidFactoryNameNotAClass', () { 1934 _ut.test('test_invalidFactoryNameNotAClass', () {
1869 final __test = new NonErrorResolverTest(); 1935 final __test = new NonErrorResolverTest();
1870 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass); 1936 runJUnitTest(__test, __test.test_invalidFactoryNameNotAClass);
1871 }); 1937 });
1938 _ut.test('test_invalidMethodOverrideNamedParamType', () {
1939 final __test = new NonErrorResolverTest();
1940 runJUnitTest(__test, __test.test_invalidMethodOverrideNamedParamType);
1941 });
1942 _ut.test('test_invalidOverrideDifferentDefaultValues_named', () {
1943 final __test = new NonErrorResolverTest();
1944 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_n amed);
1945 });
1946 _ut.test('test_invalidOverrideDifferentDefaultValues_positional', () {
1947 final __test = new NonErrorResolverTest();
1948 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p ositional);
1949 });
1950 _ut.test('test_invalidOverrideDifferentDefaultValues_positional_changedOrd er', () {
1951 final __test = new NonErrorResolverTest();
1952 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p ositional_changedOrder);
1953 });
1872 _ut.test('test_invalidOverrideNamed_unorderedNamedParameter', () { 1954 _ut.test('test_invalidOverrideNamed_unorderedNamedParameter', () {
1873 final __test = new NonErrorResolverTest(); 1955 final __test = new NonErrorResolverTest();
1874 runJUnitTest(__test, __test.test_invalidOverrideNamed_unorderedNamedPara meter); 1956 runJUnitTest(__test, __test.test_invalidOverrideNamed_unorderedNamedPara meter);
1875 }); 1957 });
1876 _ut.test('test_invalidOverrideReturnType_returnType_interface', () { 1958 _ut.test('test_invalidOverrideReturnType_returnType_interface', () {
1877 final __test = new NonErrorResolverTest(); 1959 final __test = new NonErrorResolverTest();
1878 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in terface); 1960 runJUnitTest(__test, __test.test_invalidOverrideReturnType_returnType_in terface);
1879 }); 1961 });
1880 _ut.test('test_invalidOverrideReturnType_returnType_interface2', () { 1962 _ut.test('test_invalidOverrideReturnType_returnType_interface2', () {
1881 final __test = new NonErrorResolverTest(); 1963 final __test = new NonErrorResolverTest();
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 runJUnitTest(__test, __test.test_nonConstValueInInitializer_redirecting) ; 2128 runJUnitTest(__test, __test.test_nonConstValueInInitializer_redirecting) ;
2047 }); 2129 });
2048 _ut.test('test_nonConstValueInInitializer_super', () { 2130 _ut.test('test_nonConstValueInInitializer_super', () {
2049 final __test = new NonErrorResolverTest(); 2131 final __test = new NonErrorResolverTest();
2050 runJUnitTest(__test, __test.test_nonConstValueInInitializer_super); 2132 runJUnitTest(__test, __test.test_nonConstValueInInitializer_super);
2051 }); 2133 });
2052 _ut.test('test_nonConstValueInInitializer_unary', () { 2134 _ut.test('test_nonConstValueInInitializer_unary', () {
2053 final __test = new NonErrorResolverTest(); 2135 final __test = new NonErrorResolverTest();
2054 runJUnitTest(__test, __test.test_nonConstValueInInitializer_unary); 2136 runJUnitTest(__test, __test.test_nonConstValueInInitializer_unary);
2055 }); 2137 });
2138 _ut.test('test_nonConstantDefaultValue_function_named', () {
2139 final __test = new NonErrorResolverTest();
2140 runJUnitTest(__test, __test.test_nonConstantDefaultValue_function_named) ;
2141 });
2142 _ut.test('test_nonConstantDefaultValue_function_positional', () {
2143 final __test = new NonErrorResolverTest();
2144 runJUnitTest(__test, __test.test_nonConstantDefaultValue_function_positi onal);
2145 });
2146 _ut.test('test_nonConstantDefaultValue_inConstructor_named', () {
2147 final __test = new NonErrorResolverTest();
2148 runJUnitTest(__test, __test.test_nonConstantDefaultValue_inConstructor_n amed);
2149 });
2150 _ut.test('test_nonConstantDefaultValue_inConstructor_positional', () {
2151 final __test = new NonErrorResolverTest();
2152 runJUnitTest(__test, __test.test_nonConstantDefaultValue_inConstructor_p ositional);
2153 });
2154 _ut.test('test_nonConstantDefaultValue_method_named', () {
2155 final __test = new NonErrorResolverTest();
2156 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_named);
2157 });
2158 _ut.test('test_nonConstantDefaultValue_method_positional', () {
2159 final __test = new NonErrorResolverTest();
2160 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_position al);
2161 });
2056 _ut.test('test_nonGenerativeConstructor', () { 2162 _ut.test('test_nonGenerativeConstructor', () {
2057 final __test = new NonErrorResolverTest(); 2163 final __test = new NonErrorResolverTest();
2058 runJUnitTest(__test, __test.test_nonGenerativeConstructor); 2164 runJUnitTest(__test, __test.test_nonGenerativeConstructor);
2059 }); 2165 });
2060 _ut.test('test_nonTypeInCatchClause_isClass', () { 2166 _ut.test('test_nonTypeInCatchClause_isClass', () {
2061 final __test = new NonErrorResolverTest(); 2167 final __test = new NonErrorResolverTest();
2062 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isClass); 2168 runJUnitTest(__test, __test.test_nonTypeInCatchClause_isClass);
2063 }); 2169 });
2064 _ut.test('test_nonTypeInCatchClause_isFunctionTypeAlias', () { 2170 _ut.test('test_nonTypeInCatchClause_isFunctionTypeAlias', () {
2065 final __test = new NonErrorResolverTest(); 2171 final __test = new NonErrorResolverTest();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new); 2296 runJUnitTest(__test, __test.test_typeArgumentNotMatchingBounds_new);
2191 }); 2297 });
2192 _ut.test('test_undefinedConstructorInInitializer_explicit_named', () { 2298 _ut.test('test_undefinedConstructorInInitializer_explicit_named', () {
2193 final __test = new NonErrorResolverTest(); 2299 final __test = new NonErrorResolverTest();
2194 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_named); 2300 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_named);
2195 }); 2301 });
2196 _ut.test('test_undefinedConstructorInInitializer_explicit_unnamed', () { 2302 _ut.test('test_undefinedConstructorInInitializer_explicit_unnamed', () {
2197 final __test = new NonErrorResolverTest(); 2303 final __test = new NonErrorResolverTest();
2198 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_unnamed); 2304 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_expli cit_unnamed);
2199 }); 2305 });
2306 _ut.test('test_undefinedConstructorInInitializer_hasOptionalParameters', ( ) {
2307 final __test = new NonErrorResolverTest();
2308 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_hasOp tionalParameters);
2309 });
2200 _ut.test('test_undefinedConstructorInInitializer_implicit', () { 2310 _ut.test('test_undefinedConstructorInInitializer_implicit', () {
2201 final __test = new NonErrorResolverTest(); 2311 final __test = new NonErrorResolverTest();
2202 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit); 2312 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit);
2203 }); 2313 });
2204 _ut.test('test_undefinedConstructorInInitializer_implicit_typedef', () { 2314 _ut.test('test_undefinedConstructorInInitializer_implicit_typedef', () {
2205 final __test = new NonErrorResolverTest(); 2315 final __test = new NonErrorResolverTest();
2206 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit_typedef); 2316 runJUnitTest(__test, __test.test_undefinedConstructorInInitializer_impli cit_typedef);
2207 }); 2317 });
2208 _ut.test('test_undefinedConstructorInInitializer_redirecting', () { 2318 _ut.test('test_undefinedConstructorInInitializer_redirecting', () {
2209 final __test = new NonErrorResolverTest(); 2319 final __test = new NonErrorResolverTest();
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2541 resolve(source); 2651 resolve(source);
2542 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]); 2652 assertErrors([StaticTypeWarningCode.NON_BOOL_CONDITION]);
2543 verify([source]); 2653 verify([source]);
2544 } 2654 }
2545 void test_nonBoolExpression() { 2655 void test_nonBoolExpression() {
2546 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"])); 2656 Source source = addSource(EngineTestCase.createSource(["f() {", " assert(0) ;", "}"]));
2547 resolve(source); 2657 resolve(source);
2548 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]); 2658 assertErrors([StaticTypeWarningCode.NON_BOOL_EXPRESSION]);
2549 verify([source]); 2659 verify([source]);
2550 } 2660 }
2661 void test_returnOfInvalidType_expressionFunctionBody_function() {
2662 Source source = addSource(EngineTestCase.createSource(["int f() => '0';"]));
2663 resolve(source);
2664 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2665 verify([source]);
2666 }
2667 void test_returnOfInvalidType_expressionFunctionBody_getter() {
2668 Source source = addSource(EngineTestCase.createSource(["int get g => '0';"]) );
2669 resolve(source);
2670 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2671 verify([source]);
2672 }
2673 void test_returnOfInvalidType_expressionFunctionBody_localFunction() {
2674 Source source = addSource(EngineTestCase.createSource(["class A {", " Strin g m() {", " int f() => '0';", " }", "}"]));
2675 resolve(source);
2676 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2677 verify([source]);
2678 }
2679 void test_returnOfInvalidType_expressionFunctionBody_method() {
2680 Source source = addSource(EngineTestCase.createSource(["class A {", " int f () => '0';", "}"]));
2681 resolve(source);
2682 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2683 verify([source]);
2684 }
2685 void test_returnOfInvalidType_expressionFunctionBody_void() {
2686 Source source = addSource(EngineTestCase.createSource(["void f() => 42;"]));
2687 resolve(source);
2688 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2689 verify([source]);
2690 }
2551 void test_returnOfInvalidType_function() { 2691 void test_returnOfInvalidType_function() {
2552 Source source = addSource(EngineTestCase.createSource(["int f() { return '0' ; }"])); 2692 Source source = addSource(EngineTestCase.createSource(["int f() { return '0' ; }"]));
2553 resolve(source); 2693 resolve(source);
2554 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 2694 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2555 verify([source]); 2695 verify([source]);
2556 } 2696 }
2697 void test_returnOfInvalidType_getter() {
2698 Source source = addSource(EngineTestCase.createSource(["int get g { return ' 0'; }"]));
2699 resolve(source);
2700 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2701 verify([source]);
2702 }
2557 void test_returnOfInvalidType_localFunction() { 2703 void test_returnOfInvalidType_localFunction() {
2558 Source source = addSource(EngineTestCase.createSource(["class A {", " Strin g m() {", " int f() { return '0'; }", " }", "}"])); 2704 Source source = addSource(EngineTestCase.createSource(["class A {", " Strin g m() {", " int f() { return '0'; }", " }", "}"]));
2559 resolve(source); 2705 resolve(source);
2560 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 2706 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
2561 verify([source]); 2707 verify([source]);
2562 } 2708 }
2563 void test_returnOfInvalidType_method() { 2709 void test_returnOfInvalidType_method() {
2564 Source source = addSource(EngineTestCase.createSource(["class A {", " int f () { return '0'; }", "}"])); 2710 Source source = addSource(EngineTestCase.createSource(["class A {", " int f () { return '0'; }", "}"]));
2565 resolve(source); 2711 resolve(source);
2566 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]); 2712 assertErrors([StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 runJUnitTest(__test, __test.test_nonBoolCondition_if); 2864 runJUnitTest(__test, __test.test_nonBoolCondition_if);
2719 }); 2865 });
2720 _ut.test('test_nonBoolCondition_while', () { 2866 _ut.test('test_nonBoolCondition_while', () {
2721 final __test = new StaticTypeWarningCodeTest(); 2867 final __test = new StaticTypeWarningCodeTest();
2722 runJUnitTest(__test, __test.test_nonBoolCondition_while); 2868 runJUnitTest(__test, __test.test_nonBoolCondition_while);
2723 }); 2869 });
2724 _ut.test('test_nonBoolExpression', () { 2870 _ut.test('test_nonBoolExpression', () {
2725 final __test = new StaticTypeWarningCodeTest(); 2871 final __test = new StaticTypeWarningCodeTest();
2726 runJUnitTest(__test, __test.test_nonBoolExpression); 2872 runJUnitTest(__test, __test.test_nonBoolExpression);
2727 }); 2873 });
2874 _ut.test('test_returnOfInvalidType_expressionFunctionBody_function', () {
2875 final __test = new StaticTypeWarningCodeTest();
2876 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_function);
2877 });
2878 _ut.test('test_returnOfInvalidType_expressionFunctionBody_getter', () {
2879 final __test = new StaticTypeWarningCodeTest();
2880 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_getter);
2881 });
2882 _ut.test('test_returnOfInvalidType_expressionFunctionBody_localFunction', () {
2883 final __test = new StaticTypeWarningCodeTest();
2884 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_localFunction);
2885 });
2886 _ut.test('test_returnOfInvalidType_expressionFunctionBody_method', () {
2887 final __test = new StaticTypeWarningCodeTest();
2888 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_method);
2889 });
2890 _ut.test('test_returnOfInvalidType_expressionFunctionBody_void', () {
2891 final __test = new StaticTypeWarningCodeTest();
2892 runJUnitTest(__test, __test.test_returnOfInvalidType_expressionFunctionB ody_void);
2893 });
2728 _ut.test('test_returnOfInvalidType_function', () { 2894 _ut.test('test_returnOfInvalidType_function', () {
2729 final __test = new StaticTypeWarningCodeTest(); 2895 final __test = new StaticTypeWarningCodeTest();
2730 runJUnitTest(__test, __test.test_returnOfInvalidType_function); 2896 runJUnitTest(__test, __test.test_returnOfInvalidType_function);
2731 }); 2897 });
2898 _ut.test('test_returnOfInvalidType_getter', () {
2899 final __test = new StaticTypeWarningCodeTest();
2900 runJUnitTest(__test, __test.test_returnOfInvalidType_getter);
2901 });
2732 _ut.test('test_returnOfInvalidType_localFunction', () { 2902 _ut.test('test_returnOfInvalidType_localFunction', () {
2733 final __test = new StaticTypeWarningCodeTest(); 2903 final __test = new StaticTypeWarningCodeTest();
2734 runJUnitTest(__test, __test.test_returnOfInvalidType_localFunction); 2904 runJUnitTest(__test, __test.test_returnOfInvalidType_localFunction);
2735 }); 2905 });
2736 _ut.test('test_returnOfInvalidType_method', () { 2906 _ut.test('test_returnOfInvalidType_method', () {
2737 final __test = new StaticTypeWarningCodeTest(); 2907 final __test = new StaticTypeWarningCodeTest();
2738 runJUnitTest(__test, __test.test_returnOfInvalidType_method); 2908 runJUnitTest(__test, __test.test_returnOfInvalidType_method);
2739 }); 2909 });
2740 _ut.test('test_returnOfInvalidType_void', () { 2910 _ut.test('test_returnOfInvalidType_void', () {
2741 final __test = new StaticTypeWarningCodeTest(); 2911 final __test = new StaticTypeWarningCodeTest();
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 _ut.test('test_visitTypeName_void', () { 3278 _ut.test('test_visitTypeName_void', () {
3109 final __test = new TypeResolverVisitorTest(); 3279 final __test = new TypeResolverVisitorTest();
3110 runJUnitTest(__test, __test.test_visitTypeName_void); 3280 runJUnitTest(__test, __test.test_visitTypeName_void);
3111 }); 3281 });
3112 }); 3282 });
3113 } 3283 }
3114 } 3284 }
3115 class ResolverTestCase extends EngineTestCase { 3285 class ResolverTestCase extends EngineTestCase {
3116 3286
3117 /** 3287 /**
3118 * The source factory used to create {@link Source sources}. 3288 * The source factory used to create [Source sources].
3119 */ 3289 */
3120 SourceFactory _sourceFactory; 3290 SourceFactory _sourceFactory;
3121 3291
3122 /** 3292 /**
3123 * The analysis context used to parse the compilation units being resolved. 3293 * The analysis context used to parse the compilation units being resolved.
3124 */ 3294 */
3125 AnalysisContextImpl _analysisContext; 3295 AnalysisContextImpl _analysisContext;
3126 void setUp() { 3296 void setUp() {
3127 reset(); 3297 reset();
3128 } 3298 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 * @param contents the contents to be returned by the content provider for the specified file 3357 * @param contents the contents to be returned by the content provider for the specified file
3188 * @return the source object representing the cached file 3358 * @return the source object representing the cached file
3189 */ 3359 */
3190 Source cacheSource(String filePath, String contents) { 3360 Source cacheSource(String filePath, String contents) {
3191 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath)); 3361 Source source = new FileBasedSource.con1(_sourceFactory.contentCache, FileUt ilities2.createFile(filePath));
3192 _sourceFactory.setContents(source, contents); 3362 _sourceFactory.setContents(source, contents);
3193 return source; 3363 return source;
3194 } 3364 }
3195 3365
3196 /** 3366 /**
3197 * Create a library element that represents a library named {@code "test"} con taining a single 3367 * Create a library element that represents a library named `"test"` containin g a single
3198 * empty compilation unit. 3368 * empty compilation unit.
3199 * @return the library element that was created 3369 * @return the library element that was created
3200 */ 3370 */
3201 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []); 3371 LibraryElementImpl createTestLibrary() => createTestLibrary2(new AnalysisConte xtImpl(), "test", []);
3202 3372
3203 /** 3373 /**
3204 * Create a library element that represents a library with the given name cont aining a single 3374 * Create a library element that represents a library with the given name cont aining a single
3205 * empty compilation unit. 3375 * empty compilation unit.
3206 * @param libraryName the name of the library to be created 3376 * @param libraryName the name of the library to be created
3207 * @return the library element that was created 3377 * @return the library element that was created
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 * reset test instance to reuse it. 3414 * reset test instance to reuse it.
3245 */ 3415 */
3246 void reset() { 3416 void reset() {
3247 _analysisContext = AnalysisContextFactory.contextWithCore(); 3417 _analysisContext = AnalysisContextFactory.contextWithCore();
3248 _sourceFactory = _analysisContext.sourceFactory; 3418 _sourceFactory = _analysisContext.sourceFactory;
3249 } 3419 }
3250 3420
3251 /** 3421 /**
3252 * Given a library and all of its parts, resolve the contents of the library a nd the contents of 3422 * Given a library and all of its parts, resolve the contents of the library a nd the contents of
3253 * the parts. This assumes that the sources for the library and its parts have already been added 3423 * the parts. This assumes that the sources for the library and its parts have already been added
3254 * to the content provider using the method {@link #addSource(String,String)}. 3424 * to the content provider using the method [addSource].
3255 * @param librarySource the source for the compilation unit that defines the l ibrary 3425 * @param librarySource the source for the compilation unit that defines the l ibrary
3256 * @return the element representing the resolved library 3426 * @return the element representing the resolved library
3257 * @throws AnalysisException if the analysis could not be performed 3427 * @throws AnalysisException if the analysis could not be performed
3258 */ 3428 */
3259 LibraryElement resolve(Source librarySource) => _analysisContext.computeLibrar yElement(librarySource); 3429 LibraryElement resolve(Source librarySource) => _analysisContext.computeLibrar yElement(librarySource);
3260 3430
3261 /** 3431 /**
3262 * Return the resolved compilation unit corresponding to the given source in t he given library. 3432 * Return the resolved compilation unit corresponding to the given source in t he given library.
3263 * @param source the source of the compilation unit to be returned 3433 * @param source the source of the compilation unit to be returned
3264 * @param library the library in which the compilation unit is to be resolved 3434 * @param library the library in which the compilation unit is to be resolved
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
3873 resolve(source); 4043 resolve(source);
3874 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); 4044 assertErrors([CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
3875 verify([source]); 4045 verify([source]);
3876 } 4046 }
3877 void fail_mixinOfNonClass() { 4047 void fail_mixinOfNonClass() {
3878 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex tends Object mixin A {}"])); 4048 Source source = addSource(EngineTestCase.createSource(["var A;", "class B ex tends Object mixin A {}"]));
3879 resolve(source); 4049 resolve(source);
3880 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]); 4050 assertErrors([CompileTimeErrorCode.MIXIN_OF_NON_CLASS]);
3881 verify([source]); 4051 verify([source]);
3882 } 4052 }
3883 void fail_nonConstantDefaultValue_named() {
3884 Source source = addSource(EngineTestCase.createSource(["f({x : 2 + 3}) {}"]) );
3885 resolve(source);
3886 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
3887 verify([source]);
3888 }
3889 void fail_nonConstantDefaultValue_positional() {
3890 Source source = addSource(EngineTestCase.createSource(["f([x = 2 + 3]) {}"]) );
3891 resolve(source);
3892 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
3893 verify([source]);
3894 }
3895 void fail_objectCannotExtendAnotherClass() { 4053 void fail_objectCannotExtendAnotherClass() {
3896 Source source = addSource(EngineTestCase.createSource([])); 4054 Source source = addSource(EngineTestCase.createSource([]));
3897 resolve(source); 4055 resolve(source);
3898 assertErrors([CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]); 4056 assertErrors([CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS]);
3899 verify([source]); 4057 verify([source]);
3900 } 4058 }
3901 void fail_recursiveCompileTimeConstant() { 4059 void fail_recursiveCompileTimeConstant() {
3902 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", " const y = x + 1;"])); 4060 Source source = addSource(EngineTestCase.createSource(["const x = y + 1;", " const y = x + 1;"]));
3903 resolve(source); 4061 resolve(source);
3904 assertErrors([CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]); 4062 assertErrors([CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT]);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
4357 } 4515 }
4358 void test_extendsNonClass_class() { 4516 void test_extendsNonClass_class() {
4359 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends A {}"])); 4517 Source source = addSource(EngineTestCase.createSource(["int A;", "class B ex tends A {}"]));
4360 resolve(source); 4518 resolve(source);
4361 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]); 4519 assertErrors([CompileTimeErrorCode.EXTENDS_NON_CLASS]);
4362 verify([source]); 4520 verify([source]);
4363 } 4521 }
4364 void test_extendsOrImplementsDisallowedClass_extends_bool() { 4522 void test_extendsOrImplementsDisallowedClass_extends_bool() {
4365 Source source = addSource(EngineTestCase.createSource(["class A extends bool {}"])); 4523 Source source = addSource(EngineTestCase.createSource(["class A extends bool {}"]));
4366 resolve(source); 4524 resolve(source);
4367 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4525 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4368 verify([source]); 4526 verify([source]);
4369 } 4527 }
4370 void test_extendsOrImplementsDisallowedClass_extends_double() { 4528 void test_extendsOrImplementsDisallowedClass_extends_double() {
4371 Source source = addSource(EngineTestCase.createSource(["class A extends doub le {}"])); 4529 Source source = addSource(EngineTestCase.createSource(["class A extends doub le {}"]));
4372 resolve(source); 4530 resolve(source);
4373 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4531 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4374 verify([source]); 4532 verify([source]);
4375 } 4533 }
4376 void test_extendsOrImplementsDisallowedClass_extends_int() { 4534 void test_extendsOrImplementsDisallowedClass_extends_int() {
4377 Source source = addSource(EngineTestCase.createSource(["class A extends int {}"])); 4535 Source source = addSource(EngineTestCase.createSource(["class A extends int {}"]));
4378 resolve(source); 4536 resolve(source);
4379 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4537 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4380 verify([source]); 4538 verify([source]);
4381 } 4539 }
4382 void test_extendsOrImplementsDisallowedClass_extends_num() { 4540 void test_extendsOrImplementsDisallowedClass_extends_num() {
4383 Source source = addSource(EngineTestCase.createSource(["class A extends num {}"])); 4541 Source source = addSource(EngineTestCase.createSource(["class A extends num {}"]));
4384 resolve(source); 4542 resolve(source);
4385 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4543 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4386 verify([source]); 4544 verify([source]);
4387 } 4545 }
4388 void test_extendsOrImplementsDisallowedClass_extends_String() { 4546 void test_extendsOrImplementsDisallowedClass_extends_String() {
4389 Source source = addSource(EngineTestCase.createSource(["class A extends Stri ng {}"])); 4547 Source source = addSource(EngineTestCase.createSource(["class A extends Stri ng {}"]));
4390 resolve(source); 4548 resolve(source);
4391 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS]); 4549 assertErrors([CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, StaticWarningCo de.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
4392 verify([source]); 4550 verify([source]);
4393 } 4551 }
4394 void test_extendsOrImplementsDisallowedClass_implements_bool() { 4552 void test_extendsOrImplementsDisallowedClass_implements_bool() {
4395 Source source = addSource(EngineTestCase.createSource(["class A implements b ool {}"])); 4553 Source source = addSource(EngineTestCase.createSource(["class A implements b ool {}"]));
4396 resolve(source); 4554 resolve(source);
4397 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 4555 assertErrors([CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
4398 verify([source]); 4556 verify([source]);
4399 } 4557 }
4400 void test_extendsOrImplementsDisallowedClass_implements_double() { 4558 void test_extendsOrImplementsDisallowedClass_implements_double() {
4401 Source source = addSource(EngineTestCase.createSource(["class A implements d ouble {}"])); 4559 Source source = addSource(EngineTestCase.createSource(["class A implements d ouble {}"]));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4497 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.named() {}", " A(this.x) : this.named();", "}"])); 4655 Source source = addSource(EngineTestCase.createSource(["class A {", " int x ;", " A.named() {}", " A(this.x) : this.named();", "}"]));
4498 resolve(source); 4656 resolve(source);
4499 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR ]); 4657 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR ]);
4500 verify([source]); 4658 verify([source]);
4501 } 4659 }
4502 4660
4503 /** 4661 /**
4504 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR code, but tests the 4662 * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR code, but tests the
4505 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid ed here to show 4663 * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provid ed here to show
4506 * coverage over all of the permutations of initializers in constructor declar ations. 4664 * coverage over all of the permutations of initializers in constructor declar ations.
4507 * <p> 4665 *
4508 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of 4666 * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of
4509 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w e use it instead of 4667 * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, w e use it instead of
4510 * the broader code 4668 * the broader code
4511 */ 4669 */
4512 void test_finalInitializedInDeclarationAndConstructor_initializers() { 4670 void test_finalInitializedInDeclarationAndConstructor_initializers() {
4513 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A() : x = 0 {}", "}"])); 4671 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A() : x = 0 {}", "}"]));
4514 resolve(source); 4672 resolve(source);
4515 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]); 4673 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECL ARATION]);
4516 verify([source]); 4674 verify([source]);
4517 } 4675 }
4518 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() { 4676 void test_finalInitializedInDeclarationAndConstructor_initializingFormal() {
4519 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"])); 4677 Source source = addSource(EngineTestCase.createSource(["class A {", " final x = 0;", " A(this.x) {}", "}"]));
4520 resolve(source); 4678 resolve(source);
4521 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONS TRUCTOR]); 4679 assertErrors([CompileTimeErrorCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONS TRUCTOR]);
4522 verify([source]); 4680 verify([source]);
4523 } 4681 }
4524 void test_finalInitializedMultipleTimes_initializers() { 4682 void test_finalInitializedMultipleTimes_initializers() {
4525 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 0, x = 0 {}", "}"])); 4683 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A() : x = 0, x = 0 {}", "}"]));
4526 resolve(source); 4684 resolve(source);
4527 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]); 4685 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZER S]);
4528 verify([source]); 4686 verify([source]);
4529 } 4687 }
4530 4688
4531 /** 4689 /**
4532 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests the 4690 * This test doesn't test the FINAL_INITIALIZED_MULTIPLE_TIMES code, but tests the
4533 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided here to show 4691 * FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER code instead. It is provided here to show
4534 * coverage over all of the permutations of initializers in constructor declar ations. 4692 * coverage over all of the permutations of initializers in constructor declar ations.
4535 * <p> 4693 *
4536 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of 4694 * Note: FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER covers a subset of
4537 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code 4695 * FINAL_INITIALIZED_MULTIPLE_TIMES, since it more specific, we use it instead of the broader code
4538 */ 4696 */
4539 void test_finalInitializedMultipleTimes_initializingFormal_initializer() { 4697 void test_finalInitializedMultipleTimes_initializingFormal_initializer() {
4540 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) : x = 0 {}", "}"])); 4698 Source source = addSource(EngineTestCase.createSource(["class A {", " final x;", " A(this.x) : x = 0 {}", "}"]));
4541 resolve(source); 4699 resolve(source);
4542 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA LIZER]); 4700 assertErrors([CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIA LIZER]);
4543 verify([source]); 4701 verify([source]);
4544 } 4702 }
4545 void test_finalInitializedMultipleTimes_initializingFormals() { 4703 void test_finalInitializedMultipleTimes_initializingFormals() {
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
4919 resolve(source); 5077 resolve(source);
4920 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]); 5078 assertErrors([ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE]);
4921 verify([source]); 5079 verify([source]);
4922 } 5080 }
4923 void test_newWithInvalidTypeParameters() { 5081 void test_newWithInvalidTypeParameters() {
4924 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"])); 5082 Source source = addSource(EngineTestCase.createSource(["class A {}", "f() { return new A<A>(); }"]));
4925 resolve(source); 5083 resolve(source);
4926 assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]); 5084 assertErrors([CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS]);
4927 verify([source]); 5085 verify([source]);
4928 } 5086 }
5087 void test_nonConstantDefaultValue_function_named() {
5088 Source source = addSource(EngineTestCase.createSource(["int y;", "f({x : y}) {}"]));
5089 resolve(source);
5090 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
5091 verify([source]);
5092 }
5093 void test_nonConstantDefaultValue_function_positional() {
5094 Source source = addSource(EngineTestCase.createSource(["int y;", "f([x = y]) {}"]));
5095 resolve(source);
5096 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
5097 verify([source]);
5098 }
5099 void test_nonConstantDefaultValue_inConstructor_named() {
5100 Source source = addSource(EngineTestCase.createSource(["class A {", " int y ;", " A({x : y}) {}", "}"]));
5101 resolve(source);
5102 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
5103 verify([source]);
5104 }
5105 void test_nonConstantDefaultValue_inConstructor_positional() {
5106 Source source = addSource(EngineTestCase.createSource(["class A {", " int y ;", " A([x = y]) {}", "}"]));
5107 resolve(source);
5108 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
5109 verify([source]);
5110 }
5111 void test_nonConstantDefaultValue_method_named() {
5112 Source source = addSource(EngineTestCase.createSource(["class A {", " int y ;", " m({x : y}) {}", "}"]));
5113 resolve(source);
5114 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
5115 verify([source]);
5116 }
5117 void test_nonConstantDefaultValue_method_positional() {
5118 Source source = addSource(EngineTestCase.createSource(["class A {", " int y ;", " m([x = y]) {}", "}"]));
5119 resolve(source);
5120 assertErrors([CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
5121 verify([source]);
5122 }
4929 void test_nonConstCaseExpression() { 5123 void test_nonConstCaseExpression() {
4930 Source source = addSource(EngineTestCase.createSource(["f(int p, int q) {", " switch (p) {", " case 3 + q:", " break;", " }", "}"])); 5124 Source source = addSource(EngineTestCase.createSource(["f(int p, int q) {", " switch (p) {", " case 3 + q:", " break;", " }", "}"]));
4931 resolve(source); 5125 resolve(source);
4932 assertErrors([CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]); 5126 assertErrors([CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]);
4933 verify([source]); 5127 verify([source]);
4934 } 5128 }
4935 void test_nonConstListElement() { 5129 void test_nonConstListElement() {
4936 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst [a];", "}"])); 5130 Source source = addSource(EngineTestCase.createSource(["f(a) {", " return c onst [a];", "}"]));
4937 resolve(source); 5131 resolve(source);
4938 assertErrors([CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); 5132 assertErrors([CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
6069 runJUnitTest(__test, __test.test_nonConstValueInInitializer_field); 6263 runJUnitTest(__test, __test.test_nonConstValueInInitializer_field);
6070 }); 6264 });
6071 _ut.test('test_nonConstValueInInitializer_redirecting', () { 6265 _ut.test('test_nonConstValueInInitializer_redirecting', () {
6072 final __test = new CompileTimeErrorCodeTest(); 6266 final __test = new CompileTimeErrorCodeTest();
6073 runJUnitTest(__test, __test.test_nonConstValueInInitializer_redirecting) ; 6267 runJUnitTest(__test, __test.test_nonConstValueInInitializer_redirecting) ;
6074 }); 6268 });
6075 _ut.test('test_nonConstValueInInitializer_super', () { 6269 _ut.test('test_nonConstValueInInitializer_super', () {
6076 final __test = new CompileTimeErrorCodeTest(); 6270 final __test = new CompileTimeErrorCodeTest();
6077 runJUnitTest(__test, __test.test_nonConstValueInInitializer_super); 6271 runJUnitTest(__test, __test.test_nonConstValueInInitializer_super);
6078 }); 6272 });
6273 _ut.test('test_nonConstantDefaultValue_function_named', () {
6274 final __test = new CompileTimeErrorCodeTest();
6275 runJUnitTest(__test, __test.test_nonConstantDefaultValue_function_named) ;
6276 });
6277 _ut.test('test_nonConstantDefaultValue_function_positional', () {
6278 final __test = new CompileTimeErrorCodeTest();
6279 runJUnitTest(__test, __test.test_nonConstantDefaultValue_function_positi onal);
6280 });
6281 _ut.test('test_nonConstantDefaultValue_inConstructor_named', () {
6282 final __test = new CompileTimeErrorCodeTest();
6283 runJUnitTest(__test, __test.test_nonConstantDefaultValue_inConstructor_n amed);
6284 });
6285 _ut.test('test_nonConstantDefaultValue_inConstructor_positional', () {
6286 final __test = new CompileTimeErrorCodeTest();
6287 runJUnitTest(__test, __test.test_nonConstantDefaultValue_inConstructor_p ositional);
6288 });
6289 _ut.test('test_nonConstantDefaultValue_method_named', () {
6290 final __test = new CompileTimeErrorCodeTest();
6291 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_named);
6292 });
6293 _ut.test('test_nonConstantDefaultValue_method_positional', () {
6294 final __test = new CompileTimeErrorCodeTest();
6295 runJUnitTest(__test, __test.test_nonConstantDefaultValue_method_position al);
6296 });
6079 _ut.test('test_nonGenerativeConstructor_explicit', () { 6297 _ut.test('test_nonGenerativeConstructor_explicit', () {
6080 final __test = new CompileTimeErrorCodeTest(); 6298 final __test = new CompileTimeErrorCodeTest();
6081 runJUnitTest(__test, __test.test_nonGenerativeConstructor_explicit); 6299 runJUnitTest(__test, __test.test_nonGenerativeConstructor_explicit);
6082 }); 6300 });
6083 _ut.test('test_nonGenerativeConstructor_implicit', () { 6301 _ut.test('test_nonGenerativeConstructor_implicit', () {
6084 final __test = new CompileTimeErrorCodeTest(); 6302 final __test = new CompileTimeErrorCodeTest();
6085 runJUnitTest(__test, __test.test_nonGenerativeConstructor_implicit); 6303 runJUnitTest(__test, __test.test_nonGenerativeConstructor_implicit);
6086 }); 6304 });
6087 _ut.test('test_notEnoughRequiredArguments_const', () { 6305 _ut.test('test_notEnoughRequiredArguments_const', () {
6088 final __test = new CompileTimeErrorCodeTest(); 6306 final __test = new CompileTimeErrorCodeTest();
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
6317 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooFew); 6535 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooFew);
6318 }); 6536 });
6319 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () { 6537 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () {
6320 final __test = new CompileTimeErrorCodeTest(); 6538 final __test = new CompileTimeErrorCodeTest();
6321 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooMany); 6539 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooMany);
6322 }); 6540 });
6323 }); 6541 });
6324 } 6542 }
6325 } 6543 }
6326 /** 6544 /**
6327 * Instances of the class {@code StaticTypeVerifier} verify that all of the node s in an AST 6545 * Instances of the class `StaticTypeVerifier` verify that all of the nodes in a n AST
6328 * structure that should have a static type associated with them do have a stati c type. 6546 * structure that should have a static type associated with them do have a stati c type.
6329 */ 6547 */
6330 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> { 6548 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> {
6331 6549
6332 /** 6550 /**
6333 * A list containing all of the AST Expression nodes that were not resolved. 6551 * A list containing all of the AST Expression nodes that were not resolved.
6334 */ 6552 */
6335 List<Expression> _unresolvedExpressions = new List<Expression>(); 6553 List<Expression> _unresolvedExpressions = new List<Expression>();
6336 6554
6337 /** 6555 /**
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
6451 return "<unknown file- CompilationUnit.getElement() returned null>"; 6669 return "<unknown file- CompilationUnit.getElement() returned null>";
6452 } 6670 }
6453 } else { 6671 } else {
6454 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>"; 6672 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
6455 } 6673 }
6456 } 6674 }
6457 return "<unknown file- ASTNode is null>"; 6675 return "<unknown file- ASTNode is null>";
6458 } 6676 }
6459 } 6677 }
6460 /** 6678 /**
6461 * The class {@code StrictModeTest} contains tests to ensure that the correct er rors and warnings 6679 * The class `StrictModeTest` contains tests to ensure that the correct errors a nd warnings
6462 * are reported when the analysis engine is run in strict mode. 6680 * are reported when the analysis engine is run in strict mode.
6463 */ 6681 */
6464 class StrictModeTest extends ResolverTestCase { 6682 class StrictModeTest extends ResolverTestCase {
6465 void fail_for() { 6683 void fail_for() {
6466 Source source = addSource(EngineTestCase.createSource(["int f(List<int> list ) {", " num sum = 0;", " for (num i = 0; i < list.length; i++) {", " sum += list[i];", " }", "}"])); 6684 Source source = addSource(EngineTestCase.createSource(["int f(List<int> list ) {", " num sum = 0;", " for (num i = 0; i < list.length; i++) {", " sum += list[i];", " }", "}"]));
6467 resolve(source); 6685 resolve(source);
6468 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]); 6686 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6469 } 6687 }
6470 void setUp() { 6688 void setUp() {
6471 super.setUp(); 6689 super.setUp();
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
7531 resolve(source); 7749 resolve(source);
7532 assertErrors([StaticWarningCode.INCORRECT_NUMBER_OF_ARGUMENTS]); 7750 assertErrors([StaticWarningCode.INCORRECT_NUMBER_OF_ARGUMENTS]);
7533 verify([source]); 7751 verify([source]);
7534 } 7752 }
7535 void fail_invalidFactoryName() { 7753 void fail_invalidFactoryName() {
7536 Source source = addSource(EngineTestCase.createSource([])); 7754 Source source = addSource(EngineTestCase.createSource([]));
7537 resolve(source); 7755 resolve(source);
7538 assertErrors([StaticWarningCode.INVALID_FACTORY_NAME]); 7756 assertErrors([StaticWarningCode.INVALID_FACTORY_NAME]);
7539 verify([source]); 7757 verify([source]);
7540 } 7758 }
7541 void fail_invalidOverrideDifferentDefaultValues() {
7542 Source source = addSource(EngineTestCase.createSource(["class A {", " m([in t p = 0]) {}", "}", "class B extends A {", " m([int p = 1]) {}", "}"]));
7543 resolve(source);
7544 assertErrors([StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES]);
7545 verify([source]);
7546 }
7547 void fail_invocationOfNonFunction() { 7759 void fail_invocationOfNonFunction() {
7548 Source source = addSource(EngineTestCase.createSource([])); 7760 Source source = addSource(EngineTestCase.createSource([]));
7549 resolve(source); 7761 resolve(source);
7550 assertErrors([StaticWarningCode.INVOCATION_OF_NON_FUNCTION]); 7762 assertErrors([StaticWarningCode.INVOCATION_OF_NON_FUNCTION]);
7551 verify([source]); 7763 verify([source]);
7552 } 7764 }
7553 void fail_mismatchedAccessorTypes_getterAndSuperSetter() { 7765 void fail_mismatchedAccessorTypes_getterAndSuperSetter() {
7554 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", " set g(int v) {}", "}", "class B extends A {", " set g(S tring v) {}", "}"])); 7766 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", " set g(int v) {}", "}", "class B extends A {", " set g(S tring v) {}", "}"]));
7555 resolve(source); 7767 resolve(source);
7556 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); 7768 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
8034 resolve(source); 8246 resolve(source);
8035 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 8247 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
8036 verify([source]); 8248 verify([source]);
8037 } 8249 }
8038 void test_invalidMethodOverrideReturnType_void() { 8250 void test_invalidMethodOverrideReturnType_void() {
8039 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () {}", "}", "class B extends A {", " void m() {}", "}"])); 8251 Source source = addSource(EngineTestCase.createSource(["class A {", " int m () {}", "}", "class B extends A {", " void m() {}", "}"]));
8040 resolve(source); 8252 resolve(source);
8041 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]); 8253 assertErrors([StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE]);
8042 verify([source]); 8254 verify([source]);
8043 } 8255 }
8256 void test_invalidOverrideDifferentDefaultValues_named() {
8257 Source source = addSource(EngineTestCase.createSource(["class A {", " m({in t p : 0}) {}", "}", "class B extends A {", " m({int p : 1}) {}", "}"]));
8258 resolve(source);
8259 assertErrors([StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NA MED]);
8260 verify([source]);
8261 }
8262 void test_invalidOverrideDifferentDefaultValues_positional() {
8263 Source source = addSource(EngineTestCase.createSource(["class A {", " m([in t p = 0]) {}", "}", "class B extends A {", " m([int p = 1]) {}", "}"]));
8264 resolve(source);
8265 assertErrors([StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_PO SITIONAL]);
8266 verify([source]);
8267 }
8044 void test_invalidSetterOverrideNormalParamType() { 8268 void test_invalidSetterOverrideNormalParamType() {
8045 Source source = addSource(EngineTestCase.createSource(["class A {", " void set s(int v) {}", "}", "class B extends A {", " void set s(String v) {}", "}"]) ); 8269 Source source = addSource(EngineTestCase.createSource(["class A {", " void set s(int v) {}", "}", "class B extends A {", " void set s(String v) {}", "}"]) );
8046 resolve(source); 8270 resolve(source);
8047 assertErrors([StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]); 8271 assertErrors([StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE]);
8048 verify([source]); 8272 verify([source]);
8049 } 8273 }
8050 void test_mismatchedAccessorTypes_class() { 8274 void test_mismatchedAccessorTypes_class() {
8051 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", " set g(String v) {}", "}"])); 8275 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et g { return 0; }", " set g(String v) {}", "}"]));
8052 resolve(source); 8276 resolve(source);
8053 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); 8277 assertErrors([StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
(...skipping 21 matching lines...) Expand all
8075 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A.name();", "}"])); 8299 Source source = addSource(EngineTestCase.createSource(["class A {", " A() { }", "}", "f() {", " new A.name();", "}"]));
8076 resolve(source); 8300 resolve(source);
8077 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]); 8301 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR]);
8078 } 8302 }
8079 void test_newWithUndefinedConstructorDefault() { 8303 void test_newWithUndefinedConstructorDefault() {
8080 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam e() {}", "}", "f() {", " new A();", "}"])); 8304 Source source = addSource(EngineTestCase.createSource(["class A {", " A.nam e() {}", "}", "f() {", " new A();", "}"]));
8081 resolve(source); 8305 resolve(source);
8082 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]); 8306 assertErrors([StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT]);
8083 verify([source]); 8307 verify([source]);
8084 } 8308 }
8309 void test_noDefaultSuperConstructorExplicit() {
8310 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p); ", "}", "class B extends A {", " B() {}", "}"]));
8311 resolve(source);
8312 assertErrors([StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT]);
8313 verify([source]);
8314 }
8315 void test_noDefaultSuperConstructorImplicit_superHasParameters() {
8316 Source source = addSource(EngineTestCase.createSource(["class A {", " A(p); ", "}", "class B extends A {", "}"]));
8317 resolve(source);
8318 assertErrors([StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
8319 verify([source]);
8320 }
8321 void test_noDefaultSuperConstructorImplicit_superOnlyNamed() {
8322 Source source = addSource(EngineTestCase.createSource(["class A { A.named() {} }", "class B extends A {}"]));
8323 resolve(source);
8324 assertErrors([StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT]);
8325 verify([source]);
8326 }
8085 void test_nonAbstractClassInheritsAbstractMemberFivePlus() { 8327 void test_nonAbstractClassInheritsAbstractMemberFivePlus() {
8086 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", " q();", "}", "class C extends A {", " }"])); 8328 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", " q();", "}", "class C extends A {", " }"]));
8087 resolve(source); 8329 resolve(source);
8088 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FIVE_PLUS]); 8330 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FIVE_PLUS]);
8089 verify([source]); 8331 verify([source]);
8090 } 8332 }
8091 void test_nonAbstractClassInheritsAbstractMemberFour() { 8333 void test_nonAbstractClassInheritsAbstractMemberFour() {
8092 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", "}", "class C extends A {", "}"])); 8334 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", " p();", "}", "class C extends A {", "}"]));
8093 resolve(source); 8335 resolve(source);
8094 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FOUR]); 8336 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ FOUR]);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
8129 resolve(source); 8371 resolve(source);
8130 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]); 8372 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
8131 verify([source]); 8373 verify([source]);
8132 } 8374 }
8133 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() { 8375 void test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperclass() {
8134 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " set s(int i);", "}", "class C extends A {", "}"])); 8376 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " set s(int i);", "}", "class C extends A {", "}"]));
8135 resolve(source); 8377 resolve(source);
8136 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]); 8378 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
8137 verify([source]); 8379 verify([source]);
8138 } 8380 }
8381 void test_nonAbstractClassInheritsAbstractMemberOne_superclasses_interface() {
8382 Source source = addSource(EngineTestCase.createSource(["class A {", " get a => 'a';", "}", "abstract class B implements A {", " get b => 'b';", "}", "clas s C extends B {", "}"]));
8383 resolve(source);
8384 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ ONE]);
8385 verify([source]);
8386 }
8139 void test_nonAbstractClassInheritsAbstractMemberThree() { 8387 void test_nonAbstractClassInheritsAbstractMemberThree() {
8140 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", "}", "class C extends A {", "}"])); 8388 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", " o();", "}", "class C extends A {", "}"]));
8141 resolve(source); 8389 resolve(source);
8142 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ THREE]); 8390 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ THREE]);
8143 verify([source]); 8391 verify([source]);
8144 } 8392 }
8145 void test_nonAbstractClassInheritsAbstractMemberTwo() { 8393 void test_nonAbstractClassInheritsAbstractMemberTwo() {
8146 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", "}", "class C extends A {", "}"])); 8394 Source source = addSource(EngineTestCase.createSource(["abstract class A {", " m();", " n();", "}", "class C extends A {", "}"]));
8147 resolve(source); 8395 resolve(source);
8148 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ TWO]); 8396 assertErrors([StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ TWO]);
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
8595 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_supercl ass); 8843 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_supercl ass);
8596 }); 8844 });
8597 _ut.test('test_invalidMethodOverrideReturnType_superclass2', () { 8845 _ut.test('test_invalidMethodOverrideReturnType_superclass2', () {
8598 final __test = new StaticWarningCodeTest(); 8846 final __test = new StaticWarningCodeTest();
8599 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_supercl ass2); 8847 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_supercl ass2);
8600 }); 8848 });
8601 _ut.test('test_invalidMethodOverrideReturnType_void', () { 8849 _ut.test('test_invalidMethodOverrideReturnType_void', () {
8602 final __test = new StaticWarningCodeTest(); 8850 final __test = new StaticWarningCodeTest();
8603 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_void); 8851 runJUnitTest(__test, __test.test_invalidMethodOverrideReturnType_void);
8604 }); 8852 });
8853 _ut.test('test_invalidOverrideDifferentDefaultValues_named', () {
8854 final __test = new StaticWarningCodeTest();
8855 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_n amed);
8856 });
8857 _ut.test('test_invalidOverrideDifferentDefaultValues_positional', () {
8858 final __test = new StaticWarningCodeTest();
8859 runJUnitTest(__test, __test.test_invalidOverrideDifferentDefaultValues_p ositional);
8860 });
8605 _ut.test('test_invalidSetterOverrideNormalParamType', () { 8861 _ut.test('test_invalidSetterOverrideNormalParamType', () {
8606 final __test = new StaticWarningCodeTest(); 8862 final __test = new StaticWarningCodeTest();
8607 runJUnitTest(__test, __test.test_invalidSetterOverrideNormalParamType); 8863 runJUnitTest(__test, __test.test_invalidSetterOverrideNormalParamType);
8608 }); 8864 });
8609 _ut.test('test_mismatchedAccessorTypes_class', () { 8865 _ut.test('test_mismatchedAccessorTypes_class', () {
8610 final __test = new StaticWarningCodeTest(); 8866 final __test = new StaticWarningCodeTest();
8611 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_class); 8867 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_class);
8612 }); 8868 });
8613 _ut.test('test_mismatchedAccessorTypes_topLevel', () { 8869 _ut.test('test_mismatchedAccessorTypes_topLevel', () {
8614 final __test = new StaticWarningCodeTest(); 8870 final __test = new StaticWarningCodeTest();
8615 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_topLevel); 8871 runJUnitTest(__test, __test.test_mismatchedAccessorTypes_topLevel);
8616 }); 8872 });
8617 _ut.test('test_newWithAbstractClass', () { 8873 _ut.test('test_newWithAbstractClass', () {
8618 final __test = new StaticWarningCodeTest(); 8874 final __test = new StaticWarningCodeTest();
8619 runJUnitTest(__test, __test.test_newWithAbstractClass); 8875 runJUnitTest(__test, __test.test_newWithAbstractClass);
8620 }); 8876 });
8621 _ut.test('test_newWithNonType', () { 8877 _ut.test('test_newWithNonType', () {
8622 final __test = new StaticWarningCodeTest(); 8878 final __test = new StaticWarningCodeTest();
8623 runJUnitTest(__test, __test.test_newWithNonType); 8879 runJUnitTest(__test, __test.test_newWithNonType);
8624 }); 8880 });
8625 _ut.test('test_newWithUndefinedConstructor', () { 8881 _ut.test('test_newWithUndefinedConstructor', () {
8626 final __test = new StaticWarningCodeTest(); 8882 final __test = new StaticWarningCodeTest();
8627 runJUnitTest(__test, __test.test_newWithUndefinedConstructor); 8883 runJUnitTest(__test, __test.test_newWithUndefinedConstructor);
8628 }); 8884 });
8629 _ut.test('test_newWithUndefinedConstructorDefault', () { 8885 _ut.test('test_newWithUndefinedConstructorDefault', () {
8630 final __test = new StaticWarningCodeTest(); 8886 final __test = new StaticWarningCodeTest();
8631 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault); 8887 runJUnitTest(__test, __test.test_newWithUndefinedConstructorDefault);
8632 }); 8888 });
8889 _ut.test('test_noDefaultSuperConstructorExplicit', () {
8890 final __test = new StaticWarningCodeTest();
8891 runJUnitTest(__test, __test.test_noDefaultSuperConstructorExplicit);
8892 });
8893 _ut.test('test_noDefaultSuperConstructorImplicit_superHasParameters', () {
8894 final __test = new StaticWarningCodeTest();
8895 runJUnitTest(__test, __test.test_noDefaultSuperConstructorImplicit_super HasParameters);
8896 });
8897 _ut.test('test_noDefaultSuperConstructorImplicit_superOnlyNamed', () {
8898 final __test = new StaticWarningCodeTest();
8899 runJUnitTest(__test, __test.test_noDefaultSuperConstructorImplicit_super OnlyNamed);
8900 });
8633 _ut.test('test_nonAbstractClassInheritsAbstractMemberFivePlus', () { 8901 _ut.test('test_nonAbstractClassInheritsAbstractMemberFivePlus', () {
8634 final __test = new StaticWarningCodeTest(); 8902 final __test = new StaticWarningCodeTest();
8635 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF ivePlus); 8903 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF ivePlus);
8636 }); 8904 });
8637 _ut.test('test_nonAbstractClassInheritsAbstractMemberFour', () { 8905 _ut.test('test_nonAbstractClassInheritsAbstractMemberFour', () {
8638 final __test = new StaticWarningCodeTest(); 8906 final __test = new StaticWarningCodeTest();
8639 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF our); 8907 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberF our);
8640 }); 8908 });
8641 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterf ace', () { 8909 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_getter_fromInterf ace', () {
8642 final __test = new StaticWarningCodeTest(); 8910 final __test = new StaticWarningCodeTest();
(...skipping 16 matching lines...) Expand all
8659 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_method_optionalParamCount); 8927 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_method_optionalParamCount);
8660 }); 8928 });
8661 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterf ace', () { 8929 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_setter_fromInterf ace', () {
8662 final __test = new StaticWarningCodeTest(); 8930 final __test = new StaticWarningCodeTest();
8663 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_setter_fromInterface); 8931 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_setter_fromInterface);
8664 }); 8932 });
8665 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperc lass', () { 8933 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_setter_fromSuperc lass', () {
8666 final __test = new StaticWarningCodeTest(); 8934 final __test = new StaticWarningCodeTest();
8667 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_setter_fromSuperclass); 8935 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_setter_fromSuperclass);
8668 }); 8936 });
8937 _ut.test('test_nonAbstractClassInheritsAbstractMemberOne_superclasses_inte rface', () {
8938 final __test = new StaticWarningCodeTest();
8939 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberO ne_superclasses_interface);
8940 });
8669 _ut.test('test_nonAbstractClassInheritsAbstractMemberThree', () { 8941 _ut.test('test_nonAbstractClassInheritsAbstractMemberThree', () {
8670 final __test = new StaticWarningCodeTest(); 8942 final __test = new StaticWarningCodeTest();
8671 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberT hree); 8943 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberT hree);
8672 }); 8944 });
8673 _ut.test('test_nonAbstractClassInheritsAbstractMemberTwo', () { 8945 _ut.test('test_nonAbstractClassInheritsAbstractMemberTwo', () {
8674 final __test = new StaticWarningCodeTest(); 8946 final __test = new StaticWarningCodeTest();
8675 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberT wo); 8947 runJUnitTest(__test, __test.test_nonAbstractClassInheritsAbstractMemberT wo);
8676 }); 8948 });
8677 _ut.test('test_nonTypeInCatchClause_noElement', () { 8949 _ut.test('test_nonTypeInCatchClause_noElement', () {
8678 final __test = new StaticWarningCodeTest(); 8950 final __test = new StaticWarningCodeTest();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
8809 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember); 9081 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember);
8810 }); 9082 });
8811 _ut.test('test_continueLabelOnSwitch', () { 9083 _ut.test('test_continueLabelOnSwitch', () {
8812 final __test = new ErrorResolverTest(); 9084 final __test = new ErrorResolverTest();
8813 runJUnitTest(__test, __test.test_continueLabelOnSwitch); 9085 runJUnitTest(__test, __test.test_continueLabelOnSwitch);
8814 }); 9086 });
8815 }); 9087 });
8816 } 9088 }
8817 } 9089 }
8818 /** 9090 /**
8819 * Instances of the class {@code TestTypeProvider} implement a type provider tha t can be used by 9091 * Instances of the class `TestTypeProvider` implement a type provider that can be used by
8820 * tests without creating the element model for the core library. 9092 * tests without creating the element model for the core library.
8821 */ 9093 */
8822 class TestTypeProvider implements TypeProvider { 9094 class TestTypeProvider implements TypeProvider {
8823 9095
8824 /** 9096 /**
8825 * The type representing the built-in type 'bool'. 9097 * The type representing the built-in type 'bool'.
8826 */ 9098 */
8827 InterfaceType _boolType; 9099 InterfaceType _boolType;
8828 9100
8829 /** 9101 /**
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
8930 initializeNumericTypes(); 9202 initializeNumericTypes();
8931 } 9203 }
8932 return _intType; 9204 return _intType;
8933 } 9205 }
8934 InterfaceType get iterableType { 9206 InterfaceType get iterableType {
8935 if (_iterableType == null) { 9207 if (_iterableType == null) {
8936 ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable" , ["E"]); 9208 ClassElementImpl iterableElement = ElementFactory.classElement2("Iterable" , ["E"]);
8937 _iterableType = iterableElement.type; 9209 _iterableType = iterableElement.type;
8938 Type2 eType = iterableElement.typeVariables[0].type; 9210 Type2 eType = iterableElement.typeVariables[0].type;
8939 iterableElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("iterator", false, iteratorType.substitute5(<Type2> [eType])), Element Factory.getterElement("last", false, eType)]; 9211 iterableElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("iterator", false, iteratorType.substitute5(<Type2> [eType])), Element Factory.getterElement("last", false, eType)];
9212 propagateTypeArguments(iterableElement);
8940 } 9213 }
8941 return _iterableType; 9214 return _iterableType;
8942 } 9215 }
8943 InterfaceType get iteratorType { 9216 InterfaceType get iteratorType {
8944 if (_iteratorType == null) { 9217 if (_iteratorType == null) {
8945 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator" , ["E"]); 9218 ClassElementImpl iteratorElement = ElementFactory.classElement2("Iterator" , ["E"]);
8946 _iteratorType = iteratorElement.type; 9219 _iteratorType = iteratorElement.type;
8947 Type2 eType = iteratorElement.typeVariables[0].type; 9220 Type2 eType = iteratorElement.typeVariables[0].type;
8948 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("current", false, eType)]; 9221 iteratorElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("current", false, eType)];
9222 propagateTypeArguments(iteratorElement);
8949 } 9223 }
8950 return _iteratorType; 9224 return _iteratorType;
8951 } 9225 }
8952 InterfaceType get listType { 9226 InterfaceType get listType {
8953 if (_listType == null) { 9227 if (_listType == null) {
8954 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]) ; 9228 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]) ;
8955 listElement.constructors = <ConstructorElement> [ElementFactory.constructo rElement(listElement, null)]; 9229 listElement.constructors = <ConstructorElement> [ElementFactory.constructo rElement(listElement, null)];
8956 _listType = listElement.type; 9230 _listType = listElement.type;
8957 Type2 eType = listElement.typeVariables[0].type; 9231 Type2 eType = listElement.typeVariables[0].type;
8958 InterfaceType supertype = iterableType.substitute5(<Type2> [eType]); 9232 InterfaceType supertype = iterableType.substitute5(<Type2> [eType]);
8959 listElement.supertype = supertype; 9233 listElement.supertype = supertype;
8960 listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEl ement("length", false, intType)]; 9234 listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEl ement("length", false, intType)];
8961 listElement.methods = <MethodElement> [ElementFactory.methodElement("[]", eType, [intType]), ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [i ntType, eType])]; 9235 listElement.methods = <MethodElement> [ElementFactory.methodElement("[]", eType, [intType]), ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [i ntType, eType]), ElementFactory.methodElement("add", VoidTypeImpl.instance, [eTy pe])];
9236 propagateTypeArguments(listElement);
8962 } 9237 }
8963 return _listType; 9238 return _listType;
8964 } 9239 }
8965 InterfaceType get mapType { 9240 InterfaceType get mapType {
8966 if (_mapType == null) { 9241 if (_mapType == null) {
8967 ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V "]); 9242 ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V "]);
8968 _mapType = mapElement.type; 9243 _mapType = mapElement.type;
8969 mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEle ment("length", false, intType)]; 9244 mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEle ment("length", false, intType)];
9245 propagateTypeArguments(mapElement);
8970 } 9246 }
8971 return _mapType; 9247 return _mapType;
8972 } 9248 }
8973 InterfaceType get numType { 9249 InterfaceType get numType {
8974 if (_numType == null) { 9250 if (_numType == null) {
8975 initializeNumericTypes(); 9251 initializeNumericTypes();
8976 } 9252 }
8977 return _numType; 9253 return _numType;
8978 } 9254 }
8979 InterfaceType get objectType { 9255 InterfaceType get objectType {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
9028 List<FieldElement> fields = <FieldElement> [ElementFactory.fieldElement("NAN ", true, false, true, _doubleType), ElementFactory.fieldElement("INFINITY", true , false, true, _doubleType), ElementFactory.fieldElement("NEGATIVE_INFINITY", tr ue, false, true, _doubleType), ElementFactory.fieldElement("MIN_POSITIVE", true, false, true, _doubleType), ElementFactory.fieldElement("MAX_FINITE", true, fals e, true, _doubleType)]; 9304 List<FieldElement> fields = <FieldElement> [ElementFactory.fieldElement("NAN ", true, false, true, _doubleType), ElementFactory.fieldElement("INFINITY", true , false, true, _doubleType), ElementFactory.fieldElement("NEGATIVE_INFINITY", tr ue, false, true, _doubleType), ElementFactory.fieldElement("MIN_POSITIVE", true, false, true, _doubleType), ElementFactory.fieldElement("MAX_FINITE", true, fals e, true, _doubleType)];
9029 doubleElement.fields = fields; 9305 doubleElement.fields = fields;
9030 int fieldCount = fields.length; 9306 int fieldCount = fields.length;
9031 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount); 9307 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount);
9032 for (int i = 0; i < fieldCount; i++) { 9308 for (int i = 0; i < fieldCount; i++) {
9033 accessors[i] = fields[i].getter; 9309 accessors[i] = fields[i].getter;
9034 } 9310 }
9035 doubleElement.accessors = accessors; 9311 doubleElement.accessors = accessors;
9036 doubleElement.methods = <MethodElement> [ElementFactory.methodElement("remai nder", _doubleType, [_numType]), ElementFactory.methodElement("+", _doubleType, [_numType]), ElementFactory.methodElement("-", _doubleType, [_numType]), Element Factory.methodElement("*", _doubleType, [_numType]), ElementFactory.methodElemen t("%", _doubleType, [_numType]), ElementFactory.methodElement("/", _doubleType, [_numType]), ElementFactory.methodElement("~/", _doubleType, [_numType]), Elemen tFactory.methodElement("-", _doubleType, []), ElementFactory.methodElement("abs" , _doubleType, []), ElementFactory.methodElement("round", _doubleType, []), Elem entFactory.methodElement("floor", _doubleType, []), ElementFactory.methodElement ("ceil", _doubleType, []), ElementFactory.methodElement("truncate", _doubleType, []), ElementFactory.methodElement("toString", _stringType, [])]; 9312 doubleElement.methods = <MethodElement> [ElementFactory.methodElement("remai nder", _doubleType, [_numType]), ElementFactory.methodElement("+", _doubleType, [_numType]), ElementFactory.methodElement("-", _doubleType, [_numType]), Element Factory.methodElement("*", _doubleType, [_numType]), ElementFactory.methodElemen t("%", _doubleType, [_numType]), ElementFactory.methodElement("/", _doubleType, [_numType]), ElementFactory.methodElement("~/", _doubleType, [_numType]), Elemen tFactory.methodElement("-", _doubleType, []), ElementFactory.methodElement("abs" , _doubleType, []), ElementFactory.methodElement("round", _doubleType, []), Elem entFactory.methodElement("floor", _doubleType, []), ElementFactory.methodElement ("ceil", _doubleType, []), ElementFactory.methodElement("truncate", _doubleType, []), ElementFactory.methodElement("toString", _stringType, [])];
9037 } 9313 }
9314
9315 /**
9316 * Given a class element representing a class with type parameters, propagate those type
9317 * parameters to all of the accessors, methods and constructors defined for th e class.
9318 * @param classElement the element representing the class with type parameters
9319 */
9320 void propagateTypeArguments(ClassElementImpl classElement) {
9321 List<Type2> typeArguments = TypeVariableTypeImpl.getTypes(classElement.typeV ariables);
9322 for (PropertyAccessorElement accessor in classElement.accessors) {
9323 FunctionTypeImpl functionType = accessor.type as FunctionTypeImpl;
9324 functionType.typeArguments = typeArguments;
9325 }
9326 for (MethodElement method in classElement.methods) {
9327 FunctionTypeImpl functionType = method.type as FunctionTypeImpl;
9328 functionType.typeArguments = typeArguments;
9329 }
9330 for (ConstructorElement constructor in classElement.constructors) {
9331 FunctionTypeImpl functionType = constructor.type as FunctionTypeImpl;
9332 functionType.typeArguments = typeArguments;
9333 }
9334 }
9038 } 9335 }
9039 /** 9336 /**
9040 * The class {@code AnalysisContextFactory} defines utility methods used to crea te analysis contexts 9337 * The class `AnalysisContextFactory` defines utility methods used to create ana lysis contexts
9041 * for testing purposes. 9338 * for testing purposes.
9042 */ 9339 */
9043 class AnalysisContextFactory { 9340 class AnalysisContextFactory {
9044 9341
9045 /** 9342 /**
9046 * Create an analysis context that has a fake core library already resolved. 9343 * Create an analysis context that has a fake core library already resolved.
9047 * @return the analysis context that was created 9344 * @return the analysis context that was created
9048 */ 9345 */
9049 static AnalysisContextImpl contextWithCore() { 9346 static AnalysisContextImpl contextWithCore() {
9050 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl; 9347 AnalysisContextImpl sdkContext = DirectoryBasedDartSdk.defaultSdk.context as AnalysisContextImpl;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
9203 runJUnitTest(__test, __test.test_getErrorListener); 9500 runJUnitTest(__test, __test.test_getErrorListener);
9204 }); 9501 });
9205 _ut.test('test_prefixedAndNonPrefixed', () { 9502 _ut.test('test_prefixedAndNonPrefixed', () {
9206 final __test = new LibraryImportScopeTest(); 9503 final __test = new LibraryImportScopeTest();
9207 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed); 9504 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed);
9208 }); 9505 });
9209 }); 9506 });
9210 } 9507 }
9211 } 9508 }
9212 /** 9509 /**
9213 * Instances of the class {@code ResolutionVerifier} verify that all of the node s in an AST 9510 * Instances of the class `ResolutionVerifier` verify that all of the nodes in a n AST
9214 * structure that should have been resolved were resolved. 9511 * structure that should have been resolved were resolved.
9215 */ 9512 */
9216 class ResolutionVerifier extends RecursiveASTVisitor<Object> { 9513 class ResolutionVerifier extends RecursiveASTVisitor<Object> {
9217 9514
9218 /** 9515 /**
9219 * A set containing nodes that are known to not be resolvable and should there fore not cause the 9516 * A set containing nodes that are known to not be resolvable and should there fore not cause the
9220 * test to fail. 9517 * test to fail.
9221 */ 9518 */
9222 Set<ASTNode> _knownExceptions; 9519 Set<ASTNode> _knownExceptions;
9223 9520
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
9764 indexExpression.staticElement = indexMethod; 10061 indexExpression.staticElement = indexMethod;
9765 indexExpression.element = indexMethod; 10062 indexExpression.element = indexMethod;
9766 ASTFactory.assignmentExpression(indexExpression, TokenType.EQ, ASTFactory.in teger(0)); 10063 ASTFactory.assignmentExpression(indexExpression, TokenType.EQ, ASTFactory.in teger(0));
9767 JUnitTestCase.assertSame(intType, analyze(indexExpression)); 10064 JUnitTestCase.assertSame(intType, analyze(indexExpression));
9768 _listener.assertNoErrors(); 10065 _listener.assertNoErrors();
9769 } 10066 }
9770 void test_visitInstanceCreationExpression_named() { 10067 void test_visitInstanceCreationExpression_named() {
9771 ClassElementImpl classElement = ElementFactory.classElement2("C", []); 10068 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
9772 String constructorName = "m"; 10069 String constructorName = "m";
9773 ConstructorElementImpl constructor = ElementFactory.constructorElement(class Element, constructorName); 10070 ConstructorElementImpl constructor = ElementFactory.constructorElement(class Element, constructorName);
10071 constructor.returnType = classElement.type;
9774 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 10072 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
9775 constructorType.returnType = classElement.type;
9776 constructor.type = constructorType; 10073 constructor.type = constructorType;
9777 classElement.constructors = <ConstructorElement> [constructor]; 10074 classElement.constructors = <ConstructorElement> [constructor];
9778 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam e)]); 10075 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), [ASTFactory.identifier3(constructorNam e)]);
9779 node.element = constructor; 10076 node.element = constructor;
9780 JUnitTestCase.assertSame(classElement.type, analyze(node)); 10077 JUnitTestCase.assertSame(classElement.type, analyze(node));
9781 _listener.assertNoErrors(); 10078 _listener.assertNoErrors();
9782 } 10079 }
9783 void test_visitInstanceCreationExpression_typeParameters() { 10080 void test_visitInstanceCreationExpression_typeParameters() {
9784 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]); 10081 ClassElementImpl elementC = ElementFactory.classElement2("C", ["E"]);
9785 ClassElementImpl elementI = ElementFactory.classElement2("I", []); 10082 ClassElementImpl elementI = ElementFactory.classElement2("I", []);
9786 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme ntC, null); 10083 ConstructorElementImpl constructor = ElementFactory.constructorElement(eleme ntC, null);
9787 elementC.constructors = <ConstructorElement> [constructor]; 10084 elementC.constructors = <ConstructorElement> [constructor];
10085 constructor.returnType = elementC.type;
9788 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 10086 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
9789 constructorType.returnType = elementC.type;
9790 constructor.type = constructorType; 10087 constructor.type = constructorType;
9791 TypeName typeName = ASTFactory.typeName(elementC, [ASTFactory.typeName(eleme ntI, [])]); 10088 TypeName typeName = ASTFactory.typeName(elementC, [ASTFactory.typeName(eleme ntI, [])]);
9792 typeName.type = elementC.type.substitute5(<Type2> [elementI.type]); 10089 typeName.type = elementC.type.substitute5(<Type2> [elementI.type]);
9793 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, typeName, []); 10090 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, typeName, []);
9794 node.element = constructor; 10091 node.element = constructor;
9795 InterfaceType interfaceType = analyze(node) as InterfaceType; 10092 InterfaceType interfaceType = analyze(node) as InterfaceType;
9796 List<Type2> typeArgs = interfaceType.typeArguments; 10093 List<Type2> typeArgs = interfaceType.typeArguments;
9797 JUnitTestCase.assertEquals(1, typeArgs.length); 10094 JUnitTestCase.assertEquals(1, typeArgs.length);
9798 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]); 10095 JUnitTestCase.assertEquals(elementI.type, typeArgs[0]);
9799 _listener.assertNoErrors(); 10096 _listener.assertNoErrors();
9800 } 10097 }
9801 void test_visitInstanceCreationExpression_unnamed() { 10098 void test_visitInstanceCreationExpression_unnamed() {
9802 ClassElementImpl classElement = ElementFactory.classElement2("C", []); 10099 ClassElementImpl classElement = ElementFactory.classElement2("C", []);
9803 ConstructorElementImpl constructor = ElementFactory.constructorElement(class Element, null); 10100 ConstructorElementImpl constructor = ElementFactory.constructorElement(class Element, null);
10101 constructor.returnType = classElement.type;
9804 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); 10102 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor);
9805 constructorType.returnType = classElement.type;
9806 constructor.type = constructorType; 10103 constructor.type = constructorType;
9807 classElement.constructors = <ConstructorElement> [constructor]; 10104 classElement.constructors = <ConstructorElement> [constructor];
9808 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), []); 10105 InstanceCreationExpression node = ASTFactory.instanceCreationExpression2(nul l, ASTFactory.typeName(classElement, []), []);
9809 node.element = constructor; 10106 node.element = constructor;
9810 JUnitTestCase.assertSame(classElement.type, analyze(node)); 10107 JUnitTestCase.assertSame(classElement.type, analyze(node));
9811 _listener.assertNoErrors(); 10108 _listener.assertNoErrors();
9812 } 10109 }
9813 void test_visitIntegerLiteral() { 10110 void test_visitIntegerLiteral() {
9814 Expression node = resolvedInteger(42); 10111 Expression node = resolvedInteger(42);
9815 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node)); 10112 JUnitTestCase.assertSame(_typeProvider.intType, analyze(node));
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
10118 * @return an integer literal that has been resolved to the correct type 10415 * @return an integer literal that has been resolved to the correct type
10119 */ 10416 */
10120 DoubleLiteral resolvedDouble(double value) { 10417 DoubleLiteral resolvedDouble(double value) {
10121 DoubleLiteral literal = ASTFactory.doubleLiteral(value); 10418 DoubleLiteral literal = ASTFactory.doubleLiteral(value);
10122 literal.staticType = _typeProvider.doubleType; 10419 literal.staticType = _typeProvider.doubleType;
10123 return literal; 10420 return literal;
10124 } 10421 }
10125 10422
10126 /** 10423 /**
10127 * Create a function expression that has an element associated with it, where the element has an 10424 * Create a function expression that has an element associated with it, where the element has an
10128 * incomplete type associated with it (just like the one{@link ElementBuilder# visitFunctionExpression(FunctionExpression)} would have built if we had 10425 * incomplete type associated with it (just like the one[ElementBuilder#visitF unctionExpression] would have built if we had
10129 * run it). 10426 * run it).
10130 * @param parameters the parameters to the function 10427 * @param parameters the parameters to the function
10131 * @param body the body of the function 10428 * @param body the body of the function
10132 * @return a resolved function expression 10429 * @return a resolved function expression
10133 */ 10430 */
10134 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters2, FunctionBody body) { 10431 FunctionExpression resolvedFunctionExpression(FormalParameterList parameters2, FunctionBody body) {
10135 for (FormalParameter parameter in parameters2.parameters) { 10432 for (FormalParameter parameter in parameters2.parameters) {
10136 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er); 10433 ParameterElementImpl element = new ParameterElementImpl(parameter.identifi er);
10137 element.parameterKind = parameter.kind; 10434 element.parameterKind = parameter.kind;
10138 element.type = _typeProvider.dynamicType; 10435 element.type = _typeProvider.dynamicType;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
10522 LibraryElement definingLibrary3; 10819 LibraryElement definingLibrary3;
10523 GatheringErrorListener errorListener3; 10820 GatheringErrorListener errorListener3;
10524 Scope_17(this.definingLibrary3, this.errorListener3) : super(); 10821 Scope_17(this.definingLibrary3, this.errorListener3) : super();
10525 LibraryElement get definingLibrary => definingLibrary3; 10822 LibraryElement get definingLibrary => definingLibrary3;
10526 AnalysisErrorListener get errorListener => errorListener3; 10823 AnalysisErrorListener get errorListener => errorListener3;
10527 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null; 10824 Element lookup3(Identifier identifier, String name, LibraryElement referencing Library) => null;
10528 } 10825 }
10529 class LibraryElementBuilderTest extends EngineTestCase { 10826 class LibraryElementBuilderTest extends EngineTestCase {
10530 10827
10531 /** 10828 /**
10532 * The source factory used to create {@link Source sources}. 10829 * The source factory used to create [Source sources].
10533 */ 10830 */
10534 SourceFactory _sourceFactory; 10831 SourceFactory _sourceFactory;
10535 void setUp() { 10832 void setUp() {
10536 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]); 10833 _sourceFactory = new SourceFactory.con2([new FileUriResolver()]);
10537 } 10834 }
10538 void test_accessorsAcrossFiles() { 10835 void test_accessorsAcrossFiles() {
10539 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "part 'first.dart';", "part 'second.dart';"])); 10836 Source librarySource = addSource("/lib.dart", EngineTestCase.createSource([" library lib;", "part 'first.dart';", "part 'second.dart';"]));
10540 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "int g et V => 0;"])); 10837 addSource("/first.dart", EngineTestCase.createSource(["part of lib;", "int g et V => 0;"]));
10541 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "void set V(int v) {}"])); 10838 addSource("/second.dart", EngineTestCase.createSource(["part of lib;", "void set V(int v) {}"]));
10542 LibraryElement element = buildLibrary(librarySource, []); 10839 LibraryElement element = buildLibrary(librarySource, []);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
11085 assertNoErrors(); 11382 assertNoErrors();
11086 verify([source]); 11383 verify([source]);
11087 } 11384 }
11088 void test_resolveAgainstNull() { 11385 void test_resolveAgainstNull() {
11089 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu rn null == p;", "}"])); 11386 Source source = addSource(EngineTestCase.createSource(["f(var p) {", " retu rn null == p;", "}"]));
11090 resolve(source); 11387 resolve(source);
11091 assertNoErrors(); 11388 assertNoErrors();
11092 verify([source]); 11389 verify([source]);
11093 } 11390 }
11094 void test_setter_inherited() { 11391 void test_setter_inherited() {
11095 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et x => 0;", " set x(int p) {}", "}", "class B extends A {", " int get x => su per.x == null ? 0 : super.x;", " void f() => x = 1;", "}"])); 11392 Source source = addSource(EngineTestCase.createSource(["class A {", " int g et x => 0;", " set x(int p) {}", "}", "class B extends A {", " int get x => su per.x == null ? 0 : super.x;", " int f() => x = 1;", "}"]));
11096 resolve(source); 11393 resolve(source);
11097 assertNoErrors(); 11394 assertNoErrors();
11098 verify([source]); 11395 verify([source]);
11099 } 11396 }
11100 void test_setter_static() { 11397 void test_setter_static() {
11101 Source source = addSource(EngineTestCase.createSource(["set s(x) {", "}", "" , "main() {", " s = 123;", "}"])); 11398 Source source = addSource(EngineTestCase.createSource(["set s(x) {", "}", "" , "main() {", " s = 123;", "}"]));
11102 resolve(source); 11399 resolve(source);
11103 assertNoErrors(); 11400 assertNoErrors();
11104 verify([source]); 11401 verify([source]);
11105 } 11402 }
11106 11403
11107 /** 11404 /**
11108 * Resolve the given source and verify that the arguments in a specific method invocation were 11405 * Resolve the given source and verify that the arguments in a specific method invocation were
11109 * correctly resolved. 11406 * correctly resolved.
11110 * <p> 11407 *
11111 * The source is expected to be source for a compilation unit, the first decla ration is expected 11408 * The source is expected to be source for a compilation unit, the first decla ration is expected
11112 * to be a class, the first member of which is expected to be a method with a block body, and the 11409 * to be a class, the first member of which is expected to be a method with a block body, and the
11113 * first statement in the body is expected to be an expression statement whose expression is a 11410 * first statement in the body is expected to be an expression statement whose expression is a
11114 * method invocation. It is the arguments to that method invocation that are t ested. The method 11411 * method invocation. It is the arguments to that method invocation that are t ested. The method
11115 * invocation can contain errors. 11412 * invocation can contain errors.
11116 * <p> 11413 *
11117 * The arguments were resolved correctly if the number of expressions in the l ist matches the 11414 * The arguments were resolved correctly if the number of expressions in the l ist matches the
11118 * length of the array of indices and if, for each index in the array of indic es, the parameter to 11415 * length of the array of indices and if, for each index in the array of indic es, the parameter to
11119 * which the argument expression was resolved is the parameter in the invoked method's list of 11416 * which the argument expression was resolved is the parameter in the invoked method's list of
11120 * parameters at that index. Arguments that should not be resolved to a parame ter because of an 11417 * parameters at that index. Arguments that should not be resolved to a parame ter because of an
11121 * error can be denoted by including a negative index in the array of indices. 11418 * error can be denoted by including a negative index in the array of indices.
11122 * @param source the source to be resolved 11419 * @param source the source to be resolved
11123 * @param indices the array of indices used to associate arguments with parame ters 11420 * @param indices the array of indices used to associate arguments with parame ters
11124 * @throws Exception if the source could not be resolved or if the structure o f the source is not 11421 * @throws Exception if the source could not be resolved or if the structure o f the source is not
11125 * valid 11422 * valid
11126 */ 11423 */
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
11340 // TypeOverrideManagerTest.dartSuite(); 11637 // TypeOverrideManagerTest.dartSuite();
11341 // TypeProviderImplTest.dartSuite(); 11638 // TypeProviderImplTest.dartSuite();
11342 // TypeResolverVisitorTest.dartSuite(); 11639 // TypeResolverVisitorTest.dartSuite();
11343 // EnclosedScopeTest.dartSuite(); 11640 // EnclosedScopeTest.dartSuite();
11344 // LibraryImportScopeTest.dartSuite(); 11641 // LibraryImportScopeTest.dartSuite();
11345 // LibraryScopeTest.dartSuite(); 11642 // LibraryScopeTest.dartSuite();
11346 // ScopeTest.dartSuite(); 11643 // ScopeTest.dartSuite();
11347 // CompileTimeErrorCodeTest.dartSuite(); 11644 // CompileTimeErrorCodeTest.dartSuite();
11348 // ErrorResolverTest.dartSuite(); 11645 // ErrorResolverTest.dartSuite();
11349 // NonErrorResolverTest.dartSuite(); 11646 // NonErrorResolverTest.dartSuite();
11350 // PubSuggestionCodeTest.dartSuite();
11351 // SimpleResolverTest.dartSuite(); 11647 // SimpleResolverTest.dartSuite();
11352 // StaticTypeWarningCodeTest.dartSuite(); 11648 // StaticTypeWarningCodeTest.dartSuite();
11353 // StaticWarningCodeTest.dartSuite(); 11649 // StaticWarningCodeTest.dartSuite();
11354 // StrictModeTest.dartSuite(); 11650 // StrictModeTest.dartSuite();
11355 // TypePropagationTest.dartSuite(); 11651 // TypePropagationTest.dartSuite();
11356 } 11652 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/test/generated/parser_test.dart ('k') | pkg/analyzer_experimental/test/generated/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698