R/missing_args.R

missing_args <- function(args_expected, args_incoming) {
  
  incoming_missing <- setdiff(args_expected, args_incoming)
  
  msg1 <- NULL
  
  if (length(incoming_missing) != 0) {
    msg1 <- paste0("Function wasn't called with the following expected arguments: ",
                   paste0("'", incoming_missing, "'", collapse = ', '))
  }
  
  extra_args <- setdiff(args_incoming, args_expected)
  
  msg2 <- NULL
  
  if (length(extra_args) != 0) {
    msg2 <- paste0("Function was called with the following extra arguments: ",
                   paste0("'", extra_args, "'", collapse = ', '))
  }
  
  paste0(c(msg1, msg2), collapse = '\n')
}

Try the stubthat package in your browser

Any scripts or data that you put into this service are public.

stubthat documentation built on May 1, 2019, 11:16 p.m.