[Native][tests] Minor. Make computePackageName() a bit more comprehensive
This commit is contained in:
+9
-5
@@ -33,12 +33,16 @@ internal fun computePackageName(testDataBaseDir: File, testDataFile: File): Pack
|
|||||||
else
|
else
|
||||||
buildString {
|
buildString {
|
||||||
packagePart.forEachIndexed { index, ch ->
|
packagePart.forEachIndexed { index, ch ->
|
||||||
if (index == 0) when {
|
if (ch.isJavaIdentifierPart()) {
|
||||||
ch.isJavaIdentifierStart() -> append(ch)
|
if (index == 0 && !ch.isJavaIdentifierStart()) {
|
||||||
ch.isJavaIdentifierPart() -> append('_').append(ch)
|
// If the first character is not suitable for start, escape it with '_'.
|
||||||
else -> append('_')
|
append('_')
|
||||||
|
}
|
||||||
|
append(ch)
|
||||||
|
} else {
|
||||||
|
// Replace incorrect character.
|
||||||
|
append('_')
|
||||||
}
|
}
|
||||||
else append(if (ch.isJavaIdentifierPart()) ch else '_')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user