Skip to content

Documentation for expect_error argument 'regexp' says it accepts a character vector but it does not聽#2351

Description

@BrentWHR

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions