Merge boxWithStdlib testData into box, delete BoxWithStdlib test

This commit is contained in:
Alexander Udalov
2016-03-07 13:36:14 +03:00
committed by Alexander Udalov
parent 22bfc9786a
commit 06a67e6602
535 changed files with 3520 additions and 3871 deletions
@@ -0,0 +1,49 @@
// WITH_RUNTIME
// FULL_JDK
@file:JvmName("XYZ")
import java.lang.reflect.Modifier
private const val privateConst: Int = 1
public const val publicConst: Int = 3
public object A {
private const val privateConst: Int = 1
public const val publicConst: Int = 3
}
public class B {
companion object {
private const val privateConst: Int = 1
protected const val protectedConst: Int = 2
public const val publicConst: Int = 3
}
}
fun check(clazz: Class<*>, expectProtected: Boolean = true) {
val fields = clazz.declaredFields.filter { it.name.contains("Const") }
assert(fields.all { Modifier.isStatic(it.modifiers) }) { "`$clazz` contains non-static fields" }
assert(Modifier.isPrivate(fields.single { it.name.contains("private") }.modifiers)) {
"`$clazz`.privateConst is not private"
}
assert(Modifier.isPublic(fields.single { it.name.contains("public") }.modifiers)) {
"`$clazz`.publicConst is not public"
}
if (expectProtected) {
assert(Modifier.isProtected(fields.single { it.name.contains("protected") }.modifiers)) {
"`$clazz`.protectedConst is not protected"
}
}
}
fun box(): String {
check(A::class.java, false)
check(B::class.java)
check(Class.forName("XYZ"), false)
return "OK"
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
const val z = "OK"
annotation class A(val value: String = z)
@A
class Test
fun box(): String {
return Test::class.java.getAnnotation(A::class.java).value
}
@@ -0,0 +1,20 @@
// WITH_RUNTIME
interface KInt {
companion object {
const val a = "a"
const val b = "b$a"
}
}
fun box(): String {
val a = KInt::class.java.getField("a").get(null)
val b = KInt::class.java.getField("b").get(null)
if (a !== KInt.a) return "fail 1: KInt.a !== KInt.Companion.a"
if (b !== KInt.b) return "fail 2: KInt.b !== KInt.Companion.b"
if (b !== "ba") return "fail 2: 'ba' !== KInt.Companion.b"
return "OK"
}