snowe
01/29/2019, 6:52 AMfun Suite.mapsTo(expected: String) {
val testObject by memoized<Any>()
it("test value") {
pp(testObject)
outContent shouldRenderLike expected
}
}
fun testObject(obj: Any?) {
val testObject by memoized { obj }
}
describe("tiny object should") {
context("render a single field") {
testObject(TinyObject(1))
mapsTo(
"""
TinyObject(
int = 1
)
"""
)
}
}
but I find it very messy, and I can't use an infix....fun Suite.validateTestOutput(testObject: Any?, expected: String) {
it("test value") {
pp(testObject)
outContent shouldRenderLike expected
}
}
describe("tiny object should") {
infix fun Any.mapsTo(expected: String) {
validateTestOutput(this, expected)
}
context("render a single field") {
TinyObject(1) mapsTo """
TinyObject(
int = 1
)
"""
}
}
Alan Evans
01/29/2019, 3:43 PMinfix
requires exactly two parameters. But you seem to need the Suite
, the testObject
and the expected
snowe
01/29/2019, 4:13 PMAny
and Suite
. if I had that then this would be easy.Alan Evans
01/29/2019, 6:25 PMX to Y mapsTo Z
...Pair
. You needn't use to
, can make your own, you also needn't use Pair
, any data class will do.TinyObject(1) validateWith this thatItMapsTo """...
snowe
01/29/2019, 6:47 PM