Files
kotlin/compiler/testData/codegen/box/reflection/lambdaClasses/parameterNamesAndNullability.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

49 lines
1.2 KiB
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.reflect.jvm.*
import kotlin.test.assertEquals
import kotlin.test.assertNull
fun lambda() {
val f = { x: Int, y: String? -> }
val g = f.reflect()!!
// TODO: maybe change this name
assertEquals("<anonymous>", g.name)
assertEquals(listOf("x", "y"), g.parameters.map { it.name })
assertEquals(listOf(false, true), g.parameters.map { it.type.isMarkedNullable })
}
fun funExpr() {
val f = fun(x: Int, y: String?) {}
val g = f.reflect()!!
// TODO: maybe change this name
assertEquals("<no name provided>", g.name)
assertEquals(listOf("x", "y"), g.parameters.map { it.name })
assertEquals(listOf(false, true), g.parameters.map { it.type.isMarkedNullable })
}
fun extensionFunExpr() {
val f = fun String.(): String = this
val g = f.reflect()!!
assertEquals(KParameter.Kind.EXTENSION_RECEIVER, g.parameters.single().kind)
assertEquals(null, g.parameters.single().name)
}
fun box(): String {
lambda()
funExpr()
extensionFunExpr()
return "OK"
}