-
Notifications
You must be signed in to change notification settings - Fork 187
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
New expect_identical_linter #958
Conversation
R/expect_identical_linter.R
Outdated
"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)." |
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.
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"?
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.
put some of the details in the man page, should be more digestible now
Part of #884
This one has become slightly controversial owing to Hadley's comments here: #910 (comment)
Meaning some divergence between how the
testthat
maintainers 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.