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).
makeExpectation(x, res, info, label) makeExpectationFunction( check.fun, c.fun = NULL, use.namespace = FALSE, env = parent.frame() )
| x | [any] |
|---|---|
| res | [ |
| info | [ |
| label | [ |
| check.fun | [ |
| c.fun | [ |
| use.namespace | [ |
| env | [ |
makeExpectation invisibly returns the checked object.
makeExpectationFunction returns a function.
Other CustomConstructors:
makeAssertion(),
makeTest()
# 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)#> function (x, info = NULL, label = vname(x)) #> { #> if (missing(x)) #> stop(sprintf("Argument '%s' is missing", label)) #> res = checkFalse(x) #> makeExpectation(x, res, info, label) #> } #> <environment: 0x7fb843782790>