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

Unified Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 677583002: 'Create Local Varaible' quick fix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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/services/correction/fix_internal.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/services/correction/fix_test.dart
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index 9af602c2d9f443e795616c033243442c609844c4..132ce52fea3e4eabf86780f1a1f89e50cf652b1a 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -623,6 +623,81 @@ import 'my_file.dart';
expect(fileEdit.edits[0].replacement, contains('library my.file;'));
}
+ void test_createLocalVariable_read_typeAssignment() {
+ _indexTestUnit('''
+main() {
+ int a = test;
+}
+''');
+ assertHasFix(FixKind.CREATE_LOCAL_VARIABLE, '''
+main() {
+ int test;
+ int a = test;
+}
+''');
+ }
+
+ void test_createLocalVariable_read_typeCondition() {
+ _indexTestUnit('''
+main() {
+ if (!test) {
+ print(42);
+ }
+}
+''');
+ assertHasFix(FixKind.CREATE_LOCAL_VARIABLE, '''
+main() {
+ bool test;
+ if (!test) {
+ print(42);
+ }
+}
+''');
+ }
+
+ void test_createLocalVariable_read_typeInvocationArgument() {
+ _indexTestUnit('''
+main() {
+ f(test);
+}
+f(String p) {}
+''');
+ assertHasFix(FixKind.CREATE_LOCAL_VARIABLE, '''
+main() {
+ String test;
+ f(test);
+}
+f(String p) {}
+''');
+ }
+
+ void test_createLocalVariable_write_assignment() {
+ _indexTestUnit('''
+main() {
+ test = 42;
+}
+''');
+ assertHasFix(FixKind.CREATE_LOCAL_VARIABLE, '''
+main() {
+ var test = 42;
+}
+''');
+ }
+
+ void test_createLocalVariable_write_assignment_compound() {
+ _indexTestUnit('''
+main() {
+ test += 42;
+}
+''');
+ assertHasFix(FixKind.CREATE_LOCAL_VARIABLE, '''
+main() {
+ int test;
+ test += 42;
+}
+''');
+ }
+
void test_createMissingOverrides_functionType() {
_indexTestUnit('''
abstract class A {
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698