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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/extract_method_test.dart

Issue 533913002: Fix for 'returnType' when extract a method with a single expression. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.refactoring.extract_method; 5 library test.services.refactoring.extract_method;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/services/refactoring/extract_method.dart'; 10 import 'package:analysis_server/src/services/refactoring/extract_method.dart';
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 return refactoring.checkInitialConditions().then((_) { 1025 return refactoring.checkInitialConditions().then((_) {
1026 expect( 1026 expect(
1027 refactoring.names, 1027 refactoring.names,
1028 unorderedEquals(['selectedItem', 'item', 'my', 'treeItem2'])); 1028 unorderedEquals(['selectedItem', 'item', 'my', 'treeItem2']));
1029 }); 1029 });
1030 } 1030 }
1031 1031
1032 test_offsets_lengths() { 1032 test_offsets_lengths() {
1033 indexTestUnit(''' 1033 indexTestUnit('''
1034 main() { 1034 main() {
1035 main() {
1036 int a = 1 + 2; 1035 int a = 1 + 2;
1037 int b = 1 + 2; 1036 int b = 1 + 2;
1038 } 1037 }
1039 }
1040 '''); 1038 ''');
1041 _createRefactoringForString('1 + 2'); 1039 _createRefactoringForString('1 + 2');
1042 // apply refactoring 1040 // apply refactoring
1043 return refactoring.checkInitialConditions().then((_) { 1041 return refactoring.checkInitialConditions().then((_) {
1044 expect( 1042 expect(
1045 refactoring.offsets, 1043 refactoring.offsets,
1046 unorderedEquals([findOffset('1 + 2'), findOffset('1 + 2')])); 1044 unorderedEquals([findOffset('1 + 2'), findOffset('1 + 2')]));
1047 expect(refactoring.lengths, unorderedEquals([5, 6])); 1045 expect(refactoring.lengths, unorderedEquals([5, 6]));
1048 }); 1046 });
1049 } 1047 }
1050 1048
1049 test_returnType_expression() {
1050 indexTestUnit('''
1051 main() {
1052 int a = 1 + 2;
1053 }
1054 ''');
1055 _createRefactoringForString('1 + 2');
1056 // do check
1057 return refactoring.checkInitialConditions().then((_) {
1058 expect(refactoring.returnType, 'int');
1059 });
1060 }
1061
1062 test_returnType_statements() {
1063 indexTestUnit('''
1064 main() {
1065 // start
1066 double v = 5.0;
1067 // end
1068 print(v);
1069 }
1070 ''');
1071 _createRefactoringForStartEndComments();
1072 // do check
1073 return refactoring.checkInitialConditions().then((_) {
1074 expect(refactoring.returnType, 'double');
1075 });
1076 }
1077
1078 test_returnType_statements_void() {
1079 indexTestUnit('''
1080 main() {
1081 // start
1082 print(42);
1083 // end
1084 }
1085 ''');
1086 _createRefactoringForStartEndComments();
1087 // do check
1088 return refactoring.checkInitialConditions().then((_) {
1089 expect(refactoring.returnType, 'void');
1090 });
1091 }
1092
1051 test_setExtractGetter() { 1093 test_setExtractGetter() {
1052 indexTestUnit(''' 1094 indexTestUnit('''
1053 main() { 1095 main() {
1054 int a = 1 + 2; 1096 int a = 1 + 2;
1055 } 1097 }
1056 '''); 1098 ''');
1057 _createRefactoringForString('1 + 2'); 1099 _createRefactoringForString('1 + 2');
1058 // apply refactoring 1100 // apply refactoring
1059 return assertRefactoringConditionsOK().then((_) { 1101 return assertRefactoringConditionsOK().then((_) {
1060 expect(refactoring.canCreateGetter, true); 1102 expect(refactoring.canCreateGetter, true);
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 int length = search.length; 2297 int length = search.length;
2256 _createRefactoring(offset, length); 2298 _createRefactoring(offset, length);
2257 } 2299 }
2258 2300
2259 void _createRefactoringWithSuffix(String selectionSearch, String suffix) { 2301 void _createRefactoringWithSuffix(String selectionSearch, String suffix) {
2260 int offset = findOffset(selectionSearch + suffix); 2302 int offset = findOffset(selectionSearch + suffix);
2261 int length = selectionSearch.length; 2303 int length = selectionSearch.length;
2262 _createRefactoring(offset, length); 2304 _createRefactoring(offset, length);
2263 } 2305 }
2264 } 2306 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/refactoring/extract_method.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698