Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: pkg/analysis_server/test/services/refactoring/naming_conventions_test.dart

Issue 573803002: Issue 18926. Rename refactoring for labels. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/src/protocol.dart' show 7 import 'package:analysis_server/src/protocol.dart' show
8 RefactoringProblemSeverity; 8 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';
11 import '../../reflective_tests.dart';
12 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
13 12
13 import '../../reflective_tests.dart';
14 import 'abstract_refactoring.dart'; 14 import 'abstract_refactoring.dart';
15 15
16 16
17 main() { 17 main() {
18 groupSep = ' | '; 18 groupSep = ' | ';
19 runReflectiveTests(NamingConventionsTest); 19 runReflectiveTests(NamingConventionsTest);
20 } 20 }
21 21
22 22
23 @ReflectiveTestCase() 23 @ReflectiveTestCase()
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 expectedMessage: "Import prefix name must not be null."); 456 expectedMessage: "Import prefix name must not be null.");
457 } 457 }
458 458
459 void test_validateImportPrefixName_trailingBlanks() { 459 void test_validateImportPrefixName_trailingBlanks() {
460 assertRefactoringStatus( 460 assertRefactoringStatus(
461 validateImportPrefixName("newName "), 461 validateImportPrefixName("newName "),
462 RefactoringProblemSeverity.ERROR, 462 RefactoringProblemSeverity.ERROR,
463 expectedMessage: "Import prefix name must not start or end with a blank. "); 463 expectedMessage: "Import prefix name must not start or end with a blank. ");
464 } 464 }
465 465
466 void test_validateLabelName_OK() {
467 assertRefactoringStatusOK(validateLabelName("newName"));
468 }
469
470 void test_validateLabelName_OK_leadingDollar() {
471 assertRefactoringStatusOK(validateLabelName("\$newName"));
472 }
473
474 void test_validateLabelName_OK_leadingUnderscore() {
475 assertRefactoringStatusOK(validateLabelName("_newName"));
476 }
477
478 void test_validateLabelName_OK_middleUnderscore() {
479 assertRefactoringStatusOK(validateLabelName("new_name"));
480 }
481
482 void test_validateLabelName_doesNotStartWithLowerCase() {
483 assertRefactoringStatus(
484 validateLabelName("NewName"),
485 RefactoringProblemSeverity.WARNING,
486 expectedMessage: "Label name should start with a lowercase letter.");
487 }
488
489 void test_validateLabelName_empty() {
490 assertRefactoringStatus(
491 validateLabelName(""),
492 RefactoringProblemSeverity.FATAL,
493 expectedMessage: "Label name must not be empty.");
494 }
495
496 void test_validateLabelName_leadingBlanks() {
497 assertRefactoringStatus(
498 validateLabelName(" newName"),
499 RefactoringProblemSeverity.ERROR,
500 expectedMessage: "Label name must not start or end with a blank.");
501 }
502
503 void test_validateLabelName_notIdentifierMiddle() {
504 assertRefactoringStatus(
505 validateLabelName("new-Name"),
506 RefactoringProblemSeverity.ERROR,
507 expectedMessage: "Label name must not contain '-'.");
508 }
509
510 void test_validateLabelName_notIdentifierStart() {
511 assertRefactoringStatus(
512 validateLabelName("2newName"),
513 RefactoringProblemSeverity.ERROR,
514 expectedMessage:
515 "Label name must begin with a lowercase letter or underscore.");
516 }
517
518 void test_validateLabelName_null() {
519 assertRefactoringStatus(
520 validateLabelName(null),
521 RefactoringProblemSeverity.FATAL,
522 expectedMessage: "Label name must not be null.");
523 }
524
525 void test_validateLabelName_trailingBlanks() {
526 assertRefactoringStatus(
527 validateLabelName("newName "),
528 RefactoringProblemSeverity.ERROR,
529 expectedMessage: "Label name must not start or end with a blank.");
530 }
531
466 void test_validateLibraryName_OK_oneIdentifier() { 532 void test_validateLibraryName_OK_oneIdentifier() {
467 assertRefactoringStatusOK(validateLibraryName("name")); 533 assertRefactoringStatusOK(validateLibraryName("name"));
468 } 534 }
469 535
470 void test_validateLibraryName_OK_severalIdentifiers() { 536 void test_validateLibraryName_OK_severalIdentifiers() {
471 assertRefactoringStatusOK(validateLibraryName("my.library.name")); 537 assertRefactoringStatusOK(validateLibraryName("my.library.name"));
472 } 538 }
473 539
474 void test_validateLibraryName_blank() { 540 void test_validateLibraryName_blank() {
475 assertRefactoringStatus( 541 assertRefactoringStatus(
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 expectedMessage: "Variable name must not be null."); 786 expectedMessage: "Variable name must not be null.");
721 } 787 }
722 788
723 void test_validateVariableName_trailingBlanks() { 789 void test_validateVariableName_trailingBlanks() {
724 assertRefactoringStatus( 790 assertRefactoringStatus(
725 validateVariableName("newName "), 791 validateVariableName("newName "),
726 RefactoringProblemSeverity.ERROR, 792 RefactoringProblemSeverity.ERROR,
727 expectedMessage: "Variable name must not start or end with a blank."); 793 expectedMessage: "Variable name must not start or end with a blank.");
728 } 794 }
729 } 795 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698