Add `infix fun String.selfieIs` (similar to Kotest `shouldBe`)
- Lingua principale
- Kotlin
- Stelle
- 101
- Fork
- 18
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- kotlin
- Ambito
- testing
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100