Add infix fun String.selfieIs
(similar to Kotest shouldBe
) #214
Open
Description
Kotest has a very nice shouldBe
method:
someFunction() shouldBe "some value"
It would be handy if Selfie had an infix version:
someFunction() selfieIs null // equivalent to `toBe_TODO`, run and it becomes
someFunction() selfieIs "some value"
And all the //selfieonce
, //SELFIEWRITE
would work too if implemented roughly like so:
// in com.diffplug.selfie
infix fun String.selfieIs(expected: String?) : Unit {
if (expected == null) {
Selfie.expectSelfie(this).toBe_TODO()
} else {
Selfie.expectSelfie(this).toBe(expected)
}
}
// in com.diffplug.selfie.coroutines
suspend infix fun String.selfieIs(expected: String?) : Unit {
if (expected == null) {
Selfie.expectSelfie(this).toBe_TODO()
} else {
Selfie.expectSelfie(this).toBe(expected)
}
}
The main challenge will be adapting this code to parse infix multiline literals