Skip to content

Conversation

nmdefries
Copy link
Contributor

Currently we expect f to take 2 args, x and g.

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 only x, like function(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

`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.
@nmdefries nmdefries marked this pull request as ready for review April 24, 2023 15:55
Copy link
Contributor

@brookslogan brookslogan left a 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.

@nmdefries nmdefries requested a review from brookslogan May 11, 2023 19:03
Copy link
Contributor

@brookslogan brookslogan left a 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.

Copy link
Contributor Author

@nmdefries nmdefries left a 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.

brookslogan and others added 4 commits May 18, 2023 15:51
* 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.
@brookslogan brookslogan merged commit a1a53c5 into dev May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants