The function assert() doesn't seem to be doing what is described in the documentation: The resulting assertion is successful, if combine is “or” (default) and at least one check evaluates to TRUE or combine is “and” and all checks evaluate to TRUE. Otherwise, assert throws an informative error message. I always get error messages, no matter what I do.
Did I understand something wrong or overlook something, or are theses errors in the function (or in the documentation)?
idCol <- "ID"
assert(
assert_character(idCol),
assert_numeric(idCol)
)
# I expect it to pass, but I get this error message:
> Error in eval(dots[[i]], envir = env) :
> Assertion on 'idCol' failed: Must be of type 'numeric', not 'character'.
idCol <- "ID"
assert(
assert_character(idCol),
assert_subset(idCol, choices = c("ID", "id", "1"))
)
# I expect it to pass, but I get this error message:
> Error: Assertion failed. One of the following must apply:
> * assert_character(idCol): ID
> * assert_subset(idCol): ID
assert(
assert_character(idCol),
assert_subset(idCol, choices = c("ID", "id", "1")),
combine = "and"
)
# I expect it to pass, but I get this error message:
> Error: Assertion on 'idCol' failed: ID.
The function
assert()doesn't seem to be doing what is described in the documentation:The resulting assertion is successful, if combine is “or” (default) and at least one check evaluates to TRUE or combine is “and” and all checks evaluate to TRUE. Otherwise, assert throws an informative error message.I always get error messages, no matter what I do.Did I understand something wrong or overlook something, or are theses errors in the function (or in the documentation)?