Skip to content

expect_condition() #621

Closed
Closed
@lionel-

Description

@lionel-
expect_condition <- function(expr,
                             class = NULL,
                             regex = NULL,
                             ...,
                             info = NULL,
                             label = NULL) {
  object <- tryCatch(expr, condition = identity)

  if (is_na(class)) {
    expect_false(inherits(object, "condition"), info = info, label = label)
    return(invisible(object))
  }

  expect_is(object, "condition", info = info, label = label)

  if (!is_null(class)) {
    expect_is(object, class, info = info, label = label)
  }
  if (!is_null(regex)) {
    expect_match(object$message, regex, ..., info = info, label = label)
  }

  invisible(object)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions