-
Notifications
You must be signed in to change notification settings - Fork 120
Closed
Description
I am having problems with S3 and development covr (89029d4). CRAN covr appears unaffected.
# Example file with S3:
source <- quote({
mtd <- function(x, ...) {
UseMethod("mtd")
}
mtd.cls <- function(x, ...) {
x[[1]]
}
})
# A test:
test <- quote({
library(testthat)
test_that("", {
x <- structure(list("x"), class = "cls")
expect_equal(mtd(x), "x")
})
})
# The test passes.
eval(source)
eval(test)
# The same test fails with https://github.com/r-lib/covr/commit/89029d4670c09a106bbadfb384eec8b7ed42e885.
# Passes with CRAN covr.
writeLines(deparse(source), "source.R")
writeLines(deparse(test), "test.R")
library(covr)
file_coverage("source.R", "test.R")
#> Error: Test failed: ''
#> * 'UseMethod' used in an inappropriate fashion
#> 1: expect_equal(mtd(x), "x") at test.R:5
#> 2: quasi_label(enquo(object), label, arg = "object")
#> 3: eval_bare(get_expr(quo), get_env(quo))
#> 4: mtd(x)
#> 5: identity({
#> covr:::count("source.R:3:9:3:24:9:24:3:3")
#> UseMethod("mtd")
#> }) at source.R:3Created on 2019-08-08 by the reprex package (v0.3.0)
Metadata
Metadata
Assignees
Labels
No labels