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

Generate distinct singleton enum collections #157

Merged
merged 1 commit into from
Nov 1, 2016
Merged

Generate distinct singleton enum collections #157

merged 1 commit into from
Nov 1, 2016

Conversation

Stephan202
Copy link
Contributor

Currently, the following test fails:

public final class Test {
    @Immutable
    public static final class Dummy {
        public enum SingletonEnum {
            ELEM
        }

        private final ImmutableSet<SingletonEnum> values;

        Dummy(ImmutableSet<SingletonEnum> values) {
            this.values = values;
        }

        @Override
        public boolean equals(@Nullable final Object o) {
            return (o instanceof Dummy) && Objects.equals(this.values, ((Dummy) o).values);
        }

        @Override
        public int hashCode() {
            return Objects.hash(this.values);
        }
    }

    @Test
    public void testDummy() {
        EqualsVerifier.forClass(Dummy.class).verify();
    }
}

The error message is:

java.lang.AssertionError: Significant fields: equals does not use values, or it is stateless.
For more information, go to: http://www.jqno.nl/equalsverifier/errormessages
    at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:381)
    at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:367)
    at com.example.Test.testDummy(TestTest.java:150)
    ...

This PR proposes a change which causes the test to pass, as it should. Interested to hear whether you think the approach taken is acceptable.

If `red` and `black` are equal, as may be the case if their type is a singleton
enum, then distinct collections can be generated by returning a collection with
and without the element.
@coveralls
Copy link

coveralls commented Oct 15, 2016

Coverage Status

Coverage increased (+0.004%) to 97.427% when pulling b52a7ae on PicnicSupermarket:generate-distinct-singleton-enum-collections into 820f10d on jqno:master.

@jqno
Copy link
Owner

jqno commented Oct 15, 2016

Thanks for taking the time to make a PR! I'm on vacation right now, I'll
check it out when I get back.

equalsverifier/errormessages http://www.jqno.nl/equalsverifier/errormessages
at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:381)
at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:367)
at com.example.Test.testDummy(TestTest.java:150)
...

This PR proposes a change which causes the test to pass, as it should.

Interested to hear whether you think the approach taken is acceptable.

You can view, comment on, or merge this pull request online at:

#157
Commit Summary

  • Generate distinct singleton enum collections

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#157, or mute the thread
https://github.com/notifications/unsubscribe-auth/AA0osa0XH3g7bGusSLUK5VGJXBCDlrxJks5q0PvmgaJpZM4KXvmu
.

@jqno jqno merged commit 5c22589 into jqno:master Nov 1, 2016
@jqno
Copy link
Owner

jqno commented Nov 1, 2016

Looks good! Thanks again!
I have a few other issues to look at before I can make a release. I'll let you know when I do.

@Stephan202 Stephan202 deleted the generate-distinct-singleton-enum-collections branch November 1, 2016 07:49
@jqno
Copy link
Owner

jqno commented Nov 18, 2016

I've just released this fix in version 2.1.7.

Sorry for the delay!

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.

3 participants