Can anybody help me and explain why expect_that
doesn't work if []
is added to the stop message, i.e. f1
works but f2
doesn't.
library(testthat)
f1 <- function(x){
if( x >= 1 ){
stop("error 1")
}
}
expect_that(f1(x=1.4), throws_error("error 1"))
f2 <- function(x){
if( x >= 1 ){
stop("error [1]")
}
}
expect_that(f2(x=1.4), throws_error("error [1]"))
expect_that(f2(x=1.4), throws_error("error [1]", fixed = TRUE))
– Ileus