All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.io.kotest.matchers.reflection.propertyMatchers.kt Maven / Gradle / Ivy

package io.kotest.matchers.reflection

import io.kotest.matchers.Matcher
import io.kotest.matchers.MatcherResult
import io.kotest.matchers.should
import io.kotest.matchers.shouldNot
import kotlin.reflect.KProperty

inline fun  KProperty<*>.shouldBeOfType() = this.returnType.shouldBeOfType()
inline fun  KProperty<*>.shouldNotBeOfType() = this.returnType.shouldNotBeOfType()

fun KProperty<*>.shouldBeConst() = this should beConst()
fun KProperty<*>.shouldNotBeConst() = this shouldNot beConst()
fun beConst() = object : Matcher> {
   override fun test(value: KProperty<*>) = MatcherResult(
      value.isConst,
      { "Property $value should be const" },
      {
         "Property $value should not be const"
      })
}

fun KProperty<*>.shouldBeLateInit() = this should beLateInit()
fun KProperty<*>.shouldNotBeLateInit() = this shouldNot beLateInit()
fun beLateInit() = object : Matcher> {
   override fun test(value: KProperty<*>) = MatcherResult(
      value.isLateinit,
      { "Property $value should be lateinit" },
      {
         "Property $value should not be lateinit"
      })
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy