Add `infix fun String.selfieIs` (similar to Kotest `shouldBe`)
- Vorherrschende Sprache
- Kotlin
- Sterne
- 101
- Forks
- 18
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Kotest has a very nice `shouldBe` method:
```kotlin
someFunction() shouldBe "some value"
```
It would be handy if Selfie had an infix version:
```kotlin
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:
```kotlin
// 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
https://github.com/diffplug/selfie/blob/952a4ebfdf4911deeb08a7378048c80a0a9bb3ff/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/SourceFile.kt#L105-L111
Beitragsleitfaden
Rechercherichtung
Start with jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/SourceFile.kt at the linked parsing logic around lines 105–111. Review the proposed com.diffplug.selfie and com.diffplug.selfie.coroutines selfieIs entry points, then trace how toBe_TODO, toBe, //selfieonce, and //SELFIEWRITE are handled. Done means infix multiline literals and both regular and suspend forms work with the shown examples.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- kotlin
- Bereich
- testing
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100