Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'UseMethod' used in an inappropriate fashion #392

Closed
wlandau opened this issue Aug 8, 2019 · 1 comment
Closed

'UseMethod' used in an inappropriate fashion #392

wlandau opened this issue Aug 8, 2019 · 1 comment

Comments

@wlandau
Copy link

wlandau commented Aug 8, 2019

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:3

Created on 2019-08-08 by the reprex package (v0.3.0)

@wlandau
Copy link
Author

wlandau commented Aug 9, 2019

Thanks @jimhester!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant