Skip to content

Commit 1036d61

Browse files
committed
More polishing
1 parent df98f3a commit 1036d61

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

tests/testthat/test-method-ops.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,19 @@ test_that("Ops generics dispatch to S3 methods", {
4343
})
4444

4545
test_that("operator methods on S3/S4 classes work when neither operand is S7", {
46-
local_methods(base_ops[["+"]], base_ops[["*"]])
46+
local_methods(base_ops[["+"]])
4747

4848
class_foo <- new_S3_class("foo")
4949
foo <- structure(list(), class = "foo")
5050
method(`+`, list(class_foo, class_any)) <- function(e1, e2) "foo+any"
51-
52-
# Primitive `+` dispatches into S7 even though `foo` is not an S7 object
5351
expect_equal(foo + 10, "foo+any")
54-
# An unregistered operator falls back to the base behaviour
55-
expect_error(foo * 10, regexp = "non-numeric argument")
5652

5753
fooS4 <- local_S4_class("fooS4")
5854
method(`+`, list(fooS4, class_any)) <- function(e1, e2) "fooS4+any"
5955
expect_equal(fooS4("x") + 10, "fooS4+any")
56+
57+
# An unregistered operator still falls back to the base behaviour
58+
expect_error(foo * 10, regexp = "non-numeric argument")
6059
})
6160

6261
test_that("operator bridge does not clobber an existing group method", {

0 commit comments

Comments
 (0)