Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

uchecks

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 = TRUE, msg = NULL)

Arguments

expr

an R expression

expected

expected value as regular expression pattern. If a logical, then it specifies if a warning is expected or not.

For backward compatibility, a NULL value is equivalent to TRUE.

msg

informative message to add to the error in case of failure

Examples

# 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') )

pkgmaker

Development Utilities for R Packages

v0.32.2
GPL (>= 2)
Authors
Renaud Gaujoux [aut, cre]
Initial release
2020-10-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.