env <- new.env()
code <- "f <- function(x) {
if (x) {
'yes'
} else {
'no'
}
}"
eval(parse(text = code, keep.source = TRUE), env)
with_coverage(
{
env$f(TRUE)
first <- current_coverage(reset = TRUE)
env$f(FALSE)
second <- current_coverage()
},
env = env
)
tally_coverage(first)
tally_coverage(second)
Run the code above in your browser using DataLab