Description
Preamble
Consider the following code and its corresponding test:
empty <- function(df) {
(is.null(df) || nrow(df) == 0 || ncol(df) == 0)
}
test_that("empty works", {
expect_true(empty(NULL))
})
If you use {covr}
to compute code coverage for a package that contains this function, it will be 100%
.
But, note that the test covers only one of the conditions from the control statement (is.null(df)
); the other two are untested and may contain bugs.
FR
Is it possible for {covr}
to also take into account all conditions—either on the same line or on different lines—while computing code coverage?
With such an update, in the example above, the code coverage should be 0%
because the tests don't fully cover all the conditions on that line. I am not sure what should happen if the conditional statement spans multiple lines, but I can see how 0%
could be reasonable in that case as well.
Related to, but still distinct from #279