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))
}