File: test-vectorized.R

package info (click to toggle)
r-cran-covr 3.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 984 kB
  • sloc: javascript: 238; cpp: 54; ansic: 48; xml: 41; sh: 18; makefile: 11
file content (20 lines) | stat: -rw-r--r-- 449 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
context("Vectorize")
writeLines(con = "s1",
'scalar_func <- function(x,y) {
  z <- x + y
}

vector_func <- Vectorize(scalar_func,vectorize.args=c("x","y"),SIMPLIFY=TRUE)')

writeLines(con = "t1",
"vector_func(1:10, 2)")

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, "vector_func")
  expect_equal(cov_d$value, 10)
})