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_inSDK() async { |
| 228 indexTestUnit(''' |
| 229 main() { |
| 230 String s; |
| 231 } |
| 232 '''); |
| 233 createRenameRefactoringAtString('String s'); |
| 234 // check status |
| 235 refactoring.newName = 'NewName'; |
| 236 RefactoringStatus status = await refactoring.checkInitialConditions(); |
| 237 assertRefactoringStatus(status, RefactoringProblemSeverity.FATAL, |
| 238 expectedMessage: |
| 239 "The class 'String' is defined in the SDK, so cannot be renamed."); |
| 240 } |
| 241 |
227 test_checkNewName_ClassElement() { | 242 test_checkNewName_ClassElement() { |
228 indexTestUnit(''' | 243 indexTestUnit(''' |
229 class Test {} | 244 class Test {} |
230 '''); | 245 '''); |
231 createRenameRefactoringAtString('Test {}'); | 246 createRenameRefactoringAtString('Test {}'); |
232 // null | 247 // null |
233 refactoring.newName = null; | 248 refactoring.newName = null; |
234 assertRefactoringStatus( | 249 assertRefactoringStatus( |
235 refactoring.checkNewName(), RefactoringProblemSeverity.FATAL, | 250 refactoring.checkNewName(), RefactoringProblemSeverity.FATAL, |
236 expectedMessage: "Class name must not be null."); | 251 expectedMessage: "Class name must not be null."); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 return assertSuccessfulRefactoring(''' | 511 return assertSuccessfulRefactoring(''' |
497 int newName = 0; | 512 int newName = 0; |
498 main() { | 513 main() { |
499 print(newName); | 514 print(newName); |
500 newName = 1; | 515 newName = 1; |
501 newName += 2; | 516 newName += 2; |
502 } | 517 } |
503 '''); | 518 '''); |
504 } | 519 } |
505 } | 520 } |
OLD | NEW |