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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/rename_local_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.rename_local; 5 library test.services.refactoring.rename_local;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 int test() => 0; 279 int test() => 0;
280 print(test); 280 print(test);
281 print(test()); 281 print(test());
282 } 282 }
283 '''); 283 ''');
284 // configure refactoring 284 // configure refactoring
285 createRenameRefactoringAtString('test() => 0'); 285 createRenameRefactoringAtString('test() => 0');
286 expect(refactoring.refactoringName, 'Rename Local Function'); 286 expect(refactoring.refactoringName, 'Rename Local Function');
287 refactoring.newName = 'newName'; 287 refactoring.newName = 'newName';
288 // validate change 288 // validate change
289 return assertSuccessfulRename(''' 289 return assertSuccessfulRefactoring('''
290 main() { 290 main() {
291 int newName() => 0; 291 int newName() => 0;
292 print(newName); 292 print(newName);
293 print(newName()); 293 print(newName());
294 } 294 }
295 '''); 295 ''');
296 } 296 }
297 297
298 test_createChange_localFunction_sameNameDifferenceScopes() { 298 test_createChange_localFunction_sameNameDifferenceScopes() {
299 indexTestUnit(''' 299 indexTestUnit('''
(...skipping 10 matching lines...) Expand all
310 int test() => 2; 310 int test() => 2;
311 print(test); 311 print(test);
312 } 312 }
313 } 313 }
314 '''); 314 ''');
315 // configure refactoring 315 // configure refactoring
316 createRenameRefactoringAtString('test() => 1'); 316 createRenameRefactoringAtString('test() => 1');
317 expect(refactoring.refactoringName, 'Rename Local Function'); 317 expect(refactoring.refactoringName, 'Rename Local Function');
318 refactoring.newName = 'newName'; 318 refactoring.newName = 'newName';
319 // validate change 319 // validate change
320 return assertSuccessfulRename(''' 320 return assertSuccessfulRefactoring('''
321 main() { 321 main() {
322 { 322 {
323 int test() => 0; 323 int test() => 0;
324 print(test); 324 print(test);
325 } 325 }
326 { 326 {
327 int newName() => 1; 327 int newName() => 1;
328 print(newName); 328 print(newName);
329 } 329 }
330 { 330 {
(...skipping 11 matching lines...) Expand all
342 test = 1; 342 test = 1;
343 test += 2; 343 test += 2;
344 print(test); 344 print(test);
345 } 345 }
346 '''); 346 ''');
347 // configure refactoring 347 // configure refactoring
348 createRenameRefactoringAtString('test = 0'); 348 createRenameRefactoringAtString('test = 0');
349 expect(refactoring.refactoringName, 'Rename Local Variable'); 349 expect(refactoring.refactoringName, 'Rename Local Variable');
350 refactoring.newName = 'newName'; 350 refactoring.newName = 'newName';
351 // validate change 351 // validate change
352 return assertSuccessfulRename(''' 352 return assertSuccessfulRefactoring('''
353 main() { 353 main() {
354 int newName = 0; 354 int newName = 0;
355 newName = 1; 355 newName = 1;
356 newName += 2; 356 newName += 2;
357 print(newName); 357 print(newName);
358 } 358 }
359 '''); 359 ''');
360 } 360 }
361 361
362 test_createChange_localVariable_sameNameDifferenceScopes() { 362 test_createChange_localVariable_sameNameDifferenceScopes() {
(...skipping 11 matching lines...) Expand all
374 int test = 2; 374 int test = 2;
375 print(test); 375 print(test);
376 } 376 }
377 } 377 }
378 '''); 378 ''');
379 // configure refactoring 379 // configure refactoring
380 createRenameRefactoringAtString('test = 1'); 380 createRenameRefactoringAtString('test = 1');
381 expect(refactoring.refactoringName, 'Rename Local Variable'); 381 expect(refactoring.refactoringName, 'Rename Local Variable');
382 refactoring.newName = 'newName'; 382 refactoring.newName = 'newName';
383 // validate change 383 // validate change
384 return assertSuccessfulRename(''' 384 return assertSuccessfulRefactoring('''
385 main() { 385 main() {
386 { 386 {
387 int test = 0; 387 int test = 0;
388 print(test); 388 print(test);
389 } 389 }
390 { 390 {
391 int newName = 1; 391 int newName = 1;
392 print(newName); 392 print(newName);
393 } 393 }
394 { 394 {
(...skipping 13 matching lines...) Expand all
408 } 408 }
409 main() { 409 main() {
410 myFunction(test: 2); 410 myFunction(test: 2);
411 } 411 }
412 '''); 412 ''');
413 // configure refactoring 413 // configure refactoring
414 createRenameRefactoringAtString('test}) {'); 414 createRenameRefactoringAtString('test}) {');
415 expect(refactoring.refactoringName, 'Rename Parameter'); 415 expect(refactoring.refactoringName, 'Rename Parameter');
416 refactoring.newName = 'newName'; 416 refactoring.newName = 'newName';
417 // validate change 417 // validate change
418 return assertSuccessfulRename(''' 418 return assertSuccessfulRefactoring('''
419 myFunction({int newName}) { 419 myFunction({int newName}) {
420 newName = 1; 420 newName = 1;
421 newName += 2; 421 newName += 2;
422 print(newName); 422 print(newName);
423 } 423 }
424 main() { 424 main() {
425 myFunction(newName: 2); 425 myFunction(newName: 2);
426 } 426 }
427 '''); 427 ''');
428 } 428 }
429 429
430 test_createChange_parameter_namedInOtherFile() { 430 test_createChange_parameter_namedInOtherFile() {
431 indexTestUnit(''' 431 indexTestUnit('''
432 class A { 432 class A {
433 A({test}); 433 A({test});
434 } 434 }
435 '''); 435 ''');
436 indexUnit('/test2.dart', ''' 436 indexUnit('/test2.dart', '''
437 import 'test.dart'; 437 import 'test.dart';
438 main() { 438 main() {
439 new A(test: 2); 439 new A(test: 2);
440 } 440 }
441 '''); 441 ''');
442 // configure refactoring 442 // configure refactoring
443 createRenameRefactoringAtString('test});'); 443 createRenameRefactoringAtString('test});');
444 expect(refactoring.refactoringName, 'Rename Parameter'); 444 expect(refactoring.refactoringName, 'Rename Parameter');
445 refactoring.newName = 'newName'; 445 refactoring.newName = 'newName';
446 // validate change 446 // validate change
447 return assertSuccessfulRename(''' 447 return assertSuccessfulRefactoring('''
448 class A { 448 class A {
449 A({newName}); 449 A({newName});
450 } 450 }
451 ''').then((_) { 451 ''').then((_) {
452 assertFileChangeResult('/test2.dart', ''' 452 assertFileChangeResult('/test2.dart', '''
453 import 'test.dart'; 453 import 'test.dart';
454 main() { 454 main() {
455 new A(newName: 2); 455 new A(newName: 2);
456 } 456 }
457 '''); 457 ''');
458 }); 458 });
459 } 459 }
460 460
461 test_oldName() { 461 test_oldName() {
462 indexTestUnit(''' 462 indexTestUnit('''
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