d-edge / d-edge/Diffract

Better output for strings

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
F#
Stars
60
Forks
7
PR merge metrics
No merged PRs in 30d

Description

The output for different strings just prints the two strings on separate lines. This is fine for short strings, but for longer ones, especially multiline, it can be difficult to find where exactly the difference is. We could take inspiration from other assertion libraries that indicate at which character position the strings begin to differ, and only print the section of the string around that position.

Hint for the person who wants to take up this issue: I think the best way to go would be to add a case `String of x1: string * x2: string` to [the type `Diff`](https://github.com/d-edge/Diffract/blob/4809555d0d90b28477e40c2f9bc785aadfeb0b6b/src/Diffract/Types.fs#L9). This case would be used [in `Differ.diffWith`](https://github.com/d-edge/Diffract/blob/4809555d0d90b28477e40c2f9bc785aadfeb0b6b/src/Diffract/Differ.fs#L80) instead of `simpleEquality` (which returns a `Diff.Value`). Its display format would then be applied [in DiffPrinter.toStreamImpl](https://github.com/d-edge/Diffract/blob/4809555d0d90b28477e40c2f9bc785aadfeb0b6b/src/Diffract/DiffPrinter.fs#L5).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.