class-tests: Enhanced Class Tests

Description Usage Arguments Functions See Also Examples

Description

These tests allow for mapped and enhanced tests regarding class.

Usage

1
2
3
4
5
6
7
all_inherit(lst, class, label = NULL)

are(lst, class)

is_exactly(object, class)

all_are_exactly(lst, class, label = NULL)

Arguments

lst

A list of objects to test

class

The class object is to be, or classes it is allowed to be.

label

object label. When NULL, computed from deparsed object.

object

An object to test

Functions

See Also

Other class: class-expectations

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
lst <- list(1L, 2, TRUE)

# all_inherit uses `inherits`
all_inherit(lst, 'numeric')
all_inherit(lst, 'integer')
all_inherit(lst, 'ANY')

# are uses `is` so gets different results.
are(lst, "numeric")
are(lst, "integer")
are(lst, "ANY")

# is_exactly the class must match exactly
is_exactly(1L, "integer")
# no inheritance allowed
is_exactly(1L, "numeric")

testextra documentation built on Dec. 18, 2019, 9:38 a.m.