Skip to content
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

Opaque implicit dependency of tests on {tibble} #1761

Open
MichaelChirico opened this issue Nov 25, 2024 · 0 comments
Open

Opaque implicit dependency of tests on {tibble} #1761

MichaelChirico opened this issue Nov 25, 2024 · 0 comments

Comments

@MichaelChirico
Copy link
Contributor

test_that("formulas are deparsed (#1169)", {
# Evaluated formulas are treated as objects
expect_equal(
expr_deparse(~foo),
"<formula>"
)
# Unevaluated formulas with a symbol have no space
expect_equal(
expr_deparse(quote(~foo)),
"~foo"
)
# Unevaluated formulas with expressions have a space
expect_equal(
expr_deparse(quote(~+foo)),
"~ +foo"
)
expect_equal(
expr_deparse(quote(~foo())),
"~ foo()"
)
})
test_that("matrices and arrays are formatted (#383)", {
mat <- matrix(1:3)
expect_equal(as_label(mat), "<int[,1]>")
expect_equal(expr_deparse(mat), "<int[,1]: 1L, 2L, 3L>")
mat2 <- matrix(1:4, 2)
expect_equal(as_label(mat2), "<int[,2]>")
expect_equal(expr_deparse(mat2), "<int[,2]: 1L, 2L, 3L, 4L>")
arr <- array(1:3, c(1, 1, 3))
expect_equal(as_label(arr), "<int[,1,3]>")
expect_equal(expr_deparse(arr), "<int[,1,3]: 1L, 2L, 3L>")
})

Recently {waldo} dropped {tibble} as a required package, which caused these tests to break for us:

══ Failed tests ════════════════════════════════════════════════════════════════
── Failure (test-deparse.R:571:3): formulas are deparsed (#1169) ───────────────
expr_deparse(~foo) (`actual`) not equal to "<formula>" (`expected`).

`actual`:   "<S3: formula>"
`expected`: "<formula>"    
── Failure (test-deparse.R:595:3): matrices and arrays are formatted (#383) ────
as_label(mat) (`actual`) not equal to "<int[,1]>" (`expected`).

`actual`:   "<int>"    
`expected`: "<int[,1]>"
── Failure (test-deparse.R:596:3): matrices and arrays are formatted (#383) ────
expr_deparse(mat) (`actual`) not equal to "<int[,1]: 1L, 2L, 3L>" (`expected`).

`actual`:   "<int: 1L, 2L, 3L>"    
`expected`: "<int[,1]: 1L, 2L, 3L>"
── Failure (test-deparse.R:599:3): matrices and arrays are formatted (#383) ────
as_label(mat2) (`actual`) not equal to "<int[,2]>" (`expected`).

`actual`:   "<int>"    
`expected`: "<int[,2]>"
── Failure (test-deparse.R:600:3): matrices and arrays are formatted (#383) ────
expr_deparse(mat2) (`actual`) not equal to "<int[,2]: 1L, 2L, 3L, 4L>" (`expected`).

`actual`:   "<int: 1L, 2L, 3L, 4L>"    
`expected`: "<int[,2]: 1L, 2L, 3L, 4L>"
── Failure (test-deparse.R:603:3): matrices and arrays are formatted (#383) ────
as_label(arr) (`actual`) not equal to "<int[,1,3]>" (`expected`).

`actual`:   "<int>"      
`expected`: "<int[,1,3]>"
── Failure (test-deparse.R:604:3): matrices and arrays are formatted (#383) ────
expr_deparse(arr) (`actual`) not equal to "<int[,1,3]: 1L, 2L, 3L>" (`expected`).

`actual`:   "<int: 1L, 2L, 3L>"      
`expected`: "<int[,1,3]: 1L, 2L, 3L>"

There are a few ways we could improve this; the simplest is to use skip_if_not_installed("tibble") for those tests where {tibble} is required.

I haven't looked into the underlying code to comment on what might be preferable :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant