Skip to content

Commit 3d91def

Browse files
authored
Capitalize method names properly (#504)
* Capitalize method names properly #485 * Use isLegitSymbolForFunctionName() instead of regex #485
1 parent 80e37a2 commit 3d91def

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest(
126126
" 2nd return statement: return a;\n"
127127

128128
val methodName1 = "testCompareChars_NLessThan1"
129-
val methodName2 = "testCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming
130-
val methodName3 = "testCompareChars_0OfCharactertoCharsiEqualsB"
131-
val methodName4 = "testCompareChars_0OfCharactertoCharsiNotEqualsB" // TODO: si -> is
129+
val methodName2 = "testCompareChars_0OfCharacterToCharsIEqualsA" // TODO: a weird unclear naming
130+
val methodName3 = "testCompareChars_0OfCharacterToCharsIEqualsB"
131+
val methodName4 = "testCompareChars_0OfCharacterToCharsINotEqualsB"
132132

133133
val displayName1 = "n < 1 : True -> return ' '"
134134
val displayName2 = "Character.toChars(i)[0] == a : True -> return b"
@@ -196,9 +196,9 @@ class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest(
196196
" returns from: return a;"
197197

198198
val methodName1 = "testInnerVoidCompareChars_NLessThan1"
199-
val methodName2 = "testInnerVoidCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming
200-
val methodName3 = "testInnerVoidCompareChars_0OfCharactertoCharsiNotEqualsB"
201-
val methodName4 = "testInnerVoidCompareChars_0OfCharactertoCharsiEqualsB" // TODO: si -> is
199+
val methodName2 = "testInnerVoidCompareChars_0OfCharacterToCharsIEqualsA" // TODO: a weird unclear naming
200+
val methodName3 = "testInnerVoidCompareChars_0OfCharacterToCharsINotEqualsB"
201+
val methodName4 = "testInnerVoidCompareChars_0OfCharacterToCharsIEqualsB"
202202

203203
val displayName1 = "n < 1 : True -> return ' '"
204204
val displayName2 = "Character.toChars(i)[0] == a : True -> return b"
@@ -270,9 +270,9 @@ class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest(
270270
"Test afterwards returns from: return compareChars(a, b, n);\n"
271271

272272
val methodName1 = "testInnerReturnCompareChars_NLessThan1"
273-
val methodName2 = "testInnerReturnCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming
274-
val methodName3 = "testInnerReturnCompareChars_0OfCharactertoCharsiNotEqualsB"
275-
val methodName4 = "testInnerReturnCompareChars_0OfCharactertoCharsiEqualsB" // TODO: si -> is
273+
val methodName2 = "testInnerReturnCompareChars_0OfCharacterToCharsIEqualsA" // TODO: a weird unclear naming
274+
val methodName3 = "testInnerReturnCompareChars_0OfCharacterToCharsINotEqualsB"
275+
val methodName4 = "testInnerReturnCompareChars_0OfCharacterToCharsIEqualsB"
276276

277277
val displayName1 = "n < 1 : True -> return ' '"
278278
val displayName2 = "Character.toChars(i)[0] == a : True -> return b"

utbot-summary/src/main/kotlin/org/utbot/summary/name/NodeConvertor.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,13 @@ class NodeConvertor {
352352
}
353353

354354
/**
355-
* Filters out all of the symbols that cannot be used in a function name and capitalizes String
355+
* Capitalizes method name.
356+
*
357+
* It splits the text by delimiters, capitalizes each part, removes special characters and concatenates result.
356358
*/
357-
private fun postProcessName(name: String) = name.filter { isLegitSymbolForFunctionName(it) }.capitalize()
359+
private fun postProcessName(name: String) =
360+
name.split(".", "(", ")", ",")
361+
.joinToString("") { it -> it.capitalize().filter { isLegitSymbolForFunctionName(it) } }
358362

359363
/**
360364
* Converts Javaparser BinaryOperator and all of its children into a String

0 commit comments

Comments
 (0)