Description Usage Arguments Functions See Also Examples
These tests allow for mapped and enhanced tests regarding class.
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)
|
lst |
A list of objects to test |
class |
The class object is to be, or classes it is allowed to be. |
label |
Used to customise failure messages. For expert use only. |
object |
An object to test |
all_inherit
: Check if all elements of a list are or inherit from the given class.
Uses base::inherits()
to check inheritance.
are
: methods::is mapped over a vector.
Similar to all_inherit
but uses methods::is()
for test.
This manifests in S4 Virtual classes such as the 'ANY' class
is_exactly
: Test that an object is exactly a class; excludes inheritance.
all_are_exactly
: Version of is_exactly
for all elements of a list.
Other class:
class-expectations
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.