| 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_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:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import '../../reflective_tests.dart'; | 10 import '../../reflective_tests.dart'; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 refactoring.newName = ''; | 235 refactoring.newName = ''; |
| 236 assertRefactoringStatus( | 236 assertRefactoringStatus( |
| 237 refactoring.checkNewName(), | 237 refactoring.checkNewName(), |
| 238 RefactoringProblemSeverity.FATAL, | 238 RefactoringProblemSeverity.FATAL, |
| 239 expectedMessage: "Variable name must not be empty."); | 239 expectedMessage: "Variable name must not be empty."); |
| 240 // OK | 240 // OK |
| 241 refactoring.newName = 'newName'; | 241 refactoring.newName = 'newName'; |
| 242 assertRefactoringStatusOK(refactoring.checkNewName()); | 242 assertRefactoringStatusOK(refactoring.checkNewName()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 test_checkNewName_LocalVariableElement_const() { | |
| 246 indexTestUnit(''' | |
| 247 main() { | |
| 248 const int TEST = 0; | |
| 249 } | |
| 250 '''); | |
| 251 createRenameRefactoringAtString('TEST = 0;'); | |
| 252 // null | |
| 253 refactoring.newName = null; | |
| 254 assertRefactoringStatus( | |
| 255 refactoring.checkNewName(), | |
| 256 RefactoringProblemSeverity.FATAL, | |
| 257 expectedMessage: "Constant name must not be null."); | |
| 258 // empty | |
| 259 refactoring.newName = ''; | |
| 260 assertRefactoringStatus( | |
| 261 refactoring.checkNewName(), | |
| 262 RefactoringProblemSeverity.FATAL, | |
| 263 expectedMessage: "Constant name must not be empty."); | |
| 264 // same | |
| 265 refactoring.newName = 'TEST'; | |
| 266 assertRefactoringStatus( | |
| 267 refactoring.checkNewName(), | |
| 268 RefactoringProblemSeverity.FATAL, | |
| 269 expectedMessage: "The new name must be different than the current name."
); | |
| 270 // OK | |
| 271 refactoring.newName = 'NEW_NAME'; | |
| 272 assertRefactoringStatusOK(refactoring.checkNewName()); | |
| 273 } | |
| 274 | |
| 275 test_checkNewName_ParameterElement() { | 245 test_checkNewName_ParameterElement() { |
| 276 indexTestUnit(''' | 246 indexTestUnit(''' |
| 277 main(test) { | 247 main(test) { |
| 278 } | 248 } |
| 279 '''); | 249 '''); |
| 280 createRenameRefactoringAtString('test) {'); | 250 createRenameRefactoringAtString('test) {'); |
| 281 // null | 251 // null |
| 282 refactoring.newName = null; | 252 refactoring.newName = null; |
| 283 assertRefactoringStatus( | 253 assertRefactoringStatus( |
| 284 refactoring.checkNewName(), | 254 refactoring.checkNewName(), |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 main() { | 452 main() { |
| 483 int test = 0; | 453 int test = 0; |
| 484 } | 454 } |
| 485 '''); | 455 '''); |
| 486 // configure refactoring | 456 // configure refactoring |
| 487 createRenameRefactoringAtString('test = 0'); | 457 createRenameRefactoringAtString('test = 0'); |
| 488 // old name | 458 // old name |
| 489 expect(refactoring.oldName, 'test'); | 459 expect(refactoring.oldName, 'test'); |
| 490 } | 460 } |
| 491 } | 461 } |
| OLD | NEW |