-
Notifications
You must be signed in to change notification settings - Fork 33
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 105] Fix ModelObject#equivalent not being symmetric #106
Conversation
@nicoweidner Thanks for the PR! For the |
@goneall Now I am confused again about clone 😅 . My reasoning was this: In the clone method, a new The test The reason the test passed so far is exactly the bug fixed in this PR: The assertion was written in the form On a different note, I noticed one bug I introduced (erroneous early return) and several test failures (I only executed |
I pushed some changes that should fix CI. In my effort to simplify the logic, I accidentally broke some edge cases with my previous commit 😬 . Luckily, some test caught it; I also added specific unit tests for those cases (empty model collections and noassertion values, which are treated like null in comparisons). As mentioned before, the additional 4 commits should all be part of the initial commit. @goneall I will wait for a quick opinion before squashing them and force-pushing. |
@goneall One further question: I noticed that in the propertyValuesEquivalent method (which is called when comparing two This would only be relevant in specific situations I believe (and I can't tell at this point whether they can actually occur, but still...). Let's say we are comparing
|
@nicoweidner You're correct - I just looked at the code and indeed it doesn't copy the properties. I think this is yet another bug :( It can be fixed by copying the properties in the cloned object. In thinking about this, the
It's been a while since I've worked on this method, but I'm pretty sure I intended the properties to be copied. I did a search in all my local projects and couldn't find any instance of clone being used, so perhaps we should just deprecate this method?
Yes - that would be preferred. Thanks! |
I created #107 to discuss the |
Signed-off-by: Nicolaus Weidner <nicolaus.weidner@tngtech.com>
47d6c5c
to
5d9fbc5
Compare
Ok, commits are squashed, should be good to go now unless someone finds another bug :-) (the small refactor commit was squashed into the others since it would have been some effort to separate it, and it only changed a few lines anyway) |
Thanks @nicoweidner |
Fixes #105
Note: After making my changes,
ModelObjectTest#testClone
failed. I removed the line testing thatresult.equivalent(gmo)
because my current understanding is thatclone
only creates a copy with the same identifiers in a new store, but without the properties populated;copyFrom
seems to be the method to use for copying properties. Hence the check that the objects are equivalent is misplaced in that test (and wasn't noticed because of the bug fixed in this PR)Signed-off-by: Nicolaus Weidner nicolaus.weidner@tngtech.com