expect_condition: Are conditions signaled correctly?

Description Usage Arguments Value Examples

View source: R/TestingExceptions.R

Description

Are conditions signaled correctly?

Usage

1
expect_condition(object, class = "condition", label = NULL, info = NULL)

Arguments

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

Value

Called only for its side effects during testing.

Examples

 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)

jefferys/Exception documentation built on May 19, 2019, 3:59 a.m.