Check that typeof(current) is type

expect_type(current, type, ..., info = NA_character_)

Arguments

current

[R object or expression] Object or expression to be tested

type

[character(1L)] Expected base type (as given by typeof())

...

Ignored

info

[character(1L)] Optional user-defined message; must be a single string value

Value

A tinytest object. A tinytest object is a logical with attributes holding information about the test that was run

See also

testthat equivalent: testthat::expect_type()

Other typing expectation predicates: expect_s3_class(), expect_s4_class()

Examples

expect_type(1L, "integer") # Pass
#> ----- PASSED      : <-->
#>  call| expect_type(1, "integer") 
expect_type(1.0, "integer") # Fail
#> ----- FAILED[attr]: <-->
#>  call| expect_type(1, "integer")
#>  diff| Expected object of type 'integer', got 'double'