-
Notifications
You must be signed in to change notification settings - Fork 8
Check that the f
passed to epi[x]_slide
takes enough args
#302
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
Conversation
`testthat::expect_no_error` and `testthat::expect_no_warning` are new, experimental functions available in the newest version of `testthat`. The old `testthat::expect_error`, etc, functions also support testing that no errors are raised by setting the `regexp` arg to `NA`. Use these functions so we don't need to require the very newest version of `testthat`.
We only need to make sure errors/warnings are raised in a subset of cases to make sure `f`s are being passed correctly to the check function. There are separate tests for the check function that are more exhaustive.
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.
Looks good, but I have a few edits (will push momentarily) + we should probably try to warn on attempts to use functions like lm
.
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.
I used a suppressWarnings
to prevent some warnings from a warning+error case from popping up during test()
. Not sure if we want warning+error but it's probably okay either way. (Feel free to adjust this case.)
I also (hopefully) addressed some technicalities dealing with dots forwarding; this could use some review. I'll go ahead and mark this approved so you can go ahead and merge if it looks all right.
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.
@brookslogan Mostly looks good. Thanks for handling dots, I forgot that that was a complication.
One suggestion that I'll add in, and what looks like an issue -- would like you to verify.
Co-authored-by: nmdefries <[email protected]>
* Add some explanatory comments * Use `cli_warn` instead of `sprintf` with `ansi_collapse` so length-2 things are formatted "thing 1 and thing 2" not "thing 1, and thing 2" * Fix default-replacement error message when some mandatory args are absorbed by `f`'s dots. (This could give a faulty message due to broadcasting when there was just one arg with a default before the dots, or potentially an R error in other situations if/when there are >2 mandatory args.) * Add regexp's to our tests to test some of this message preparation.
Currently we expect
f
to take 2 args,x
andg
.If
f
has...
as one of its args, it ideally would take 2 or more args before...
; a warning is raised if not. We don't error in this case to add flexibility. A user may want to handle onlyx
, likefunction(x, ...) { <do stuff with x only> }
if they don't need the group key or ref time value, letting...
capture the other args.If
f
doesn't have...
as one of its args, it must take 2 or more args in total, and exits with an error if not.Closes #168