-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend conjunct_expectation_linter to include stopifnot(), rename to …
…conjunct_test_linter (#1011) * New stopifnot_conjunct_linter * rename * fix inst/linters entry * merge with conjunct_expectation_linter --> conjunct_test_linter * tidy TODO * fix db entry
- Loading branch information
1 parent
b225fda
commit fada0a9
Showing
12 changed files
with
112 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
man/conjunct_expectation_linter.Rd → man/conjunct_test_linter.Rd
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
test_that("conjunct_test_linter skips allowed usages of expect_true", { | ||
expect_lint("expect_true(x)", NULL, conjunct_test_linter()) | ||
expect_lint("testthat::expect_true(x, y, z)", NULL, conjunct_test_linter()) | ||
|
||
# more complicated expression | ||
expect_lint("expect_true(x || (y && z))", NULL, conjunct_test_linter()) | ||
# the same by operator precedence, though not obvious a priori | ||
expect_lint("expect_true(x || y && z)", NULL, conjunct_test_linter()) | ||
expect_lint("expect_true(x && y || z)", NULL, conjunct_test_linter()) | ||
}) | ||
|
||
test_that("conjunct_test_linter skips allowed usages of expect_true", { | ||
expect_lint("expect_false(x)", NULL, conjunct_test_linter()) | ||
expect_lint("testthat::expect_false(x, y, z)", NULL, conjunct_test_linter()) | ||
|
||
# more complicated expression | ||
# (NB: xx && yy || zz and xx || yy && zz both parse with || first) | ||
expect_lint("expect_false(x && (y || z))", NULL, conjunct_test_linter()) | ||
}) | ||
|
||
test_that("conjunct_test_linter blocks && conditions with expect_true()", { | ||
expect_lint( | ||
"expect_true(x && y)", | ||
rex::rex("Instead of expect_true(A && B), write multiple expectations"), | ||
conjunct_test_linter() | ||
) | ||
|
||
expect_lint( | ||
"expect_true(x && y && z)", | ||
rex::rex("Instead of expect_true(A && B), write multiple expectations"), | ||
conjunct_test_linter() | ||
) | ||
}) | ||
|
||
test_that("conjunct_test_linter blocks || conditions with expect_false()", { | ||
expect_lint( | ||
"expect_false(x || y)", | ||
rex::rex("Instead of expect_false(A || B), write multiple expectations"), | ||
conjunct_test_linter() | ||
) | ||
|
||
expect_lint( | ||
"expect_false(x || y || z)", | ||
rex::rex("Instead of expect_false(A || B), write multiple expectations"), | ||
conjunct_test_linter() | ||
) | ||
|
||
# these lint because `||` is always outer by operator precedence | ||
expect_lint( | ||
"expect_false(x || y && z)", | ||
rex::rex("Instead of expect_false(A || B), write multiple expectations"), | ||
conjunct_test_linter() | ||
) | ||
expect_lint( | ||
"expect_false(x && y || z)", | ||
rex::rex("Instead of expect_false(A || B), write multiple expectations"), | ||
conjunct_test_linter() | ||
) | ||
}) | ||
|
||
test_that("conjunct_test_linter skips allowed usages", { | ||
expect_lint("stopifnot(x)", NULL, conjunct_test_linter()) | ||
expect_lint("stopifnot(x, y, z)", NULL, conjunct_test_linter()) | ||
|
||
# more complicated expression | ||
expect_lint("stopifnot(x || (y && z))", NULL, conjunct_test_linter()) | ||
# the same by operator precedence, though not obvious a priori | ||
expect_lint("stopifnot(x || y && z)", NULL, conjunct_test_linter()) | ||
expect_lint("stopifnot(x && y || z)", NULL, conjunct_test_linter()) | ||
}) | ||
|
||
test_that("conjunct_stopifnot_linter blocks simple disallowed usages", { | ||
expect_lint( | ||
"stopifnot(x && y)", | ||
rex::rex("Instead of stopifnot(A && B), write multiple conditions"), | ||
conjunct_test_linter() | ||
) | ||
|
||
expect_lint( | ||
"stopifnot(x && y && z)", | ||
rex::rex("Instead of stopifnot(A && B), write multiple conditions"), | ||
conjunct_test_linter() | ||
) | ||
}) |