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

renaming iterableAssertions to consistent to + infitinive naming schema #889

Merged
merged 9 commits into from
May 4, 2021
168 changes: 93 additions & 75 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import kotlin.jvm.JvmName
*
* @return The newly created builder.
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
*/
fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<T, S>.atLeast(
times: Int
Expand All @@ -39,7 +39,7 @@ fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<
*
* @return The newly created builder.
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
* @throws IllegalArgumentException In case [times] of this `at most` restriction equals to the number of the
* `at least` restriction; use the [exactly] restriction instead.
*/
Expand All @@ -64,7 +64,7 @@ fun <T : CharSequence, S : SearchBehaviour> AtLeastCheckerStep<T, S>.butAtMost(
*
* @return The newly created builder.
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
*/
fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<T, S>.exactly(
times: Int
Expand All @@ -84,7 +84,7 @@ fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<
*
* @return The newly created builder.
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
* @throws IllegalArgumentException In case [times] equals to one; use [exactly] instead.
robstoll marked this conversation as resolved.
Show resolved Hide resolved
*/
fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<T, S>.atMost(
Expand All @@ -106,7 +106,7 @@ fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<
*
* @return The newly created builder.
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
*/
fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<T, S>.notOrAtMost(
times: Int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logic
import ch.tutteli.atrium.logic._logicAppend
import ch.tutteli.atrium.logic.isEmpty
import ch.tutteli.atrium.logic.isNotEmpty
import ch.tutteli.atrium.logic.size
import ch.tutteli.kbox.identity

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ch.tutteli.atrium.logic.creating.charsequence.contains.steps.AtLeastCheck
import kotlin.reflect.KFunction3

internal object StaticNames {
//TODO rename with 0.18.0 to notToContain
val containsNotValuesFun = run {
val f: KFunction3<Expect<CharSequence>, Any, Array<out Any>, Expect<CharSequence>> =
Expect<CharSequence>::notToContain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import ch.tutteli.atrium.logic.creating.iterable.contains.steps.AtLeastCheckerSt
import kotlin.reflect.KFunction3

internal object StaticNames {
//TODO rename with 0.18.0 notToContain
val containsNotValuesFun = run {
val f: KFunction3<Expect<Iterable<Double>>, Double, Array<out Double>, Expect<Iterable<Double>>> =
Expect<Iterable<Double>>::containsNot
Expect<Iterable<Double>>::notToContain
f.name
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//TODO rename file with 0.18.0
package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.api.fluent.en_GB.creating.feature.MetaFeatureOption
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//TODO rename file to fun0Expecations.kt with 0.18.0
package ch.tutteli.atrium.api.fluent.en_GB

import ch.tutteli.atrium.creating.Expect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import kotlin.jvm.JvmName
*
* @return The newly created builder.
*/
@Deprecated("Use toContain; will be removed with 1.0.0 at the latest", ReplaceWith("this.toContain"))
val <E, T : Iterable<E>> Expect<T>.contains: IterableLikeContains.EntryPointStep<E, T, NoOpSearchBehaviour>
get() = _logic.builderContainsInIterableLike(::identity)

Expand All @@ -29,6 +30,7 @@ val <E, T : Iterable<E>> Expect<T>.contains: IterableLikeContains.EntryPointStep
*
* @return The newly created builder.
*/
@Deprecated("Use notToContain; will be removed with 1.0.0 at the latest", ReplaceWith("this.notToContain"))
val <E, T : Iterable<E>> Expect<T>.containsNot: NotCheckerStep<E, T, NotSearchBehaviour>
get() = _logic.builderContainsNotInIterableLike(::identity)

Expand All @@ -49,8 +51,12 @@ val <E, T : Iterable<E>> Expect<T>.containsNot: NotCheckerStep<E, T, NotSearchBe
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toContain; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toContain<E, T>(expected, *otherExpected)")
)
fun <E, T : Iterable<E>> Expect<T>.contains(expected: E, vararg otherExpected: E): Expect<T> =
contains.inAnyOrder.atLeast(1).values(expected, *otherExpected)
toContain.inAnyOrder.atLeast(1).values(expected, *otherExpected)

/**
* Expects that the subject of `this` expectation (an [Iterable]) contains an entry holding the
Expand All @@ -65,8 +71,12 @@ fun <E, T : Iterable<E>> Expect<T>.contains(expected: E, vararg otherExpected: E
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toContain; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toContain<E, T>(assertionCreatorOrNull)")
)
fun <E : Any, T : Iterable<E?>> Expect<T>.contains(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
contains.inAnyOrder.atLeast(1).entry(assertionCreatorOrNull)
toContain.inAnyOrder.atLeast(1).entry(assertionCreatorOrNull)

/**
* Expects that the subject of `this` expectation (an [Iterable]) contains an entry holding the
Expand All @@ -84,10 +94,14 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.contains(assertionCreatorOrNull: (Expe
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toContain; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toContain<E, T>(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)")
)
fun <E : Any, T : Iterable<E?>> Expect<T>.contains(
assertionCreatorOrNull: (Expect<E>.() -> Unit)?,
vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?
): Expect<T> = contains.inAnyOrder.atLeast(1).entries(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)
): Expect<T> = toContain.inAnyOrder.atLeast(1).entries(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)

/**
* Expects that the subject of `this` expectation (an [Iterable]) contains only
Expand All @@ -101,8 +115,12 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.contains(
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toContainExactly; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toContainExactly<E, T>(expected, *otherExpected)")
)
fun <E, T : Iterable<E>> Expect<T>.containsExactly(expected: E, vararg otherExpected: E): Expect<T> =
contains.inOrder.only.values(expected, *otherExpected)
toContain.inOrder.only.values(expected, *otherExpected)

/**
* Expects that the subject of `this` expectation (an [Iterable]) contains only an entry holding
Expand All @@ -121,8 +139,12 @@ fun <E, T : Iterable<E>> Expect<T>.containsExactly(expected: E, vararg otherExpe
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toContainExactly; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toContainExactly<E, T>(assertionCreatorOrNull)")
)
fun <E : Any, T : Iterable<E?>> Expect<T>.containsExactly(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
contains.inOrder.only.entry(assertionCreatorOrNull)
toContain.inOrder.only.entry(assertionCreatorOrNull)

/**
* Expects that the subject of `this` expectation (an [Iterable]) contains only an entry holding
Expand All @@ -144,10 +166,14 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.containsExactly(assertionCreatorOrNull
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toContainExactly; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toContainExactly<E, T>(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)")
)
fun <E : Any, T : Iterable<E?>> Expect<T>.containsExactly(
assertionCreatorOrNull: (Expect<E>.() -> Unit)?,
vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?
): Expect<T> = contains.inOrder.only.entries(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)
): Expect<T> = toContain.inOrder.only.entries(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)

/**
* Expects that the subject of `this` expectation (an [Iterable]) contains only elements of [expectedIterableLike]
Expand All @@ -166,9 +192,13 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.containsExactly(
*
* @since 0.13.0
*/
@Deprecated(
"Use toContainExactlyElementsOf; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toContainExactlyElementsOf<E, T>(expectedIterableLike)")
)
inline fun <reified E, T : Iterable<E>> Expect<T>.containsExactlyElementsOf(
expectedIterableLike: IterableLike
): Expect<T> = contains.inOrder.only.elementsOf(expectedIterableLike)
): Expect<T> = toContain.inOrder.only.elementsOf(expectedIterableLike)

/** Expects that the subject of `this` expectation (an [Iterable]) contains all elements of [expectedIterableLike].
*
Expand All @@ -185,9 +215,13 @@ inline fun <reified E, T : Iterable<E>> Expect<T>.containsExactlyElementsOf(
*
* @since 0.13.0
*/
@Deprecated(
"Use toContainElementsOf; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toContainElementsOf<E, T>(expectedIterableLike)")
)
inline fun <reified E, T : Iterable<E>> Expect<T>.containsElementsOf(
expectedIterableLike: IterableLike
): Expect<T> = contains.inAnyOrder.atLeast(1).elementsOf(expectedIterableLike)
): Expect<T> = toContain.inAnyOrder.atLeast(1).elementsOf(expectedIterableLike)

/**
* Expects that the subject of `this` expectation (an [Iterable]) has at least one element and
Expand All @@ -197,10 +231,14 @@ inline fun <reified E, T : Iterable<E>> Expect<T>.containsElementsOf(
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use notToContain; will be removed with 1.0.0 at the latest",
ReplaceWith("this.notToContain<E, T>(expected, *otherExpected)")
)
fun <E, T : Iterable<E>> Expect<T>.containsNot(expected: E, vararg otherExpected: E): Expect<T> =
containsNot.values(expected, *otherExpected)

notToContain.values(expected, *otherExpected)

//TODO 0.18.0 move to iterableExpectations.kt
/**
* Creates an [Expect] for the result of calling `min()` on the subject of `this` expectation,
* so that further fluent calls are assertions about it.
Expand All @@ -212,6 +250,7 @@ fun <E, T : Iterable<E>> Expect<T>.containsNot(expected: E, vararg otherExpected
fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(): Expect<E> =
_logic.min(::identity).transform()

//TODO 0.18.0 move to iterableExpectations.kt
/**
* Expects that the result of calling `min()` on the subject of `this` expectation
* holds all assertions the given [assertionCreator] creates for it and
Expand All @@ -224,6 +263,7 @@ fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(): Expect<E> =
fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(assertionCreator: Expect<E>.() -> Unit): Expect<T> =
_logic.min(::identity).collectAndAppend(assertionCreator)

//TODO 0.18.0 move to iterableExpectations.kt
/**
* Creates an [Expect] for the result of calling `max()` on the subject of `this` expectation,
* so that further fluent calls are assertions about it.
Expand All @@ -235,6 +275,7 @@ fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(assertionCreator: Expect<
fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(): Expect<E> =
_logic.max(::identity).transform()

//TODO 0.18.0 move to iterableExpectations.kt
/**
* Expects that the result of calling `max()` on the subject of `this` expectation
* holds all assertions the given [assertionCreator] creates for it and
Expand All @@ -257,8 +298,12 @@ fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(assertionCreator: Expect<
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toHaveElementsAndAny; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toHaveElementsAndAny<E, T>(assertionCreatorOrNull)")
)
fun <E : Any, T : Iterable<E?>> Expect<T>.any(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
contains.inAnyOrder.atLeast(1).entry(assertionCreatorOrNull)
toContain.inAnyOrder.atLeast(1).entry(assertionCreatorOrNull)

/**
* Expects that the subject of `this` expectation (an [Iterable]) has at least one element and
Expand All @@ -269,8 +314,12 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.any(assertionCreatorOrNull: (Expect<E>
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toHaveElementsAndNone; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toHaveElementsAndNone<E, T>(assertionCreatorOrNull)")
)
fun <E : Any, T : Iterable<E?>> Expect<T>.none(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
containsNot.entry(assertionCreatorOrNull)
notToContain.entry(assertionCreatorOrNull)

/**
* Expects that the subject of `this` expectation (an [Iterable]) has at least one element and
Expand All @@ -279,6 +328,10 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.none(assertionCreatorOrNull: (Expect<E
*
* @return an [Expect] for the subject of `this` expectation.
*/
@Deprecated(
"Use toHaveElementsAndAll; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toHaveElementsAndAll<E, T>(assertionCreatorOrNull)")
)
fun <E : Any, T : Iterable<E?>> Expect<T>.all(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
_logicAppend { all(::identity, assertionCreatorOrNull) }

Expand All @@ -290,6 +343,10 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.all(assertionCreatorOrNull: (Expect<E>
*
* @since 0.9.0
*/
@Deprecated(
"Use toHaveElements; will be removed with 1.0.0 at the latest",
ReplaceWith("this.toHaveElements<E, T>()")
)
fun <E, T : Iterable<E>> Expect<T>.hasNext(): Expect<T> =
_logicAppend { hasNext(::identity) }

Expand All @@ -300,6 +357,10 @@ fun <E, T : Iterable<E>> Expect<T>.hasNext(): Expect<T> =
*
* @since 0.9.0
*/
@Deprecated(
"Use notToHaveElements; will be removed with 1.0.0 at the latest",
ReplaceWith("this.notToHaveElements<E, T>()")
)
fun <E, T : Iterable<E>> Expect<T>.hasNotNext(): Expect<T> =
_logicAppend { hasNotNext(::identity) }

Expand All @@ -310,9 +371,14 @@ fun <E, T : Iterable<E>> Expect<T>.hasNotNext(): Expect<T> =
*
* @since 0.14.0
*/
@Deprecated(
"Use notToContainDuplicates; will be removed with 1.0.0 at the latest",
ReplaceWith("this.notToContainDuplicates<E, T>()")
)
fun <E, T : Iterable<E>> Expect<T>.containsNoDuplicates(): Expect<T> =
_logicAppend { containsNoDuplicates(::identity) }

//TODO 0.18.0 move to iterableExpectations.kt
/**
* Turns `Expect<E, T : Iterable<E>>` into `Expect<List<E>`.
*
Expand All @@ -325,6 +391,7 @@ fun <E, T : Iterable<E>> Expect<T>.containsNoDuplicates(): Expect<T> =
*/
fun <E, T : Iterable<E>> Expect<T>.asList(): Expect<List<E>> = _logic.changeSubject.unreported { it.toList() }

//TODO 0.18.0 move to iterableExpectations.kt
/**
* Expects that the subject of `this` expectation holds all assertions the given [assertionCreator] creates for
* the subject as [List].
Expand Down
Loading