Files
kotlin-fork/compiler/testData/codegen/box/collectionLiterals/defaultAnnotationParameterValues.kt
T
Alexander Udalov 5b58eb8491 Remove LANGUAGE_VERSION from non-coroutine codegen tests
Most of these tests used this directive as a way to opt in to a new
language feature, and most of those features are already stable for a
long time, so no opt-in is needed. Some other tests used the directive
to opt out from a language feature, replace those by the `LANGUAGE`
directive. One test used the directive to test behavior that actually
depended on the API version; use `API_VERSION` directive there instead.
2018-12-20 12:53:23 +01:00

42 lines
1.2 KiB
Kotlin
Vendored

// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
// WITH_REFLECT
// IGNORE_BACKEND: JS
// IGNORE_BACKEND: NATIVE
import java.util.Arrays
import kotlin.reflect.KClass
import kotlin.reflect.KFunction0
inline fun <reified T> test(kFunction: KFunction0<Unit>, test: T.() -> String): String {
val annotation = kFunction.annotations.single() as T
return annotation.test()
}
fun check(b: Boolean, message: String) {
if (!b) throw RuntimeException(message)
}
annotation class Foo(
val a: IntArray = [],
val b: IntArray = [1, 2, 3],
val c: Array<String> = ["/"],
val d: Array<KClass<*>> = [Int::class, Array<Int>::class],
val e: DoubleArray = [1.0]
)
@Foo
fun withAnn() {}
fun box(): String {
return test<Foo>(::withAnn) {
check(a.contentEquals(intArrayOf()), "Fail 1: ${a.joinToString()}")
check(b.contentEquals(intArrayOf(1, 2, 3)), "Fail 2: ${b.joinToString()}")
check(c.contentEquals(arrayOf("/")), "Fail 3: ${c.joinToString()}")
check(d.contentEquals(arrayOf(Int::class, Array<Int>::class)), "Fail 4: ${d.joinToString()}")
check(e.contentEquals(doubleArrayOf(1.0)), "Fail 5: ${e.joinToString()}")
"OK"
}
}