Skip to content
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

fix(assert): fix swapping of multiline str diff #3685

Merged

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Oct 3, 2023

This PR fixes the bug of multiline str diff when there are more diff lines in actual than expected.

The multiline diff algorithm (diffstr) performs diffing in 2 different ways: First it takes diff of the entire multiple string, comparing each line. Then it takes diff of words for each line over the combination of added (expected) lines and removed (actual) lines.

When computing word diffs for each line combination, the code swaps the main array to use for the loop (probably for optimization), but it forgot to swap diffing target. It resulted in swapped diff when there are more removed (actual) lines.

closes #3039
closes #3681

ref #948

@kt3k kt3k requested a review from bartlomieju October 3, 2023 13:57
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing this!

@kt3k kt3k merged commit 3b79ccf into denoland:main Oct 4, 2023
@kt3k kt3k deleted the fix-diff-swap-when-there-are-more-removed-lines branch October 4, 2023 01:50
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.

Assert diff swaps actual and expected when comparing multiline strings assertEquals shows an incorrect diff
2 participants