| 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 '../../reflective_tests.dart'; | 8 import '../../reflective_tests.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 refactoring.newName = ''; | 296 refactoring.newName = ''; |
| 297 assertRefactoringStatus( | 297 assertRefactoringStatus( |
| 298 refactoring.checkNewName(), | 298 refactoring.checkNewName(), |
| 299 RefactoringProblemSeverity.FATAL, | 299 RefactoringProblemSeverity.FATAL, |
| 300 expectedMessage: "Variable name must not be empty."); | 300 expectedMessage: "Variable name must not be empty."); |
| 301 // OK | 301 // OK |
| 302 refactoring.newName = 'newName'; | 302 refactoring.newName = 'newName'; |
| 303 assertRefactoringStatusOK(refactoring.checkNewName()); | 303 assertRefactoringStatusOK(refactoring.checkNewName()); |
| 304 } | 304 } |
| 305 | 305 |
| 306 test_checkNewName_TopLevelVariableElement_const() { | |
| 307 indexTestUnit(''' | |
| 308 const TEST = 0; | |
| 309 '''); | |
| 310 createRenameRefactoringAtString('TEST ='); | |
| 311 // null | |
| 312 refactoring.newName = null; | |
| 313 assertRefactoringStatus( | |
| 314 refactoring.checkNewName(), | |
| 315 RefactoringProblemSeverity.FATAL, | |
| 316 expectedMessage: "Constant name must not be null."); | |
| 317 // empty | |
| 318 refactoring.newName = ''; | |
| 319 assertRefactoringStatus( | |
| 320 refactoring.checkNewName(), | |
| 321 RefactoringProblemSeverity.FATAL, | |
| 322 expectedMessage: "Constant name must not be empty."); | |
| 323 // OK | |
| 324 refactoring.newName = 'NEW_NAME'; | |
| 325 assertRefactoringStatusOK(refactoring.checkNewName()); | |
| 326 } | |
| 327 | |
| 328 test_createChange_ClassElement() { | 306 test_createChange_ClassElement() { |
| 329 indexTestUnit(''' | 307 indexTestUnit(''' |
| 330 class Test implements Other { | 308 class Test implements Other { |
| 331 Test() {} | 309 Test() {} |
| 332 Test.named() {} | 310 Test.named() {} |
| 333 } | 311 } |
| 334 class Other { | 312 class Other { |
| 335 factory Other.a() = Test; | 313 factory Other.a() = Test; |
| 336 factory Other.b() = Test.named; | 314 factory Other.b() = Test.named; |
| 337 } | 315 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 return assertSuccessfulRefactoring(''' | 494 return assertSuccessfulRefactoring(''' |
| 517 int newName = 0; | 495 int newName = 0; |
| 518 main() { | 496 main() { |
| 519 print(newName); | 497 print(newName); |
| 520 newName = 1; | 498 newName = 1; |
| 521 newName += 2; | 499 newName += 2; |
| 522 } | 500 } |
| 523 '''); | 501 '''); |
| 524 } | 502 } |
| 525 } | 503 } |
| OLD | NEW |