View source: R/makeExpectation.R
makeExpectation | R Documentation |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.