1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
## ----setup, include = FALSE---------------------------------------------------
library(covr)
## -----------------------------------------------------------------------------
identical(x = { 1 + 2; 3 + 4 },
y = `{`(1 + 2, 3 + 4))
## ---- eval = FALSE------------------------------------------------------------
# `{`(count(), as.call(recurse(x)))
## -----------------------------------------------------------------------------
f1 <- function() 1
f1 <- function() 2
f1() == 2
## -----------------------------------------------------------------------------
env <- new.env()
f1 <- function() 1
env$f2 <- function() f1() + 1
env$f1 <- function() 2
env$f2() == 3
## -----------------------------------------------------------------------------
# an object to analyze
f1 <- function(x) { x + 1 }
# get results with no unit tests
c1 <- function_coverage(fun = f1, code = NULL)
c1
# get results with unit tests
c2 <- function_coverage(fun = f1, code = f1(x = 1) == 2)
c2
|