Learn R Programming

testthat (version 0.11.0)

expect_is: Expectation: does the object inherit from a class?

Description

Tests whether or not an object inherits from any of a list of classes.

Usage

expect_is(object, class, info = NULL, label = NULL)

Arguments

object
object to test
class
character vector of class names
info
extra information to be included in the message (useful when writing tests in loops).
label
object label. When NULL, computed from deparsed object.

See Also

inherits

Other expectations: equivalence, expect_equal, expect_equivalent, expect_identical; expect-compare, expect_gt, expect_gte, expect_less_than, expect_lt, expect_lte, expect_more_than; expect_equal_to_reference; expect_error, expect_match, expect_message, expect_output, expect_warning, matching-expectations; expect_false, expect_true; expect_named; expect_null; expect_silent; takes_less_than

Examples

Run this code
expect_is(1, "numeric")
a <- matrix(1:10, nrow = 5)
expect_is(a, "matrix")

expect_is(mtcars, "data.frame")
# alternatively for classes that have an is method
expect_true(is.data.frame(mtcars))

Run the code above in your browser using DataLab