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

Unified Diff: pkg/analysis_server/test/services/refactoring/extract_method_test.dart

Issue 725393002: Issue 21612. Support for multiple returns in the 'Extract Method' refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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/analysis_server/test/services/refactoring/extract_method_test.dart
diff --git a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
index 67e46cc94632280ac070e36e919593c7610bd0de..c21cbb8c03e5ec6c14ea1cd732708a161f7db6d3 100644
--- a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
@@ -2189,6 +2189,95 @@ int res() {
''');
}
+ test_statements_return_multiple_ifElse() {
+ indexTestUnit('''
+num main(bool b) {
+// start
+ if (b) {
+ return 1;
+ } else {
+ return 2.0;
+ }
+// end
+}
+''');
+ _createRefactoringForStartEndComments();
+ // apply refactoring
+ return _assertSuccessfulRefactoring('''
+num main(bool b) {
+// start
+ return res(b);
+// end
+}
+
+num res(bool b) {
+ if (b) {
+ return 1;
+ } else {
+ return 2.0;
+ }
+}
+''');
+ }
+
+ test_statements_return_multiple_ifThen() {
+ indexTestUnit('''
+num main(bool b) {
+// start
+ if (b) {
+ return 1;
+ }
+ return 2.0;
+// end
+}
+''');
+ _createRefactoringForStartEndComments();
+ // apply refactoring
+ return _assertSuccessfulRefactoring('''
+num main(bool b) {
+// start
+ return res(b);
+// end
+}
+
+num res(bool b) {
+ if (b) {
+ return 1;
+ }
+ return 2.0;
+}
+''');
+ }
+
+ test_statements_return_multiple_ignoreInFunction() {
+ indexTestUnit('''
+int main() {
+// start
+ localFunction() {
+ return 'abc';
+ }
+ return 42;
+// end
+}
+''');
+ _createRefactoringForStartEndComments();
+ // apply refactoring
+ return _assertSuccessfulRefactoring('''
+int main() {
+// start
+ return res();
+// end
+}
+
+int res() {
+ localFunction() {
+ return 'abc';
+ }
+ return 42;
+}
+''');
+ }
+
test_statements_return_single() {
indexTestUnit('''
main() {

Powered by Google App Engine
This is Rietveld 408576698