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

Unified Diff: pkg/analysis_server/test/edit/refactoring_test.dart

Issue 538583002: Integrate INLINE_METHOD into the server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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/analysis_server/lib/src/edit/edit_domain.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/edit/refactoring_test.dart
diff --git a/pkg/analysis_server/test/edit/refactoring_test.dart b/pkg/analysis_server/test/edit/refactoring_test.dart
index 0f8f1bbd337e2546d79bccde188af9b6a0143e69..1736661accd612610280c248390fe67207bb535a 100644
--- a/pkg/analysis_server/test/edit/refactoring_test.dart
+++ b/pkg/analysis_server/test/edit/refactoring_test.dart
@@ -21,6 +21,7 @@ main() {
groupSep = ' | ';
runReflectiveTests(ExtractLocalVariableTest);
runReflectiveTests(ExtractMethodTest);
+ runReflectiveTests(InlineMethodTest);
runReflectiveTests(GetAvailableRefactoringsTest);
runReflectiveTests(RenameTest);
}
@@ -521,6 +522,111 @@ main() {
@ReflectiveTestCase()
+class InlineMethodTest extends _AbstractGetRefactoring_Test {
+ InlineMethodOptions options = new InlineMethodOptions(true, true);
+
+ test_init_fatalError_noMethod() {
+ addTestFile('// nothing to inline');
+ return getRefactoringResult(() {
+ return _sendInlineRequest('// nothing');
+ }).then((result) {
+ assertResultProblemsFatal(
+ result,
+ 'Method declaration or reference must be selected to activate this refactoring.');
+ // ...there is no any change
+ expect(result.change, isNull);
+ });
+ }
+
+ test_method() {
+ addTestFile('''
+class A {
+ int f;
+ test(int p) {
+ print(f + p);
+ }
+ main() {
+ test(1);
+ }
+}
+main(A a) {
+ a.test(2);
+}
+''');
+ return assertSuccessfulRefactoring(() {
+ return _sendInlineRequest('test(int p)');
+ }, '''
+class A {
+ int f;
+ main() {
+ print(f + 1);
+ }
+}
+main(A a) {
+ print(a.f + 2);
+}
+''');
+ }
+
+ test_topLevelFunction() {
+ addTestFile('''
+test(a, b) {
+ print(a + b);
+}
+main() {
+ test(1, 2);
+ test(10, 20);
+}
+''');
+ return assertSuccessfulRefactoring(() {
+ return _sendInlineRequest('test(a');
+ }, '''
+main() {
+ print(1 + 2);
+ print(10 + 20);
+}
+''');
+ }
+
+ test_topLevelFunction_oneInvocation() {
+ addTestFile('''
+test(a, b) {
+ print(a + b);
+}
+main() {
+ test(1, 2);
+ test(10, 20);
+}
+''');
+ options.deleteSource = false;
+ options.inlineAll = false;
+ return assertSuccessfulRefactoring(() {
+ return _sendInlineRequest('test(10,');
+ }, '''
+test(a, b) {
+ print(a + b);
+}
+main() {
+ test(1, 2);
+ print(10 + 20);
+}
+''');
+ }
+
+ Future<Response> _sendInlineRequest(String search) {
+ Request request = new EditGetRefactoringParams(
+ RefactoringKind.INLINE_METHOD,
+ testFile,
+ findOffset(search),
+ 0,
+ false,
+ options: options.toJson()).toRequest('0');
+ return serverChannel.sendRequest(request);
+ }
+}
+
+
+@ReflectiveTestCase()
class RenameTest extends _AbstractGetRefactoring_Test {
Future<Response> sendRenameRequest(String search, String newName,
[bool validateOnly = false]) {
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698