Skip to content

Commit

Permalink
Missed a spot
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedsamehsalah committed Jul 10, 2024
1 parent 3a3e47a commit c7c6d3d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ boolean after(T a, T b) {
}
}

/**
* Prefer reference-based equality for enums over {@link Predicate#isEqual(Object)} comparison.
*/
static final class PredicateIsEqualEnums<T extends Enum<T>> {
/** Prefer reference-based equality for enums over more contrived equality checks. */
static final class EnumsReferenceEqualityLambda<T extends Enum<T>> {
@BeforeTemplate
Predicate<T> before(T a) {
return isEqual(a);
return Refaster.anyOf(isEqual(a), a::equals);
}

@AfterTemplate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ boolean testEqualsPredicate() {
return Stream.of("foo").anyMatch(s -> "bar".equals(s));
}

boolean testPredicateIsEqualEnums() {
return Stream.of(RoundingMode.UP).anyMatch(isEqual(RoundingMode.DOWN));
ImmutableSet<Boolean> testEnumsReferenceEqualityLambda() {

return ImmutableSet.of(
Stream.of(RoundingMode.UP).anyMatch(isEqual(RoundingMode.DOWN)),
Stream.of(RoundingMode.UP).anyMatch(RoundingMode.DOWN::equals));
}

boolean testDoubleNegation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ boolean testEqualsPredicate() {
return Stream.of("foo").anyMatch("bar"::equals);
}

boolean testPredicateIsEqualEnums() {
return Stream.of(RoundingMode.UP).anyMatch(v -> v == RoundingMode.DOWN);
ImmutableSet<Boolean> testEnumsReferenceEqualityLambda() {

return ImmutableSet.of(
Stream.of(RoundingMode.UP).anyMatch(v -> v == RoundingMode.DOWN),
Stream.of(RoundingMode.UP).anyMatch(v -> v == RoundingMode.DOWN));
}

boolean testDoubleNegation() {
Expand Down

0 comments on commit c7c6d3d

Please sign in to comment.