File: test-methods.R

package info (click to toggle)
dbi 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,740 kB
  • sloc: makefile: 2
file content (25 lines) | stat: -rw-r--r-- 574 bytes parent folder | download
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
expect_ellipsis <- function(name, method) {
  sym <- as.name(name)
  eval(bquote({
    .(sym) <- method
    expect_true("..." %in% names(formals(.(sym))))
  }))
}

test_that("all methods have ellipsis", {
  symbols <- ls(env = asNamespace("DBI"))
  objects <- mget(
    symbols,
    env = asNamespace("DBI"),
    mode = "function",
    ifnotfound = rep(list(NULL), length(symbols))
  )
  is_method <- vapply(
    objects,
    inherits,
    "standardGeneric",
    FUN.VALUE = logical(1L)
  )
  methods <- objects[is_method]
  Map(expect_ellipsis, names(methods), methods)
})