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