Skip to content

Should expect_mapequal() be recursive?Β #1521

@nealrichardson

Description

@nealrichardson

It seems only to make unordered comparisons at the top level. I would expect nested lists to get the same mapequal treatment.

testthat::expect_mapequal(
  list(
    outer_1 = 1,
    outer_2 = list(
      inner_1 = 1,
      inner_2 = 2
    )
  ),
  list(
    outer_2 = list(
      inner_2 = 2,
      inner_1 = 1
    ),
    outer_1 = 1
  )
)
#> Error: act$val[exp_nms] not equal to exp$val.
#> Component "outer_2": Names: 2 string mismatches
#> Component "outer_2": Component 1: Mean relative difference: 1
#> Component "outer_2": Component 2: Mean relative difference: 0.5

Created on 2021-12-31 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions