Learn R Programming

pkgmaker (version 0.10.1)

checkWarning: Extra Check Functions for RUnit

Description

checkWarning checks if a warning is generated by an expression, and optionally follows an expected regular expression pattern.

Usage

checkWarning(expr, expected = NULL, msg = NULL)

Arguments

expr
an R expression
expected
expected value or regular expression pattern
msg
informative message to add to the error in case of failure

Examples

Run this code
# check warnings
checkWarning({ warning('ah ah'); 3})
checkWarning({ warning('ah oh ah'); 3}, 'oh')
try( checkWarning(3) )
try( checkWarning({ warning('ah ah'); 3}, 'warn you') )

Run the code above in your browser using DataLab