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

Reflection equality improvements #1413

Merged
merged 3 commits into from
Apr 26, 2020
Merged

Conversation

sschuberth
Copy link
Member

Please have a look at the individual commit messages for the details.

@sschuberth sschuberth force-pushed the reflection-equality-improvements branch from ee07b97 to 34f0eac Compare April 26, 2020 11:24
@@ -139,7 +141,6 @@ fun <T : Any> beEqualToUsingFields(other: T, vararg fields: KProperty<*>): Match
* Note: Throws [IllegalArgumentException] in case [properties] parameter is not provided.
*/
fun <T : Any> T.shouldBeEqualToIgnoringFields(other: T, vararg properties: KProperty<*>) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this method should allow specifying no fields? Equal to ignoring nothing? That would seem to be a strange way to use this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, that's what has been recommend to me for me use case. From a strictly logical perspective this sounds alright, but I agree it feels a bit unnatural.

But if neither shouldBeEqualToUsingFields nor shouldBeEqualToIgnoringFields offer an easy way to compare all fields, and preferably also with an option to compare private fields, what's the alternative?

@sksamuel
Copy link
Member

sksamuel commented Apr 26, 2020 via email

@sksamuel
Copy link
Member

sksamuel commented Apr 26, 2020 via email

@sschuberth
Copy link
Member Author

I think shouldBeEqualToUsingFields makes more sense than the ignored one.

Yes, that's how I expected it to work in the first place. I'll make that change.

So that the check is also performed when using "should beEqualTo*Fields"
directly. While at it, slightly improve the check's message wording.
…gFields

We are not really interersted in the concrete fields, but only if there are
any.
@sschuberth sschuberth force-pushed the reflection-equality-improvements branch 2 times, most recently from ada8717 to 3cca2dd Compare April 26, 2020 20:36
@sschuberth sschuberth force-pushed the reflection-equality-improvements branch from 3cca2dd to ca98c52 Compare April 26, 2020 20:43
@sksamuel
Copy link
Member

lgtm

@sksamuel sksamuel merged commit d39fbce into master Apr 26, 2020
@sksamuel sksamuel deleted the reflection-equality-improvements branch April 26, 2020 21:42
@sksamuel sksamuel mentioned this pull request Jun 7, 2020
33 tasks
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.

2 participants