Merge boxWithStdlib testData into box, delete BoxWithStdlib test
This commit is contained in:
committed by
Alexander Udalov
parent
22bfc9786a
commit
06a67e6602
+16
@@ -0,0 +1,16 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Anno
|
||||
|
||||
fun box(): String {
|
||||
val a = Anno::class.annotations
|
||||
|
||||
if (a.size != 1) return "Fail 1: $a"
|
||||
val ann = a.single() as? Retention ?: return "Fail 2: ${a.single()}"
|
||||
assertEquals(AnnotationRetention.RUNTIME, ann.value)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
annotation class Get
|
||||
annotation class Set
|
||||
annotation class SetParam
|
||||
|
||||
var foo: String
|
||||
@Get get() = ""
|
||||
@Set set(@SetParam value) {}
|
||||
|
||||
fun box(): String {
|
||||
assert(::foo.getter.annotations.single() is Get)
|
||||
assert(::foo.setter.annotations.single() is Set)
|
||||
assert(::foo.setter.parameters.single().annotations.single() is SetParam)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
annotation class Ann(val value: String)
|
||||
|
||||
@Ann("OK")
|
||||
val property: String
|
||||
get() = ""
|
||||
|
||||
fun box(): String {
|
||||
return (::property.annotations.single() as Ann).value
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class SourceAnno
|
||||
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class BinaryAnno
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class RuntimeAnno
|
||||
|
||||
@SourceAnno
|
||||
@BinaryAnno
|
||||
@RuntimeAnno
|
||||
fun box(): String {
|
||||
assertEquals(listOf(RuntimeAnno::class.java), ::box.annotations.map { it.annotationClass.java })
|
||||
return "OK"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Simple(val value: String)
|
||||
|
||||
@Simple("OK")
|
||||
class A
|
||||
|
||||
fun box(): String {
|
||||
return (A::class.annotations.single() as Simple).value
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
annotation class Primary
|
||||
annotation class Secondary
|
||||
|
||||
class C @Primary constructor() {
|
||||
@Secondary
|
||||
constructor(s: String): this()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val ans = C::class.constructors.map { it.annotations.single().annotationClass.java.simpleName }.sorted()
|
||||
if (ans != listOf("Primary", "Secondary")) return "Fail: $ans"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Simple(val value: String)
|
||||
|
||||
@Simple("OK")
|
||||
fun box(): String {
|
||||
return (::box.annotations.single() as Simple).value
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Simple(val value: String)
|
||||
|
||||
fun test(@Simple("OK") x: Int) {}
|
||||
|
||||
fun box(): String {
|
||||
return (::test.parameters.single().annotations.single() as Simple).value
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_REFLECT
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Simple(val value: String)
|
||||
|
||||
@property:Simple("OK")
|
||||
val foo: Int = 0
|
||||
|
||||
fun box(): String {
|
||||
return (::foo.annotations.single() as Simple).value
|
||||
}
|
||||
Reference in New Issue
Block a user