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

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

Issue 540503002: Integrate INLINE_LOCAL_VARIABLE 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 1ab6c2c44c0f5c4160a4f7cd0afa3b6f708fa359..7b7ce358088c0cdcf9bba73cc0505bc030c782d3 100644
--- a/pkg/analysis_server/test/edit/refactoring_test.dart
+++ b/pkg/analysis_server/test/edit/refactoring_test.dart
@@ -11,16 +11,17 @@ import 'package:analysis_server/src/protocol.dart';
import 'package:analysis_server/src/services/index/index.dart';
import 'package:analysis_server/src/services/index/local_memory_index.dart';
import 'package:analysis_server/src/services/json.dart';
-import '../reflective_tests.dart';
import 'package:unittest/unittest.dart' hide ERROR;
import '../analysis_abstract.dart';
+import '../reflective_tests.dart';
main() {
groupSep = ' | ';
runReflectiveTests(ExtractLocalVariableTest);
runReflectiveTests(ExtractMethodTest);
+ runReflectiveTests(InlineLocalTest);
runReflectiveTests(InlineMethodTest);
runReflectiveTests(GetAvailableRefactoringsTest);
runReflectiveTests(RenameTest);
@@ -522,6 +523,51 @@ main() {
@ReflectiveTestCase()
+class InlineLocalTest extends _AbstractGetRefactoring_Test {
+ test_OK() {
+ addTestFile('''
+main() {
+ int test = 42;
+ int a = test + 2;
+ print(test);
+}
+''');
+ return assertSuccessfulRefactoring(() {
+ return _sendInlineRequest('test + 2');
+ }, '''
+main() {
+ int a = 42 + 2;
+ print(42);
+}
+''');
+ }
+
+ test_init_fatalError_notVariable() {
+ addTestFile('main() {}');
+ return getRefactoringResult(() {
+ return _sendInlineRequest('main() {}');
+ }).then((result) {
+ assertResultProblemsFatal(
+ result,
+ 'Local variable declaration or reference must be selected to activate this refactoring.');
+ // ...there is no any change
+ expect(result.change, isNull);
+ });
+ }
+
+ Future<Response> _sendInlineRequest(String search) {
+ Request request = new EditGetRefactoringParams(
+ RefactoringKind.INLINE_LOCAL_VARIABLE,
+ testFile,
+ findOffset(search),
+ 0,
+ false).toRequest('0');
+ return serverChannel.sendRequest(request);
+ }
+}
+
+
+@ReflectiveTestCase()
class InlineMethodTest extends _AbstractGetRefactoring_Test {
InlineMethodOptions options = new InlineMethodOptions(true, true);
« 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