[Native][tests] Minor. Make computePackageName() a bit more comprehensive

This commit is contained in:
Dmitriy Dolovov
2021-11-13 13:15:56 +03:00
parent e30f33b18d
commit 407e82adbb
@@ -33,12 +33,16 @@ internal fun computePackageName(testDataBaseDir: File, testDataFile: File): Pack
else
buildString {
packagePart.forEachIndexed { index, ch ->
if (index == 0) when {
ch.isJavaIdentifierStart() -> append(ch)
ch.isJavaIdentifierPart() -> append('_').append(ch)
else -> append('_')
if (ch.isJavaIdentifierPart()) {
if (index == 0 && !ch.isJavaIdentifierStart()) {
// If the first character is not suitable for start, escape it with '_'.
append('_')
}
append(ch)
} else {
// Replace incorrect character.
append('_')
}
else append(if (ch.isJavaIdentifierPart()) ch else '_')
}
}
}