Add different tests on class loaders in reflection

This commit is contained in:
Alexander Udalov
2015-04-02 18:35:12 +03:00
parent 87ef4ff7c5
commit 47e7235e64
5 changed files with 131 additions and 11 deletions
@@ -0,0 +1,23 @@
package test
import kotlin.reflect.KClass
import kotlin.test.*
class K(val p: String)
class Test {
fun kClass(): Any = K::class
fun doTest(k1: KClass<*>, k2: KClass<*>) {
// KClass instances for classes loaded with different class loaders should have the same string representation,
// but should not be equal
assertEquals("$k1", "$k2")
assertNotEquals(k1, k2)
// The same for properties of these classes
val p1 = k1.properties.first()
val p2 = k2.properties.first()
assertEquals("$p1", "$p2")
assertNotEquals(p1, p2)
}
}
@@ -0,0 +1,15 @@
package test
import kotlin.reflect.KClass
import kotlin.test.*
class K
class Test {
fun kClass(): Any = K::class
fun doTest(k1: KClass<*>, k2: KClass<*>) {
// KClass instances should be equal for classes loaded with the child and the parent
assertEquals(k1, k2)
}
}