Skip to content

Opaque implicit dependency of tests on {tibble} #1761

Description

@MichaelChirico

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 :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tidy-dev-day 🤓Tidyverse Developer Day rstd.io/tidy-dev-day

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions