OLD | NEW |
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_unit_member; | 5 library test.services.refactoring.rename_unit_member; |
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'; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 217 } |
218 } | 218 } |
219 '''); | 219 '''); |
220 createRenameRefactoringAtString('Test {}'); | 220 createRenameRefactoringAtString('Test {}'); |
221 // check status | 221 // check status |
222 refactoring.newName = 'NewName'; | 222 refactoring.newName = 'NewName'; |
223 RefactoringStatus status = await refactoring.checkFinalConditions(); | 223 RefactoringStatus status = await refactoring.checkFinalConditions(); |
224 assertRefactoringStatusOK(status); | 224 assertRefactoringStatusOK(status); |
225 } | 225 } |
226 | 226 |
| 227 test_checkInitialConditions_inPubCache_posix() async { |
| 228 addSource( |
| 229 '/.pub-cache/lib.dart', |
| 230 r''' |
| 231 class A {} |
| 232 '''); |
| 233 indexTestUnit(''' |
| 234 import '/.pub-cache/lib.dart'; |
| 235 main() { |
| 236 A a; |
| 237 } |
| 238 '''); |
| 239 createRenameRefactoringAtString('A a'); |
| 240 // check status |
| 241 refactoring.newName = 'NewName'; |
| 242 RefactoringStatus status = await refactoring.checkInitialConditions(); |
| 243 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, |
| 244 expectedMessage: |
| 245 "The class 'A' is defined in a pub package, so cannot be renamed."); |
| 246 } |
| 247 |
| 248 test_checkInitialConditions_inPubCache_windows() async { |
| 249 addSource( |
| 250 '/Pub/Cache/lib.dart', |
| 251 r''' |
| 252 class A {} |
| 253 '''); |
| 254 indexTestUnit(''' |
| 255 import '/Pub/Cache/lib.dart'; |
| 256 main() { |
| 257 A a; |
| 258 } |
| 259 '''); |
| 260 createRenameRefactoringAtString('A a'); |
| 261 // check status |
| 262 refactoring.newName = 'NewName'; |
| 263 RefactoringStatus status = await refactoring.checkInitialConditions(); |
| 264 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, |
| 265 expectedMessage: |
| 266 "The class 'A' is defined in a pub package, so cannot be renamed."); |
| 267 } |
| 268 |
227 test_checkInitialConditions_inSDK() async { | 269 test_checkInitialConditions_inSDK() async { |
228 indexTestUnit(''' | 270 indexTestUnit(''' |
229 main() { | 271 main() { |
230 String s; | 272 String s; |
231 } | 273 } |
232 '''); | 274 '''); |
233 createRenameRefactoringAtString('String s'); | 275 createRenameRefactoringAtString('String s'); |
234 // check status | 276 // check status |
235 refactoring.newName = 'NewName'; | 277 refactoring.newName = 'NewName'; |
236 RefactoringStatus status = await refactoring.checkInitialConditions(); | 278 RefactoringStatus status = await refactoring.checkInitialConditions(); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 return assertSuccessfulRefactoring(''' | 553 return assertSuccessfulRefactoring(''' |
512 int newName = 0; | 554 int newName = 0; |
513 main() { | 555 main() { |
514 print(newName); | 556 print(newName); |
515 newName = 1; | 557 newName = 1; |
516 newName += 2; | 558 newName += 2; |
517 } | 559 } |
518 '''); | 560 '''); |
519 } | 561 } |
520 } | 562 } |
OLD | NEW |