Examples for 'checkmate::makeExpectation'


Turn a Check into an Expectation

Aliases: makeExpectation makeExpectationFunction

Keywords:

### ** 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)
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: 0x55ccff7f1ff8>

[Package checkmate version 2.3.2 Index]