OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library engine.resolver_test; | 5 library engine.resolver_test; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/context/context.dart' as newContext; | 9 import 'package:analyzer/src/context/context.dart' as newContext; |
10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
(...skipping 3135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3146 void test_missingReturn_method() { | 3146 void test_missingReturn_method() { |
3147 Source source = addSource(r''' | 3147 Source source = addSource(r''' |
3148 class A { | 3148 class A { |
3149 int m() {} | 3149 int m() {} |
3150 }'''); | 3150 }'''); |
3151 computeLibrarySourceErrors(source); | 3151 computeLibrarySourceErrors(source); |
3152 assertErrors(source, [HintCode.MISSING_RETURN]); | 3152 assertErrors(source, [HintCode.MISSING_RETURN]); |
3153 verify([source]); | 3153 verify([source]); |
3154 } | 3154 } |
3155 | 3155 |
| 3156 void test_nullAwareInCondition_do() { |
| 3157 Source source = addSource(r''' |
| 3158 m(x) { |
| 3159 do {} while (x?.y); |
| 3160 } |
| 3161 '''); |
| 3162 computeLibrarySourceErrors(source); |
| 3163 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); |
| 3164 verify([source]); |
| 3165 } |
| 3166 |
| 3167 void test_nullAwareInCondition_for() { |
| 3168 Source source = addSource(r''' |
| 3169 m(x) { |
| 3170 for (var v = x; v?.y; v = v.next) {} |
| 3171 } |
| 3172 '''); |
| 3173 computeLibrarySourceErrors(source); |
| 3174 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); |
| 3175 verify([source]); |
| 3176 } |
| 3177 |
| 3178 void test_nullAwareInCondition_if() { |
| 3179 Source source = addSource(r''' |
| 3180 m(x) { |
| 3181 if (x?.y) {} |
| 3182 } |
| 3183 '''); |
| 3184 computeLibrarySourceErrors(source); |
| 3185 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); |
| 3186 verify([source]); |
| 3187 } |
| 3188 |
| 3189 void test_nullAwareInCondition_if_parenthesized() { |
| 3190 Source source = addSource(r''' |
| 3191 m(x) { |
| 3192 if ((x?.y)) {} |
| 3193 } |
| 3194 '''); |
| 3195 computeLibrarySourceErrors(source); |
| 3196 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); |
| 3197 verify([source]); |
| 3198 } |
| 3199 |
| 3200 void test_nullAwareInCondition_while() { |
| 3201 Source source = addSource(r''' |
| 3202 m(x) { |
| 3203 while (x?.y) {} |
| 3204 } |
| 3205 '''); |
| 3206 computeLibrarySourceErrors(source); |
| 3207 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); |
| 3208 verify([source]); |
| 3209 } |
| 3210 |
3156 void test_overrideOnNonOverridingGetter_invalid() { | 3211 void test_overrideOnNonOverridingGetter_invalid() { |
3157 Source source = addSource(r''' | 3212 Source source = addSource(r''' |
3158 library dart.core; | 3213 library dart.core; |
3159 const override = null; | 3214 const override = null; |
3160 class A { | 3215 class A { |
3161 } | 3216 } |
3162 class B extends A { | 3217 class B extends A { |
3163 @override | 3218 @override |
3164 int get m => 1; | 3219 int get m => 1; |
3165 }'''); | 3220 }'''); |
(...skipping 3727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6893 verify([source]); | 6948 verify([source]); |
6894 } | 6949 } |
6895 | 6950 |
6896 void test_missingReturn_voidReturnType() { | 6951 void test_missingReturn_voidReturnType() { |
6897 Source source = addSource("void f() {}"); | 6952 Source source = addSource("void f() {}"); |
6898 computeLibrarySourceErrors(source); | 6953 computeLibrarySourceErrors(source); |
6899 assertNoErrors(source); | 6954 assertNoErrors(source); |
6900 verify([source]); | 6955 verify([source]); |
6901 } | 6956 } |
6902 | 6957 |
| 6958 void test_nullAwareInCondition_for_noCondition() { |
| 6959 Source source = addSource(r''' |
| 6960 m(x) { |
| 6961 for (var v = x; ; v++) {} |
| 6962 } |
| 6963 '''); |
| 6964 computeLibrarySourceErrors(source); |
| 6965 assertNoErrors(source); |
| 6966 verify([source]); |
| 6967 } |
| 6968 |
| 6969 void test_nullAwareInCondition_if_notTopLevel() { |
| 6970 Source source = addSource(r''' |
| 6971 m(x) { |
| 6972 if (x?.y == null) {} |
| 6973 } |
| 6974 '''); |
| 6975 computeLibrarySourceErrors(source); |
| 6976 assertNoErrors(source); |
| 6977 verify([source]); |
| 6978 } |
| 6979 |
6903 void test_overrideEqualsButNotHashCode() { | 6980 void test_overrideEqualsButNotHashCode() { |
6904 Source source = addSource(r''' | 6981 Source source = addSource(r''' |
6905 class A { | 6982 class A { |
6906 bool operator ==(x) { return x; } | 6983 bool operator ==(x) { return x; } |
6907 get hashCode => 0; | 6984 get hashCode => 0; |
6908 }'''); | 6985 }'''); |
6909 computeLibrarySourceErrors(source); | 6986 computeLibrarySourceErrors(source); |
6910 assertNoErrors(source); | 6987 assertNoErrors(source); |
6911 verify([source]); | 6988 verify([source]); |
6912 } | 6989 } |
(...skipping 7940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14853 | 14930 |
14854 void _resolveTestUnit(String code) { | 14931 void _resolveTestUnit(String code) { |
14855 testCode = code; | 14932 testCode = code; |
14856 testSource = addSource(testCode); | 14933 testSource = addSource(testCode); |
14857 LibraryElement library = resolve2(testSource); | 14934 LibraryElement library = resolve2(testSource); |
14858 assertNoErrors(testSource); | 14935 assertNoErrors(testSource); |
14859 verify([testSource]); | 14936 verify([testSource]); |
14860 testUnit = resolveCompilationUnit(testSource, library); | 14937 testUnit = resolveCompilationUnit(testSource, library); |
14861 } | 14938 } |
14862 } | 14939 } |
OLD | NEW |