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

Unified Diff: pkg/analyzer/test/generated/non_hint_code_test.dart

Issue 1943443002: If an if or do statement always exits, following statements are dead. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add tests Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/generated/non_hint_code_test.dart
diff --git a/pkg/analyzer/test/generated/non_hint_code_test.dart b/pkg/analyzer/test/generated/non_hint_code_test.dart
index 9fc1dfb311802623f4f9e70422f44aa7148fb980..2bccd5e755fef5f8ed2b5741515d54a7f2cdfec2 100644
--- a/pkg/analyzer/test/generated/non_hint_code_test.dart
+++ b/pkg/analyzer/test/generated/non_hint_code_test.dart
@@ -158,6 +158,76 @@ f() {
verify([source]);
}
+ void test_deadCode_statementAfterLabelledBreak() {
+ Source source = addSource(r'''
+f() {
+ outer:
+ while (1 < 2) {
+ while (2 < 3) {
+ break outer;
+ int a = 1;
+ }
+ }
+}''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_deadCode_statementAfterIfWithoutThen() {
+ Source source = addSource(r'''
+f() {
+ if (1 < 0);
+ int a = 1;
+}''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_deadCode_statementAfterIfWithoutElse() {
+ Source source = addSource(r'''
+f() {
+ if (1 < 0) {
+ return;
+ }
+ int a = 1;
+}''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_deadCode_statementAfterIfDoesntExit() {
+ Source source = addSource(r'''
+f() {
+ if (1 < 0) {
+ if (1 > 0)
+ return;
+ } else {
+ return;
+ }
+ int a = 1;
+}''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_deadCode_statementAfterDoDoesntAlwaysExit() {
+ Source source = addSource(r'''
+f() {
+ do {
+ if (1 > 0)
+ return;
+ } while (1 > 0);
+ int a = 1;
+}''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
void test_deprecatedMemberUse_inDeprecatedClass() {
Source source = addSource(r'''
@deprecated

Powered by Google App Engine
This is Rietveld 408576698