The documentation reads:
regexp
Regular expression to test against.
- A character vector giving a regular expression that must match the error message.
Yetexpect_error(object = x, regexp = c('foo', 'bar')) does not work.
Repex:
f <- function(x){
foo <- 'foo is not '
stop(foo, x)
}
testthat::test_that('expect_error() can use a character vector for regexp',{
expect_error(
object = f('bar'),
regexp = c('foo', 'bar')
)
})
# test fails because of an error in expect_error():
# Error in `expect_error(object = f("bar"), regexp = c("foo", "bar"))`: `regexp` must be a single string, `NA`, or `NULL`, not a character vector.
Is it intended for expect_error() to work with a regexp vector of patterns or should one always use a single pattern?
The documentation reads:
Yet
expect_error(object = x, regexp = c('foo', 'bar'))does not work.Repex:
Is it intended for expect_error() to work with a regexp vector of patterns or should one always use a single pattern?