makeExpectation {checkmate} | R Documentation |
Turn a Check into an Expectation
Description
makeExpectation
is the internal function used to evaluate the result of a
check and turn it into an expectation
.
makeExceptionFunction
can be used to automatically create an expectation
function based on a check function (see example).
Usage
makeExpectation(x, res, info, label)
makeExpectationFunction(
check.fun,
c.fun = NULL,
use.namespace = FALSE,
env = parent.frame()
)
Arguments
x |
[any] |
res |
[ |
info |
[ |
label |
[ |
check.fun |
[ |
c.fun |
[ |
use.namespace |
[ |
env |
[ |
Value
makeExpectation
invisibly returns the checked object.
makeExpectationFunction
returns a function
.
See Also
Other CustomConstructors:
makeAssertion()
,
makeTest()
Examples
# Simple custom check function
checkFalse = function(x) if (!identical(x, FALSE)) "Must be FALSE" else TRUE
# Create the respective expect function
expect_false = function(x, info = NULL, label = vname(x)) {
res = checkFalse(x)
makeExpectation(x, res, info = info, label = label)
}
# Alternative: Automatically create such a function
expect_false = makeExpectationFunction(checkFalse)
print(expect_false)