Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions R/expect-inheritance.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
#' See [expect_vector()] for testing properties of objects created by vctrs.
#'
#' @param type String giving base type (as returned by [typeof()]).
#' @param class
#' * `expect_type()`: a single string giving an R base type.
#' * `expect_s3_class()`: a character vector of class names or `NA` to assert
#' that `object` isn't an S3 object. If you provide multiple class names,
#' the test will pass if `object` inherits from any of them, unless
#' `exact = TRUE`.
#' * `expect_s4_class()`: a character vector of class names or `NA` to assert
#' that `object` isn't an S4 object.
#' * `expect_r6_class()`: a string.
#' * `expect_s7_class()`: an [S7::S7_class()] object.
#' @param class The required type varies depending on the function:
#' * `expect_type()`: a string.
#' * `expect_s3_class()`: a string or character vector. The behaviour of
#' multiple values (i.e. a character vector) is controlled by the
#' `exact` argument.
#' * `expect_s4_class()`: a string.
#' * `expect_r6_class()`: a string.
#' * `expect_s7_class()`: an [S7::S7_class()] object.
#'
#' For historical reasons, `expect_s3_class()` and `expect_s4_class()` also
#' take `NA` to assert that the `object` is not an S3 or S4 object.
#' @inheritParams expect_that
#' @family expectations
#' @examples
Expand Down Expand Up @@ -85,7 +86,7 @@ expect_type <- function(object, type) {
#' @rdname inheritance-expectations
#' @param exact If `FALSE`, the default, checks that `object` inherits
#' from any element of `class`. If `TRUE`, checks that object has a class
#' that's identical to `class`.
#' that exactly matches `class`.
expect_s3_class <- function(object, class, exact = FALSE) {
check_bool(exact)

Expand Down
22 changes: 12 additions & 10 deletions man/inheritance-expectations.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading