File: how_it_works.R

package info (click to toggle)
r-cran-covr 3.6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,132 kB
  • sloc: javascript: 238; cpp: 74; ansic: 48; xml: 41; sh: 18; makefile: 11
file content (35 lines) | stat: -rw-r--r-- 980 bytes parent folder | download | duplicates (2)
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