OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.generated.non_hint_code_test; | 5 library analyzer.test.generated.non_hint_code_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/error.dart'; | 7 import 'package:analyzer/src/generated/error.dart'; |
8 import 'package:analyzer/src/generated/source_io.dart'; | 8 import 'package:analyzer/src/generated/source_io.dart'; |
9 | 9 |
10 import '../reflective_tests.dart'; | 10 import '../reflective_tests.dart'; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 Source source = addSource(r''' | 151 Source source = addSource(r''' |
152 const bool DEBUG = true; | 152 const bool DEBUG = true; |
153 f() { | 153 f() { |
154 bool b = DEBUG || true; | 154 bool b = DEBUG || true; |
155 }'''); | 155 }'''); |
156 computeLibrarySourceErrors(source); | 156 computeLibrarySourceErrors(source); |
157 assertNoErrors(source); | 157 assertNoErrors(source); |
158 verify([source]); | 158 verify([source]); |
159 } | 159 } |
160 | 160 |
| 161 void test_deadCode_statementAfterLabelledBreak() { |
| 162 Source source = addSource(r''' |
| 163 f() { |
| 164 outer: |
| 165 while (1 < 2) { |
| 166 while (2 < 3) { |
| 167 break outer; |
| 168 int a = 1; |
| 169 } |
| 170 } |
| 171 }'''); |
| 172 computeLibrarySourceErrors(source); |
| 173 assertNoErrors(source); |
| 174 verify([source]); |
| 175 } |
| 176 |
| 177 void test_deadCode_statementAfterIfWithoutThen() { |
| 178 Source source = addSource(r''' |
| 179 f() { |
| 180 if (1 < 0); |
| 181 int a = 1; |
| 182 }'''); |
| 183 computeLibrarySourceErrors(source); |
| 184 assertNoErrors(source); |
| 185 verify([source]); |
| 186 } |
| 187 |
| 188 void test_deadCode_statementAfterIfWithoutElse() { |
| 189 Source source = addSource(r''' |
| 190 f() { |
| 191 if (1 < 0) { |
| 192 return; |
| 193 } |
| 194 int a = 1; |
| 195 }'''); |
| 196 computeLibrarySourceErrors(source); |
| 197 assertNoErrors(source); |
| 198 verify([source]); |
| 199 } |
| 200 |
| 201 void test_deadCode_statementAfterIfDoesntExit() { |
| 202 Source source = addSource(r''' |
| 203 f() { |
| 204 if (1 < 0) { |
| 205 if (1 > 0) |
| 206 return; |
| 207 } else { |
| 208 return; |
| 209 } |
| 210 int a = 1; |
| 211 }'''); |
| 212 computeLibrarySourceErrors(source); |
| 213 assertNoErrors(source); |
| 214 verify([source]); |
| 215 } |
| 216 |
| 217 void test_deadCode_statementAfterDoDoesntAlwaysExit() { |
| 218 Source source = addSource(r''' |
| 219 f() { |
| 220 do { |
| 221 if (1 > 0) |
| 222 return; |
| 223 } while (1 > 0); |
| 224 int a = 1; |
| 225 }'''); |
| 226 computeLibrarySourceErrors(source); |
| 227 assertNoErrors(source); |
| 228 verify([source]); |
| 229 } |
| 230 |
161 void test_deprecatedMemberUse_inDeprecatedClass() { | 231 void test_deprecatedMemberUse_inDeprecatedClass() { |
162 Source source = addSource(r''' | 232 Source source = addSource(r''' |
163 @deprecated | 233 @deprecated |
164 f() {} | 234 f() {} |
165 | 235 |
166 @deprecated | 236 @deprecated |
167 class C { | 237 class C { |
168 m() { | 238 m() { |
169 f(); | 239 f(); |
170 } | 240 } |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 | 1296 |
1227 void test_import_valid_outside_lib() { | 1297 void test_import_valid_outside_lib() { |
1228 cacheSource("/myproj/pubspec.yaml", ""); | 1298 cacheSource("/myproj/pubspec.yaml", ""); |
1229 cacheSource("/myproj/web/other.dart", ""); | 1299 cacheSource("/myproj/web/other.dart", ""); |
1230 Source source = | 1300 Source source = |
1231 addNamedSource("/myproj/lib2/test.dart", "import '../web/other.dart';"); | 1301 addNamedSource("/myproj/lib2/test.dart", "import '../web/other.dart';"); |
1232 computeLibrarySourceErrors(source); | 1302 computeLibrarySourceErrors(source); |
1233 assertNoErrors(source); | 1303 assertNoErrors(source); |
1234 } | 1304 } |
1235 } | 1305 } |
OLD | NEW |