Expectation predicate for testing that a given function does not raise a condition

expect_no_condition(
  current,
  pattern = NULL,
  class = NULL,
  ...,
  info = NA_character_
)

Arguments

current

[R object or expression] Object or expression to be tested

pattern

[character(1L)] A regular expression to match the condition message; any conditions thrown with a message matching pattern will trigger a failure while all other conditions thrown will trigger a success. Must be a single character string

class

[character] Optional vector of condition classes that should not be thrown; conditions thrown that inherit from class will trigger a failure while all other conditions thrown will trigger a success. If NULL, any condition thrown will trigger a failure

...

Ignored

info

[character(1L)] Optional user-defined message; must be a single string value

Value

A tinytest object. A tinytest object is a logical with attributes holding information about the test that was run

See also

testthat equivalent: testthat::expect_no_condition()

Other condition expectation predicates: expect_condition()

Examples

expect_no_condition("tomato") # Pass
#> ----- PASSED      : <-->
#>  call| expect_no_condition("tomato") 

expect_no_condition(message("test")) # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_no_condition(message("test"))
#>  diff| Expected no conditions to be thrown 

expect_no_condition(message("test"), pattern = "test") # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_no_condition(message("test"), pattern = "test")
#>  diff| Expected no conditions matching the pattern ‘test’ to be thrown 
expect_no_condition(message("test"), pattern = "tomato") # Pass
#> ----- PASSED      : <-->
#>  call| expect_no_condition(message("test"), pattern = "tomato") 

expect_no_condition(message("test"), class = "message") # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_no_condition(message("test"), class = "message")
#>  diff| Expected no conditions inheriting from ‘message’ to be thrown 
expect_no_condition(message("test"), class = "error") # Pass
#> ----- PASSED      : <-->
#>  call| expect_no_condition(message("test"), class = "error") 

expect_no_condition(message("test"), pattern = "test", class = "message") # Fail
#> ----- FAILED[xcpt]: <-->
#>  call| expect_no_condition(message("test"), pattern = "test", class = "message")
#>  diff| Expected no conditions inheriting from ‘message’ matching the pattern ‘test’ to be thrown 
expect_no_condition(message("test"), pattern = "tomato", class = "message") # Pass
#> ----- PASSED      : <-->
#>  call| expect_no_condition(message("test"), pattern = "tomato", class = "message") 
expect_no_condition(message("test"), pattern = "test", class = "error") # Pass
#> ----- PASSED      : <-->
#>  call| expect_no_condition(message("test"), pattern = "test", class = "error") 
expect_no_condition(message("test"), pattern = "tomato", class = "error") # Pass
#> ----- PASSED      : <-->
#>  call| expect_no_condition(message("test"), pattern = "tomato", class = "error")