[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 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 '_')
} }
} }
} }