[Native][tests] Add standalone test for KClass package names

To ensure that after introducing `ReflectionPackageName` annotation,
we still have tests that check KClass package names without it.
This commit is contained in:
Svyatoslav Scherbina
2022-07-28 19:36:10 +02:00
parent c1853a0218
commit 09c131afd2
2 changed files with 46 additions and 0 deletions
@@ -0,0 +1,40 @@
// TARGET_BACKEND: NATIVE
// NATIVE_STANDALONE
// Purpose of this test is to check that Kotlin/Native still generates correct
// package names in reflection information without package patching.
//
// Native test engine by default groups tests to single compilation, and
// renames packages to avoid clashes.
// To make reflection-related tests work, it inserts ReflectionPackageName
// annotations when patching, to instruct the compiler to use the original
// package name for reflection information.
//
// The NATIVE_STANDALONE directive above disables test grouping.
// So this test basically checks that without ReflectionPackageName the compiler
// can still properly handle reflection information for classes and generates
// correct package names.
// FILE: pkg.kt
package pkg
class A
// FILE: pkg.sub.kt
package pkg.sub
class B
// FILE: defaut.kt
import pkg.*
import pkg.sub.*
class C
fun box(): String {
if (A::class.qualifiedName != "pkg.A") return "FAIL 1: ${A::class.qualifiedName}"
if (B::class.qualifiedName != "pkg.sub.B") return "FAIL 2: ${B::class.qualifiedName}"
if (C::class.qualifiedName != "C") return "FAIL 3: ${C::class.qualifiedName}"
return "OK"
}