-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
More readable assert_eq proposal #1866
Conversation
Improve `assert_eq` failure message formatting to increase legibility A continuation of rust-lang#1864.
I think panics in general could benefit from a multi-line scheme |
@jethrogb While I wouldn't want to block this focused PR over that, yes, in general I'd love to see panics handled more gracefully. I don't want to encourage people to use |
Do note that textual diffs (mis)take the map for the territory; I don't think should be a deal breaker; but it is a limitation which spells diminishing returns for text-based strategies. Compared to textual diffs, the linebreaks and 1-space alignment in the RFC provide quite a bit more bang to the buck. |
I think we should only do string based diffing for strings, other types could have their own algorithms. |
Unfortunately that would require a new trait bound for This is something that could be experimented with in a third party crate though. |
Should we generally not put too many words into the panic message?
|
Punting to @BurntSushi, sorry for the very long delay :( |
Thank you :) |
@rfcbot fcp merge |
@lpil Thanks so much for this! I think the libs team is generally in favor of this, and we think this could probably could have squeak its way through as a PR. However, we should just move forward with the RFC since it is already written. :-)
|
Team member @BurntSushi has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Might be a bit late but I think this would be great and really plays into the ergonomics goal of Rust in 2017. I'm in favor of it. If it could look like the Elixir example given in the RFC I'd prefer that personally but LLVM style arrows is good too if that's not possible yet. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The RFC should also address How would those LLVM style arrows look like, if both left/right expressions wrap around several lines and the difference is somewhere in the middle? Would that still be readable and look good? Just as a sidenote: The quick [-red-]{+brown+} fox jumps over the lazy dog Maybe printing a diff in this style could be a colorless alternative to LLVM style arrows, but it might become less readable or even ambiguous if the underlying text contains a lot of special characters, too. Alternatively, inspecting/printing the diff of the debug outputs could be left to a third party crate like |
I've had a chance to use |
It clearly is a major improvement which will surely make using Rust even more comfortable than it currently is. I don't see any reason why it shouldn't be approved. As mentioned above, colours would be great but we can settle for LLVM style arrows if that's currently not possible. |
I think |
Specialization provides a backwards compatible manner to add this feature: create a new trait |
Note that this has been discussed before: https://users.rust-lang.org/t/suggestions-for-better-test-output/7494 |
The final comment period is now complete. |
This RFC has now been merged! Discussion should move to the tracking issue. I added a couple of unresolved questions, one of them for For some reason github isn't recognizing the merge, so I'm going to manually close, but the official RFC is here. |
Thank you :) |
This is not strickly related to the RFC -- I think this is a great first step! -- but do you think we could have a new traits related to the I ask because this is really great for comparing strings but does almost nothing in those extremely common cases. Again, super happy to see this change! |
Rendered
Improve
assert_eq
failure message formatting to increase legibilityA continuation of #1864.