Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4019)

Issue 30770043: testing/checkers: implement DeepEquals

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 5 months ago by rog
Modified:
10 years, 5 months ago
Reviewers:
dimitern, mp+196247
Visibility:
Public.

Description

testing/checkers: implement DeepEquals After coming across the nil vs empty slice equality problem for the nth time, I think it might be time to bite the bullet and provide a version of DeepEquals that treats nil slices as equal to empty slices. This proposal copies code from the Go reflect package with a couple of small adaptations to enable that. Apart from the two trivial if statements deleted to implement the logic differences, there are also some extra cases required because unlike the reflect implementation, we have not got privileged access to a value's content (we can't call Interface on values derived from private struct members). I'm not entirely sure if the name should remain identical ("jc.DeepEquals" vs "gc.DeepEquals" is not an obvious distinction) but since the semantics are so similar, perhaps that's ok. https://code.launchpad.net/~rogpeppe/juju-core/467-checkers-deepequals/+merge/196247 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : testing/checkers: implement DeepEquals #

Total comments: 16
Unified diffs Side-by-side diffs Delta from patch set Stats (+355 lines, -0 lines) Patch
A [revision details] View 1 chunk +2 lines, -0 lines 0 comments Download
M testing/checkers/bool.go View 1 chunk +25 lines, -0 lines 0 comments Download
M testing/checkers/bool_test.go View 1 chunk +9 lines, -0 lines 0 comments Download
A testing/checkers/deepequal.go View 1 chunk +165 lines, -0 lines 10 comments Download
A testing/checkers/deepequal_test.go View 1 chunk +154 lines, -0 lines 6 comments Download

Messages

Total messages: 4
rog
Please take a look.
10 years, 5 months ago (2013-11-22 10:20:04 UTC) #1
dimitern
Looks great, apart from a few minor suggestions. https://codereview.appspot.com/30770043/diff/20001/testing/checkers/deepequal.go File testing/checkers/deepequal.go (right): https://codereview.appspot.com/30770043/diff/20001/testing/checkers/deepequal.go#newcode12 testing/checkers/deepequal.go:12: import ...
10 years, 5 months ago (2013-11-22 10:37:31 UTC) #2
rog
In general, when copy-pasting, I think it's good to leave things unchanged when possible. https://codereview.appspot.com/30770043/diff/20001/testing/checkers/deepequal.go ...
10 years, 5 months ago (2013-11-22 11:49:14 UTC) #3
dimitern
10 years, 5 months ago (2013-11-22 12:22:16 UTC) #4
LGTM, for the sake of having this useful code landed. I still disagree that we
need to use either a consistent formatting across the juju-core codebase, or
extract such bits of reusable helpers as external projects (all of checkers
perhaps).
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b