Files
kotlin-fork/libraries/stdlib/test/AnnotationsTest.kt
T
Mikhail Glukhikh 609d696202 Annotations have now retention of "RUNTIME" by default. Java retention is generated as given by kotlin annotation. Annotation rendering changed.
Annotation arguments with default values are rendered as ... if renderDefaultAnnotationArguments is true.
Tests: java retention does not taken into account by Descriptor comparator.
Java retentinon changed to kotlin retention in some tests + one new test with java retention added.
More accurate tests for intentions in byte code (visibility controlled).
2015-07-14 16:25:01 +03:00

34 lines
817 B
Kotlin

package test.annotations
import kotlin.*
import kotlin.test.assertTrue
import org.junit.Test as test
annotation(retention = AnnotationRetention.RUNTIME) class MyAnno
MyAnno
Deprecated
class AnnotatedClass
class AnnotationTest {
test fun annotationType() {
val annotations = javaClass<AnnotatedClass>().getAnnotations()!!
var foundMyAnno = false
var foundDeprecated = false
for (annotation in annotations) {
val clazz = annotation!!.annotationType()
when {
clazz == javaClass<MyAnno>() -> foundMyAnno = true
clazz == javaClass<Deprecated>() -> foundDeprecated = true
else -> {}
}
}
assertTrue(foundMyAnno)
assertTrue(foundDeprecated)
}
}