-
Notifications
You must be signed in to change notification settings - Fork 29
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
An eval
that tells me why the predicate failed
#7
Comments
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Apr 1, 2018
This will be more helpful when assert-rs#7 is implemented. Fixes assert-rs#9
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Apr 2, 2018
This will be more helpful when assert-rs#7 is implemented. Fixes assert-rs#9
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Apr 2, 2018
This will be more helpful when assert-rs#7 is implemented. Fixes assert-rs#9
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Apr 4, 2018
This will be more helpful when assert-rs#7 is implemented. Fixes assert-rs#9
This comment has been minimized.
This comment has been minimized.
Given: let between_5_and_10 = predicate::ge(5).and(predicate::le(10));
assert_eq!(true, between_5_and_10.eval(&7));
assert_eq!(false, between_5_and_10.eval(&11));
assert_eq!(false, between_5_and_10.eval(&4)); ideally the output would be
And because of So API requirements
|
This comment has been minimized.
This comment has been minimized.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
May 15, 2018
This is a step towards assert-rs#7. We can now display the expression under test. Next steps: - Ellipsis the strings being reported from this change. - Ability to enumerate failure cases. I'm mixed about building this enumeration functionality directly into `Predcate` or if we should instead provide an expanded trait that is only implemented when `Predicate` is `Display` and `T` is `Debug`. For now, I'm going with the simplest implementation, to assume every predicate will want this functionality. BREAKING CHANGES: - `Display` is now required to implement `Predicate`. - Generic traits (taking `T`) now require `T` to be `Debug`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
May 15, 2018
This can be important for - Clarifying the intent of a predicate, especially when looking at test results - Shortening `Predicate::display`s that are too big This is another step towards assert-rs#7.
epage
added a commit
that referenced
this issue
May 15, 2018
Implement `Display` support in lead up to #7
This was referenced May 28, 2018
A great example of a failure message is from pytest
|
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 6, 2018
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`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 6, 2018
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. 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. BREAKING CHANGE: `Predicate`s must also implement `reflection::PredicateReflection`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 11, 2018
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`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 13, 2018
This is the last of the foundation for resolving assert-rs#7.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 19, 2018
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`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 19, 2018
This is the last of the foundation for resolving assert-rs#7.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 20, 2018
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`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 20, 2018
This is the last of the foundation for resolving assert-rs#7.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 20, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 20, 2018
This is the last of the foundation for resolving assert-rs#7.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 20, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 21, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 21, 2018
This is the last of the foundation for resolving assert-rs#7.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 21, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 21, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
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`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
This is the last of the foundation for resolving assert-rs#7.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
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`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
This is the last of the foundation for resolving assert-rs#7.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
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.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
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`.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
This is the last of the foundation for resolving assert-rs#7.
epage
added a commit
to epage/predicates-rs
that referenced
this issue
Jul 28, 2018
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.
epage
added a commit
that referenced
this issue
Oct 6, 2023
README.md list indentation and no bare URLs, as per Markdown Lint VS Code extension
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In using this with assertions, like assert_cli, it'd be a very big help for debuggability to tell people why the assertion failed.
Requirements
Some possible requirements include (yes, some will be contradictory)
is_close
has several params. If do we inline substitution, it might not be clearassert_cmd
and friends can decide whether to panic (return error, etc)Example of odd cases to watch for
is_close
taking several parametersfrom_utf8
,trim
, a potentialnormalize_newlines
,from_file_path
transform the data being passed downname
shifts the child predicate into an equivalent of a named fieldnot
flips what case we are looking forOpen Questions
Debug
implementations common enough that we can justify requiringPredicate<Item: Debug>
?API Design Options
cases_iter(item, yes: bool) -> Iterator
This returns an iterator of examples of cases for why
yes
. Each case in the iterator can show the full expression tree and what each part evaluates to.The
yes
is needed to flip what we are looking for when evaluatingnot
.tree_eval(item) -> (bool, tree)
Returns the result of
eval
plus a renderable tree using thetreeline
crate.Requires the following
Predicate
methodsstringify
: likeDisplay
but substitutes theItem
inmake_tree
: creates the renderabvle treetree_eval
: the actual function, a default trait implementation existsSee #39
table_eval(item) -> (bool, table)
Like
tree_eval
but render a table usingterm-table
See #39
prove(&'a self, item, yes:bool) -> Option<Tree<'a>>
Creates a
Tree
of the predicates and their intermediate values using references, owned values, andCow
. Different render implementations can be written against this, whether tree, table, or something else.Only return those parts for support
yes
.If
None
is returned, then nothing supportsyes
.The text was updated successfully, but these errors were encountered: