on_failure {assertthat} | R Documentation |
Custom failure messages for assertions.
Description
Custom failure messages for assertions.
Usage
on_failure(x)
on_failure(x) <- value
Arguments
x |
a assertion function that returns |
value |
a function with parameters |
Examples
is_odd <- function(x) {
assert_that(is.numeric(x), length(x) == 1)
x %% 2 == 1
}
see_if(is_odd(2))
on_failure(is_odd) <- function(call, env) {
paste0(deparse(call$x), " is even")
}
see_if(is_odd(2))
[Package assertthat version 0.2.1 Index]