Skip to content

Instantly share code, notes, and snippets.

@jakubsob
Created November 28, 2024 16:09
Show Gist options
  • Save jakubsob/f96f4cef31d83c692c067b7deef9d62f to your computer and use it in GitHub Desktop.
Save jakubsob/f96f4cef31d83c692c067b7deef9d62f to your computer and use it in GitHub Desktop.
Report all {checkmate} assertions in the style of {withr}
#' Report all assertions
#'
#' @examples
#' with_assertion_collection(
#' assert_data_frame(df),
#' assert_numeric(nums),
#' assert_character(chars)
#' )
with_assert_collection <- function(...) {
add <- makeAssertCollection()
quos <- enquos(...)
quos <- map(quos, call_modify, add = add)
walk(quos, eval_tidy)
reportAssertions(add)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment