Files
kotlin/compiler/testData/codegen/box/reflection/parameters/functionParameterNameAndIndex.kt
Ilya Matveev a5e4e0284e Mute some box tests for native backend
This patch mutes the following test categories:
   * Tests with java dependencies (System class,
     java stdlib, jvm-oriented annotations etc).
   * Coroutines tests.
   * Reflection tests.
   * Tests with an inheritance from the standard
     collections.
2017-03-10 19:59:37 +03:00

37 lines
898 B
Kotlin
Vendored

// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS, NATIVE
// WITH_REFLECT
import kotlin.reflect.*
import kotlin.test.assertEquals
fun foo(bar: String): Int = bar.length
class A(val c: String) {
fun foz(baz: Int) {}
fun Double.mext(mez: Long) {}
}
fun Int.qux(zux: String) {}
fun checkParameters(f: KFunction<*>, names: List<String?>) {
val params = f.parameters
assertEquals(names, params.map { it.name })
assertEquals(params.indices.toList(), params.map { it.index })
}
fun box(): String {
checkParameters(::box, listOf())
checkParameters(::foo, listOf("bar"))
checkParameters(A::foz, listOf(null, "baz"))
checkParameters(Int::qux, listOf(null, "zux"))
checkParameters(A::class.functions.single { it.name == "mext" }, listOf(null, null, "mez"))
checkParameters(::A, listOf("c"))
return "OK"
}