-
Notifications
You must be signed in to change notification settings - Fork 333
Add more informative feedback in expect_named()
#2130
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
base: main
Are you sure you want to change the base?
Add more informative feedback in expect_named()
#2130
Conversation
R/expect-named.R
Outdated
act_miss <- unique(act$names[!act$names %in% exp$val]) | ||
exp_miss <- unique(exp$val[!exp$val %in% act$names]) | ||
|
||
expect( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This expect()
block is copied and modified slightly from expect_setequal()
to include "Names of "
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explore extracting out a single helper function that we could use here, in expect_setequal()
and expect_mapequal()
? A expectation helper should end in _
and have an argument trace_env = caller_env()
that is passed to every use of fail()
.
@hadley for the |
Can you hold off a day or two until I've finished refactoring how we write expectations? I'll have a better set of recommendations then. |
Ok, can you please take another stab at it, following the updated |
@@ -126,7 +126,8 @@ expect_waldo_equal_ <- function( | |||
exp, | |||
info = NULL, | |||
..., | |||
trace_env = caller_env() | |||
trace_env = caller_env(), | |||
error_prefix = NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of error_prefix
here and in expect_setequal_()
are done to avoid duplication of these function by allowing me to add "Names of "
, otherwise I would need some gnarly $lab
modifications
Hope to close #2091 and close #1558
This PR aims to add more informative errors.
Created on 2025-07-28 with reprex v2.1.1