Skip to content

format.mismatch_character produces warning and erroneous output when there are many differences #513

@brodieG

Description

@brodieG

An example:

> library(testthat)
Warning message:
package ‘testthat’ was built under R version 3.2.5 
> expect_equal(letters[1:6], LETTERS[1:6])
Error: letters[1:6] not equal to LETTERS[1:6].
6/6 mismatches
x[1]: "a"
y[1]: "A"

x[2]: "b"
y[2]: "B"

x[3]: "c"
y[3]: "C"

x[4]: "d"
y[4]: "D"

x[5]: "e"
y[5]: "E"

x[6]: "a"
y[6]: "A"
In addition: Warning messages:
1: In mapply(FUN = f, ..., SIMPLIFY = FALSE) :
  longer argument not a multiple of length of shorter
2: In mapply(FUN = f, ..., SIMPLIFY = FALSE) :
  longer argument not a multiple of length of shorter

Notice that in addition to the warnings, the first 5 elements of the two vectors are being recycled (see x[6] and y[6]).

The problem is in format.mismatch_character, where anytime there are more differences than max_diffs (currently defaults to 5), show_x, show_y, and x$i are no longer the same lengths in the Map call.

Let me know if you want me to submit a PR to fix this, assuming you agree with what I laid out above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorexpectation 🙀

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions