See https://adv-r.hadley.nz/oo.html for an overview of R's OO systems, and the vocabulary used here.
expect_type(object, type) expect_s3_class(object, class, exact = FALSE) expect_s4_class(object, class)
Object to test.
Supports limited unquoting to make it easier to generate readable failures within a function or for loop. See quasi_label for more details.
String giving base type (as returned by
character vector of class names
x <- data.frame(x = 1:10, y = "x") # A data frame is an S3 object with class data.frame expect_s3_class(x, "data.frame") show_failure(expect_s4_class(x, "data.frame"))#> Failed expectation: #> `x` is not an S4 object# A data frame is built from a list: expect_type(x, "list") # An integer vector is an atomic vector of type "integer" expect_type(x$x, "integer") # It is not an S3 object show_failure(expect_s3_class(x$x, "integer"))#> Failed expectation: #> x$x is not an S3 object# By default data.frame() converts characters to factors: show_failure(expect_type(x$y, "character"))#> Failed expectation: #> x$y has type `integer`, not `character`.expect_s3_class(x$y, "factor") expect_type(x$y, "integer")