A way to display *why* a predicate failed#60
Merged
epage merged 7 commits intoassert-rs:masterfrom Jul 28, 2018
Merged
Conversation
This was referenced Jul 21, 2018
Contributor
Author
|
@nastevens my main concern with having this reviewed is regarding vision
Luckily, I was able to avoid |
This was referenced Jul 21, 2018
Contributor
Author
|
@nastevens btw for time table, the goal is to have this PR in, #30 in, and assert_fs / assert_cmd switched over to these changes by the end of the month in preparation for the next 2018 Edition preview. |
a9647cd to
188a847
Compare
Predicates can now report parameter details that don't show up in `Display` as well as what children they have. The expectation is that this will be used by the solution for assert-rs#7. BREAKING CHANGE: `Predicate`s must also implement `reflection::PredicateReflection`.
This also saw an audit of predicates to ensure their `Display` would most likely remain as one line of text. Anything in a `Display` that seemed likely to overflow was moved to a `Parameter`.
This is the last of the foundation for resolving assert-rs#7.
A non-default implementation is provided for all predicates that can add additional information than what `eval` / `Display` provide. Exceptions - `eq_file`: I want to re-work this predicate - `BoxPredicate`: The where clause is causing problems This is the information needed for resolving assert-rs#7. Now, rendering is the only thing left.
Apparently, a provided function can't downcast `&self` but I can if I spread the implementation around. Overall, trying to meet the goal of making it simple to write a Predicate. Anyone besides us will need to copy `default_find_case` if they want the reference. Not sure what would be a good way to make that good enough for being stable.
Finnaly, Fixes assert-rs#7. Inspired by the work in assert-rs#39. Created softprops/treeline#3 for trying to find ways to make this more efficient.
takumi-earth
pushed a commit
to earthlings-dev/predicates-rs
that referenced
this pull request
Jan 27, 2026
A way to display *why* a predicate failed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Output of
case_treeexample:An extension trait is added to make a
Displayable struct that will print out the above tree.find_casewhich will find theCasethat prove whether thePredicatesucceeds or fails.Caseonly owns by-Products of thePredicateevaluation,parametersare made available as references on thePredicateReflectiontraitCaseAPI becauseParameterandProducthave different ownership requirements.PredicateReflectionis also use to homogenize the predicate treePredicate<[u8]>,Predicate<str>, etc.Once this is in, to reduce API breaks from impacting the assert-ecosystem, #30 will be implemented and this repo will be turned into a workspace for
predicate-core:core.rs,reflection.rspredicate-tree:tree.rspredicatespredicate-coreaka the only change to most end-users will be
predicate-treebeing removed from the API while the assert-ecosystem will usepredicate_core::Predicatein its public API.This supersedes #39 due to having an API that we are more comfortable moving to 1.0
itemin theDisplay, allowing us to avoid requiringItem: Debug. Instead we just rely on everyPredicateimplementingDisplay, usually doing so by having anItem: Debugrequirement but clients are free to bypass that by creating their ownPredicate.BREAKING CHANGES
PredicateReflection. Provided methods make this aimpl PredicateReflection for X {}