-
Notifications
You must be signed in to change notification settings - Fork 642
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
Conversation
ee07b97
to
34f0eac
Compare
@@ -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<*>) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
What about adding shouldBeEqualToUsingAllFields ?
…On Sun, 26 Apr 2020 at 12:27, Sebastian Schuberth ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
kotest-assertions/kotest-assertions-core/src/jvmMain/kotlin/io/kotest/matchers/equality/reflection.kt
<#1413 (comment)>:
> @@ -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<*>) {
Well, that's what has been recommend
<#1161 (comment)> 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?
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#1413 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFVSGW56EP742DJJ4TOU4LRORVI3ANCNFSM4MRFZ2KA>
.
|
Or if we have to allow empty fields on one of them, I think
shouldBeEqualToUsingFields
makes more sense than the ignored one.
…On Sun, 26 Apr 2020 at 13:19, Stephen Samuel (Sam) ***@***.***> wrote:
What about adding shouldBeEqualToUsingAllFields ?
On Sun, 26 Apr 2020 at 12:27, Sebastian Schuberth <
***@***.***> wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In
> kotest-assertions/kotest-assertions-core/src/jvmMain/kotlin/io/kotest/matchers/equality/reflection.kt
> <#1413 (comment)>:
>
> > @@ -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<*>) {
>
> Well, that's what has been recommend
> <#1161 (comment)> 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?
>
> —
> You are receiving this because your review was requested.
> Reply to this email directly, view it on GitHub
> <#1413 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAFVSGW56EP742DJJ4TOU4LRORVI3ANCNFSM4MRFZ2KA>
> .
>
|
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.
ada8717
to
3cca2dd
Compare
3cca2dd
to
ca98c52
Compare
lgtm |
Please have a look at the individual commit messages for the details.