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

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

Closed
brodieG opened this Issue Aug 6, 2016 · 0 comments

Comments

Projects
None yet
2 participants
@brodieG
Contributor

brodieG commented Aug 6, 2016

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.

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