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

Issue 239 Fix #244

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sageserpent-open
Copy link

@sageserpent-open sageserpent-open commented Apr 26, 2024

Addresses this issue: Possible bug in implementation of MapDecorator.mergeByKeyWith.

Test added to reproduce the bug in: bcc2b6e4fe84ca.

Fix to make test pass in: 5088ed68c8d67b.

@sageserpent-open sageserpent-open force-pushed the issue-239-MapDecorator-mergeByKeyWith branch from 5088ed6 to 650f115 Compare April 29, 2024 07:15
@sageserpent-open
Copy link
Author

The second commit is a bit messy - let me tidy up the history a little for the sake of clarity and force-push again...

@sageserpent-open sageserpent-open force-pushed the issue-239-MapDecorator-mergeByKeyWith branch from 650f115 to 8c8d67b Compare April 29, 2024 07:35
@sageserpent-open
Copy link
Author

Refreshed the PR and edited the original description accordingly.

@sageserpent-open
Copy link
Author

sageserpent-open commented May 15, 2024

@SethTisue , @Philippus This PR is awaiting workflow approval from a maintainer. Could somebody take a look if they have a moment, please?

@SethTisue SethTisue requested a review from a team May 20, 2024 18:38
Copy link
Contributor

@som-snytt som-snytt left a comment

Choose a reason for hiding this comment

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

Nice catch. Does this mean no one uses this code? Worth noting that the original is surprisingly hard to read, in part because Option#fold is obfuscating.


Assert.assertEquals("Expect the same keys to appear in the join taken either way around.", ourChanges.mergeByKey(theirChanges).keySet, theirChanges
.mergeByKey(ourChanges)
.keys)
Copy link
Contributor

Choose a reason for hiding this comment

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

This compares keySet and keys. Does it matter? Without a resolution to scala/scala#10766 it's fruitless to speculate.

Copy link
Author

Choose a reason for hiding this comment

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

Oops - yes, let me fix this…

Copy link
Author

Choose a reason for hiding this comment

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

DONE

@som-snytt
Copy link
Contributor

I see the PR is unsquashed, but I don't know what local policy is for this repo.

The test is interesting in that it demonstrates the old behavior. Is such a test meaningful after the fix? That is, it becomes a test where one asks sometime in the future, Why did they ever think this test could fail? It tests for apples instead of oranges.

@sageserpent-open
Copy link
Author

Nice catch. Does this mean no one uses this code? Worth noting that the original is surprisingly hard to read, in part because Option#fold is obfuscating.

Well, I certainly use the code, although in the meantime I’ve copied the fixed code locally.😊

@sageserpent-open
Copy link
Author

sageserpent-open commented May 25, 2024

EDIT: where are my manners? I should say from the start, thanks for the review, @som-snytt and @SethTisue.

I see the PR is unsquashed, but I don't know what local policy is for this repo.

I was aiming to show the test failing first, then passing with the fix - I like to split my work into testing, implementing, refactoring, tidying up to avoid one big PR - although this is just a minnow anyway. It’s no problem from my side if you want to squash the merge if you’re happy with the PR.

The test is interesting in that it demonstrates the old behavior. Is such a test meaningful after the fix? That is, it becomes a test where one asks sometime in the future, Why did they ever think this test could fail? It tests for apples instead of oranges.

I was thinking of the test as being a bug reproduction test, but wrote it as two scenarios to show the simpler situation first where values don’t collide, followed by the one where they do.

Depending on how you philosophise about testing, you might say that the second case is a case of “let’s show that the SUT does not make my breakfast / make nuisance phone calls / launch nuclear missiles”, or instead you could say that preservation of the values is part of its wider contract.

I take the latter view, but if it’s a dealbreaker, how about we split the test? FWIW, I saw this repository as more of a fast-and-loose affair, so I just got something in to support the fix.

@sageserpent-open
Copy link
Author

@som-snytt / @SethTisue Another bump for a workflow approval, please. Next time I won't fork the repository to submit a PR, lesson learned...

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.

None yet

2 participants