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

Side by Side Diff: pkg/analysis_services/test/refactoring/naming_conventions_test.dart

Issue 484733003: Import analysis_services.dart into analysis_server.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.services.refactoring.naming_conventions;
6
7 import 'package:analysis_services/correction/status.dart';
8 import 'package:analysis_services/refactoring/refactoring.dart';
9 import 'package:analysis_services/src/refactoring/naming_conventions.dart';
10 import 'package:analysis_testing/reflective_tests.dart';
11 import 'package:unittest/unittest.dart';
12
13 import 'abstract_refactoring.dart';
14
15
16 main() {
17 groupSep = ' | ';
18 runReflectiveTests(NamingConventionsTest);
19 }
20
21
22 @ReflectiveTestCase()
23 class NamingConventionsTest extends RefactoringTest {
24 @override
25 Refactoring get refactoring => null;
26
27 void test_validateClassName_OK() {
28 assertRefactoringStatusOK(validateClassName("NewName"));
29 }
30
31 void test_validateClassName_OK_leadingDollar() {
32 assertRefactoringStatusOK(validateClassName("\$NewName"));
33 }
34
35 void test_validateClassName_OK_leadingUnderscore() {
36 assertRefactoringStatusOK(validateClassName("_NewName"));
37 }
38
39 void test_validateClassName_OK_middleDollar() {
40 assertRefactoringStatusOK(validateClassName("New\$Name"));
41 }
42
43 void test_validateClassName_doesNotStartWithLowerCase() {
44 assertRefactoringStatus(
45 validateClassName("newName"),
46 RefactoringStatusSeverity.WARNING,
47 expectedMessage: "Class name should start with an uppercase letter.");
48 }
49
50 void test_validateClassName_empty() {
51 assertRefactoringStatus(
52 validateClassName(""),
53 RefactoringStatusSeverity.ERROR,
54 expectedMessage: "Class name must not be empty.");
55 }
56
57 void test_validateClassName_leadingBlanks() {
58 assertRefactoringStatus(
59 validateClassName(" NewName"),
60 RefactoringStatusSeverity.ERROR,
61 expectedMessage: "Class name must not start or end with a blank.");
62 }
63
64 void test_validateClassName_notIdentifierMiddle() {
65 assertRefactoringStatus(
66 validateClassName("New-Name"),
67 RefactoringStatusSeverity.ERROR,
68 expectedMessage: "Class name must not contain '-'.");
69 }
70
71 void test_validateClassName_notIdentifierStart() {
72 assertRefactoringStatus(
73 validateClassName("-NewName"),
74 RefactoringStatusSeverity.ERROR,
75 expectedMessage:
76 "Class name must begin with an uppercase letter or underscore.");
77 }
78
79 void test_validateClassName_null() {
80 assertRefactoringStatus(
81 validateClassName(null),
82 RefactoringStatusSeverity.ERROR,
83 expectedMessage: "Class name must not be null.");
84 }
85
86 void test_validateClassName_trailingBlanks() {
87 assertRefactoringStatus(
88 validateClassName("NewName "),
89 RefactoringStatusSeverity.ERROR,
90 expectedMessage: "Class name must not start or end with a blank.");
91 }
92 void test_validateConstantName_OK() {
93 assertRefactoringStatusOK(validateConstantName("NAME"));
94 }
95
96 void test_validateConstantName_OK_digit() {
97 assertRefactoringStatusOK(validateConstantName("NAME2"));
98 }
99
100 void test_validateConstantName_OK_underscoreLeading() {
101 assertRefactoringStatusOK(validateConstantName("_NAME"));
102 }
103
104 void test_validateConstantName_OK_underscoreMiddle() {
105 assertRefactoringStatusOK(validateConstantName("MY_NEW_NAME"));
106 }
107
108 void test_validateConstantName_empty() {
109 assertRefactoringStatus(
110 validateConstantName(""),
111 RefactoringStatusSeverity.ERROR,
112 expectedMessage: "Constant name must not be empty.");
113 }
114
115 void test_validateConstantName_leadingBlanks() {
116 assertRefactoringStatus(
117 validateConstantName(" NewName"),
118 RefactoringStatusSeverity.ERROR,
119 expectedMessage: "Constant name must not start or end with a blank.");
120 }
121
122 void test_validateConstantName_notAllCaps() {
123 assertRefactoringStatus(
124 validateConstantName("NewName"),
125 RefactoringStatusSeverity.WARNING,
126 expectedMessage: "Constant name should be all uppercase with underscores .");
127 }
128
129 void test_validateConstantName_notIdentifierMiddle() {
130 assertRefactoringStatus(
131 validateConstantName("NA-ME"),
132 RefactoringStatusSeverity.ERROR,
133 expectedMessage: "Constant name must not contain '-'.");
134 }
135
136 void test_validateConstantName_notIdentifierStart() {
137 assertRefactoringStatus(
138 validateConstantName("99_RED_BALLOONS"),
139 RefactoringStatusSeverity.ERROR,
140 expectedMessage:
141 "Constant name must begin with an uppercase letter or underscore.");
142 }
143
144 void test_validateConstantName_null() {
145 assertRefactoringStatus(
146 validateConstantName(null),
147 RefactoringStatusSeverity.ERROR,
148 expectedMessage: "Constant name must not be null.");
149 }
150
151 void test_validateConstantName_trailingBlanks() {
152 assertRefactoringStatus(
153 validateConstantName("NewName "),
154 RefactoringStatusSeverity.ERROR,
155 expectedMessage: "Constant name must not start or end with a blank.");
156 }
157
158 void test_validateConstructorName_OK() {
159 assertRefactoringStatusOK(validateConstructorName("newName"));
160 }
161
162 void test_validateConstructorName_OK_leadingUnderscore() {
163 assertRefactoringStatusOK(validateConstructorName("_newName"));
164 }
165
166 void test_validateConstructorName_doesNotStartWithLowerCase() {
167 assertRefactoringStatus(
168 validateConstructorName("NewName"),
169 RefactoringStatusSeverity.WARNING,
170 expectedMessage: "Constructor name should start with a lowercase letter. ");
171 }
172
173 void test_validateConstructorName_empty() {
174 assertRefactoringStatusOK(validateConstructorName(""));
175 }
176
177 void test_validateConstructorName_leadingBlanks() {
178 assertRefactoringStatus(
179 validateConstructorName(" newName"),
180 RefactoringStatusSeverity.ERROR,
181 expectedMessage: "Constructor name must not start or end with a blank.") ;
182 }
183
184 void test_validateConstructorName_notIdentifierMiddle() {
185 assertRefactoringStatus(
186 validateConstructorName("na-me"),
187 RefactoringStatusSeverity.ERROR,
188 expectedMessage: "Constructor name must not contain '-'.");
189 }
190
191 void test_validateConstructorName_notIdentifierStart() {
192 assertRefactoringStatus(
193 validateConstructorName("2name"),
194 RefactoringStatusSeverity.ERROR,
195 expectedMessage:
196 "Constructor name must begin with a lowercase letter or underscore." );
197 }
198
199 void test_validateConstructorName_null() {
200 assertRefactoringStatus(
201 validateConstructorName(null),
202 RefactoringStatusSeverity.ERROR,
203 expectedMessage: "Constructor name must not be null.");
204 }
205
206 void test_validateConstructorName_trailingBlanks() {
207 assertRefactoringStatus(
208 validateConstructorName("newName "),
209 RefactoringStatusSeverity.ERROR,
210 expectedMessage: "Constructor name must not start or end with a blank.") ;
211 }
212
213 void test_validateFieldName_OK() {
214 assertRefactoringStatusOK(validateFieldName("newName"));
215 }
216
217 void test_validateFieldName_OK_leadingUnderscore() {
218 assertRefactoringStatusOK(validateFieldName("_newName"));
219 }
220
221 void test_validateFieldName_OK_middleUnderscore() {
222 assertRefactoringStatusOK(validateFieldName("new_name"));
223 }
224
225 void test_validateFieldName_doesNotStartWithLowerCase() {
226 assertRefactoringStatus(
227 validateFieldName("NewName"),
228 RefactoringStatusSeverity.WARNING,
229 expectedMessage: "Field name should start with a lowercase letter.");
230 }
231
232 void test_validateFieldName_empty() {
233 assertRefactoringStatus(
234 validateFieldName(""),
235 RefactoringStatusSeverity.ERROR,
236 expectedMessage: "Field name must not be empty.");
237 }
238
239 void test_validateFieldName_leadingBlanks() {
240 assertRefactoringStatus(
241 validateFieldName(" newName"),
242 RefactoringStatusSeverity.ERROR,
243 expectedMessage: "Field name must not start or end with a blank.");
244 }
245
246 void test_validateFieldName_notIdentifierMiddle() {
247 assertRefactoringStatus(
248 validateFieldName("new-Name"),
249 RefactoringStatusSeverity.ERROR,
250 expectedMessage: "Field name must not contain '-'.");
251 }
252
253 void test_validateFieldName_notIdentifierStart() {
254 assertRefactoringStatus(
255 validateFieldName("2newName"),
256 RefactoringStatusSeverity.ERROR,
257 expectedMessage:
258 "Field name must begin with a lowercase letter or underscore.");
259 }
260
261 void test_validateFieldName_null() {
262 assertRefactoringStatus(
263 validateFieldName(null),
264 RefactoringStatusSeverity.ERROR,
265 expectedMessage: "Field name must not be null.");
266 }
267
268 void test_validateFieldName_trailingBlanks() {
269 assertRefactoringStatus(
270 validateFieldName("newName "),
271 RefactoringStatusSeverity.ERROR,
272 expectedMessage: "Field name must not start or end with a blank.");
273 }
274
275 void test_validateFunctionName_OK() {
276 assertRefactoringStatusOK(validateFunctionName("newName"));
277 }
278
279 void test_validateFunctionName_OK_leadingUnderscore() {
280 assertRefactoringStatusOK(validateFunctionName("_newName"));
281 }
282
283 void test_validateFunctionName_OK_middleUnderscore() {
284 assertRefactoringStatusOK(validateFunctionName("new_name"));
285 }
286
287 void test_validateFunctionName_doesNotStartWithLowerCase() {
288 assertRefactoringStatus(
289 validateFunctionName("NewName"),
290 RefactoringStatusSeverity.WARNING,
291 expectedMessage: "Function name should start with a lowercase letter.");
292 }
293
294 void test_validateFunctionName_empty() {
295 assertRefactoringStatus(
296 validateFunctionName(""),
297 RefactoringStatusSeverity.ERROR,
298 expectedMessage: "Function name must not be empty.");
299 }
300
301 void test_validateFunctionName_leadingBlanks() {
302 assertRefactoringStatus(
303 validateFunctionName(" newName"),
304 RefactoringStatusSeverity.ERROR,
305 expectedMessage: "Function name must not start or end with a blank.");
306 }
307
308 void test_validateFunctionName_notIdentifierMiddle() {
309 assertRefactoringStatus(
310 validateFunctionName("new-Name"),
311 RefactoringStatusSeverity.ERROR,
312 expectedMessage: "Function name must not contain '-'.");
313 }
314
315 void test_validateFunctionName_notIdentifierStart() {
316 assertRefactoringStatus(
317 validateFunctionName("2newName"),
318 RefactoringStatusSeverity.ERROR,
319 expectedMessage:
320 "Function name must begin with a lowercase letter or underscore.");
321 }
322
323 void test_validateFunctionName_null() {
324 assertRefactoringStatus(
325 validateFunctionName(null),
326 RefactoringStatusSeverity.ERROR,
327 expectedMessage: "Function name must not be null.");
328 }
329
330 void test_validateFunctionName_trailingBlanks() {
331 assertRefactoringStatus(
332 validateFunctionName("newName "),
333 RefactoringStatusSeverity.ERROR,
334 expectedMessage: "Function name must not start or end with a blank.");
335 }
336
337 void test_validateFunctionTypeAliasName_OK() {
338 assertRefactoringStatusOK(validateFunctionTypeAliasName("NewName"));
339 }
340
341 void test_validateFunctionTypeAliasName_OK_leadingDollar() {
342 assertRefactoringStatusOK(validateFunctionTypeAliasName("\$NewName"));
343 }
344
345 void test_validateFunctionTypeAliasName_OK_leadingUnderscore() {
346 assertRefactoringStatusOK(validateFunctionTypeAliasName("_NewName"));
347 }
348
349 void test_validateFunctionTypeAliasName_OK_middleDollar() {
350 assertRefactoringStatusOK(validateFunctionTypeAliasName("New\$Name"));
351 }
352
353 void test_validateFunctionTypeAliasName_doesNotStartWithLowerCase() {
354 assertRefactoringStatus(
355 validateFunctionTypeAliasName("newName"),
356 RefactoringStatusSeverity.WARNING,
357 expectedMessage:
358 "Function type alias name should start with an uppercase letter.");
359 }
360
361 void test_validateFunctionTypeAliasName_empty() {
362 assertRefactoringStatus(
363 validateFunctionTypeAliasName(""),
364 RefactoringStatusSeverity.ERROR,
365 expectedMessage: "Function type alias name must not be empty.");
366 }
367
368 void test_validateFunctionTypeAliasName_leadingBlanks() {
369 assertRefactoringStatus(
370 validateFunctionTypeAliasName(" NewName"),
371 RefactoringStatusSeverity.ERROR,
372 expectedMessage:
373 "Function type alias name must not start or end with a blank.");
374 }
375
376 void test_validateFunctionTypeAliasName_notIdentifierMiddle() {
377 assertRefactoringStatus(
378 validateFunctionTypeAliasName("New-Name"),
379 RefactoringStatusSeverity.ERROR,
380 expectedMessage: "Function type alias name must not contain '-'.");
381 }
382
383 void test_validateFunctionTypeAliasName_notIdentifierStart() {
384 assertRefactoringStatus(
385 validateFunctionTypeAliasName("-NewName"),
386 RefactoringStatusSeverity.ERROR,
387 expectedMessage:
388 "Function type alias name must begin with an uppercase letter or und erscore.");
389 }
390
391 void test_validateFunctionTypeAliasName_null() {
392 assertRefactoringStatus(
393 validateFunctionTypeAliasName(null),
394 RefactoringStatusSeverity.ERROR,
395 expectedMessage: "Function type alias name must not be null.");
396 }
397
398 void test_validateFunctionTypeAliasName_trailingBlanks() {
399 assertRefactoringStatus(
400 validateFunctionTypeAliasName("NewName "),
401 RefactoringStatusSeverity.ERROR,
402 expectedMessage:
403 "Function type alias name must not start or end with a blank.");
404 }
405
406 void test_validateImportPrefixName_OK() {
407 assertRefactoringStatusOK(validateImportPrefixName("newName"));
408 }
409
410 void test_validateImportPrefixName_OK_leadingUnderscore() {
411 assertRefactoringStatusOK(validateImportPrefixName("_newName"));
412 }
413
414 void test_validateImportPrefixName_OK_middleUnderscore() {
415 assertRefactoringStatusOK(validateImportPrefixName("new_name"));
416 }
417
418 void test_validateImportPrefixName_doesNotStartWithLowerCase() {
419 assertRefactoringStatus(
420 validateImportPrefixName("NewName"),
421 RefactoringStatusSeverity.WARNING,
422 expectedMessage: "Import prefix name should start with a lowercase lette r.");
423 }
424
425 void test_validateImportPrefixName_empty() {
426 assertRefactoringStatusOK(validateImportPrefixName(""));
427 }
428
429 void test_validateImportPrefixName_leadingBlanks() {
430 assertRefactoringStatus(
431 validateImportPrefixName(" newName"),
432 RefactoringStatusSeverity.ERROR,
433 expectedMessage: "Import prefix name must not start or end with a blank. ");
434 }
435
436 void test_validateImportPrefixName_notIdentifierMiddle() {
437 assertRefactoringStatus(
438 validateImportPrefixName("new-Name"),
439 RefactoringStatusSeverity.ERROR,
440 expectedMessage: "Import prefix name must not contain '-'.");
441 }
442
443 void test_validateImportPrefixName_notIdentifierStart() {
444 assertRefactoringStatus(
445 validateImportPrefixName("2newName"),
446 RefactoringStatusSeverity.ERROR,
447 expectedMessage:
448 "Import prefix name must begin with a lowercase letter or underscore .");
449 }
450
451 void test_validateImportPrefixName_null() {
452 assertRefactoringStatus(
453 validateImportPrefixName(null),
454 RefactoringStatusSeverity.ERROR,
455 expectedMessage: "Import prefix name must not be null.");
456 }
457
458 void test_validateImportPrefixName_trailingBlanks() {
459 assertRefactoringStatus(
460 validateImportPrefixName("newName "),
461 RefactoringStatusSeverity.ERROR,
462 expectedMessage: "Import prefix name must not start or end with a blank. ");
463 }
464
465 void test_validateLibraryName_OK_oneIdentifier() {
466 assertRefactoringStatusOK(validateLibraryName("name"));
467 }
468
469 void test_validateLibraryName_OK_severalIdentifiers() {
470 assertRefactoringStatusOK(validateLibraryName("my.library.name"));
471 }
472
473 void test_validateLibraryName_blank() {
474 assertRefactoringStatus(
475 validateLibraryName(""),
476 RefactoringStatusSeverity.ERROR,
477 expectedMessage: "Library name must not be blank.");
478 assertRefactoringStatus(
479 validateLibraryName(" "),
480 RefactoringStatusSeverity.ERROR,
481 expectedMessage: "Library name must not be blank.");
482 }
483
484 void test_validateLibraryName_blank_identifier() {
485 assertRefactoringStatus(
486 validateLibraryName("my..name"),
487 RefactoringStatusSeverity.ERROR,
488 expectedMessage: "Library name identifier must not be empty.");
489 assertRefactoringStatus(
490 validateLibraryName("my. .name"),
491 RefactoringStatusSeverity.ERROR,
492 expectedMessage: "Library name identifier must not start or end with a b lank.");
493 }
494
495 void test_validateLibraryName_hasUpperCase() {
496 assertRefactoringStatus(
497 validateLibraryName("my.newName"),
498 RefactoringStatusSeverity.WARNING,
499 expectedMessage:
500 "Library name should consist of lowercase identifier separated by do ts.");
501 }
502
503 void test_validateLibraryName_leadingBlanks() {
504 assertRefactoringStatus(
505 validateLibraryName("my. name"),
506 RefactoringStatusSeverity.ERROR,
507 expectedMessage: "Library name identifier must not start or end with a b lank.");
508 }
509
510 void test_validateLibraryName_notIdentifierMiddle() {
511 assertRefactoringStatus(
512 validateLibraryName("my.ba-d.name"),
513 RefactoringStatusSeverity.ERROR,
514 expectedMessage: "Library name identifier must not contain '-'.");
515 }
516
517 void test_validateLibraryName_notIdentifierStart() {
518 assertRefactoringStatus(
519 validateLibraryName("my.2bad.name"),
520 RefactoringStatusSeverity.ERROR,
521 expectedMessage:
522 "Library name identifier must begin with a lowercase letter or under score.");
523 }
524
525 void test_validateLibraryName_null() {
526 assertRefactoringStatus(
527 validateLibraryName(null),
528 RefactoringStatusSeverity.ERROR,
529 expectedMessage: "Library name must not be null.");
530 }
531
532 void test_validateLibraryName_trailingBlanks() {
533 assertRefactoringStatus(
534 validateLibraryName("my.bad .name"),
535 RefactoringStatusSeverity.ERROR,
536 expectedMessage: "Library name identifier must not start or end with a b lank.");
537 }
538
539 void test_validateMethodName_OK() {
540 assertRefactoringStatusOK(validateMethodName("newName"));
541 }
542
543 void test_validateMethodName_OK_leadingUnderscore() {
544 assertRefactoringStatusOK(validateMethodName("_newName"));
545 }
546
547 void test_validateMethodName_OK_middleUnderscore() {
548 assertRefactoringStatusOK(validateMethodName("new_name"));
549 }
550
551 void test_validateMethodName_doesNotStartWithLowerCase() {
552 assertRefactoringStatus(
553 validateMethodName("NewName"),
554 RefactoringStatusSeverity.WARNING,
555 expectedMessage: "Method name should start with a lowercase letter.");
556 }
557
558 void test_validateMethodName_empty() {
559 assertRefactoringStatus(
560 validateMethodName(""),
561 RefactoringStatusSeverity.ERROR,
562 expectedMessage: "Method name must not be empty.");
563 }
564
565 void test_validateMethodName_leadingBlanks() {
566 assertRefactoringStatus(
567 validateMethodName(" newName"),
568 RefactoringStatusSeverity.ERROR,
569 expectedMessage: "Method name must not start or end with a blank.");
570 }
571
572 void test_validateMethodName_notIdentifierMiddle() {
573 assertRefactoringStatus(
574 validateMethodName("new-Name"),
575 RefactoringStatusSeverity.ERROR,
576 expectedMessage: "Method name must not contain '-'.");
577 }
578
579 void test_validateMethodName_notIdentifierStart() {
580 assertRefactoringStatus(
581 validateMethodName("2newName"),
582 RefactoringStatusSeverity.ERROR,
583 expectedMessage:
584 "Method name must begin with a lowercase letter or underscore.");
585 }
586
587 void test_validateMethodName_null() {
588 assertRefactoringStatus(
589 validateMethodName(null),
590 RefactoringStatusSeverity.ERROR,
591 expectedMessage: "Method name must not be null.");
592 }
593
594 void test_validateMethodName_trailingBlanks() {
595 assertRefactoringStatus(
596 validateMethodName("newName "),
597 RefactoringStatusSeverity.ERROR,
598 expectedMessage: "Method name must not start or end with a blank.");
599 }
600
601 void test_validateParameterName_OK() {
602 assertRefactoringStatusOK(validateParameterName("newName"));
603 }
604
605 void test_validateParameterName_OK_leadingUnderscore() {
606 assertRefactoringStatusOK(validateParameterName("_newName"));
607 }
608
609 void test_validateParameterName_OK_middleUnderscore() {
610 assertRefactoringStatusOK(validateParameterName("new_name"));
611 }
612
613 void test_validateParameterName_doesNotStartWithLowerCase() {
614 assertRefactoringStatus(
615 validateParameterName("NewName"),
616 RefactoringStatusSeverity.WARNING,
617 expectedMessage: "Parameter name should start with a lowercase letter.") ;
618 }
619
620 void test_validateParameterName_empty() {
621 assertRefactoringStatus(
622 validateParameterName(""),
623 RefactoringStatusSeverity.ERROR,
624 expectedMessage: "Parameter name must not be empty.");
625 }
626
627 void test_validateParameterName_leadingBlanks() {
628 assertRefactoringStatus(
629 validateParameterName(" newName"),
630 RefactoringStatusSeverity.ERROR,
631 expectedMessage: "Parameter name must not start or end with a blank.");
632 }
633
634 void test_validateParameterName_notIdentifierMiddle() {
635 assertRefactoringStatus(
636 validateParameterName("new-Name"),
637 RefactoringStatusSeverity.ERROR,
638 expectedMessage: "Parameter name must not contain '-'.");
639 }
640
641 void test_validateParameterName_notIdentifierStart() {
642 assertRefactoringStatus(
643 validateParameterName("2newName"),
644 RefactoringStatusSeverity.ERROR,
645 expectedMessage:
646 "Parameter name must begin with a lowercase letter or underscore.");
647 }
648
649 void test_validateParameterName_null() {
650 assertRefactoringStatus(
651 validateParameterName(null),
652 RefactoringStatusSeverity.ERROR,
653 expectedMessage: "Parameter name must not be null.");
654 }
655
656 void test_validateParameterName_trailingBlanks() {
657 assertRefactoringStatus(
658 validateParameterName("newName "),
659 RefactoringStatusSeverity.ERROR,
660 expectedMessage: "Parameter name must not start or end with a blank.");
661 }
662
663 void test_validateVariableName_OK() {
664 assertRefactoringStatusOK(validateVariableName("newName"));
665 }
666
667 void test_validateVariableName_OK_leadingDollar() {
668 assertRefactoringStatusOK(validateVariableName("\$newName"));
669 }
670
671 void test_validateVariableName_OK_leadingUnderscore() {
672 assertRefactoringStatusOK(validateVariableName("_newName"));
673 }
674
675 void test_validateVariableName_OK_middleUnderscore() {
676 assertRefactoringStatusOK(validateVariableName("new_name"));
677 }
678
679 void test_validateVariableName_doesNotStartWithLowerCase() {
680 assertRefactoringStatus(
681 validateVariableName("NewName"),
682 RefactoringStatusSeverity.WARNING,
683 expectedMessage: "Variable name should start with a lowercase letter.");
684 }
685
686 void test_validateVariableName_empty() {
687 assertRefactoringStatus(
688 validateVariableName(""),
689 RefactoringStatusSeverity.ERROR,
690 expectedMessage: "Variable name must not be empty.");
691 }
692
693 void test_validateVariableName_leadingBlanks() {
694 assertRefactoringStatus(
695 validateVariableName(" newName"),
696 RefactoringStatusSeverity.ERROR,
697 expectedMessage: "Variable name must not start or end with a blank.");
698 }
699
700 void test_validateVariableName_notIdentifierMiddle() {
701 assertRefactoringStatus(
702 validateVariableName("new-Name"),
703 RefactoringStatusSeverity.ERROR,
704 expectedMessage: "Variable name must not contain '-'.");
705 }
706
707 void test_validateVariableName_notIdentifierStart() {
708 assertRefactoringStatus(
709 validateVariableName("2newName"),
710 RefactoringStatusSeverity.ERROR,
711 expectedMessage:
712 "Variable name must begin with a lowercase letter or underscore.");
713 }
714
715 void test_validateVariableName_null() {
716 assertRefactoringStatus(
717 validateVariableName(null),
718 RefactoringStatusSeverity.ERROR,
719 expectedMessage: "Variable name must not be null.");
720 }
721
722 void test_validateVariableName_trailingBlanks() {
723 assertRefactoringStatus(
724 validateVariableName("newName "),
725 RefactoringStatusSeverity.ERROR,
726 expectedMessage: "Variable name must not start or end with a blank.");
727 }
728 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698