rename toBeLess/GreaterThanOrEqual to ...OrEqualTo

This commit is contained in:
Robert Stoll
2021-04-23 22:50:18 +02:00
parent 3188ff1893
commit 6c0095d738
23 changed files with 60 additions and 61 deletions

View File

@@ -2075,7 +2075,7 @@ Say you want to build a `isBetween` assertion function for `java.util.Date`, you
```kotlin
fun <T : Date> Expect<T>.isBetween(lowerBoundInclusive: T, upperBoundExclusive: T) =
toBeGreaterThanOrEqual(lowerBoundInclusive).and.toBeLessThan(upperBoundExclusive)
toBeGreaterThanOrEqualTo(lowerBoundInclusive).and.toBeLessThan(upperBoundExclusive)
```
</code-own-compose-1>
@@ -2092,7 +2092,7 @@ import ch.tutteli.atrium.logic._logic
fun <T : Date> Expect<T>.isBetween(lowerBoundInclusive: T, upperBoundExclusive: T) =
_logic.appendAssertionsCreatedBy {
toBeGreaterThanOrEqual(lowerBoundInclusive)
toBeGreaterThanOrEqualTo(lowerBoundInclusive)
toBeLessThan(upperBoundExclusive)
}
```
@@ -2173,7 +2173,7 @@ Another example: assert the person has children which are all adults (assuming 1
```kotlin
fun Expect<Person>.hasAdultChildren(): Expect<Person> =
feature(Person::children) {
all { feature(Person::age).toBeGreaterThanOrEqual(18) }
all { feature(Person::age).toBeGreaterThanOrEqualTo(18) }
}
```

View File

@@ -24,8 +24,8 @@ fun <T : Comparable<T>> Expect<T>.isLessThan(expected: T): Expect<T> =
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.deprecated.ComparableAssertionSamples.isLessThanOrEqual
*/
@Deprecated(
"Use toBeLessThanOrEqual; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toBeLessThanOrEqual<T>(expected)")
"Use toBeLessThanOrEqualTo; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toBeLessThanOrEqualTo<T>(expected)")
)
fun <T : Comparable<T>> Expect<T>.isLessThanOrEqual(expected: T): Expect<T> =
_logicAppend { isLessThanOrEqual(expected) }
@@ -54,8 +54,8 @@ fun <T : Comparable<T>> Expect<T>.isGreaterThan(expected: T): Expect<T> =
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.deprecated.ComparableAssertionSamples.isGreaterThanOrEqual
*/
@Deprecated(
"Use toBeGreaterThanOrEqual; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toBeGreaterThanOrEqual<T>(expected)")
"Use toBeGreaterThanOrEqualTo; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toBeGreaterThanOrEqualTo<T>(expected)")
)
fun <T : Comparable<T>> Expect<T>.isGreaterThanOrEqual(expected: T): Expect<T> =
_logicAppend { isGreaterThanOrEqual(expected) }

View File

@@ -22,11 +22,11 @@ fun <T : Comparable<T>> Expect<T>.toBeLessThan(expected: T): Expect<T> =
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ComparableExpectationSamples.toBeLessThanOrEqual
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ComparableExpectationSamples.toBeLessThanOrEqualTo
*
* @since 0.17.0
*/
fun <T : Comparable<T>> Expect<T>.toBeLessThanOrEqual(expected: T): Expect<T> =
fun <T : Comparable<T>> Expect<T>.toBeLessThanOrEqualTo(expected: T): Expect<T> =
_logicAppend { isLessThanOrEqual(expected) }
/**
@@ -48,11 +48,11 @@ fun <T : Comparable<T>> Expect<T>.toBeGreaterThan(expected: T): Expect<T> =
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ComparableExpectationSamples.toBeGreaterThanOrEqual
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.ComparableExpectationSamples.toBeGreaterThanOrEqualTo
*
* @since 0.17.0
*/
fun <T : Comparable<T>> Expect<T>.toBeGreaterThanOrEqual(expected: T): Expect<T> =
fun <T : Comparable<T>> Expect<T>.toBeGreaterThanOrEqualTo(expected: T): Expect<T> =
_logicAppend { isGreaterThanOrEqual(expected) }
/**

View File

@@ -6,9 +6,9 @@ import ch.tutteli.atrium.specs.integration.DiffEqualsCompareTo
object ComparableExpectationsSpec : ch.tutteli.atrium.specs.integration.ComparableExpectationsSpec(
fun1(Expect<Int>::toBeLessThan),
fun1(Expect<Int>::toBeLessThanOrEqual),
fun1(Expect<Int>::toBeLessThanOrEqualTo),
fun1(Expect<Int>::toBeGreaterThan),
fun1(Expect<Int>::toBeGreaterThanOrEqual),
fun1(Expect<Int>::toBeGreaterThanOrEqualTo),
fun1(Expect<Int>::toBeEqualComparingTo),
fun1(Expect<DiffEqualsCompareTo>::toBeEqualComparingTo)
)

View File

@@ -135,7 +135,7 @@ class AnyExpectationSamples {
val n: Number = 16
expect(n)
.toBeAnInstanceOf<Int> { // subject is now of type Int
toBeGreaterThanOrEqual(15)
toBeGreaterThanOrEqualTo(15)
} // subject remains type Int also after the block
.toBeLessThan(20)
@@ -212,7 +212,7 @@ class AnyExpectationSamples {
expect(customers).all {
because("the legal age of maturity in Switzerland is 18") {
feature { f(it::age) }.toBeGreaterThanOrEqual(18)
feature { f(it::age) }.toBeGreaterThanOrEqualTo(18)
}
}
}

View File

@@ -16,12 +16,12 @@ class ComparableExpectationSamples {
}
@Test
fun toBeLessThanOrEqual() {
expect(1).toBeLessThanOrEqual(2)
expect(2).toBeLessThanOrEqual(2)
fun toBeLessThanOrEqualTo() {
expect(1).toBeLessThanOrEqualTo(2)
expect(2).toBeLessThanOrEqualTo(2)
fails {
expect(2).toBeLessThanOrEqual(1)
expect(2).toBeLessThanOrEqualTo(1)
}
}
@@ -35,12 +35,12 @@ class ComparableExpectationSamples {
}
@Test
fun toBeGreaterThanOrEqual() {
expect(2).toBeGreaterThanOrEqual(1)
expect(2).toBeGreaterThanOrEqual(2)
fun toBeGreaterThanOrEqualTo() {
expect(2).toBeGreaterThanOrEqualTo(1)
expect(2).toBeGreaterThanOrEqualTo(2)
fails {
expect(1).toBeGreaterThanOrEqual(2)
expect(1).toBeGreaterThanOrEqualTo(2)
}
}

View File

@@ -24,8 +24,8 @@ infix fun <T : Comparable<T>> Expect<T>.isLessThan(expected: T): Expect<T> =
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.deprecated.ComparableAssertionSamples.isLessThanOrEqual
*/
@Deprecated(
"Use toBeLessThanOrEqual; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toBeLessThanOrEqual<T>(expected)")
"Use toBeLessThanOrEqualTo; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toBeLessThanOrEqualTo<T>(expected)")
)
infix fun <T : Comparable<T>> Expect<T>.isLessThanOrEqual(expected: T): Expect<T> =
_logicAppend { isLessThanOrEqual(expected) }
@@ -54,8 +54,8 @@ infix fun <T : Comparable<T>> Expect<T>.isGreaterThan(expected: T): Expect<T> =
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.deprecated.ComparableAssertionSamples.isGreaterThanOrEqual
*/
@Deprecated(
"Use toBeGreaterThanOrEqual; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toBeGreaterThanOrEqual<T>(expected)")
"Use toBeGreaterThanOrEqualTo; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toBeGreaterThanOrEqualTo<T>(expected)")
)
infix fun <T : Comparable<T>> Expect<T>.isGreaterThanOrEqual(expected: T): Expect<T> =
_logicAppend { isGreaterThanOrEqual(expected) }

View File

@@ -22,11 +22,11 @@ infix fun <T : Comparable<T>> Expect<T>.toBeLessThan(expected: T): Expect<T> =
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.ComparableExpectationSamples.toBeLessThanOrEqual
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.ComparableExpectationSamples.toBeLessThanOrEqualTo
*
* @since 0.17.0
*/
infix fun <T : Comparable<T>> Expect<T>.toBeLessThanOrEqual(expected: T): Expect<T> =
infix fun <T : Comparable<T>> Expect<T>.toBeLessThanOrEqualTo(expected: T): Expect<T> =
_logicAppend { isLessThanOrEqual(expected) }
/**
@@ -48,11 +48,11 @@ infix fun <T : Comparable<T>> Expect<T>.toBeGreaterThan(expected: T): Expect<T>
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.ComparableExpectationSamples.toBeGreaterThanOrEqual
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.ComparableExpectationSamples.toBeGreaterThanOrEqualTo
*
* @since 0.17.0
*/
infix fun <T : Comparable<T>> Expect<T>.toBeGreaterThanOrEqual(expected: T): Expect<T> =
infix fun <T : Comparable<T>> Expect<T>.toBeGreaterThanOrEqualTo(expected: T): Expect<T> =
_logicAppend { isGreaterThanOrEqual(expected) }
/**

View File

@@ -7,9 +7,9 @@ import ch.tutteli.atrium.specs.notImplemented
class ComparableExpectationsSpec : ch.tutteli.atrium.specs.integration.ComparableExpectationsSpec(
fun1(Expect<Int>::toBeLessThan),
fun1(Expect<Int>::toBeLessThanOrEqual),
fun1(Expect<Int>::toBeLessThanOrEqualTo),
fun1(Expect<Int>::toBeGreaterThan),
fun1(Expect<Int>::toBeGreaterThanOrEqual),
fun1(Expect<Int>::toBeGreaterThanOrEqualTo),
fun1(Expect<Int>::toBeEqualComparingTo),
fun1(Expect<DiffEqualsCompareTo>::toBeEqualComparingTo)
) {
@@ -18,9 +18,9 @@ class ComparableExpectationsSpec : ch.tutteli.atrium.specs.integration.Comparabl
fun ambiguityTest() {
val a1: Expect<Int> = notImplemented()
a1 toBeLessThan 1
a1 toBeLessThanOrEqual 1
a1 toBeLessThanOrEqualTo 1
a1 toBeGreaterThan 1
a1 toBeGreaterThanOrEqual 1
a1 toBeGreaterThanOrEqualTo 1
a1 toBeEqualComparingTo 1
}
}

View File

@@ -129,7 +129,7 @@ class AnyExpectationSamples {
fun toBeAnInstanceOf() {
val n: Number = 16
expect(n).toBeAnInstanceOf<Int> { // subject is now of type Int
it toBeGreaterThanOrEqual 15
it toBeGreaterThanOrEqualTo 15
} /* subject remains type Int also after the block
*/ toBeLessThan 20
@@ -204,7 +204,7 @@ class AnyExpectationSamples {
expect(customers) all {
it because of("the legal age of maturity in Switzerland is 18") {
feature { f(it::age) } toBeGreaterThanOrEqual 18
feature { f(it::age) } toBeGreaterThanOrEqualTo 18
}
}
}

View File

@@ -3,8 +3,7 @@ package ch.tutteli.atrium.api.infix.en_GB.samples
import ch.tutteli.atrium.api.infix.en_GB.toBeEqualComparingTo
import ch.tutteli.atrium.api.infix.en_GB.toBeGreaterThan
import ch.tutteli.atrium.api.infix.en_GB.toBeLessThan
import ch.tutteli.atrium.api.infix.en_GB.toBeLessThanOrEqual
import ch.tutteli.atrium.api.infix.en_GB.samples.fails
import ch.tutteli.atrium.api.infix.en_GB.toBeLessThanOrEqualTo
import ch.tutteli.atrium.api.verbs.internal.expect
import kotlin.test.Test
@@ -20,12 +19,12 @@ class ComparableExpectationSamples {
}
@Test
fun toBeLessThanOrEqual() {
expect(1) toBeLessThanOrEqual 2
expect(2) toBeLessThanOrEqual 2
fun toBeLessThanOrEqualTo() {
expect(1) toBeLessThanOrEqualTo 2
expect(2) toBeLessThanOrEqualTo 2
fails {
expect(2) toBeLessThanOrEqual 1
expect(2) toBeLessThanOrEqualTo 1
}
}
@@ -39,7 +38,7 @@ class ComparableExpectationSamples {
}
@Test
fun toBeGreaterThanOrEqual() {
fun toBeGreaterThanOrEqualTo() {
expect(2) toBeEqualComparingTo 2
fails {

View File

@@ -801,7 +801,7 @@ abstract class AnyExpectationsSpec(
expect {
expect(21)
.becauseFunForInt("we use the definition that teens are between 12 and 18 years old") {
toBeGreaterThanOrEqual(12)
toBeGreaterThanOrEqualTo(12)
toBeLessThan(18)
notToEqualOneOf(21)
}

View File

@@ -32,7 +32,7 @@ abstract class MapAsEntriesExpectationsSpec(
{ isKeyValue("b", 2) },
{
key { toStartWith("a") }
value.toBeGreaterThanOrEqual(1)
value.toBeGreaterThanOrEqualTo(1)
}
)
}

View File

@@ -24,7 +24,7 @@ abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
describePrefix,
keyWithValueAssertions.forSubjectLess(
keyValue("a") { toEqual(1) },
arrayOf(keyValue("a") { toBeLessThanOrEqual(2) })
arrayOf(keyValue("a") { toBeLessThanOrEqualTo(2) })
)
) {})

View File

@@ -17,7 +17,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
describePrefix,
keyWithValueAssertions.forSubjectLess(
keyValue("a") { toEqual(1) },
arrayOf(keyValue("a") { toBeLessThanOrEqual(2) })
arrayOf(keyValue("a") { toBeLessThanOrEqualTo(2) })
)
) {})

View File

@@ -16,7 +16,7 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
describePrefix,
keyWithValueAssertions.forSubjectLess(
keyValue("a") { toEqual(1) },
arrayOf(keyValue("a") { toBeLessThanOrEqual(2) })
arrayOf(keyValue("a") { toBeLessThanOrEqualTo(2) })
)
) {})

View File

@@ -160,7 +160,7 @@ private fun Suite.testNonNullableSubject(assertionVerb: (Int) -> Expect<Int>) {
}
it("throws an AssertionError as soon as one assertion fails") {
assert {
assertionVerb(1).toBeLessThanOrEqual(10).and.toBeLessThanOrEqual(0).and.toBeGreaterThanOrEqual(2)
assertionVerb(1).toBeLessThanOrEqualTo(10).and.toBeLessThanOrEqualTo(0).and.toBeGreaterThanOrEqualTo(2)
}.toThrow<AssertionError> {
message {
toContain(": 1")

View File

@@ -29,9 +29,9 @@ abstract class LocalDateExpectationsSpec(
monthFeature.forSubjectLess().adjustName { "$it feature" },
month.forSubjectLess { toBeLessThan(12) },
dayFeature.forSubjectLess().adjustName { "$it feature" },
day.forSubjectLess { toBeLessThanOrEqual(20) },
day.forSubjectLess { toBeLessThanOrEqualTo(20) },
dayOfWeekFeature.forSubjectLess().adjustName { "$it feature" },
dayOfWeek.forSubjectLess { toBeLessThanOrEqual(DayOfWeek.SUNDAY) }
dayOfWeek.forSubjectLess { toBeLessThanOrEqualTo(DayOfWeek.SUNDAY) }
) {})
include(object : AssertionCreatorSpec<LocalDate>(

View File

@@ -28,9 +28,9 @@ abstract class LocalDateTimeExpectationsSpec(
monthFeature.forSubjectLess().adjustName { "$it feature" },
month.forSubjectLess { toBeLessThan(12) },
dayFeature.forSubjectLess().adjustName { "$it feature" },
day.forSubjectLess { toBeLessThanOrEqual(20) },
day.forSubjectLess { toBeLessThanOrEqualTo(20) },
dayOfWeekFeature.forSubjectLess().adjustName { "$it feature" },
dayOfWeek.forSubjectLess { toBeLessThanOrEqual(DayOfWeek.SUNDAY) }
dayOfWeek.forSubjectLess { toBeLessThanOrEqualTo(DayOfWeek.SUNDAY) }
) {})
include(object : AssertionCreatorSpec<LocalDateTime>(

View File

@@ -28,9 +28,9 @@ abstract class ZonedDateTimeExpectationsSpec(
monthFeature.forSubjectLess().adjustName { "$it feature" },
month.forSubjectLess { toBeLessThan(12) },
dayFeature.forSubjectLess().adjustName { "$it feature" },
day.forSubjectLess { toBeLessThanOrEqual(20) },
day.forSubjectLess { toBeLessThanOrEqualTo(20) },
dayOfWeekFeature.forSubjectLess().adjustName { "$it feature" },
dayOfWeek.forSubjectLess { toBeLessThanOrEqual(DayOfWeek.SUNDAY) }
dayOfWeek.forSubjectLess { toBeLessThanOrEqualTo(DayOfWeek.SUNDAY) }
) {})
include(object : AssertionCreatorSpec<ZonedDateTime>(

View File

@@ -1,7 +1,7 @@
package readme.examples
import ch.tutteli.atrium.api.fluent.en_GB.and
import ch.tutteli.atrium.api.fluent.en_GB.toBeGreaterThanOrEqual
import ch.tutteli.atrium.api.fluent.en_GB.toBeGreaterThanOrEqualTo
import ch.tutteli.atrium.api.fluent.en_GB.toBeLessThan
import ch.tutteli.atrium.creating.Expect
import org.spekframework.spek2.Spek
@@ -25,6 +25,6 @@ import java.util.*
object Between1Spec : Spek({
test("code-own-compose-1") {
fun <T : Date> Expect<T>.isBetween(lowerBoundInclusive: T, upperBoundExclusive: T) =
toBeGreaterThanOrEqual(lowerBoundInclusive).and.toBeLessThan(upperBoundExclusive)
toBeGreaterThanOrEqualTo(lowerBoundInclusive).and.toBeLessThan(upperBoundExclusive)
}
})

View File

@@ -1,6 +1,6 @@
package readme.examples
import ch.tutteli.atrium.api.fluent.en_GB.toBeGreaterThanOrEqual
import ch.tutteli.atrium.api.fluent.en_GB.toBeGreaterThanOrEqualTo
import ch.tutteli.atrium.api.fluent.en_GB.toBeLessThan
import ch.tutteli.atrium.creating.Expect
import org.spekframework.spek2.Spek
@@ -31,7 +31,7 @@ object Between2Spec : Spek({
fun <T : Date> Expect<T>.isBetween(lowerBoundInclusive: T, upperBoundExclusive: T) =
_logic.appendAssertionsCreatedBy {
toBeGreaterThanOrEqual(lowerBoundInclusive)
toBeGreaterThanOrEqualTo(lowerBoundInclusive)
toBeLessThan(upperBoundExclusive)
}
}

View File

@@ -79,7 +79,7 @@ object OwnExpectationFunctionsSpec : Spek({
//snippet-own-compose-4-start
fun Expect<Person>.hasAdultChildren(): Expect<Person> =
feature(Person::children) {
all { feature(Person::age).toBeGreaterThanOrEqual(18) }
all { feature(Person::age).toBeGreaterThanOrEqualTo(18) }
}
//snippet-own-compose-4-end