makeAssertionFunction: Turn a Check into an Assertion

View source: R/makeAssertionFunction.R

makeAssertionFunctionR Documentation

Turn a Check into an Assertion

Description

makeAssertionFunction can be used to automatically create an assertion function based on a check function (see example). This is a modification of checkmate::makeAssertionFunction that includes the argument comment in the assertion function.

Usage

makeAssertionFunction(
  check.fun,
  c.fun = NULL,
  coerce = FALSE,
  env = parent.frame()
)

Arguments

check.fun

[function] Function which checks the input. Must return TRUE on success and a string with the error message otherwise.

c.fun

[character(1)] If not NULL, instead of calling the function check.fun, use .Call to call a C function “c.fun” with the identical set of parameters. The C function must be registered as a native symbol, see CallExternal. Useful if check.fun is just a simple wrapper.

coerce

[logical(1)]
If TRUE, injects some lines of code to convert numeric values to integer after an successful assertion. Currently used in assertCount, assertInt and assertIntegerish.

env

[environment] The environment of the created function. Default is the parent.frame, see sys.parent.

Details

The code is imported from checkmate. The modifications in the code is marked. The argument use.namespace is deleted as checkmate::makeAssertion and checkmate::vname always should be used.


PetterHopp/NVIcheckmate documentation built on Dec. 15, 2024, 12:49 a.m.