Skip to content

Commit e35122a

Browse files
S3 dispatch check
1 parent a88340d commit e35122a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/testthat/test-expect-shape.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ test_that("length compared correctly", {
33
expect_snapshot_failure(expect_shape(1, length = 2))
44
expect_success(expect_shape(1:10, length = 10))
55
expect_success(expect_shape(letters[1:5], length = 5))
6+
expect_success(expect_shape(integer(), length = 0))
67
})
78

89
test_that("dim compared correctly", {
@@ -38,6 +39,13 @@ test_that("ncol compared correctly", {
3839
expect_success(expect_shape(array(dim = dd), ncol = 0L))
3940
})
4041

42+
test_that("uses S3 dim method", {
43+
dim.testthat_expect_shape <- function(x) 1:2
44+
x <- integer()
45+
class(x) <- "testthat_expect_shape"
46+
expect_success(expect_shape(x, dim = 1:2))
47+
})
48+
4149
test_that("uses S4 dim method", {
4250
A <- setClass("ExpectShapeA", slots = c(x = "numeric", y = "numeric"))
4351
setMethod("dim", "ExpectShapeA", function(x) 8:10)

0 commit comments

Comments
 (0)