You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Comparing named vectors, ignoring order (again) #863
This is the same as #473. That previous issue was indirectly considered resolved by the implementation expect_setequal, but that's not what I had in mind. expect_setequal tests that two sortable vectors have the same contents, but what I had in mind was that two named vectors (including lists, which aren't generally sortable) would be tested to have the same key-value pairs.
The idea is that a and b below would be considered to be equivalent:
a<-list(x="a", y=2)
b<-list(y=2, x="a")
But these would not:
a<-list(x="a", y=2)
c<-list(x="a", z=2)
It was closed before because @hadley thought that doing it well would require quite a bit of code, but I don't think that's necessarily true -- I had a basic implementation of it in the previous issue.
I like expect_mapequal(). Although there is the odd case where a named vector has multiple entries with the same name. I'm not sure how we want to handle that.
Activity
hadley commentedon Apr 11, 2019
I'd definitely consider a PR if you can figure out a good name for it.
kevinushey commentedon Apr 11, 2019
expect_same_members()?expect_mapequal()? (since we're sort of treating the list like a map in this case)wch commentedon Apr 11, 2019
I like
expect_mapequal(). Although there is the odd case where a named vector has multiple entries with the same name. I'm not sure how we want to handle that.Implement expect_mapequal()