Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value diffs #154

Open
TysonMN opened this issue Jul 15, 2020 · 6 comments
Open

Value diffs #154

TysonMN opened this issue Jul 15, 2020 · 6 comments

Comments

@TysonMN
Copy link

TysonMN commented Jul 15, 2020

This talk about Haskell's Hedgehog (only need to watch from that starting point for 30 seconds) mentions "value diffs". When some equality expression is false, instead of printing both sides separately, they are printed together except with diff notation to highlight the difference. Here is a screenshot from that talk.

2020-07-15_08-25-49_179

I asked about if F# Hedgehog has this feature in hedgehogqa/fsharp-hedgehog#211, and it does not.

Does it make sense for Unquote to consider a feature like value diffs?

@akhansari
Copy link

This feature would be a real time and life saver 🙏 🙏

Currently at each failure we need to copy/past the two part and compare them in a diff tool.
It's very painful!

@stephen-swensen
Copy link
Contributor

stephen-swensen commented Oct 27, 2020

I agree something like this would be a nice addition to Unquote. I often run into the same issue, namely with equality comparison between two record types that contain many properties. I wonder if a first iteration that might go a long way would be to have a second reduction step after {record1 of type 'T} = {record2 of type 'T}) like {properties of record1 that aren't equal to corresponding record2 properties} = {properties of record2 that aren't equal to corresponding record1 properties}) e.g.

given

let x = { A=1; B=2; C=3; D=4 }
let y = { A=2; B=2; C=3; D=3 }

test <@ x = y @>

instead of failure output like

x = y
{ A=1; B=2; C=3; D=4 } = { A=2; B=2; C=3; D=3 }
false

we could have something like

x = y
{ A=1; B=2; C=3; D=4 } = { A=2; B=2; C=3; D=3 }
{ A=1; D=4; ... } = { A=2; D=3; ... }
false

@natalie-o-perret
Copy link

Guess starting from there and trying to see where the exact differences can be represented.

Wondering if the issue is all about making a copycat of this particular Hedgehog feature (ie. colours and whatnot?) or nawt.

@baronfel
Copy link

Expecto went through this and eventually added an integration with DiffSharp, outsourcing the creation of the diff: https://github.com/haf/expecto/blob/master/Expecto.Diff/Library.fs

@natalie-o-perret
Copy link

Expecto went through this and eventually added an integration with DiffSharp, outsourcing the creation of the diff: https://github.com/haf/expecto/blob/master/Expecto.Diff/Library.fs

Thanks, might worth looking at their impl.

@stephen-swensen
Copy link
Contributor

stephen-swensen commented Dec 31, 2023

Someone (Urz Enzler) using Diffract to augment Unquote output (it's limited to quality expressions and coded specifically for Xunit assertions): https://www.planetgeek.ch/2023/02/20/todays-random-f-code-nice-test-error-messages-with-unquote-and-diffract/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants