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

commonMain.korlibs.test.AnySubject.kt Maven / Gradle / Ivy

The newest version!
package korlibs.test

import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
import kotlin.test.assertEquals
import kotlin.test.assertIs

open class AnySubject(val subject: T) {
    fun isEqualTo(expected: T) {
        assertEquals(expected, subject)
    }

    inline fun  isInstanceOf(): E {
        return isInstanceOf(subject)
    }

    @OptIn(ExperimentalContracts::class)
    inline fun  isInstanceOf(value: Any?): E {
        contract { returns() implies (value is E) }
        assertIs(subject)
        return subject as E
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy