Open ncalexan opened 7 years ago
I have interest in working on this as well, possibly after #195. If there's anyone else interested in taking this though, please feel free.
This can either be done via structural diff, or textual diff. Structural is likely more difficult to get right, one can imagine a tree traversal iterator using itertools::diff_with
, but that likely won't offer meaningful data when diffing two sufficiently different ASTs (need to bail out early). Textual diff seems like a reasonable approach, especially after #195
This is really an answer to https://github.com/mozilla/mentat/issues/247#issue-205518531, but I'm putting it here since this is the relevant ticket.
I want pretty output during tests -- basically, I want assert_eq!
to help me find differences in EDN (presented as &str
slices). This probably looks like a new macro, assert_eq_edn!
or similar, that parses both sides into EDN (bonus points: handles edn::Value
and anything that can be parsed into EDN) and then provides a helpful diff message as well as the string inputs if the two sides aren't equal.
@ncalexan It would seem that textual diffing is something sufficient for your needs (and thus requiring some new pretty printing rules for json-like expanding of edn, which would also allow me to highlight the usefulness of some of the generalizations in #245). Is that correct?
On Thu, Feb 9, 2017 at 12:07 PM, Victor Porof notifications@github.com wrote:
@ncalexan https://github.com/ncalexan It would seem that textual diffing is something sufficient for your needs (and thus some new pretty printing rules for json-like expanding of edn, which would also allow me to highlight the usefulness of some of the generalizations in #245 https://github.com/mozilla/mentat/pull/245). Is that correct?
Textual diffing is great for test reports and helping humans figure out where things are broken. The EDN matching I describe is really about letting us write tests easily, which is slightly different. Progress on either front would be great!
Similar to #195, it gets really tiresome trying to visually diff to subtly different
edn::Value
instances. This ticket tracks implementing some structured diff algorithm. Even just pretty printing and doing a text diff on the two outputs would be better than the madness I'm doing to compare right now!