Skip to content

Commit

Permalink
Other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Sep 8, 2022
1 parent 19f3da2 commit 9d7b2fc
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ AbstractDoubleAssert<?> after(AbstractDoubleAssert<?> doubleAssert, double n) {
}
}

static final class AbstractDoubleAssertActualIsEqualToExpected {
static final class AssertThatIsEqualTo {
@BeforeTemplate
AbstractBooleanAssert<?> before(boolean actual, boolean expected) {
return Refaster.anyOf(
assertThat(actual == expected).isTrue(), assertThat(actual != expected).isFalse());
}

@BeforeTemplate
AbstractBooleanAssert<?> before(double actual, double expected) {
return Refaster.anyOf(
Expand All @@ -58,7 +64,7 @@ AbstractBooleanAssert<?> before(double actual, double expected) {

@AfterTemplate
@UseImportPolicy(STATIC_IMPORT_ALWAYS)
AbstractDoubleAssert<?> after(double actual, double expected) {
AbstractBooleanAssert<?> after(boolean actual, boolean expected) {
return assertThat(actual).isEqualTo(expected);
}
}
Expand All @@ -77,7 +83,13 @@ AbstractDoubleAssert<?> after(AbstractDoubleAssert<?> doubleAssert, double n) {
}
}

static final class AbstractDoubleAssertActualIsNotEqualToExpected {
static final class AssertThatIsNotEqualTo {
@BeforeTemplate
AbstractBooleanAssert<?> before(boolean actual, boolean expected) {
return Refaster.anyOf(
assertThat(actual != expected).isTrue(), assertThat(actual == expected).isFalse());
}

@BeforeTemplate
AbstractBooleanAssert<?> before(double actual, double expected) {
return Refaster.anyOf(
Expand All @@ -86,7 +98,7 @@ AbstractBooleanAssert<?> before(double actual, double expected) {

@AfterTemplate
@UseImportPolicy(STATIC_IMPORT_ALWAYS)
AbstractDoubleAssert<?> after(double actual, double expected) {
AbstractBooleanAssert<?> after(boolean actual, boolean expected) {
return assertThat(actual).isNotEqualTo(expected);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ boolean before(boolean a, boolean b) {
return Refaster.anyOf(!(a == b), a ? !b : b);
}

@BeforeTemplate
boolean before(long a, long b) {
return !(a == b);
}

@BeforeTemplate
boolean before(double a, double b) {
return !(a == b);
Expand All @@ -105,11 +100,6 @@ boolean before(boolean a, boolean b) {
return Refaster.anyOf(!(a != b), a ? b : !b);
}

@BeforeTemplate
boolean before(long a, long b) {
return !(a != b);
}

@BeforeTemplate
boolean before(double a, double b) {
return !(a != b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,23 @@ ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsEqualTo() {
assertThat(0.0).isCloseTo(1, offset(0.0)), assertThat(0.0).isCloseTo(1, withPercentage(0)));
}

ImmutableSet<AbstractAssert<?, ?>> testAbstractDoubleAssertActualIsEqualToExpected() {
@SuppressWarnings("SimplifyBooleanExpression")
ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsEqualTo() {
return ImmutableSet.of(
assertThat(1.0 == 2.0).isTrue(),
assertThat(1.0 != 2.0).isFalse(),
assertThat(true == false).isTrue(),
assertThat(true != false).isFalse(),
assertThat((byte) 1 == (byte) 2).isTrue(),
assertThat(1F == 2F).isTrue(),
assertThat((byte) 1 != (byte) 2).isFalse(),
assertThat((short) 1 == (short) 2).isTrue(),
assertThat((short) 1 != (short) 2).isFalse(),
assertThat(1 == 2).isTrue(),
assertThat(1 != 2).isFalse(),
assertThat(1L == 2L).isTrue(),
assertThat((short) 1 == (short) 2).isTrue());
assertThat(1L != 2L).isFalse(),
assertThat(1F == 2F).isTrue(),
assertThat(1F != 2F).isFalse(),
assertThat(1.0 == 2.0).isTrue(),
assertThat(1.0 != 2.0).isFalse());
}

ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsNotEqualTo() {
Expand All @@ -43,15 +51,23 @@ ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsNotEqualTo() {
assertThat(0.0).isNotCloseTo(1, withPercentage(0)));
}

ImmutableSet<AbstractAssert<?, ?>> testAbstractDoubleAssertActualIsNotEqualToExpected() {
@SuppressWarnings("SimplifyBooleanExpression")
ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNotEqualTo() {
return ImmutableSet.of(
assertThat(1.0 != 2.0).isTrue(),
assertThat(1.0 == 2.0).isFalse(),
assertThat(true != false).isTrue(),
assertThat(true == false).isFalse(),
assertThat((byte) 1 != (byte) 2).isTrue(),
assertThat(1F != 2F).isTrue(),
assertThat((byte) 1 == (byte) 2).isFalse(),
assertThat((short) 1 != (short) 2).isTrue(),
assertThat((short) 1 == (short) 2).isFalse(),
assertThat(1 != 2).isTrue(),
assertThat(1 == 2).isFalse(),
assertThat(1L != 2L).isTrue(),
assertThat((short) 1 != (short) 2).isTrue());
assertThat(1L == 2L).isFalse(),
assertThat(1F != 2F).isTrue(),
assertThat(1F == 2F).isFalse(),
assertThat(1.0 != 2.0).isTrue(),
assertThat(1.0 == 2.0).isFalse());
}

AbstractDoubleAssert<?> testAbstractDoubleAssertIsZero() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,46 @@ ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsEqualTo() {
return ImmutableSet.of(assertThat(0.0).isEqualTo(1), assertThat(0.0).isEqualTo(1));
}

ImmutableSet<AbstractAssert<?, ?>> testAbstractDoubleAssertActualIsEqualToExpected() {
@SuppressWarnings("SimplifyBooleanExpression")
ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsEqualTo() {
return ImmutableSet.of(
assertThat(1.0).isEqualTo(2.0),
assertThat(1.0).isEqualTo(2.0),
assertThat(true).isEqualTo(false),
assertThat(true).isEqualTo(false),
assertThat((byte) 1).isEqualTo((byte) 2),
assertThat(1F).isEqualTo(2F),
assertThat((byte) 1).isEqualTo((byte) 2),
assertThat((short) 1).isEqualTo((short) 2),
assertThat((short) 1).isEqualTo((short) 2),
assertThat(1).isEqualTo(2),
assertThat(1).isEqualTo(2),
assertThat(1L).isEqualTo(2L),
assertThat((short) 1).isEqualTo((short) 2));
assertThat(1L).isEqualTo(2L),
assertThat(1F).isEqualTo(2F),
assertThat(1F).isEqualTo(2F),
assertThat(1.0).isEqualTo(2.0),
assertThat(1.0).isEqualTo(2.0));
}

ImmutableSet<AbstractDoubleAssert<?>> testAbstractDoubleAssertIsNotEqualTo() {
return ImmutableSet.of(assertThat(0.0).isNotEqualTo(1), assertThat(0.0).isNotEqualTo(1));
}

ImmutableSet<AbstractAssert<?, ?>> testAbstractDoubleAssertActualIsNotEqualToExpected() {
@SuppressWarnings("SimplifyBooleanExpression")
ImmutableSet<AbstractAssert<?, ?>> testAssertThatIsNotEqualTo() {
return ImmutableSet.of(
assertThat(1.0).isNotEqualTo(2.0),
assertThat(1.0).isNotEqualTo(2.0),
assertThat(true).isNotEqualTo(false),
assertThat(true).isNotEqualTo(false),
assertThat((byte) 1).isNotEqualTo((byte) 2),
assertThat(1F).isNotEqualTo(2F),
assertThat((byte) 1).isNotEqualTo((byte) 2),
assertThat((short) 1).isNotEqualTo((short) 2),
assertThat((short) 1).isNotEqualTo((short) 2),
assertThat(1).isNotEqualTo(2),
assertThat(1).isNotEqualTo(2),
assertThat(1L).isNotEqualTo(2L),
assertThat((short) 1).isNotEqualTo((short) 2));
assertThat(1L).isNotEqualTo(2L),
assertThat(1F).isNotEqualTo(2F),
assertThat(1F).isNotEqualTo(2F),
assertThat(1.0).isNotEqualTo(2.0),
assertThat(1.0).isNotEqualTo(2.0));
}

AbstractDoubleAssert<?> testAbstractDoubleAssertIsZero() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ boolean testDoubleNegation() {
return !!Boolean.TRUE;
}

@SuppressWarnings("SimplifyBooleanExpression")
ImmutableSet<Boolean> testNegation() {
return ImmutableSet.of(
// XXX: This causes a reference equality check. Review.
Boolean.TRUE ? !Boolean.FALSE : Boolean.FALSE,
!(Boolean.TRUE == Boolean.FALSE),
!(true == false),
!((byte) 3 == (byte) 4),
!((short) 3 == (short) 4),
!(3 == 4),
Expand All @@ -44,10 +46,12 @@ ImmutableSet<Boolean> testNegation() {
!(BoundType.OPEN == BoundType.CLOSED));
}

@SuppressWarnings("SimplifyBooleanExpression")
ImmutableSet<Boolean> testIndirectDoubleNegation() {
return ImmutableSet.of(
// XXX: This causes a reference equality check. Review.
Boolean.TRUE ? Boolean.FALSE : !Boolean.FALSE,
!(Boolean.TRUE != Boolean.FALSE),
!(true != false),
!((byte) 3 != (byte) 4),
!((short) 3 != (short) 4),
!(3 != 4),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ boolean testDoubleNegation() {
return Boolean.TRUE;
}

@SuppressWarnings("SimplifyBooleanExpression")
ImmutableSet<Boolean> testNegation() {
return ImmutableSet.of(
// XXX: This causes a reference equality check. Review.
Boolean.TRUE != Boolean.FALSE,
Boolean.TRUE != Boolean.FALSE,
true != false,
(byte) 3 != (byte) 4,
(short) 3 != (short) 4,
3 != 4,
Expand All @@ -44,10 +46,12 @@ ImmutableSet<Boolean> testNegation() {
BoundType.OPEN != BoundType.CLOSED);
}

@SuppressWarnings("SimplifyBooleanExpression")
ImmutableSet<Boolean> testIndirectDoubleNegation() {
return ImmutableSet.of(
// XXX: This causes a reference equality check. Review.
Boolean.TRUE == Boolean.FALSE,
Boolean.TRUE == Boolean.FALSE,
true == false,
(byte) 3 == (byte) 4,
(short) 3 == (short) 4,
3 == 4,
Expand Down

0 comments on commit 9d7b2fc

Please sign in to comment.