misc/old_check_private.R

# start_check <- function() {
#   c()
# }
# 
# check <- function(x, condition, ...) {
#   message <- paste0(...)
#   if (isFALSE(condition)) {
#     x <- c(x, paste0(length(x) + 1, ": ", message, "\n"))
#   }
#   x
# }
# 
# check_not <- function(x, condition, ...) {
#   check(x, !condition, ...)
# }
# 
# check_in <- function(x, arg, ...) {
#   match <- c(...)
#   msg <- paste0("'", match, "'")
#   if (length(match) == 2) msg <- paste0(msg, collapse = " or ")
#   if (length(match) > 2) msg <- paste0("one of ", paste0(msg, collapse = ", "))
#   check(x, arg %in% match, as.character(match.call()[3]), " is not ", msg, ".")
# }
# 
# check_within <- function(x, arg, lower, upper) {
#   if (!missing(lower))
#     x <- check_not(
#       x, any(unlist(arg) < lower), as.character(match.call()[3]), " < ", lower
#     ) 
#   if (!missing(upper))
#     x <- check_not(
#       x, any(unlist(arg) > upper), as.character(match.call()[3]), " > ", upper
#     ) 
#   x
# }
# 
# check_class <- function(x, param, class, ...) {
#   check(
#     x, 
#     inherits(param, class), 
#     as.character(match.call()[3]), " not of class ", class
#   )
# }
# 
# end_check <- function(x) {
#   if (length(x) > 0) {
#     stop("\n", x, call. = FALSE)
#   }
# }
jazznbass/scan documentation built on Sept. 14, 2024, 8:53 a.m.