Skip to content

Commit

Permalink
fix typo, malformed test
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Nov 4, 2024
1 parent 38e5850 commit 270cd0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 13 additions & 1 deletion tests/testthat/_snaps/method-dispatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,17 @@
Code
traceback()
Output
No traceback available
No traceback available

---

Code
my_generic(3, 4)
Condition
Error in `my_generic@methods$double$double`:
! hi
Code
traceback()
Output
No traceback available

6 changes: 5 additions & 1 deletion tests/testthat/test-method-dispatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ test_that("method dispatch works for class_missing", {
variant = if (getRversion() < "4.3") "R-lt-4-3",
foo_wrapper()
)
})

test_that("errors from dispatched methods have reasonable tracebacks", {
my_generic <- new_generic("my_generic", "x")
Expand All @@ -237,5 +238,8 @@ test_that("errors from dispatched methods have reasonable tracebacks", {
my_generic <- new_generic("my_generic", c("x", "y"))
method(my_generic, list(class_numeric, class_numeric)) <- function(x, y) stop("hi")

my_generic(3, 4)
expect_snapshot(error = TRUE, {
my_generic(3, 4)
traceback()
})
})

0 comments on commit 270cd0d

Please sign in to comment.