Why doesn't this test pass?
my_fun <- function(x){
if(x > 1){stop("my_fun() must be called on values of x less than or equal to 1")}
x
}
library(testthat)
expect_error(my_fun(2),
"my_fun() must be called on values of x less than or equal to 1")
It returns the error message:
Error: error$message does not match "my_fun() must be called on values of x less than or equal to 1". Actual value: "my_fun() must be called on values of x less than or equal to 1"
If you remove the () from both the function and the test, the test does pass, leading me to think it's something about the parentheses.