-
Notifications
You must be signed in to change notification settings - Fork 209
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
Incorrect slice diff output #238
Comments
Having the same on uint8 slices: func TestDiff(t *testing.T) {
fmt.Println(cmp.Diff(
// Hello Universe
[]uint8{0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x55, 0x6e, 0x69, 0x76, 0x65, 0x72, 0x73, 0x65},
// Hello World
[]uint8{0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64},
))
} sometimes reports
sometimes
|
Hi @Eun, thanks for the report, but it's not the same issue. My original one is about the fact that the
This is incorrect. The example you provided is one where the |
@dsnet Yeah I also realized that this might be a different issue than yours, I wasn't sure tho. I will create a new issue for that. |
It appears that the problem may be related to the fact that when I notice the comments state:
Is this correct? Perhaps I'm misunderstanding, but it seems like |
A previous attempt to add non-determinism to the diffing algorithm unfortunately broke the algorithm for half the cases. This change modifies the algorithm to truly switch between starting with a forward search versus a reverse search. The main for-loop of Difference would switch repeatedly between performing a forward search, then a reverse search, and vice-versa. Since we can't jump into the middle of a for-loop to start with the reverse search first, we use a series of labels and goto statements to accomplish the same effect. Fixes #238
This bug is definitely related to Coincidentally, this also fixes the case that @Eun reported. However, I'm going to keep #244 open since improving the optimality of the diffing algorithm is still something we want to do. |
Nice. Here is a somewhat simpler solution that I had envisioned if you are interested. |
Thanks @C-DY for the PR! Mine may be a slightly more lines of change, but I was aiming to more clearly preserve the symmetry that exists between the forward and backward searches. They are identical except operating in different directions. |
A previous attempt to add non-determinism to the diffing algorithm unfortunately broke the algorithm for half the cases. This change modifies the algorithm to truly switch between starting with a forward search versus a reverse search. The main for-loop of Difference would switch repeatedly between performing a forward search, then a reverse search, and vice-versa. Since we can't jump into the middle of a for-loop to start with the reverse search first, we use a series of labels and goto statements to accomplish the same effect. Fixes #238
A previous attempt to add non-determinism to the diffing algorithm unfortunately broke the algorithm for half the cases. This change modifies the algorithm to truly switch between starting with a forward search versus a reverse search. The main for-loop of Difference would switch repeatedly between performing a forward search, then a reverse search, and vice-versa. Since we can't jump into the middle of a for-loop to start with the reverse search first, we use a series of labels and goto statements to accomplish the same effect. Fixes #238
A previous attempt to add non-determinism to the diffing algorithm unfortunately broke the algorithm for half the cases. This change modifies the algorithm to truly switch between starting with a forward search versus a reverse search. The main for-loop of Difference would switch repeatedly between performing a forward search, then a reverse search, and vice-versa. Since we can't jump into the middle of a for-loop to start with the reverse search first, we use a series of labels and goto statements to accomplish the same effect. Fixes #238
Consider the following snippet:
Depending on the randomization involved, this sometimes prints:
when it should print:
Not that it incorrectly reports that
"rwar"
is different?The text was updated successfully, but these errors were encountered: