Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Nov 1, 2024
1 parent 6a5fb06 commit 219930f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test-method-dispatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ test_that("can substitute() args", {
method(foo, class_character) <- function(x, ..., z = 1) substitute(z)
)
expect_equal(foo("x", z = letters), quote(letters))

suppressMessages(
method(foo, class_character) <- function(x, ..., z = 1) substitute(list(...))
)
expect_equal(foo("x", abc = xyz), quote(list(abc = xyz)))

suppressMessages(
method(foo, class_character) <- function(x, ..., z = 1, y) missing(y)
)
expect_true(foo("x"), TRUE)
expect_true(foo("x", y =), TRUE)
expect_true(foo("x", y =), TRUE)

suppressMessages(
method(foo, class_character) <- function(x, ..., z = 1, y) ...length()
)

expect_equal(foo("x"), 0)
expect_equal(foo("x", y =), 0)
expect_equal(foo("x", y =, abc), 1)
expect_equal(foo("x", y =, abc = xyz), 1)
expect_equal(foo("x", y =, abc, xyz), 2)
})

test_that("methods get values modified in the generic", {
Expand Down

0 comments on commit 219930f

Please sign in to comment.