Description Usage Arguments Value Examples
View source: R/TestingExceptions.R
Are conditions signaled correctly?
1 | expect_condition(object, class = "condition", label = NULL, info = NULL)
|
object |
Code that is expected to signal a condition. |
class |
Class of the condition signaled, as a character vector. At least one of these class names must be amongst the condition's classes. By default this checks for "condition" which is the ubiquitous base class all signals must inherit. |
label |
The object label. NULL is treated as the string "Condition". |
info |
Extra information to be included in the message |
Called only for its side effects during testing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
### Pass
expect_condition( stop( "Oops" )) # Checks if condition by default
expect_condition( stop( "Oops" ), "error" )
expect_condition( stop( "Oops" ), "simple-error" )
expect_condition( warning( "Oops" ), "warning" )
expect_condition( warning( "Oops" ), c("Foo", error, "Bar", "simple-error"))
### Fail
# Nothing signaled
expect_condition( "Oops" )
# error, simple-error, or condition, not warning
expect_condition( stop("Oops"), "warning" )
# error, simple-error, or condition, neither Foo nor Bar
expect_condition( stop( "Oops" ), c( "Foo", "Bar" ))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.