Assert a condition
assert.RdA simpler and more efficient replacement for base::stopifnot().
As opposed to stopifnot(), assert() only works with a single (scalar) assertions.
Usage
assert(cond, ..., call = sys.call(-1))Arguments
- cond
TRUEorFALSE(without any attributes).TRUEwill returnTRUEFALSEwill throw an exception with an automatically constructed error if none was supplied in....any other value will throw an error indicating that
condwas illegal
- ...
Either
characterscalars that will be combined withbase::paste0()or a singleconditionobject.
Examples
if (FALSE) {
assert(1 == 1)
assert(1 == 2)
assert(1 == 2, "one is not ", "two")
assert(1 == 2, errorCondition("one is not two", class = "ObviousError"))
}