Is it possible to compare function types? Given s...
# kotest
m
Is it possible to compare function types? Given something like:
Copy code
typealias Matcher = (String) -> Boolean
data class Thing(matcher: Matcher)
This fails:
Copy code
it("compares values of function types") {
    val testThing = Thing({ it.startsWith("test") })
    testThing.matcher shouldBe { it.startsWith("test") }
}
with messages like:
Copy code
expected:<(kotlin.String) -> kotlin.Boolean> but was:<(kotlin.String) -> kotlin.Boolean>
s
It can't compare the code inside the functions as that's not made available so it's comparing by reference here
m
Thanks! That’s what I thought.