Repository navigation
New expect_identical_linter - #958
Merged
Merged
Conversation
76 tasks done
AshesITR
reviewed
Mar 19, 2022
Comment on lines
+68
to
+75
| "expect_identical(x, y) is the default way of comparing two objects in", | ||
| "testthat unit tests. Only use expect_equal() if testing numeric", | ||
| "equality (and specifying tolerance= explicitly) or there's a need to", | ||
| "ignore some attributes, e.g. with ignore_attr = 'names' for the 3rd", | ||
| "edition or check.attributes = FALSE for the second. For testing", | ||
| "approximate equality to a whole number, you can also avoid setting", | ||
| "tolerance= by including an explicit decimal point, e.g.,", | ||
| "expect_equal(x, 1.0), not expect_equal(x, 1)." |
Collaborator
There was a problem hiding this comment.
That's a rather long message compared to other linters.
Maybe shorten to "only use expect_equal() if non-default arguments, e.g. tolerance, are needed"?
Collaborator
Author
There was a problem hiding this comment.
put some of the details in the man page, should be more digestible now
38 tasks done
AshesITR
reviewed
Mar 21, 2022
AshesITR
approved these changes
Mar 21, 2022
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.
Part of #884
This one has become slightly controversial owing to Hadley's comments here: #910 (comment)
Meaning some divergence between how the
testthatmaintainers viewexpect_equal()vs.expect_identical()and how we do internally at Google, where we do want to keep encouragingexpect_identical()as the default because we find stricter tests are a better default.I think that means we want to be careful in wording/documentation not to imply that this linter is enacting the advice of
testthat. Hope that makes sense; not sure if I achieved it in the current iteration.