Skip to content

Commit

Permalink
another test
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Aug 6, 2023
1 parent 0538682 commit fe90657
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions tests/testthat/test-unnecessary_placeholder_linter.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
linter <- unnecessary_placeholder_linter()
pipes <- pipes(exclude = "|>")

patrick::with_parameters_test_that(
"unnecessary_placeholder_linter skips allowed usages",
{
linter <- unnecessary_placeholder_linter()

# . used in position other than first --> ok
expect_lint(sprintf("x %s foo(y, .)", pipe), NULL, linter)
# ditto for nested usage
Expand All @@ -14,29 +15,25 @@ patrick::with_parameters_test_that(
# . used inside a scope --> ok
expect_lint(sprintf("x %s { foo(arg = .) }", pipe), NULL, linter)
},
.test_name = c("forward", "assignment", "tee", "greedy", "extraction"),
pipe = c("%>%", "%<>%", "%T>%", "%!>%", "%$%")
.test_name = names(pipes),
pipe = pipes
)

local({
linter <- unnecessary_placeholder_linter()
pipes <- pipes(exclude = "|>")
patrick::with_parameters_test_that(
"unnecessary_placeholder_linter blocks simple disallowed usages",
{
expect_lint(
sprintf("x %s sum(.)", pipe),
rex::rex("Don't use the placeholder (`.`) when it's not needed"),
unnecessary_placeholder_linter()
)
patrick::with_parameters_test_that(
"unnecessary_placeholder_linter blocks simple disallowed usages",
{
expect_lint(
sprintf("x %s sum(.)", pipe),
rex::rex("Don't use the placeholder (`.`) when it's not needed"),
unnecessary_placeholder_linter()
)

expect_lint(
sprintf("x %s y(.) %s sum()", pipe, pipe),
rex::rex("Don't use the placeholder (`.`) when it's not needed"),
unnecessary_placeholder_linter()
)
},
.test_name = names(pipes),
pipe = pipes
)
})
expect_lint(
sprintf("x %s y(.) %s sum()", pipe, pipe),
rex::rex("Don't use the placeholder (`.`) when it's not needed"),
unnecessary_placeholder_linter()
)
},
.test_name = names(pipes),
pipe = pipes
)

0 comments on commit fe90657

Please sign in to comment.