tests/testthat/test-memoised.R

context("memoised")
s1 <- tempfile()
t1 <- tempfile()
writeLines(con = s1,
"a <- memoise::memoise(function(x) {
  x + 1
})")

writeLines(con = t1,
"
a(1)
a(1)
a(1)
a(1)
a(2)
a(3)")

on.exit(unlink(c(s1, t1)))

test_that("it works on Vectorized functions", {
  cov <- file_coverage(s1, t1)
  cov_d <- as.data.frame(cov)

  expect_equal(cov_d$functions, "a")
  expect_equal(cov_d$value, 3)
})

Try the covr package in your browser

Any scripts or data that you put into this service are public.

covr documentation built on Nov. 9, 2023, 9:07 a.m.