Skip to content

Conversation

krlmlr
Copy link
Member

@krlmlr krlmlr commented Jun 25, 2015

  • bugfix: don't show more items than necessary when comparing long vectors with few differences
  • bugfix: reverse order in expectation so that output of detailed comparison matches expectation output
  • compare vectors of different length in detail
    • if one vector is shorter, hide (non-existing) value in detailed diff

Similar improvements for compare.numeric are possible but not yet implemented.

Examples:

> expect_equal(letters, c(letters[-26], "a"))
Error: letters not equal to c(letters[-26], "a")
1 string mismatches:
x[26]: "z"
y[26]: "a"
> expect_equal(letters, c("A", letters[-c(1,25,26)]))
Error: letters not equal to c("A", letters[-c(1, 25, 26)])
Lengths (26, 24) differ
3 string mismatches:
x[1]: "a"
y[1]: "A"

x[25]: "y"

x[26]: "z"

Current state:

> expect_equal(letters, c(letters[-26], "a"))
Error: letters not equal to c(letters[-26], "a")
1 string mismatches:
x[26]: "a"
y[26]: "z"

x[NA]: NA
y[NA]: NA

x[NA]: NA
y[NA]: NA

x[NA]: NA
y[NA]: NA

x[NA]: NA
y[NA]: NA
> expect_equal(letters, c("A", letters[-c(1,25,26)]))
Error: letters not equal to c("A", letters[-c(1, 25, 26)])
Lengths (24, 26) differ (string compare on first 24)
1 string mismatch

R/compare.r Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be <- not =

@hadley
Copy link
Member

hadley commented Sep 24, 2015

Looks good - just a few minor suggestions.

@krlmlr
Copy link
Member Author

krlmlr commented Sep 25, 2015

Done. Tests succeed, but covr seems to be hanging for the PR test...

@hadley hadley merged commit 30e3ff8 into r-lib:master Sep 29, 2015
@hadley
Copy link
Member

hadley commented Sep 29, 2015

Thanks!

@krlmlr krlmlr deleted the compare-strings branch February 19, 2016 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants