lambdaisland / lambdaisland/deep-diff2
Print string-based diff if there's a mismatch of two strings
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Clojure
- Sterne
- 326
- Forks
- 18
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I sometimes need to write tests for functions that output strings, in particular multi-line strings. Right now deep-diff2 will just say -<expected-string> +<actual-string>, which isn't very useful for longer strings and strings containing newlines.
Right now I try to work around this by splitting the strings on newlines and letting deep-diff2 diff the arrays, which at least will highlight the lines with changes, but it's not great.
I think it'd be useful to print a string-based diff, like git-diff would, if both expressions for a mismatch are string.
For no newlines they could still be printed in place, but for newlines it likely would make sense to introduce a linebreak and then show the diff without worrying about indentation.
I found deep-diff2.printer-impl/print-mismatch, and (and (string? (:- expr)) (string? (:+ expr))) seems like an easy enough condition there, so I'm playing around with it.
Would you consider this for deep-diff2, or do you see problems with the approach? Perhaps it could be an option to not break any existing consumers.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, deep-diff2.printer-impl/print-mismatch und das bestehende Verhalten bei der Ausgabe von Mismatches zu lesen. Entscheide, wie Mismatches zwischen Strings dargestellt werden sollen, einschließlich mehrzeiliger Werte und der Frage, ob das Verhalten eine Option benötigt; erledigt bedeutet eine nützliche git-ähnliche Ausgabe, ohne bestehende Consumer zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- clojure
- Bereich
- testing-qa
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100