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

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

Issue 499723002: Implement 'edit.getRefactoring' for rename refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak for comment 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.rename_local; 5 library test.services.refactoring.rename_local;
6 6
7 import 'package:analysis_server/src/protocol2.dart'; 7 import 'package:analysis_server/src/protocol2.dart';
8 import 'package:analysis_testing/reflective_tests.dart'; 8 import 'package:analysis_testing/reflective_tests.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 indexTestUnit(''' 188 indexTestUnit('''
189 main() { 189 main() {
190 int test() {} 190 int test() {}
191 } 191 }
192 '''); 192 ''');
193 createRenameRefactoringAtString('test() {}'); 193 createRenameRefactoringAtString('test() {}');
194 // null 194 // null
195 refactoring.newName = null; 195 refactoring.newName = null;
196 assertRefactoringStatus( 196 assertRefactoringStatus(
197 refactoring.checkNewName(), 197 refactoring.checkNewName(),
198 RefactoringProblemSeverity.ERROR, 198 RefactoringProblemSeverity.FATAL,
199 expectedMessage: "Function name must not be null."); 199 expectedMessage: "Function name must not be null.");
200 // OK 200 // OK
201 refactoring.newName = 'newName'; 201 refactoring.newName = 'newName';
202 assertRefactoringStatusOK(refactoring.checkNewName()); 202 assertRefactoringStatusOK(refactoring.checkNewName());
203 } 203 }
204 204
205 test_checkNewName_LocalVariableElement() { 205 test_checkNewName_LocalVariableElement() {
206 indexTestUnit(''' 206 indexTestUnit('''
207 main() { 207 main() {
208 int test = 0; 208 int test = 0;
209 } 209 }
210 '''); 210 ''');
211 createRenameRefactoringAtString('test = 0;'); 211 createRenameRefactoringAtString('test = 0;');
212 // null 212 // null
213 refactoring.newName = null; 213 refactoring.newName = null;
214 assertRefactoringStatus( 214 assertRefactoringStatus(
215 refactoring.checkNewName(), 215 refactoring.checkNewName(),
216 RefactoringProblemSeverity.ERROR, 216 RefactoringProblemSeverity.FATAL,
217 expectedMessage: "Variable name must not be null."); 217 expectedMessage: "Variable name must not be null.");
218 // empty 218 // empty
219 refactoring.newName = ''; 219 refactoring.newName = '';
220 assertRefactoringStatus( 220 assertRefactoringStatus(
221 refactoring.checkNewName(), 221 refactoring.checkNewName(),
222 RefactoringProblemSeverity.ERROR, 222 RefactoringProblemSeverity.FATAL,
223 expectedMessage: "Variable name must not be empty."); 223 expectedMessage: "Variable name must not be empty.");
224 // OK 224 // OK
225 refactoring.newName = 'newName'; 225 refactoring.newName = 'newName';
226 assertRefactoringStatusOK(refactoring.checkNewName()); 226 assertRefactoringStatusOK(refactoring.checkNewName());
227 } 227 }
228 228
229 test_checkNewName_LocalVariableElement_const() { 229 test_checkNewName_LocalVariableElement_const() {
230 indexTestUnit(''' 230 indexTestUnit('''
231 main() { 231 main() {
232 const int TEST = 0; 232 const int TEST = 0;
233 } 233 }
234 '''); 234 ''');
235 createRenameRefactoringAtString('TEST = 0;'); 235 createRenameRefactoringAtString('TEST = 0;');
236 // null 236 // null
237 refactoring.newName = null; 237 refactoring.newName = null;
238 assertRefactoringStatus( 238 assertRefactoringStatus(
239 refactoring.checkNewName(), 239 refactoring.checkNewName(),
240 RefactoringProblemSeverity.ERROR, 240 RefactoringProblemSeverity.FATAL,
241 expectedMessage: "Constant name must not be null."); 241 expectedMessage: "Constant name must not be null.");
242 // empty 242 // empty
243 refactoring.newName = ''; 243 refactoring.newName = '';
244 assertRefactoringStatus( 244 assertRefactoringStatus(
245 refactoring.checkNewName(), 245 refactoring.checkNewName(),
246 RefactoringProblemSeverity.ERROR, 246 RefactoringProblemSeverity.FATAL,
247 expectedMessage: "Constant name must not be empty."); 247 expectedMessage: "Constant name must not be empty.");
248 // same 248 // same
249 refactoring.newName = 'TEST'; 249 refactoring.newName = 'TEST';
250 assertRefactoringStatus( 250 assertRefactoringStatus(
251 refactoring.checkNewName(), 251 refactoring.checkNewName(),
252 RefactoringProblemSeverity.FATAL, 252 RefactoringProblemSeverity.FATAL,
253 expectedMessage: "The new name must be different than the current name." ); 253 expectedMessage: "The new name must be different than the current name." );
254 // OK 254 // OK
255 refactoring.newName = 'NEW_NAME'; 255 refactoring.newName = 'NEW_NAME';
256 assertRefactoringStatusOK(refactoring.checkNewName()); 256 assertRefactoringStatusOK(refactoring.checkNewName());
257 } 257 }
258 258
259 test_checkNewName_ParameterElement() { 259 test_checkNewName_ParameterElement() {
260 indexTestUnit(''' 260 indexTestUnit('''
261 main(test) { 261 main(test) {
262 } 262 }
263 '''); 263 ''');
264 createRenameRefactoringAtString('test) {'); 264 createRenameRefactoringAtString('test) {');
265 // null 265 // null
266 refactoring.newName = null; 266 refactoring.newName = null;
267 assertRefactoringStatus( 267 assertRefactoringStatus(
268 refactoring.checkNewName(), 268 refactoring.checkNewName(),
269 RefactoringProblemSeverity.ERROR, 269 RefactoringProblemSeverity.FATAL,
270 expectedMessage: "Parameter name must not be null."); 270 expectedMessage: "Parameter name must not be null.");
271 // OK 271 // OK
272 refactoring.newName = 'newName'; 272 refactoring.newName = 'newName';
273 assertRefactoringStatusOK(refactoring.checkNewName()); 273 assertRefactoringStatusOK(refactoring.checkNewName());
274 } 274 }
275 275
276 test_createChange_localFunction() { 276 test_createChange_localFunction() {
277 indexTestUnit(''' 277 indexTestUnit('''
278 main() { 278 main() {
279 int test() => 0; 279 int test() => 0;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 main() { 463 main() {
464 int test = 0; 464 int test = 0;
465 } 465 }
466 '''); 466 ''');
467 // configure refactoring 467 // configure refactoring
468 createRenameRefactoringAtString('test = 0'); 468 createRenameRefactoringAtString('test = 0');
469 // old name 469 // old name
470 expect(refactoring.oldName, 'test'); 470 expect(refactoring.oldName, 'test');
471 } 471 }
472 } 472 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698