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

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

Issue 516673002: Tweaks for refactoring tests. (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
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';
11 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
11 import 'package:analysis_testing/reflective_tests.dart'; 12 import 'package:analysis_testing/reflective_tests.dart';
12 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
13 14
14 import 'abstract_refactoring.dart'; 15 import 'abstract_refactoring.dart';
15 16
16 17
17 main() { 18 main() {
18 groupSep = ' | '; 19 groupSep = ' | ';
19 runReflectiveTests(ExtractMethodTest); 20 runReflectiveTests(ExtractMethodTest);
20 } 21 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 res(); // marker 125 res(); // marker
125 } 126 }
126 } 127 }
127 main() { 128 main() {
128 // start 129 // start
129 print(0); 130 print(0);
130 // end 131 // end
131 } 132 }
132 '''); 133 ''');
133 _createRefactoringForStartEndComments(); 134 _createRefactoringForStartEndComments();
134 return _assertConditionsError("Created function will shadow method 'A.res'." ); 135 return _assertConditionsError(
136 "Created function will shadow method 'A.res'.");
135 } 137 }
136 138
137 test_bad_constructor_initializer() { 139 test_bad_constructor_initializer() {
138 indexTestUnit(''' 140 indexTestUnit('''
139 class A { 141 class A {
140 int f; 142 int f;
141 A() : f = 0 {} 143 A() : f = 0 {}
142 } 144 }
143 '''); 145 ''');
144 _createRefactoringForString('f = 0'); 146 _createRefactoringForString('f = 0');
(...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after
2182 */ 2184 */
2183 Future _assertSuccessfulRefactoring(String expectedCode) { 2185 Future _assertSuccessfulRefactoring(String expectedCode) {
2184 return assertRefactoringConditionsOK().then((_) { 2186 return assertRefactoringConditionsOK().then((_) {
2185 refactoring.createGetter = false; 2187 refactoring.createGetter = false;
2186 return _assertRefactoringChange(expectedCode); 2188 return _assertRefactoringChange(expectedCode);
2187 }); 2189 });
2188 } 2190 }
2189 2191
2190 void _createRefactoring(int offset, int length) { 2192 void _createRefactoring(int offset, int length) {
2191 refactoring = 2193 refactoring =
2192 new ExtractMethodRefactoringImpl(searchEngine, testUnit, offset, length) ; 2194 new ExtractMethodRefactoring(searchEngine, testUnit, offset, length);
2193 refactoring.name = 'res'; 2195 refactoring.name = 'res';
2194 } 2196 }
2195 2197
2196 void _createRefactoringForStartEndComments() { 2198 void _createRefactoringForStartEndComments() {
2197 int offset = findEnd('// start') + '\n'.length; 2199 int offset = findEnd('// start') + '\n'.length;
2198 int end = findOffset('// end'); 2200 int end = findOffset('// end');
2199 _createRefactoring(offset, end - offset); 2201 _createRefactoring(offset, end - offset);
2200 } 2202 }
2201 2203
2202 void _createRefactoringForStartEndString(String startSearch, 2204 void _createRefactoringForStartEndString(String startSearch,
(...skipping 12 matching lines...) Expand all
2215 int length = search.length; 2217 int length = search.length;
2216 _createRefactoring(offset, length); 2218 _createRefactoring(offset, length);
2217 } 2219 }
2218 2220
2219 void _createRefactoringWithSuffix(String selectionSearch, String suffix) { 2221 void _createRefactoringWithSuffix(String selectionSearch, String suffix) {
2220 int offset = findOffset(selectionSearch + suffix); 2222 int offset = findOffset(selectionSearch + suffix);
2221 int length = selectionSearch.length; 2223 int length = selectionSearch.length;
2222 _createRefactoring(offset, length); 2224 _createRefactoring(offset, length);
2223 } 2225 }
2224 } 2226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698