| 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/protocol2.dart'; | 7 import 'package:analysis_server/src/protocol2.dart'; |
| 8 import 'package:analysis_testing/reflective_tests.dart'; | 8 import 'package:analysis_testing/reflective_tests.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 217 |
| 218 test_checkNewName_ClassElement() { | 218 test_checkNewName_ClassElement() { |
| 219 indexTestUnit(''' | 219 indexTestUnit(''' |
| 220 class Test {} | 220 class Test {} |
| 221 '''); | 221 '''); |
| 222 createRenameRefactoringAtString('Test {}'); | 222 createRenameRefactoringAtString('Test {}'); |
| 223 // null | 223 // null |
| 224 refactoring.newName = null; | 224 refactoring.newName = null; |
| 225 assertRefactoringStatus( | 225 assertRefactoringStatus( |
| 226 refactoring.checkNewName(), | 226 refactoring.checkNewName(), |
| 227 RefactoringProblemSeverity.ERROR, | 227 RefactoringProblemSeverity.FATAL, |
| 228 expectedMessage: "Class name must not be null."); | 228 expectedMessage: "Class name must not be null."); |
| 229 // empty | 229 // empty |
| 230 refactoring.newName = ''; | 230 refactoring.newName = ''; |
| 231 assertRefactoringStatus( | 231 assertRefactoringStatus( |
| 232 refactoring.checkNewName(), | 232 refactoring.checkNewName(), |
| 233 RefactoringProblemSeverity.ERROR, | 233 RefactoringProblemSeverity.FATAL, |
| 234 expectedMessage: "Class name must not be empty."); | 234 expectedMessage: "Class name must not be empty."); |
| 235 // same | 235 // same |
| 236 refactoring.newName = 'Test'; | 236 refactoring.newName = 'Test'; |
| 237 assertRefactoringStatus( | 237 assertRefactoringStatus( |
| 238 refactoring.checkNewName(), | 238 refactoring.checkNewName(), |
| 239 RefactoringProblemSeverity.FATAL, | 239 RefactoringProblemSeverity.FATAL, |
| 240 expectedMessage: "The new name must be different than the current name."
); | 240 expectedMessage: "The new name must be different than the current name."
); |
| 241 // OK | 241 // OK |
| 242 refactoring.newName = 'NewName'; | 242 refactoring.newName = 'NewName'; |
| 243 assertRefactoringStatusOK(refactoring.checkNewName()); | 243 assertRefactoringStatusOK(refactoring.checkNewName()); |
| 244 } | 244 } |
| 245 | 245 |
| 246 test_checkNewName_FunctionElement() { | 246 test_checkNewName_FunctionElement() { |
| 247 indexTestUnit(''' | 247 indexTestUnit(''' |
| 248 test() {} | 248 test() {} |
| 249 '''); | 249 '''); |
| 250 createRenameRefactoringAtString('test() {}'); | 250 createRenameRefactoringAtString('test() {}'); |
| 251 // null | 251 // null |
| 252 refactoring.newName = null; | 252 refactoring.newName = null; |
| 253 assertRefactoringStatus( | 253 assertRefactoringStatus( |
| 254 refactoring.checkNewName(), | 254 refactoring.checkNewName(), |
| 255 RefactoringProblemSeverity.ERROR, | 255 RefactoringProblemSeverity.FATAL, |
| 256 expectedMessage: "Function name must not be null."); | 256 expectedMessage: "Function name must not be null."); |
| 257 // empty | 257 // empty |
| 258 refactoring.newName = ''; | 258 refactoring.newName = ''; |
| 259 assertRefactoringStatus( | 259 assertRefactoringStatus( |
| 260 refactoring.checkNewName(), | 260 refactoring.checkNewName(), |
| 261 RefactoringProblemSeverity.ERROR, | 261 RefactoringProblemSeverity.FATAL, |
| 262 expectedMessage: "Function name must not be empty."); | 262 expectedMessage: "Function name must not be empty."); |
| 263 // OK | 263 // OK |
| 264 refactoring.newName = 'newName'; | 264 refactoring.newName = 'newName'; |
| 265 assertRefactoringStatusOK(refactoring.checkNewName()); | 265 assertRefactoringStatusOK(refactoring.checkNewName()); |
| 266 } | 266 } |
| 267 | 267 |
| 268 test_checkNewName_FunctionTypeAliasElement() { | 268 test_checkNewName_FunctionTypeAliasElement() { |
| 269 indexTestUnit(''' | 269 indexTestUnit(''' |
| 270 typedef Test(); | 270 typedef Test(); |
| 271 '''); | 271 '''); |
| 272 createRenameRefactoringAtString('Test();'); | 272 createRenameRefactoringAtString('Test();'); |
| 273 // null | 273 // null |
| 274 refactoring.newName = null; | 274 refactoring.newName = null; |
| 275 assertRefactoringStatus( | 275 assertRefactoringStatus( |
| 276 refactoring.checkNewName(), | 276 refactoring.checkNewName(), |
| 277 RefactoringProblemSeverity.ERROR, | 277 RefactoringProblemSeverity.FATAL, |
| 278 expectedMessage: "Function type alias name must not be null."); | 278 expectedMessage: "Function type alias name must not be null."); |
| 279 // OK | 279 // OK |
| 280 refactoring.newName = 'NewName'; | 280 refactoring.newName = 'NewName'; |
| 281 assertRefactoringStatusOK(refactoring.checkNewName()); | 281 assertRefactoringStatusOK(refactoring.checkNewName()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 test_checkNewName_TopLevelVariableElement() { | 284 test_checkNewName_TopLevelVariableElement() { |
| 285 indexTestUnit(''' | 285 indexTestUnit(''' |
| 286 var test; | 286 var test; |
| 287 '''); | 287 '''); |
| 288 createRenameRefactoringAtString('test;'); | 288 createRenameRefactoringAtString('test;'); |
| 289 // null | 289 // null |
| 290 refactoring.newName = null; | 290 refactoring.newName = null; |
| 291 assertRefactoringStatus( | 291 assertRefactoringStatus( |
| 292 refactoring.checkNewName(), | 292 refactoring.checkNewName(), |
| 293 RefactoringProblemSeverity.ERROR, | 293 RefactoringProblemSeverity.FATAL, |
| 294 expectedMessage: "Variable name must not be null."); | 294 expectedMessage: "Variable name must not be null."); |
| 295 // empty | 295 // empty |
| 296 refactoring.newName = ''; | 296 refactoring.newName = ''; |
| 297 assertRefactoringStatus( | 297 assertRefactoringStatus( |
| 298 refactoring.checkNewName(), | 298 refactoring.checkNewName(), |
| 299 RefactoringProblemSeverity.ERROR, | 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() { | 306 test_checkNewName_TopLevelVariableElement_const() { |
| 307 indexTestUnit(''' | 307 indexTestUnit(''' |
| 308 const TEST = 0; | 308 const TEST = 0; |
| 309 '''); | 309 '''); |
| 310 createRenameRefactoringAtString('TEST ='); | 310 createRenameRefactoringAtString('TEST ='); |
| 311 // null | 311 // null |
| 312 refactoring.newName = null; | 312 refactoring.newName = null; |
| 313 assertRefactoringStatus( | 313 assertRefactoringStatus( |
| 314 refactoring.checkNewName(), | 314 refactoring.checkNewName(), |
| 315 RefactoringProblemSeverity.ERROR, | 315 RefactoringProblemSeverity.FATAL, |
| 316 expectedMessage: "Constant name must not be null."); | 316 expectedMessage: "Constant name must not be null."); |
| 317 // empty | 317 // empty |
| 318 refactoring.newName = ''; | 318 refactoring.newName = ''; |
| 319 assertRefactoringStatus( | 319 assertRefactoringStatus( |
| 320 refactoring.checkNewName(), | 320 refactoring.checkNewName(), |
| 321 RefactoringProblemSeverity.ERROR, | 321 RefactoringProblemSeverity.FATAL, |
| 322 expectedMessage: "Constant name must not be empty."); | 322 expectedMessage: "Constant name must not be empty."); |
| 323 // OK | 323 // OK |
| 324 refactoring.newName = 'NEW_NAME'; | 324 refactoring.newName = 'NEW_NAME'; |
| 325 assertRefactoringStatusOK(refactoring.checkNewName()); | 325 assertRefactoringStatusOK(refactoring.checkNewName()); |
| 326 } | 326 } |
| 327 | 327 |
| 328 test_createChange_ClassElement() { | 328 test_createChange_ClassElement() { |
| 329 indexTestUnit(''' | 329 indexTestUnit(''' |
| 330 class Test implements Other { | 330 class Test implements Other { |
| 331 Test() {} | 331 Test() {} |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 return assertSuccessfulRename(''' | 512 return assertSuccessfulRename(''' |
| 513 int newName = 0; | 513 int newName = 0; |
| 514 main() { | 514 main() { |
| 515 print(newName); | 515 print(newName); |
| 516 newName = 1; | 516 newName = 1; |
| 517 newName += 2; | 517 newName += 2; |
| 518 } | 518 } |
| 519 '''); | 519 '''); |
| 520 } | 520 } |
| 521 } | 521 } |
| OLD | NEW |