In R, is it possible to test a function with a combination of parameters without resorting to a for loop? For example, I'm currently doing something similar to this:
test_that("Function myfunction() works properly", {
a1 <- c(1, 2, 3, 10, 20, 100)
a2 <- c(-500, 0, 500)
a3 <- c("hello", "world")
for (a1i in a1) {
for (a2i in a2) {
for (a3i in a3) {
result <- myfunction(a1i, a2i, a3i)
expect_equal(result, something_expected)
expect_equal(dim(result), something_else)
# ...and other checks...
}
}
}
})
However, this is not practical with too many nested fors, and also raises cyclomatic complexity errors with lintr.
In Python we can easily do this with pytest (using test parameters or text fixtures), and this is also easy to achieve in Julia.
I found the patrick package, but it doesn't seem to do parameter combination in this way, only to define parameter sets. I guess one could create these parameter sets for patrick using for loops, but that seems to be missing the point.