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

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

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
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_server/src/services/correction/status.dart'; 8 import 'package:analysis_server/src/services/correction/status.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import '../../utils.dart';
12 import 'abstract_rename.dart'; 13 import 'abstract_rename.dart';
13 14
14 main() { 15 main() {
15 groupSep = ' | '; 16 initializeTestEnvironment();
16 defineReflectiveTests(RenameLocalTest); 17 defineReflectiveTests(RenameLocalTest);
17 } 18 }
18 19
19 @reflectiveTest 20 @reflectiveTest
20 class RenameLocalTest extends RenameRefactoringTest { 21 class RenameLocalTest extends RenameRefactoringTest {
21 test_checkFinalConditions_hasLocalFunction_after() async { 22 test_checkFinalConditions_hasLocalFunction_after() async {
22 indexTestUnit(''' 23 indexTestUnit('''
23 main() { 24 main() {
24 int test = 0; 25 int test = 0;
25 newName() => 1; 26 newName() => 1;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 print(newName); 125 print(newName);
125 } 126 }
126 } 127 }
127 '''); 128 ''');
128 createRenameRefactoringAtString('test = 0'); 129 createRenameRefactoringAtString('test = 0');
129 // check status 130 // check status
130 refactoring.newName = 'newName'; 131 refactoring.newName = 'newName';
131 RefactoringStatus status = await refactoring.checkFinalConditions(); 132 RefactoringStatus status = await refactoring.checkFinalConditions();
132 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, 133 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
133 expectedMessage: 'Usage of field "A.newName" declared in "test.dart" ' 134 expectedMessage: 'Usage of field "A.newName" declared in "test.dart" '
134 'will be shadowed by renamed local variable.', 135 'will be shadowed by renamed local variable.',
135 expectedContextSearch: 'newName);'); 136 expectedContextSearch: 'newName);');
136 } 137 }
137 138
138 test_checkFinalConditions_shadows_classMember_namedParameter() async { 139 test_checkFinalConditions_shadows_classMember_namedParameter() async {
139 indexTestUnit(''' 140 indexTestUnit('''
140 class A { 141 class A {
141 foo({test: 1}) { 142 foo({test: 1}) {
142 } 143 }
143 } 144 }
144 class B extends A { 145 class B extends A {
145 var newName = 1; 146 var newName = 1;
146 foo({test: 2}) { 147 foo({test: 2}) {
147 print(newName); 148 print(newName);
148 } 149 }
149 } 150 }
150 '''); 151 ''');
151 createRenameRefactoringAtString('test: 1}'); 152 createRenameRefactoringAtString('test: 1}');
152 // check status 153 // check status
153 refactoring.newName = 'newName'; 154 refactoring.newName = 'newName';
154 RefactoringStatus status = await refactoring.checkFinalConditions(); 155 RefactoringStatus status = await refactoring.checkFinalConditions();
155 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR, 156 assertRefactoringStatus(status, RefactoringProblemSeverity.ERROR,
156 expectedMessage: 'Usage of field "B.newName" declared in "test.dart" ' 157 expectedMessage: 'Usage of field "B.newName" declared in "test.dart" '
157 'will be shadowed by renamed parameter.', 158 'will be shadowed by renamed parameter.',
158 expectedContextSearch: 'newName);'); 159 expectedContextSearch: 'newName);');
159 } 160 }
160 161
161 test_checkFinalConditions_shadows_classMemberOK_qualifiedReference() { 162 test_checkFinalConditions_shadows_classMemberOK_qualifiedReference() {
162 indexTestUnit(''' 163 indexTestUnit('''
163 class A { 164 class A {
164 var newName = 1; 165 var newName = 1;
165 main() { 166 main() {
166 var test = 0; 167 var test = 0;
167 print(this.newName); 168 print(this.newName);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 416 }
416 '''); 417 ''');
417 } 418 }
418 419
419 test_createChange_parameter_named_inOtherFile() async { 420 test_createChange_parameter_named_inOtherFile() async {
420 indexTestUnit(''' 421 indexTestUnit('''
421 class A { 422 class A {
422 A({test}); 423 A({test});
423 } 424 }
424 '''); 425 ''');
425 indexUnit('/test2.dart', ''' 426 indexUnit(
427 '/test2.dart',
428 '''
426 import 'test.dart'; 429 import 'test.dart';
427 main() { 430 main() {
428 new A(test: 2); 431 new A(test: 2);
429 } 432 }
430 '''); 433 ''');
431 // configure refactoring 434 // configure refactoring
432 createRenameRefactoringAtString('test});'); 435 createRenameRefactoringAtString('test});');
433 expect(refactoring.refactoringName, 'Rename Parameter'); 436 expect(refactoring.refactoringName, 'Rename Parameter');
434 refactoring.newName = 'newName'; 437 refactoring.newName = 'newName';
435 // validate change 438 // validate change
436 await assertSuccessfulRefactoring(''' 439 await assertSuccessfulRefactoring('''
437 class A { 440 class A {
438 A({newName}); 441 A({newName});
439 } 442 }
440 '''); 443 ''');
441 assertFileChangeResult('/test2.dart', ''' 444 assertFileChangeResult(
445 '/test2.dart',
446 '''
442 import 'test.dart'; 447 import 'test.dart';
443 main() { 448 main() {
444 new A(newName: 2); 449 new A(newName: 2);
445 } 450 }
446 '''); 451 ''');
447 } 452 }
448 453
449 test_createChange_parameter_named_updateHierarchy() async { 454 test_createChange_parameter_named_updateHierarchy() async {
450 indexUnit('/test2.dart', ''' 455 indexUnit(
456 '/test2.dart',
457 '''
451 library test2; 458 library test2;
452 class A { 459 class A {
453 void foo({int test: 1}) { 460 void foo({int test: 1}) {
454 print(test); 461 print(test);
455 } 462 }
456 } 463 }
457 class B extends A { 464 class B extends A {
458 void foo({int test: 2}) { 465 void foo({int test: 2}) {
459 print(test); 466 print(test);
460 } 467 }
(...skipping 23 matching lines...) Expand all
484 new A().foo(newName: 10); 491 new A().foo(newName: 10);
485 new B().foo(newName: 20); 492 new B().foo(newName: 20);
486 new C().foo(newName: 30); 493 new C().foo(newName: 30);
487 } 494 }
488 class C extends A { 495 class C extends A {
489 void foo({int newName: 3}) { 496 void foo({int newName: 3}) {
490 print(newName); 497 print(newName);
491 } 498 }
492 } 499 }
493 '''); 500 ''');
494 assertFileChangeResult('/test2.dart', ''' 501 assertFileChangeResult(
502 '/test2.dart',
503 '''
495 library test2; 504 library test2;
496 class A { 505 class A {
497 void foo({int newName: 1}) { 506 void foo({int newName: 1}) {
498 print(newName); 507 print(newName);
499 } 508 }
500 } 509 }
501 class B extends A { 510 class B extends A {
502 void foo({int newName: 2}) { 511 void foo({int newName: 2}) {
503 print(newName); 512 print(newName);
504 } 513 }
505 } 514 }
506 '''); 515 ''');
507 } 516 }
508 517
509 test_oldName() { 518 test_oldName() {
510 indexTestUnit(''' 519 indexTestUnit('''
511 main() { 520 main() {
512 int test = 0; 521 int test = 0;
513 } 522 }
514 '''); 523 ''');
515 // configure refactoring 524 // configure refactoring
516 createRenameRefactoringAtString('test = 0'); 525 createRenameRefactoringAtString('test = 0');
517 // old name 526 // old name
518 expect(refactoring.oldName, 'test'); 527 expect(refactoring.oldName, 'test');
519 } 528 }
520 } 529 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698