Skip to contents

This function checks if x passes at least one of a set of tests. x is allowed to be any type typeof() in types, and needs to pass the corresponding test for its type.

For example, if x is of type "integer", then it is tested with test_integer(). Pass a list of arguments to the test function via ..., with the same argument name as the type. E.g. integer = list(len = 2).

Usage

test_multiple(x, types, ...)

Arguments

x

[any] An object to test.

types

[character()] A character vector of types to check against.

...

[list() each] Lists of arguments to pass to the test function for each type. The list names

Value

  • [TRUE | FALSE] for test_multi().

  • [=x] invisible(x) for assert_multi(), or aborts if the test fails.

Examples

x <- list(a = 1:2, b = 3:4)

args <- list(
  types = c("integer", "list"),
  list = list(
    custom_map = \(elt) is_integer(elt, 1)
  )
  # Either a integer vector of a list of integer scalars
)

do.call(test_multiple, c(list(x), args)) #> FALSE (not all tests passed)
#> [1] FALSE