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

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

Issue 2054323002: Fix exit detection for try statements. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add tests without a "finally" clause Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/non_hint_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/all_the_rest_test.dart
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index fcf09dee47dbea8966b6d5a44f4c9f13fd799970..8adce9de86a7d1c93efd445ac04e937c576edffe 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -3479,14 +3479,14 @@ class ExitDetectorTest extends ParserTestCase {
expect(new ExitDetector(), isNotNull);
}
- void test_doStatement_throwCondition() {
- _assertTrue("{ do {} while (throw ''); }");
- }
-
void test_doStatement_return() {
_assertTrue("{ do { return null; } while (1 == 2); }");
}
+ void test_doStatement_throwCondition() {
+ _assertTrue("{ do {} while (throw ''); }");
+ }
+
void test_doStatement_true_break() {
_assertFalse("{ do { break; } while (true); }");
}
@@ -3779,16 +3779,85 @@ class ExitDetectorTest extends ParserTestCase {
_assertFalse("try {} catch (e, s) {} finally {}");
}
+ void test_tryStatement_noReturn_noFinally() {
+ _assertFalse("try {} catch (e, s) {}");
+ }
+
void test_tryStatement_return_catch() {
_assertFalse("try {} catch (e, s) { return 1; } finally {}");
}
+ void test_tryStatement_return_catch_noFinally() {
+ _assertFalse("try {} catch (e, s) { return 1; }");
+ }
+
void test_tryStatement_return_finally() {
_assertTrue("try {} catch (e, s) {} finally { return 1; }");
}
- void test_tryStatement_return_try() {
- _assertTrue("try { return 1; } catch (e, s) {} finally {}");
+ void test_tryStatement_return_try_noCatch() {
+ _assertTrue("try { return 1; } finally {}");
+ }
+
+ void test_tryStatement_return_try_oneCatchDoesNotExit() {
+ _assertFalse("try { return 1; } catch (e, s) {} finally {}");
+ }
+
+ void test_tryStatement_return_try_oneCatchDoesNotExit_noFinally() {
+ _assertFalse("try { return 1; } catch (e, s) {}");
+ }
+
+ void test_tryStatement_return_try_oneCatchExits() {
+ _assertTrue("try { return 1; } catch (e, s) { return 1; } finally {}");
+ }
+
+ void test_tryStatement_return_try_oneCatchExits_noFinally() {
+ _assertTrue("try { return 1; } catch (e, s) { return 1; }");
+ }
+
+ void test_tryStatement_return_try_twoCatchesDoExit() {
+ _assertTrue('''
+try { return 1; }
+on int catch (e, s) { return 1; }
+on String catch (e, s) { return 1; }
+finally {}''');
+ }
+
+ void test_tryStatement_return_try_twoCatchesDoExit_noFinally() {
+ _assertTrue('''
+try { return 1; }
+on int catch (e, s) { return 1; }
+on String catch (e, s) { return 1; }''');
+ }
+
+ void test_tryStatement_return_try_twoCatchesDoNotExit() {
+ _assertFalse('''
+try { return 1; }
+on int catch (e, s) {}
+on String catch (e, s) {}
+finally {}''');
+ }
+
+ void test_tryStatement_return_try_twoCatchesDoNotExit_noFinally() {
+ _assertFalse('''
+try { return 1; }
+on int catch (e, s) {}
+on String catch (e, s) {}''');
+ }
+
+ void test_tryStatement_return_try_twoCatchesMixed() {
+ _assertFalse('''
+try { return 1; }
+on int catch (e, s) {}
+on String catch (e, s) { return 1; }
+finally {}''');
+ }
+
+ void test_tryStatement_return_try_twoCatchesMixed_noFinally() {
+ _assertFalse('''
+try { return 1; }
+on int catch (e, s) {}
+on String catch (e, s) { return 1; }''');
}
void test_variableDeclarationStatement_noInitializer() {
@@ -3987,28 +4056,28 @@ void f() sync* {
_assertNthStatementDoesNotExit(source, 0);
}
- void test_yieldStatement_throw() {
+ void test_yieldStatement_star_plain() {
Source source = addSource(r'''
void f() sync* {
- yield throw '';
+ yield* 1;
}
''');
- _assertNthStatementExits(source, 0);
+ _assertNthStatementDoesNotExit(source, 0);
}
- void test_yieldStatement_star_plain() {
+ void test_yieldStatement_star_throw() {
Source source = addSource(r'''
void f() sync* {
- yield* 1;
+ yield* throw '';
}
''');
- _assertNthStatementDoesNotExit(source, 0);
+ _assertNthStatementExits(source, 0);
}
- void test_yieldStatement_star_throw() {
+ void test_yieldStatement_throw() {
Source source = addSource(r'''
void f() sync* {
- yield* throw '';
+ yield throw '';
}
''');
_assertNthStatementExits(source, 0);
@@ -4025,14 +4094,14 @@ void f() sync* {
// Assert that the [n]th statement in the last function declaration of
// [source] exits.
- void _assertNthStatementExits(Source source, int n) {
- _assertHasReturn(true, source, n);
+ void _assertNthStatementDoesNotExit(Source source, int n) {
+ _assertHasReturn(false, source, n);
}
// Assert that the [n]th statement in the last function declaration of
// [source] does not exit.
- void _assertNthStatementDoesNotExit(Source source, int n) {
- _assertHasReturn(false, source, n);
+ void _assertNthStatementExits(Source source, int n) {
+ _assertHasReturn(true, source, n);
}
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/non_hint_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698