Skip to content

expect_setequal() Absent/Needs wording #2310

@jmbarbone

Description

@jmbarbone

if (length(act_miss)) sprintf("Needs: %s", values(act_miss)),
if (length(exp_miss)) sprintf("Absent: %s", values(exp_miss))

The language for errors in expect_setequal() seems a little off. To me, both "Absent" and "Needs" convey the same thing.

Would it make more sense for "Needs" to be something like "Extra", to convey that there's an unexpected value?

library(testthat)
expect_setequal(object = 1:3, expected = 1:2)
#> Error: Expected `1:3` to have the same values as `1:2`.
#> Actual: 1, 2, 3
#> Expected: 1, 2
#> Needs: 3
expect_setequal(object = 1:2, expected = 1:3)
#> Error: Expected `1:2` to have the same values as `1:3`.
#> Actual: 1, 2
#> Expected: 1, 2, 3
#> Absent: 3

Created on 2026-01-09 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions