f <- function(x) x^2
test(f) <- function() {
context("f")
test_that("correct result for complex number", {
expect_equal(f(1i), -1 + 0i)
})
}
get_test(f)
library(testthat)
## execute the test
get_test(f)()
with_reporter("summary", get_test(f)())
Run the code above in your browser using DataLab