| 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.naming_conventions; | 5 library test.services.refactoring.naming_conventions; | 
| 6 | 6 | 
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart' | 7 import 'package:analysis_server/plugin/protocol/protocol.dart' | 
| 8     show RefactoringProblemSeverity; | 8     show RefactoringProblemSeverity; | 
| 9 import 'package:analysis_server/src/services/refactoring/naming_conventions.dart
     '; | 9 import 'package:analysis_server/src/services/refactoring/naming_conventions.dart
     '; | 
| 10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 10 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 158         expectedMessage: "Field name must not contain '-'."); | 158         expectedMessage: "Field name must not contain '-'."); | 
| 159   } | 159   } | 
| 160 | 160 | 
| 161   void test_validateFieldName_notIdentifierStart() { | 161   void test_validateFieldName_notIdentifierStart() { | 
| 162     assertRefactoringStatus( | 162     assertRefactoringStatus( | 
| 163         validateFieldName("2newName"), RefactoringProblemSeverity.FATAL, | 163         validateFieldName("2newName"), RefactoringProblemSeverity.FATAL, | 
| 164         expectedMessage: | 164         expectedMessage: | 
| 165             "Field name must begin with a lowercase letter or underscore."); | 165             "Field name must begin with a lowercase letter or underscore."); | 
| 166   } | 166   } | 
| 167 | 167 | 
|  | 168   void test_validateFieldName_notKeyword() { | 
|  | 169     assertRefactoringStatus( | 
|  | 170         validateFieldName("for"), RefactoringProblemSeverity.FATAL, | 
|  | 171         expectedMessage: "Field name must not be a keyword."); | 
|  | 172   } | 
|  | 173 | 
|  | 174   void test_validateFieldName_notPseudoKeyword() { | 
|  | 175     assertRefactoringStatus( | 
|  | 176         validateFieldName("await"), RefactoringProblemSeverity.FATAL, | 
|  | 177         expectedMessage: "Field name must not be a keyword."); | 
|  | 178   } | 
|  | 179 | 
| 168   void test_validateFieldName_null() { | 180   void test_validateFieldName_null() { | 
| 169     assertRefactoringStatus( | 181     assertRefactoringStatus( | 
| 170         validateFieldName(null), RefactoringProblemSeverity.FATAL, | 182         validateFieldName(null), RefactoringProblemSeverity.FATAL, | 
| 171         expectedMessage: "Field name must not be null."); | 183         expectedMessage: "Field name must not be null."); | 
| 172   } | 184   } | 
| 173 | 185 | 
| 174   void test_validateFieldName_OK() { | 186   void test_validateFieldName_OK() { | 
| 175     assertRefactoringStatusOK(validateFieldName("newName")); | 187     assertRefactoringStatusOK(validateFieldName("newName")); | 
| 176   } | 188   } | 
| 177 | 189 | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213         expectedMessage: "Function name must not contain '-'."); | 225         expectedMessage: "Function name must not contain '-'."); | 
| 214   } | 226   } | 
| 215 | 227 | 
| 216   void test_validateFunctionName_notIdentifierStart() { | 228   void test_validateFunctionName_notIdentifierStart() { | 
| 217     assertRefactoringStatus( | 229     assertRefactoringStatus( | 
| 218         validateFunctionName("2newName"), RefactoringProblemSeverity.FATAL, | 230         validateFunctionName("2newName"), RefactoringProblemSeverity.FATAL, | 
| 219         expectedMessage: | 231         expectedMessage: | 
| 220             "Function name must begin with a lowercase letter or underscore."); | 232             "Function name must begin with a lowercase letter or underscore."); | 
| 221   } | 233   } | 
| 222 | 234 | 
|  | 235   void test_validateFunctionName_notKeyword() { | 
|  | 236     assertRefactoringStatus( | 
|  | 237         validateFunctionName("new"), RefactoringProblemSeverity.FATAL, | 
|  | 238         expectedMessage: "Function name must not be a keyword."); | 
|  | 239   } | 
|  | 240 | 
|  | 241   void test_validateFunctionName_notPseudoKeyword() { | 
|  | 242     assertRefactoringStatus( | 
|  | 243         validateFunctionName("yield"), RefactoringProblemSeverity.FATAL, | 
|  | 244         expectedMessage: "Function name must not be a keyword."); | 
|  | 245   } | 
|  | 246 | 
| 223   void test_validateFunctionName_null() { | 247   void test_validateFunctionName_null() { | 
| 224     assertRefactoringStatus( | 248     assertRefactoringStatus( | 
| 225         validateFunctionName(null), RefactoringProblemSeverity.FATAL, | 249         validateFunctionName(null), RefactoringProblemSeverity.FATAL, | 
| 226         expectedMessage: "Function name must not be null."); | 250         expectedMessage: "Function name must not be null."); | 
| 227   } | 251   } | 
| 228 | 252 | 
| 229   void test_validateFunctionName_OK() { | 253   void test_validateFunctionName_OK() { | 
| 230     assertRefactoringStatusOK(validateFunctionName("newName")); | 254     assertRefactoringStatusOK(validateFunctionName("newName")); | 
| 231   } | 255   } | 
| 232 | 256 | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 330         expectedMessage: "Import prefix name must not contain '-'."); | 354         expectedMessage: "Import prefix name must not contain '-'."); | 
| 331   } | 355   } | 
| 332 | 356 | 
| 333   void test_validateImportPrefixName_notIdentifierStart() { | 357   void test_validateImportPrefixName_notIdentifierStart() { | 
| 334     assertRefactoringStatus( | 358     assertRefactoringStatus( | 
| 335         validateImportPrefixName("2newName"), RefactoringProblemSeverity.FATAL, | 359         validateImportPrefixName("2newName"), RefactoringProblemSeverity.FATAL, | 
| 336         expectedMessage: | 360         expectedMessage: | 
| 337             "Import prefix name must begin with a lowercase letter or underscore
     ."); | 361             "Import prefix name must begin with a lowercase letter or underscore
     ."); | 
| 338   } | 362   } | 
| 339 | 363 | 
|  | 364   void test_validateImportPrefixName_notKeyword() { | 
|  | 365     assertRefactoringStatus( | 
|  | 366         validateImportPrefixName("while"), RefactoringProblemSeverity.FATAL, | 
|  | 367         expectedMessage: "Import prefix name must not be a keyword."); | 
|  | 368   } | 
|  | 369 | 
|  | 370   void test_validateImportPrefixName_notPseudoKeyword() { | 
|  | 371     assertRefactoringStatus( | 
|  | 372         validateImportPrefixName("await"), RefactoringProblemSeverity.FATAL, | 
|  | 373         expectedMessage: "Import prefix name must not be a keyword."); | 
|  | 374   } | 
|  | 375 | 
| 340   void test_validateImportPrefixName_null() { | 376   void test_validateImportPrefixName_null() { | 
| 341     assertRefactoringStatus( | 377     assertRefactoringStatus( | 
| 342         validateImportPrefixName(null), RefactoringProblemSeverity.FATAL, | 378         validateImportPrefixName(null), RefactoringProblemSeverity.FATAL, | 
| 343         expectedMessage: "Import prefix name must not be null."); | 379         expectedMessage: "Import prefix name must not be null."); | 
| 344   } | 380   } | 
| 345 | 381 | 
| 346   void test_validateImportPrefixName_OK() { | 382   void test_validateImportPrefixName_OK() { | 
| 347     assertRefactoringStatusOK(validateImportPrefixName("newName")); | 383     assertRefactoringStatusOK(validateImportPrefixName("newName")); | 
| 348   } | 384   } | 
| 349 | 385 | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 386         expectedMessage: "Label name must not contain '-'."); | 422         expectedMessage: "Label name must not contain '-'."); | 
| 387   } | 423   } | 
| 388 | 424 | 
| 389   void test_validateLabelName_notIdentifierStart() { | 425   void test_validateLabelName_notIdentifierStart() { | 
| 390     assertRefactoringStatus( | 426     assertRefactoringStatus( | 
| 391         validateLabelName("2newName"), RefactoringProblemSeverity.FATAL, | 427         validateLabelName("2newName"), RefactoringProblemSeverity.FATAL, | 
| 392         expectedMessage: | 428         expectedMessage: | 
| 393             "Label name must begin with a lowercase letter or underscore."); | 429             "Label name must begin with a lowercase letter or underscore."); | 
| 394   } | 430   } | 
| 395 | 431 | 
|  | 432   void test_validateLabelName_notKeyword() { | 
|  | 433     assertRefactoringStatus( | 
|  | 434         validateLabelName("for"), RefactoringProblemSeverity.FATAL, | 
|  | 435         expectedMessage: "Label name must not be a keyword."); | 
|  | 436   } | 
|  | 437 | 
|  | 438   void test_validateLabelName_notPseudoKeyword() { | 
|  | 439     assertRefactoringStatus( | 
|  | 440         validateLabelName("await"), RefactoringProblemSeverity.FATAL, | 
|  | 441         expectedMessage: "Label name must not be a keyword."); | 
|  | 442   } | 
|  | 443 | 
| 396   void test_validateLabelName_null() { | 444   void test_validateLabelName_null() { | 
| 397     assertRefactoringStatus( | 445     assertRefactoringStatus( | 
| 398         validateLabelName(null), RefactoringProblemSeverity.FATAL, | 446         validateLabelName(null), RefactoringProblemSeverity.FATAL, | 
| 399         expectedMessage: "Label name must not be null."); | 447         expectedMessage: "Label name must not be null."); | 
| 400   } | 448   } | 
| 401 | 449 | 
| 402   void test_validateLabelName_OK() { | 450   void test_validateLabelName_OK() { | 
| 403     assertRefactoringStatusOK(validateLabelName("newName")); | 451     assertRefactoringStatusOK(validateLabelName("newName")); | 
| 404   } | 452   } | 
| 405 | 453 | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 460         expectedMessage: "Library name identifier must not contain '-'."); | 508         expectedMessage: "Library name identifier must not contain '-'."); | 
| 461   } | 509   } | 
| 462 | 510 | 
| 463   void test_validateLibraryName_notIdentifierStart() { | 511   void test_validateLibraryName_notIdentifierStart() { | 
| 464     assertRefactoringStatus( | 512     assertRefactoringStatus( | 
| 465         validateLibraryName("my.2bad.name"), RefactoringProblemSeverity.FATAL, | 513         validateLibraryName("my.2bad.name"), RefactoringProblemSeverity.FATAL, | 
| 466         expectedMessage: | 514         expectedMessage: | 
| 467             "Library name identifier must begin with a lowercase letter or under
     score."); | 515             "Library name identifier must begin with a lowercase letter or under
     score."); | 
| 468   } | 516   } | 
| 469 | 517 | 
|  | 518   void test_validateLibraryName_notKeyword() { | 
|  | 519     assertRefactoringStatus( | 
|  | 520         validateLibraryName("my.yield.name"), RefactoringProblemSeverity.FATAL, | 
|  | 521         expectedMessage: "Library name identifier must not be a keyword."); | 
|  | 522   } | 
|  | 523 | 
| 470   void test_validateLibraryName_null() { | 524   void test_validateLibraryName_null() { | 
| 471     assertRefactoringStatus( | 525     assertRefactoringStatus( | 
| 472         validateLibraryName(null), RefactoringProblemSeverity.FATAL, | 526         validateLibraryName(null), RefactoringProblemSeverity.FATAL, | 
| 473         expectedMessage: "Library name must not be null."); | 527         expectedMessage: "Library name must not be null."); | 
| 474   } | 528   } | 
| 475 | 529 | 
| 476   void test_validateLibraryName_OK_oneIdentifier() { | 530   void test_validateLibraryName_OK_oneIdentifier() { | 
| 477     assertRefactoringStatusOK(validateLibraryName("name")); | 531     assertRefactoringStatusOK(validateLibraryName("name")); | 
| 478   } | 532   } | 
| 479 | 533 | 
| 480   void test_validateLibraryName_OK_severalIdentifiers() { | 534   void test_validateLibraryName_OK_severalIdentifiers() { | 
| 481     assertRefactoringStatusOK(validateLibraryName("my.library.name")); | 535     assertRefactoringStatusOK(validateLibraryName("my.lib.name")); | 
| 482   } | 536   } | 
| 483 | 537 | 
| 484   void test_validateLibraryName_trailingBlanks() { | 538   void test_validateLibraryName_trailingBlanks() { | 
| 485     assertRefactoringStatus( | 539     assertRefactoringStatus( | 
| 486         validateLibraryName("my.bad .name"), RefactoringProblemSeverity.FATAL, | 540         validateLibraryName("my.bad .name"), RefactoringProblemSeverity.FATAL, | 
| 487         expectedMessage: | 541         expectedMessage: | 
| 488             "Library name identifier must not start or end with a blank."); | 542             "Library name identifier must not start or end with a blank."); | 
| 489   } | 543   } | 
| 490 | 544 | 
| 491   void test_validateMethodName_doesNotStartWithLowerCase() { | 545   void test_validateMethodName_doesNotStartWithLowerCase() { | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 518         expectedMessage: "Method name must not contain '-'."); | 572         expectedMessage: "Method name must not contain '-'."); | 
| 519   } | 573   } | 
| 520 | 574 | 
| 521   void test_validateMethodName_notIdentifierStart() { | 575   void test_validateMethodName_notIdentifierStart() { | 
| 522     assertRefactoringStatus( | 576     assertRefactoringStatus( | 
| 523         validateMethodName("2newName"), RefactoringProblemSeverity.FATAL, | 577         validateMethodName("2newName"), RefactoringProblemSeverity.FATAL, | 
| 524         expectedMessage: | 578         expectedMessage: | 
| 525             "Method name must begin with a lowercase letter or underscore."); | 579             "Method name must begin with a lowercase letter or underscore."); | 
| 526   } | 580   } | 
| 527 | 581 | 
|  | 582   void test_validateMethodName_notKeyword() { | 
|  | 583     assertRefactoringStatus( | 
|  | 584         validateMethodName("do"), RefactoringProblemSeverity.FATAL, | 
|  | 585         expectedMessage: "Method name must not be a keyword."); | 
|  | 586   } | 
|  | 587 | 
|  | 588   void test_validateMethodName_notPseudoKeyword() { | 
|  | 589     assertRefactoringStatus( | 
|  | 590         validateMethodName("yield"), RefactoringProblemSeverity.FATAL, | 
|  | 591         expectedMessage: "Method name must not be a keyword."); | 
|  | 592   } | 
|  | 593 | 
| 528   void test_validateMethodName_null() { | 594   void test_validateMethodName_null() { | 
| 529     assertRefactoringStatus( | 595     assertRefactoringStatus( | 
| 530         validateMethodName(null), RefactoringProblemSeverity.FATAL, | 596         validateMethodName(null), RefactoringProblemSeverity.FATAL, | 
| 531         expectedMessage: "Method name must not be null."); | 597         expectedMessage: "Method name must not be null."); | 
| 532   } | 598   } | 
| 533 | 599 | 
| 534   void test_validateMethodName_OK() { | 600   void test_validateMethodName_OK() { | 
| 535     assertRefactoringStatusOK(validateMethodName("newName")); | 601     assertRefactoringStatusOK(validateMethodName("newName")); | 
| 536   } | 602   } | 
| 537 | 603 | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 574         expectedMessage: "Parameter name must not contain '-'."); | 640         expectedMessage: "Parameter name must not contain '-'."); | 
| 575   } | 641   } | 
| 576 | 642 | 
| 577   void test_validateParameterName_notIdentifierStart() { | 643   void test_validateParameterName_notIdentifierStart() { | 
| 578     assertRefactoringStatus( | 644     assertRefactoringStatus( | 
| 579         validateParameterName("2newName"), RefactoringProblemSeverity.FATAL, | 645         validateParameterName("2newName"), RefactoringProblemSeverity.FATAL, | 
| 580         expectedMessage: | 646         expectedMessage: | 
| 581             "Parameter name must begin with a lowercase letter or underscore."); | 647             "Parameter name must begin with a lowercase letter or underscore."); | 
| 582   } | 648   } | 
| 583 | 649 | 
|  | 650   void test_validateParameterName_notKeyword() { | 
|  | 651     assertRefactoringStatus( | 
|  | 652         validateParameterName("while"), RefactoringProblemSeverity.FATAL, | 
|  | 653         expectedMessage: "Parameter name must not be a keyword."); | 
|  | 654   } | 
|  | 655 | 
|  | 656   void test_validateParameterName_notPseudoKeyword() { | 
|  | 657     assertRefactoringStatus( | 
|  | 658         validateParameterName("await"), RefactoringProblemSeverity.FATAL, | 
|  | 659         expectedMessage: "Parameter name must not be a keyword."); | 
|  | 660   } | 
|  | 661 | 
| 584   void test_validateParameterName_null() { | 662   void test_validateParameterName_null() { | 
| 585     assertRefactoringStatus( | 663     assertRefactoringStatus( | 
| 586         validateParameterName(null), RefactoringProblemSeverity.FATAL, | 664         validateParameterName(null), RefactoringProblemSeverity.FATAL, | 
| 587         expectedMessage: "Parameter name must not be null."); | 665         expectedMessage: "Parameter name must not be null."); | 
| 588   } | 666   } | 
| 589 | 667 | 
| 590   void test_validateParameterName_OK() { | 668   void test_validateParameterName_OK() { | 
| 591     assertRefactoringStatusOK(validateParameterName("newName")); | 669     assertRefactoringStatusOK(validateParameterName("newName")); | 
| 592   } | 670   } | 
| 593 | 671 | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 629         expectedMessage: "Variable name must not contain '-'."); | 707         expectedMessage: "Variable name must not contain '-'."); | 
| 630   } | 708   } | 
| 631 | 709 | 
| 632   void test_validateVariableName_notIdentifierStart() { | 710   void test_validateVariableName_notIdentifierStart() { | 
| 633     assertRefactoringStatus( | 711     assertRefactoringStatus( | 
| 634         validateVariableName("2newName"), RefactoringProblemSeverity.FATAL, | 712         validateVariableName("2newName"), RefactoringProblemSeverity.FATAL, | 
| 635         expectedMessage: | 713         expectedMessage: | 
| 636             "Variable name must begin with a lowercase letter or underscore."); | 714             "Variable name must begin with a lowercase letter or underscore."); | 
| 637   } | 715   } | 
| 638 | 716 | 
|  | 717   void test_validateVariableName_notKeyword() { | 
|  | 718     assertRefactoringStatus( | 
|  | 719         validateVariableName("for"), RefactoringProblemSeverity.FATAL, | 
|  | 720         expectedMessage: "Variable name must not be a keyword."); | 
|  | 721   } | 
|  | 722 | 
|  | 723   void test_validateVariableName_notPseudoKeyword() { | 
|  | 724     assertRefactoringStatus( | 
|  | 725         validateVariableName("await"), RefactoringProblemSeverity.FATAL, | 
|  | 726         expectedMessage: "Variable name must not be a keyword."); | 
|  | 727   } | 
|  | 728 | 
| 639   void test_validateVariableName_null() { | 729   void test_validateVariableName_null() { | 
| 640     assertRefactoringStatus( | 730     assertRefactoringStatus( | 
| 641         validateVariableName(null), RefactoringProblemSeverity.FATAL, | 731         validateVariableName(null), RefactoringProblemSeverity.FATAL, | 
| 642         expectedMessage: "Variable name must not be null."); | 732         expectedMessage: "Variable name must not be null."); | 
| 643   } | 733   } | 
| 644 | 734 | 
| 645   void test_validateVariableName_OK() { | 735   void test_validateVariableName_OK() { | 
| 646     assertRefactoringStatusOK(validateVariableName("newName")); | 736     assertRefactoringStatusOK(validateVariableName("newName")); | 
| 647   } | 737   } | 
| 648 | 738 | 
| 649   void test_validateVariableName_OK_leadingDollar() { | 739   void test_validateVariableName_OK_leadingDollar() { | 
| 650     assertRefactoringStatusOK(validateVariableName("\$newName")); | 740     assertRefactoringStatusOK(validateVariableName("\$newName")); | 
| 651   } | 741   } | 
| 652 | 742 | 
| 653   void test_validateVariableName_OK_leadingUnderscore() { | 743   void test_validateVariableName_OK_leadingUnderscore() { | 
| 654     assertRefactoringStatusOK(validateVariableName("_newName")); | 744     assertRefactoringStatusOK(validateVariableName("_newName")); | 
| 655   } | 745   } | 
| 656 | 746 | 
| 657   void test_validateVariableName_OK_middleUnderscore() { | 747   void test_validateVariableName_OK_middleUnderscore() { | 
| 658     assertRefactoringStatusOK(validateVariableName("new_name")); | 748     assertRefactoringStatusOK(validateVariableName("new_name")); | 
| 659   } | 749   } | 
| 660 | 750 | 
| 661   void test_validateVariableName_trailingBlanks() { | 751   void test_validateVariableName_trailingBlanks() { | 
| 662     assertRefactoringStatus( | 752     assertRefactoringStatus( | 
| 663         validateVariableName("newName "), RefactoringProblemSeverity.FATAL, | 753         validateVariableName("newName "), RefactoringProblemSeverity.FATAL, | 
| 664         expectedMessage: "Variable name must not start or end with a blank."); | 754         expectedMessage: "Variable name must not start or end with a blank."); | 
| 665   } | 755   } | 
| 666 } | 756 } | 
| OLD | NEW | 
|---|