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
✨"now configurable!"; customizable auto-labels and diff style #38
Conversation
It needs some condensing and refactoring before release, but this now allows much more flexible configuration. Customized labels and git-style diff prefixes are built-in as features ('labels' and 'diffstyle-git', respectively). I'll polish it and get it ready for release as a real PR over the next week or so... |
1c43e82
to
20601d7
Compare
Code functionality and most of the code polish is done.
// from 'pretty_assertion_custom.rs'
use pretty_assertions;
macro_rules! assert_eq { ($($arg:tt)+) => ({
pretty_assertions::with_config_assert_eq!( pretty_assertions::Config {
auto_label: true,
style: pretty_assertions::Color::Yellow.normal(),
prefix: "<=>",
prefix_left: "<<=", prefix_right: "=>>",
..Default::default()
},
$($arg)+
)
})}
/// ... assert_eq!( actual, expect ); ... Commit squashing into more logical chunks is the next WIP. |
…unwind' (to catch panics)
- with the "labels" feature enabled, `assert_{eq,ne}!(...)` will auto-label arguments - `with_labels_assert_{eq,ne}!(...)` will always auto-label arguments - arguments may be manually labelled by using `with_labels_assert_{eq,ne}!(foo: ..., bar: ...)` syntax * note: to be auto-labeled, both arguments must be identifiers, not values
…ty guarantees for < v1.0.0)
…Config; repackaging related code)
ebdd31e
to
d28055c
Compare
Commits are more polished and logical. This covers the most common requested changes (labels and "git-esque" diffs) plus additional styling flexibility. I'd like to be able to configure the other text in the assert. However, I haven't found a clean method as of yet. (Any suggestions?) The added configuration flexibility is opt-in. Basic use of the "labels" or "diffstyle_git" features is straightforward by adding the feature in the dependency ... and the resulting use is still a drop-in for the usual Thoughts? |
Although the boilerplate customization is fairly simple, I'd like to present a simpler generator/helper macro to more automatically generate a replacement When I create a generator macro, the generated But, in the end, since the boilerplate is relatively simple, I'm ok with the current implementation. Thoughts? |
Is there any progress on this? |
Ping @tommilligan ... are you maintaining this now? If so, could you review? |
@rivy thanks for the ping. I have looked over the basic design and like what you've done, but I need to invest some more time in benchmarking the changes and thinking about extensibility/the right public API to expose. You might be interested in the recent discussion on this issue: #24 (comment) |
⚰️ |
Fully implements customizable labelling and diff style for
assert_eq!(...)
andassert_ne!(...)
, but easily extended).Fixes: #35
Fixes: #37
Alternative to: #33, #39