diff --git a/tests/testthat/test-fixed_regex_linter.R b/tests/testthat/test-fixed_regex_linter.R index 98a279a02..83a00c141 100644 --- a/tests/testthat/test-fixed_regex_linter.R +++ b/tests/testthat/test-fixed_regex_linter.R @@ -42,7 +42,7 @@ test_that("fixed_regex_linter blocks simple disallowed usages", { }) patrick::with_parameters_test_that( - "fixed_regex_linter is robust to unrecognized escapes error", + "fixed_regex_linter is robust to unrecognized escapes error for {char}", { expect_lint( sprintf(R"{grep('\\%s', x)}", char), @@ -56,14 +56,11 @@ patrick::with_parameters_test_that( fixed_regex_linter() ) }, - .cases = local({ - char <- c( - "^", "$", "{", "}", "(", ")", ".", "*", "+", "?", - "|", "[", "]", R"(\\)", "<", ">", "=", ":", ";", "/", - "_", "-", "!", "@", "#", "%", "&", "~" - ) - data.frame(char = char, .test_name = char) - }) + char = c( + "^", "$", "{", "}", "(", ")", ".", "*", "+", "?", + "|", "[", "]", R"(\\)", "<", ">", "=", ":", ";", "/", + "_", "-", "!", "@", "#", "%", "&", "~" + ) ) test_that("fixed_regex_linter catches regex like [.] or [$]", { @@ -326,7 +323,7 @@ local({ skip_cases <- character() } patrick::with_parameters_test_that( - "fixed replacements are correct", + "fixed replacements of {regex_expr} with {fixed_expr} is correct", { # TODO(google/patrick#19): handle this more cleanly by skipping up-front skip_if( diff --git a/tests/testthat/test-pipe_continuation_linter.R b/tests/testthat/test-pipe_continuation_linter.R index 528f0c011..0d3350bca 100644 --- a/tests/testthat/test-pipe_continuation_linter.R +++ b/tests/testthat/test-pipe_continuation_linter.R @@ -138,46 +138,42 @@ test_that("pipe-continuation linter handles native pipe", { local({ linter <- pipe_continuation_linter() - valid_code <- c( - # all on one line + .cases <- tibble::tribble( + ~code_string, ~.test_name, trim_some(" my_fun <- function() { a %>% b() } - "), + "), "two on one line", trim_some(" my_fun <- function() { a %>% b() %>% c() } - "), + "), "three on one line", trim_some(" with( diamonds, x %>% head(10) %>% tail(5) ) - "), + "), "three inside with()", trim_some(" test_that('blah', { test_data <- diamonds %>% head(10) %>% tail(5) }) - "), - - # two different single-line pipelines + "), "three inside test_that()", trim_some(" { x <- a %>% b %>% c y <- c %>% b %>% a } - "), - - # at most one pipe-character per line + "), "two different single-line pipelines", trim_some(" my_fun <- function() { a %>% b() %>% c() } - ") + "), "at most one pipe-character per line" ) patrick::with_parameters_test_that( "valid nesting is handled", @@ -185,8 +181,7 @@ local({ { expect_lint(code_string, NULL, linter) }, - .test_name = valid_code, - code_string = valid_code + .cases = .cases ) })