diff --git a/tests/testthat/_snaps/replace.md b/tests/testthat/_snaps/replace.md index a6bf200e..822914c9 100644 --- a/tests/testthat/_snaps/replace.md +++ b/tests/testthat/_snaps/replace.md @@ -32,13 +32,13 @@ # useful error if not vectorised correctly Code - str_replace_all(x, "a|c", ~ if (nchar(.x)) "x" else "y") + str_replace_all(x, "a|c", ~ if (length(x) > 1) stop("Bad")) Condition Error in `str_replace_all()`: ! Failed to apply `replacement` function. i It must accept a character vector of any length. - Caused by error in `if (nchar(.x)) ...`: - ! the condition has length > 1 + Caused by error in `replacement()`: + ! Bad # replacement function must return correct type/length diff --git a/tests/testthat/test-replace.R b/tests/testthat/test-replace.R index f0f5f7ac..a3d2c678 100644 --- a/tests/testthat/test-replace.R +++ b/tests/testthat/test-replace.R @@ -87,7 +87,7 @@ test_that("is forgiving of 0 matches with paste", { test_that("useful error if not vectorised correctly", { x <- c("a", "b", "c") expect_snapshot( - str_replace_all(x, "a|c", ~ if (nchar(.x)) "x" else "y"), + str_replace_all(x, "a|c", ~ if (length(x) > 1) stop("Bad")), error = TRUE ) })