-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proper successor for expect_is(M, "matrix")? #1448
Comments
Yeah, I don't think of a |
The |
Hmmmm, good point. But is there much benefit of Maybe we could consider a generalisation of #1423 and have something like: expect_vector(x, n = 10)
expect_matrix(m, ncol = 3, nrow = 10, type = "character")
expect_array(m, dims = c(1, 5, 10))
expect_dataframe(df, ncol = 3, nrow = 50, names = c("a", "b", "c"), ptypes = list(a = character()))`
|
Related: #1423 :) |
The same applies to things like
I think what’s missing is See the docs for
I’m not even sure if |
@flying-sheep IMO most of that is out of scope for testthat because I'd say it's mostly there for historical reasons. I don't think many people rely on |
expect_is()
is deprecated; the deprecation message mentions successors:However, all of those fail where
expect_is()
succeeded:The core issue here is that
is.object(matrix(1:10))
isFALSE
even thoughclass(matrix(1:10))
returns"matrix"
orc("matrix", "array")
because matrices in R somewhat strangely don't have aclass
set. That meanstestthat:::isS3(matrix(1:10))
returns FALSE.It seems the only thing to do is:
Is this known / intentional behavior? I don't see anything mentioned in the documentation.
The text was updated successfully, but these errors were encountered: