robertness
8/12/2017 - 5:23 PM

crap_error_tests

test.error = function(object){
  error_result = tryCatch({
    object
    FALSE
  }, error = function(e){
    TRUE
  })
  stopifnot(error_result)
}
expect.error <- function(object, regexp = NULL) {
  if(is.null(regexp)) return(FALSE)
  error <- tryCatch({
    object
    NULL
  }, error = function(e) {
    e
  })
  stopifnot(identical(error$message, regexp)) 
}