Index: pkg/analyzer/test/generated/hint_code_test.dart |
diff --git a/pkg/analyzer/test/generated/hint_code_test.dart b/pkg/analyzer/test/generated/hint_code_test.dart |
index bc5c9829dd2dfc060ebf4a60ee98ad0fe4af944d..585f24d4e725bc9d037427ec6c659c5c9c618ddb 100644 |
--- a/pkg/analyzer/test/generated/hint_code_test.dart |
+++ b/pkg/analyzer/test/generated/hint_code_test.dart |
@@ -619,6 +619,105 @@ f() { |
verify([source]); |
} |
+ void test_deadCode_statementAfterExitingIf_function() { |
Brian Wilkerson
2016/05/04 17:28:19
If ExitDetector worked, then most of these tests c
srawlins
2016/05/19 18:36:44
You're right. Dramatically reduced tests!
|
+ Source source = addSource(r''' |
+f() { |
+ if (1 > 2) { |
+ return; |
+ } else { |
+ return; |
+ } |
+ var two = 2; |
+}'''); |
+ computeLibrarySourceErrors(source); |
+ assertErrors(source, [HintCode.DEAD_CODE]); |
+ verify([source]); |
+ } |
+ |
+ void test_deadCode_statementAfterExitingIf_returns() { |
+ Source source = addSource(r''' |
+f() { |
+ if (1 > 2) { |
+ return; |
+ } else { |
+ return; |
+ } |
+ var one = 1; |
+}'''); |
+ computeLibrarySourceErrors(source); |
+ assertErrors(source, [HintCode.DEAD_CODE]); |
+ verify([source]); |
+ } |
+ |
+ void test_deadCode_statementAfterExitingIf_throws() { |
+ Source source = addSource(r''' |
+f() { |
+ if (1 > 2) { |
+ throw 'Stopping in then'; |
+ } else { |
+ throw 'Stopping in else'; |
+ } |
+ var one = 1; |
+}'''); |
+ computeLibrarySourceErrors(source); |
+ assertErrors(source, [HintCode.DEAD_CODE]); |
+ verify([source]); |
+ } |
+ |
+ void test_deadCode_statementAfterExitingIf_loops() { |
+ Source source = addSource(r''' |
+f() { |
+ if (1 > 2) { |
+ while (true) { print('Hello'); } |
+ } else { |
+ while (true) { print('Hello'); } |
+ } |
+ var one = 1; |
+}'''); |
+ computeLibrarySourceErrors(source); |
+ assertErrors(source, [HintCode.DEAD_CODE]); |
+ verify([source]); |
+ } |
+ |
+ void test_deadCode_statementAfterExitingDo_returns() { |
+ Source source = addSource(r''' |
+f() { |
+ do { |
+ return; |
+ } while (1 < 0); |
+ var one = 1; |
+}'''); |
+ computeLibrarySourceErrors(source); |
+ assertErrors(source, [HintCode.DEAD_CODE]); |
+ verify([source]); |
+ } |
+ |
+ void test_deadCode_statementAfterExitingDo_throws() { |
+ Source source = addSource(r''' |
+f() { |
+ do { |
+ throw 'me'; |
+ } while (1 < 0); |
+ var one = 1; |
+}'''); |
+ computeLibrarySourceErrors(source); |
+ assertErrors(source, [HintCode.DEAD_CODE]); |
+ verify([source]); |
+ } |
+ |
+ void test_deadCode_statementAfterExitingDo_loops() { |
+ Source source = addSource(r''' |
+f() { |
+ do { |
+ while (true) print('Hello'); |
+ } while (1 < 0); |
+ var one = 1; |
+}'''); |
+ computeLibrarySourceErrors(source); |
+ assertErrors(source, [HintCode.DEAD_CODE]); |
+ verify([source]); |
+ } |
+ |
void test_deprecatedAnnotationUse_assignment() { |
Source source = addSource(r''' |
class A { |